FinRL-Trading icon indicating copy to clipboard operation
FinRL-Trading copied to clipboard

backtest_plot Error with Crypto or any stock not listed in yfinance

Open Youbadawy opened this issue 4 years ago • 7 comments

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

Youbadawy avatar Feb 03 '21 20:02 Youbadawy

Thanks very much for your detailed feedback! Would you like to work with us and improve it? We welcome your inputs!

YangletLiu avatar Feb 03 '21 21:02 YangletLiu

Of course, thats why I am here!! quite impressed with all the hard work you guys have put in, would definitely like to help you further! @XiaoYangLiu-FinRL

Youbadawy avatar Feb 04 '21 09:02 Youbadawy

Welcome to join our Slack channel to have more interactions with the community.

YangletLiu avatar Feb 06 '21 05:02 YangletLiu

The slack channel is: https://ai4financeworkspace.slack.com/ssb/redirect

YangletLiu avatar Feb 06 '21 14:02 YangletLiu

can i join your slack channel ?

oxful avatar Mar 26 '21 15:03 oxful

Can i join the slack channel, it seems it needs an invitation

yosoul93 avatar Jun 17 '21 16:06 yosoul93

Will update the new link in one or two days. It needs monthly update.

YangletLiu avatar Jun 17 '21 17:06 YangletLiu