def test_env_buy(self): trade = Trade() trade.new_episode() print(trade.time) trade.step(ACTION.BUY) print(trade.time)
def test_buy_order(self): trade = Trade() trade.new_episode() print(trade.time) trade.step(ACTION.BUY) print(trade.time) print(trade.buy_order_price) print(trade.margin)
def test_sell_order(self): trade = Trade() trade.new_episode() print(trade.time) trade.step(ACTION.SELL) print(trade.time) print(trade.sell_order_price) print(trade.margin)
def test_env_sell_buy(self): trade = Trade() trade.new_episode() print(trade.time) trade.step(ACTION.SELL_NOW) print(trade.time) print(trade.sell_order_price) print(trade.margin) # close transaction print(trade.time) trade.step(ACTION.BUY_NOW) print(trade.time) print(trade.margin)
def test_env_step(self): trade = Trade() trade.new_episode() trade.step(ACTION.NOP) trade.step(ACTION.BUY) trade.step(ACTION.BUY_NOW) trade.step(ACTION.SELL) trade.step(ACTION.SELL_NOW)
def one_episode(self, env: Trade): s = env.new_episode() while True: action = self.policy(s) print('action->', action, end='') next_state, reward, done, info = env.step(action) print('reward->', reward) if done: break s = next_state return reward