Skip to content

Commit

Permalink
correct trading cost calc, fixes stefan-jansen#230
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-jansen committed Mar 8, 2022
1 parent f881ea0 commit 0f81653
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 22_deep_reinforcement_learning/trading_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def take_step(self, action, market_return):
trade_costs = abs(n_trades) * self.trading_cost_bps
time_cost = 0 if n_trades else self.time_cost_bps
self.costs[self.step] = trade_costs + time_cost
reward = start_position * market_return - self.costs[self.step]
reward = start_position * market_return - self.costs[max(0, self.step-1)]
self.strategy_returns[self.step] = reward

if self.step != 0:
Expand Down

0 comments on commit 0f81653

Please sign in to comment.