For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Generic way to get len() of data feed?
-
Is there a generic way to get the len(), if I don't pass the whole pandas DataFrame to cerebro?
In my case I did it like this:
df = pd.read_csv( 'ticks.csv', header=0, parse_dates=[0], date_parser=lambda x: datetime.datetime.fromtimestamp(int(x)/1000) ) todate = datetime.datetime(2021, 5, 28,22,00) datalen = len(df[df["timestamp"] < todate]) data = bt.feeds.PandasData( dataname=df, fromdate=datetime.datetime(2000, 1, 1), todate=todate, timeframe=bt.TimeFrame.Ticks datetime=0, high=9, low=10, open=7, close=8, volume=11, )
Overall, my goal is to have a simple progress bar/indicator. This solution was a bit more than I actually needed.
Any hints are more than welcome.