Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ValueError fix from Issue #6 and KeyError fix from Issue #8 #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion elegant_finrl/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyfolio import timeseries
import pyfolio
from copy import deepcopy
from datetime import datetime

class StockTradingEnv:
def __init__(self, cwd='./envs/FinRL', gamma=0.99,
Expand Down Expand Up @@ -197,6 +198,8 @@ def get_date(path, start, end, ticker_list):
ticker_list=ticker_list, ).fetch_data()
raw_df.to_pickle(path)
print("| YahooDownloader: finish processing date list")
raw_df["date"] = pd.to_datetime(raw_df.date)
raw_df = raw_df[raw_df.date >= datetime.strptime(start, "%Y-%m-%d")]
return raw_df.date.unique()

@staticmethod
Expand Down Expand Up @@ -275,7 +278,7 @@ def get_daily_return(df, value_col_name="account_value"):
df["date"] = pd.to_datetime(df["date"])
df.set_index("date", inplace=True, drop=True)
df.index = df.index.tz_localize("UTC")
return pd.Series(df["single-stock-baseline"], index=df.index)
return pd.Series(df["daily_return"], index=df.index)

def backtest_plot(self, account_value, baseline_start, baseline_end, baseline_ticker="^DJI"):
df = deepcopy(account_value)
Expand Down