DateConverter
The `DateConverter` class provides utility methods for date manipulation, including calculating pre-start dates based on given start dates and lookback periods.
To avoid errors in date calculations, always use specialized tools like Python's datetime
or a custom DateConverter
. These handle all the tricky parts of dates, like leap years or month lengths, making your calculations accurate and straightforward.
Method Signature
start
(int, str, datetime): The start date. Can be an integer inYYYYMMDD
format, a string with 'YYYYMMDD' format, or adatetime
object.lookback_days
(int): The number of days to look back from the start date.trading_day
(bool, optional): IfTrue
, only considers trading days. Defaults toFalse
.
Return Value
Returns an integer in
YYYYMMDD
format if the input is an integer or string.Returns a
datetime
object if the input is adatetime
object.
Examples
Last updated