Timeframe#
API documentation for tradingstrategy.direct_feed.timeframe.Timeframe Python class in Trading Strategy framework.
- class Timeframe[source]#
Bases:
object
Describe candle timeframe.
This structure allows us to pass candle resample data around the framework.
This class is very similar to
tradingstrategy.timebucket.TimeBucket
, but unlike the bucket it allows any time frames presented, not just predefined choices.These is also
offset
which allows to shift the starting point of candles around.- __init__(freq, offset=Timedelta('0 days 00:00:00'))#
- Parameters:
freq (str) –
offset (Timedelta) –
- Return type:
None
Methods
__init__
(freq[, offset])Get the default candle chart time buffer for this frequency.
Snap to previous available timedelta.
Attributes
- freq: str#
Pandas frequency string.
E.g. 1D for daily, 1min for minute.
See https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases
- offset: Timedelta = Timedelta('0 days 00:00:00')#
Candle shift offset
E.g. move hourly candles 5 minutes backwards to start at 00:55
- round_timestamp_down(ts)[source]#
Snap to previous available timedelta.
Preserve any timezone info on ts.
If we are at the the given exact delta, then do not round, only add offset.
- Parameters:
ts (Timestamp) – Timestamp we want to round
- Returns:
When to wake up from the sleep next time
- Return type:
Timestamp