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

I think there is a look-ahead bias #5

Open
mg64ve opened this issue Aug 12, 2019 · 1 comment
Open

I think there is a look-ahead bias #5

mg64ve opened this issue Aug 12, 2019 · 1 comment

Comments

@mg64ve
Copy link

mg64ve commented Aug 12, 2019

Hi there, nice work.
However I think there is a look-ahead bias.
Every timestep, you get state and this state includes the current closeprice.
Then with step method you calculate profit as:

self.exit_price = self.closingPrice
self.reward += ((self.entry_price - self.exit_price)/self.exit_price + 1)*(1-self.fee)**2 - 1 # calculate reward

In this case you are using the same information that you already used to predict the next action.
What do you think about it?

@miroblog
Copy link
Owner

state_n <- updateState()
action_n <- network(state_n)
reward_n <- compute_reward(action_n, state_n)


state_n_plus_1 <- updateState()
action_n_plus_1 <- network(state_n_plus_1)
reward_n_plus_1 <- compute_reward(action_n_plus_1, state_n_plus_1)

reward is computed from the current state, thus there is no lookahead bias.
Put it simply,
(e.g.) one decides to sell the stock based on past&current price and
if one does sell, then one would calculate the earning based on current price.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants