Timeframe#

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:
Return type:

None

Methods

__init__(freq[, offset])

get_default_chart_display_window()

Get the default candle chart time buffer for this frequency.

round_timestamp_down(ts)

Snap to previous available timedelta.

Attributes

offset

Candle shift offset

freq

Pandas frequency string.

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

get_default_chart_display_window()[source]#

Get the default candle chart time buffer for this frequency.

See DEFAULT_DISPLAY_WINDOW_FOR_TIMEFRAME.

Returns:

Pandas frequency string

Return type:

Timedelta

__init__(freq, offset=Timedelta('0 days 00:00:00'))#
Parameters:
Return type:

None