We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
def get_reward(self, action): """ @param action: based on the action taken it returns the reward @return: reward """ reward_index_first = self.current_state_index + self.start_index_reward reward_index_last = self.current_state_index + self.start_index_reward + self.n_step \ if self.current_state_index + self.n_step < len(self.states) else len(self.close_price) - 1 p1 = self.close_price[reward_index_first] p2 = self.close_price[reward_index_last] reward = 0 if action == 0 or (action == 1 and self.own_share): # Buy Share or Hold Share reward = ((1 - self.trading_cost_ratio) ** 2 * p2 / p1 - 1) * 100 # profit in percent elif action == 2 or (action == 1 and not self.own_share): # Sell Share or No Share # consider the transaction in the reverse order reward = ((1 - self.trading_cost_ratio) ** 2 * p1 / p2 - 1) * 100 return reward
Sorry, the function is true.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Sorry, the function is true.
The text was updated successfully, but these errors were encountered: