예제 #1
0
    def test_env_buy(self):
        trade = Trade()
        trade.new_episode()

        print(trade.time)
        trade.step(ACTION.BUY)
        print(trade.time)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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