IndexError: list index out of range #114
shirishaardak
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My Code :
#Read CSV file with Pandas
stock_price = pd.read_csv('./data/NIFTY_15minute.csv')
stock_price.columns = ['date', 'Open', 'High', 'Low', 'Close', 'volume', 'oi']
Remove time
stock_price['date'] = pd.to_datetime(stock_price['date']).dt.date
set index as date
stock_price['date'] = stock_price.set_index(['date'], inplace=True)
daily returns
stock_price['Pct Change'] = (stock_price['Close'] - stock_price['Open'])/ stock_price['Open']
pct_change = stock_price['Pct Change']
print(pct_change)
quantstats.reports.basic(pct_change)
please check below issue
date
2021-01-01 0.000353
2021-01-01 0.000524
2021-01-01 -0.000517
2021-01-01 0.000642
2021-01-01 -0.000317
...
2021-07-19 -0.001171
2021-07-19 -0.001592
2021-07-19 0.002279
2021-07-19 0.000270
2021-07-19 0.000432
Name: Pct Change, Length: 3358, dtype: float64
[Performance Metrics]
Traceback (most recent call last):
File "d:/Algorithmic Trading Proejct/algorithmic-trading-strategies/strategies/test.py", line 25, in
quantstats.reports.basic(pct_change)
File "C:\Users\91989\anaconda3\lib\site-packages\quantstats\reports.py", line 280, in basic
metrics(returns=returns, benchmark=benchmark,
File "C:\Users\91989\anaconda3\lib\site-packages\quantstats\reports.py", line 327, in metrics
dd = _calc_dd(df, display=(display or "internal" in kwargs))
File "C:\Users\91989\anaconda3\lib\site-packages\quantstats\reports.py", line 604, in _calc_dd
dd_info = _stats.drawdown_details(dd)
File "C:\Users\91989\anaconda3\lib\site-packages\quantstats\stats.py", line 576, in drawdown_details
_dfs[col] = _drawdown_details(drawdown[col])
File "C:\Users\91989\anaconda3\lib\site-packages\quantstats\stats.py", line 553, in _drawdown_details
dd = drawdown[starts[i]:ends[i]]
IndexError: list index out of range
Beta Was this translation helpful? Give feedback.
All reactions