コード例 #1
0
 def handle_bar(context, bar_dict):
     order_id = order_percent(context.s1, 0.0001, style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.price == context.limitprice
コード例 #2
0
 def handle_bar(context, bar_dict):
     order_id = order_shares(context.s1, context.amount, style=LimitOrder(context.limitprice))
     cancel_order(order_id)
     order = get_order(order_id)
     assert order.order_book_id == context.s1
     assert order.filled_quantity == 0
     return order_id
     assert order.price == context.limitprice
コード例 #3
0
 def handle_bar(context, bar_dict):
     order_id = order_shares(context.s1,
                             context.amount,
                             style=LimitOrder(9.5))
     order = get_order(order_id)
     assert order.order_book_id == context.s1
     assert order.quantity == context.amount
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
コード例 #4
0
ファイル: test_api_stock.py プロジェクト: kknet/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_target_percent(context.s1, 0.02, style=LimitOrder(context.limitprice))
     print("after: ", context.portfolio.cash)
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.price == context.limitprice
コード例 #5
0
 def handle_bar(context, bar_dict):
     order_id = order_target_percent(context.s1, 0.02, style=LimitOrder(context.limitprice))
     print("after: ", context.portfolio.cash)
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.price == context.limitprice
コード例 #6
0
ファイル: test_api_base.py プロジェクト: 8dspaces/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_shares(context.s1, context.amount, style=LimitOrder(context.limitprice))
     cancel_order(order_id)
     order = get_order(order_id)
     assert order.order_book_id == context.s1
     assert order.filled_quantity == 0
     return order_id
     assert order.price == context.limitprice
コード例 #7
0
ファイル: test_api_stock.py プロジェクト: kknet/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_percent(context.s1, 0.0001, style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.price == context.limitprice
コード例 #8
0
ファイル: test_api_stock.py プロジェクト: kknet/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_lots(context.s1, 1, style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if context.amount > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.quantity == 100
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.price == context.limitprice
コード例 #9
0
 def handle_bar(context, bar_dict):
     order_id = order_lots(context.s1, 1, style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if context.amount > 0 else SIDE.SELL
     assert order.side == order_side
     assert order.order_book_id == context.s1
     assert order.quantity == 100
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.price == context.limitprice
コード例 #10
0
ファイル: test_api_stock.py プロジェクト: 8dspaces/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_value(context.s1, 1000, style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side, 'order.side is wrong'
     assert order.order_book_id == context.s1, 'Order_book_id is wrong'
     assert order.quantity == 100, 'order.quantity is wrong'
     assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
     assert order.price == context.limitprice, 'order.price is wrong'
コード例 #11
0
ファイル: test_api_future.py プロジェクト: kknet/rqalpha
 def handle_bar(context, bar_dict):
     order_id = buy_open(context.f1, 1)
     order = get_order(order_id)
     assert order.order_book_id == context.f1
     assert order.quantity == 1
     assert order.status == ORDER_STATUS.ACTIVE
     assert order.unfilled_quantity == 1
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.side == SIDE.BUY
     assert order.position_effect == POSITION_EFFECT.OPEN
コード例 #12
0
 def handle_bar(context, bar_dict):
     order_id = buy_close(context.f1, 1)
     order = get_order(order_id)
     assert order.order_book_id == context.f1
     assert order.quantity == 1
     assert order.status == ORDER_STATUS.ACTIVE
     assert order.unfilled_quantity == 1
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.side == SIDE.BUY
     assert order.position_effect == POSITION_EFFECT.CLOSE
コード例 #13
0
 def handle_bar(context, bar_dict):
     order_id = buy_close(context.f1, 1)
     order = get_order(order_id)
     assert order.order_book_id == context.f1, 'Order_book_id is wrong'
     assert order.quantity == 1, 'order.quantity is wrong'
     assert order.status == ORDER_STATUS.REJECTED, 'order.status is wrong'
     assert order.unfilled_quantity == 1, 'order.unfilled_quantity is wrong'
     assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
     assert order.side == SIDE.BUY, 'order.side is wrong'
     assert order.position_effect == POSITION_EFFECT.CLOSE, 'order.position_effect is wrong'
コード例 #14
0
 def handle_bar(context, bar_dict):
     order_id = sell_open(context.f1, 1)
     order = get_order(order_id)
     assert order.order_book_id == context.f1, 'Order_book_id is wrong'
     assert order.quantity == 1, 'order.quantity is wrong'
     assert order.status == ORDER_STATUS.FILLED, 'order.status is wrong'
     assert order.unfilled_quantity == 0, 'order.unfilled_quantity is wrong'
     assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
     assert order.side == SIDE.SELL, 'order.side is wrong'
     assert order.position_effect == POSITION_EFFECT.OPEN, 'order.position_effect is wrong'
コード例 #15
0
ファイル: test_api_future.py プロジェクト: ruyiqf/rqalpha
 def handle_bar(context, bar_dict):
     order_id = sell_close(context.f1, 1)
     order = get_order(order_id)
     assert order.order_book_id == context.f1
     assert order.quantity == 1
     assert order.status == ORDER_STATUS.REJECTED
     assert order.unfilled_quantity == 1
     assert order.unfilled_quantity + order.filled_quantity == order.quantity
     assert order.side == SIDE.SELL
     assert order.position_effect == POSITION_EFFECT.CLOSE
コード例 #16
0
ファイル: test_api_stock.py プロジェクト: handsomu/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_value(context.s1,
                            1000,
                            style=LimitOrder(context.limitprice))
     order = get_order(order_id)
     order_side = SIDE.BUY if order.quantity > 0 else SIDE.SELL
     assert order.side == order_side, 'order.side is wrong'
     assert order.order_book_id == context.s1, 'Order_book_id is wrong'
     assert order.quantity == 100, 'order.quantity is wrong'
     assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
     assert order.price == context.limitprice, 'order.price is wrong'
コード例 #17
0
ファイル: test_api_stock.py プロジェクト: handsomu/rqalpha
    def handle_bar(context, bar_dict):
        order_id = order_shares(context.s1,
                                10010,
                                style=LimitOrder(context.limitprice))
        order = get_order(order_id)
        assert order.side == SIDE.BUY, 'order.side is wrong'
        assert order.order_book_id == context.s1, 'Order_book_id is wrong'
        assert order.quantity == 10000, 'order.quantity is wrong'
        assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
        assert order.price == context.limitprice, 'order.price is wrong'

        order_id = order_shares(context.s1,
                                -10010,
                                style=LimitOrder(context.limitprice))
        order = get_order(order_id)
        assert order.side == SIDE.SELL, 'order.side is wrong'
        assert order.order_book_id == context.s1, 'Order_book_id is wrong'
        assert order.quantity == 10010, 'order.quantity is wrong'
        assert order.unfilled_quantity + order.filled_quantity == order.quantity, 'order.unfilled_quantity is wrong'
        assert order.price == context.limitprice, 'order.price is wrong'
コード例 #18
0
ファイル: test_api_base.py プロジェクト: 8dspaces/rqalpha
    def handle_bar(context, bar_dict):
        context.counter += 1

        order = order_shares(context.s1, context.amount, style=LimitOrder(context.limitprice))
        context.order_id = order.order_id
        print('cash: ', context.portfolio.cash)
        print('check_get_open_orders done')
        print(order.order_id)
        # print(get_open_orders())
        print(get_open_orders())
        print(get_order(order.order_id))
        if context.counter == 2:
            assert order.order_id in get_open_orders()
        context.counter = 0
コード例 #19
0
    def handle_bar(context, bar_dict):
        context.counter += 1

        order = order_shares(context.s1, context.amount, style=LimitOrder(context.limitprice))
        context.order_id = order.order_id
        print('cash: ', context.portfolio.cash)
        print('check_get_open_orders done')
        print(order.order_id)
        # print(get_open_orders())
        print(get_open_orders())
        print(get_order(order.order_id))
        if context.counter == 2:
            assert order.order_id in get_open_orders()
        context.counter = 0
コード例 #20
0
ファイル: test_api_base.py プロジェクト: 8dspaces/rqalpha
 def handle_bar(context, bar_dict):
     order_id = order_shares(context.s1, context.amount, style=LimitOrder(9.5))
     order = get_order(order_id)
     assert order.order_book_id == context.s1
     assert order.quantity == context.amount
     assert order.unfilled_quantity + order.filled_quantity == order.quantity