Time window presentation.
- class tradingstrategy.timebucket.TimeBucket¶
We use term “bucket”, from the TimescaleDB slang to symbol the time window of a candle data we are querying.
The raw blockchain data is assembled to 1 minute time buckets. Then the 1 minute timebuckets are resampled to other windows.
All time windows are in UTC. Daily time buckets have their hour, minute and second set to the zero in the outputted data. Hourly time buckets have minute and hour set to zero, etc.
Python labels are reserved from the actual values, because Python symbol cannot start with a number.
- m1 = '1m'¶
One minute candles
- m5 = '5m'¶
Five minute candles
- m15 = '15m'¶
- h1 = '1h'¶
- h4 = '4h'¶
Four hour candles
- d1 = '1d'¶
- d7 = '7d'¶
- d30 = '30d'¶
- d360 = '360d'¶
We do not have “yearly” candles, but some trade statistics are calculated for 360 days, thus we need a corresponding time bucket for them.
- infinite = 'infinite'¶
Some statistics like “all time high”, for example, only make sense if a “bucket” spans across the entire timeline.
- not_applicable = 'not_applicable'¶
A placeholder value representing a “NULL value” for cases where Python’s None is not a favorable choice for some reason.
- to_timedelta() datetime.timedelta ¶
Get delta object for a TimeBucket definition.
You can use this to construct arbitrary timespans or iterate candle data.