Exemple #1
0
def cancel_privous_1_order():
    global unfilled_buy_1_order, unfilled_sell_1_order
    if unfilled_sell_1_order:
        order_id=unfilled_sell_1_order["order_id"]
        others=unfilled_sell_1_order["others"]
        ret=cancel_order(order_id,others,HOST_ACT)
    if unfilled_buy_1_order:
        order_id=unfilled_buy_1_order["order_id"]
        others=unfilled_buy_1_order["others"]
        ret=cancel_order(order_id,others,HOST_ACT)
Exemple #2
0
def setup_env():
    unfilled_orders_ = query_unfilled_orders(TARGET_PID, HOST_ACT)
    easylog.info("Going to cancel unfilled_orders_ count:%d", len(unfilled_orders_['rows']))
    for row in unfilled_orders_["rows"]:
        ret=cancel_order(row["order_id"],{'trade_no':row["trade_no"]},HOST_ACT)
    if len(unfilled_orders_["rows"])>0:
        sltime = 6.0
        easylog.info("will sleep %f seconds to wait cancel order ", sltime)
        time.sleep(sltime)
Exemple #3
0
def create_sell_order(order):
    global unfilled_sell_1_order,sell_1

    if 'order_id' in unfilled_sell_1_order:
        order_id=unfilled_sell_1_order["order_id"]
        others=unfilled_sell_1_order["others"]
        ret=cancel_order(order_id,others,HOST_ACT)

    ret=create_order(TARGET_PID, str(order[1]), str(order[0]), ORDER_SIDE_SELL, get_uuid_str(), HOST_ACT)
    sell_1.add(ret['order_id'])
    unfilled_sell_1_order={
        "price":order[1],
        "created_at":0,
        "amount":order[0],
        "filled_amount" :0,
        "filled_cash_amount" :0,
        'order_id': ret['order_id'],
        'others': ret['others']
    }
    return ret['order_id']
Exemple #4
0
def create_sell_orders(orders):
    global self_unfilled_orders_sell,self_unfilled_orders_sell_helper
    self_unfilled_orders_sell_helper.sort(key=take_first)
    for order in orders:
        if len(self_unfilled_orders_sell_helper)>0 :
            orderc=self_unfilled_orders_sell_helper[0]
            order_id=orderc[1]
            others=self_unfilled_orders_sell[order_id]["others"]
            ret=cancel_order(order_id,others,HOST_ACT)

        ret=create_order(TARGET_PID, str(order[1]), str(order[0]), ORDER_SIDE_SELL, get_uuid_str(), HOST_ACT)
        self_unfilled_orders_sell[ret["order_id"]]={
        "price":order[1],
        "created_at":0,
        "amount":order[0],
        "filled_amount" :0,
        "filled_cash_amount" :0,
        'order_id': ret['order_id'],
        'others': ret['others']
    }
    for record_id in self_unfilled_orders_sell:
        self_unfilled_orders_sell_helper.append((self_unfilled_orders_sell[record_id]["price"],self_unfilled_orders_sell[record_id]["order_id"]))
Exemple #5
0
def create_buy_order(order,status=False):
    global unfilled_buy_1_order,buy_1,back_buy_orders

    if "order_id" in unfilled_buy_1_order:
        order_id=unfilled_buy_1_order["order_id"]
        others=unfilled_buy_1_order["others"]
        ret=cancel_order(order_id,others,HOST_ACT)

    ret=create_order(TARGET_PID, str(order[1]), str(order[0]), ORDER_SIDE_BUY, get_uuid_str(), HOST_ACT)
    buy_1.add(ret['order_id'])

    unfilled_buy_1_order={
        "price":order[1],
        "created_at":0,
        "amount":order[0],
        "filled_amount" :0,
        "filled_cash_amount" :0,
        'order_id': ret['order_id'],
        'others': ret['others']
    }
    if status:
        back_buy_orders[ret['order_id']]=unfilled_buy_1_order

    return ret['order_id']
Exemple #6
0
def cancel_order_for_back_buy(order_id):
    global back_buy_orders
    others=back_buy_orders[order_id]["others"]
    ret=cancel_order(order_id,others,HOST_ACT)
    if order_id in back_buy_orders:
        del back_buy_orders[order_id]
Exemple #7
0
def cancel_all_orders():
    global self_unfilled_orders_buy,self_unfilled_orders_buy_helper
    for order_id in self_unfilled_orders_buy:
        ret = cancel_order(order_id, self_unfilled_orders_buy[order_id]['others'],HOST_ACT)
    self_unfilled_orders_buy, self_unfilled_orders_buy_helper = {}, []