def handle_bar(context, bar_dict): context.cnt += 1 if context.cnt % 2 == 1: order_shares("000001.XSHE", 5000) else: order_shares("000001.XSHE", -5000)
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
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
def handle_bar(context, bar_dict): order_id = order_shares(context.s1, context.amount, 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 == context.amount assert order.unfilled_quantity + order.filled_quantity == order.quantity assert order.price == context.limitprice
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'
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
def handle_bar(context, bar_dict): context.cnt += 1 if context.cnt < 3: order_shares("000001.XSHE", 5000)