Created
February 14, 2021 12:11
-
-
Save iSevenDays/378a75e392a92a602cc80ffe8df6ddd7 to your computer and use it in GitHub Desktop.
get_feed_for_csv_path.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import backtrader as bt | |
from backtrader.feeds import GenericCSVData | |
class GenericCSV_Signal(GenericCSVData): | |
# Add a 'pe' line to the inherited ones from the base class | |
lines = ('autoencoder_signal',) | |
# auto encoder signal in GenericCSVData has index 8 ... | |
# add the parameter to the parameters inherited from the base class | |
params = (('autoencoder_signal', 8),) | |
def get_feed_for_csv_path(path, fromdate, todate, has_signal=False): | |
config = dict(dataname=path, | |
fromdate=fromdate, | |
todate=todate, | |
nullvalue=0.0, | |
dtformat='%Y-%m-%d', | |
datetime=0, | |
high=2, | |
low=3, | |
open=1, | |
close=4, | |
volume=5, | |
openinterest=-1) | |
return bt.feeds.GenericCSVData(**config) if not has_signal else GenericCSV_Signal(**config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment