AI4Finance-Foundation / AI4Finance-Foundation/FinRL-Trading
backtest_plot Error with Crypto or any stock not listed in yfinance
- 主要言語
- Python
- スター
- 3.7k
- フォーク
- 1.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
So I was testing out one of the crypto notebooks, it came to my attention that new new project master branch has a new naming convention for the backtest methods, so old notebooks will need to be updated with that.
I also realized a few issues with the data intake of the methods. They are only accepting data formatted in a specific way, like the date column, needs to be named "date" (unlike in crypto "time").
One of the major issues with the project right now is the non standardized methods, classes, inputs and naming conventions used.
Also, there is a redundancy in the operations, for example the below method uses get_baseline, which typically redownloads the data that you have downloaded at the beginning of the notebook? is there something I am not seeing? can we not create a deepcopy of the data at the beginning once and for all and use that as the baseline?
All the above are just me writing down my thoughts, please do let me know what you all think and the best solution so we work on it together to reduce inefficiency and redundant fixes. would truly love to hear your thoughts!
@XiaoYangLiu-FinRL @BruceYanghy
```
def backtest_plot(
account_value,
baseline_start=config.START_TRADE_DATE,
baseline_end=config.END_DATE,
baseline_ticker="^DJI",
value_col_name="account_value",
):
df = deepcopy(account_value)
test_returns = get_daily_return(df, value_col_name=value_col_name)
baseline_df = get_baseline(
ticker=baseline_ticker, start=baseline_start, end=baseline_end
)
baseline_returns = get_daily_return(baseline_df, value_col_name="close")
with pyfolio.plotting.plotting_context(font_scale=1.1):
pyfolio.create_full_tear_sheet(
returns=test_returns, benchmark_rets=baseline_returns, set_context=False
)
def get_baseline(ticker, start, end):
dji = YahooDownloader(
start_date=start, end_date=end, ticker_list=[ticker]
).fetch_data()
return dji
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。