Backtrader - Add new custom value in data feeds 新増自定義的值

发布时间 2023-10-12 17:33:13作者: chankuang

1. Add new custom value in data feeds 新増自定義的值

class PandasDataV2(bt.feeds.PandasData):
    lines = ('close', 't5')
    params = (('datetime', None), ('open', -1), ('high', -1), ('low', -1), ('close', -1), ('volume', -1), ('t5', -1),)

  t5 is new val.

 

2. Apply PandasDataV2

df0 = df0[['Open', 'High', 'Low', 'Close', 'Volume', 'T5']]
data0 = PandasDataV2(dataname=df0)

  apply PandasDataV2