For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Extending Pandas Dataframe with string/datetime column values.
-
Hi BT community,
I need help regarding extending Pandas Datafeed:My dataframe looks like this :
open high low close volume expiry time_stamp 2015-04-01 09:15:00 18250.00 18315.00 18226.15 18295.00 222650 2015-04-30 2015-04-01 09:30:00 18295.00 18299.50 18261.55 18278.00 66875 2015-04-30 2015-04-01 09:45:00 18275.20 18358.95 18266.95 18345.05 162800 2015-04-30 2015-04-01 10:00:00 18345.05 18390.00 18332.60 18374.95 146525 2015-04-30 2015-04-01 10:15:00 18375.00 18411.65 18361.35 18383.20 119875 2015-04-30
I have tried to figure this out by myself but would love help .
class custom(bt.feeds.PandasData): lines = ('open', 'high', 'low', 'close', 'volume', 'expiry', ) params = ( ('open', -1), ('high', -1), ('low', -1), ('close', -1), ('volume', -1), ('expiry', -1), )
How can I use string/datetime as lines ?
-
@Dastaan-Sharma said in Extending Pandas Dataframe with string/datetime column values.:
How can I use string/datetime as lines ?
You cannot. It it's a timestamp, encode it to be a
float
(for a date the integral part of the number should be enough for most practical uses) -
Ah Alright.
It is better to applydate2num
Solved my problem though.
-
-
@tianjixuetu
Thanks. Your analysis is really helpful for me.