API documentation for tradingstrategy.direct_feed.ohlcv_aggregate.resample_trades_into_ohlcv Python function.
- resample_trades_into_ohlcv(df, timeframe)#
Resample incoming “tick” data.
The incoming DataFrame is not groupe by pairs yet, but presents stream of data from the blockchain.
It must have columns pair, amount, price, exchange_rate. It will be indexed by timestamp for the operations.
There must be a price given externally for the first open
Build OHLCV dataframe from individual trades
Handle any exchange rate conversion
Any missing values will be filled with the last valid close
Exchange rate resample is the avg exchange rate of the candle. Thus, resampled data might not be accurately converted between native quote asset and US dollar value. Any currency conversion must happen before.
… and be timestamp indexed.
df (DataFrame) –
DataFrame of incoming trades.
Must have columns price, amount
Pandas frequency string for the new timeframe duration.
E.g. D for daily.
offset – Allows you to “shift” candles
conversion – Convert the incomign values if needed
timeframe (Timeframe) –
OHLCV dataframes that are grouped by pair.
Open price is not the price of the previous close, but the first trade done within the timeframe.
- Return type: