示例#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_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
示例#3
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
示例#4
0
 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'
示例#5
0
    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'