Exemplo n.º 1
0
def deal_single_ins(item):
    r = False
    if item['ins'] == 'down_sell':
        df = ts.get_realtime_quotes(item['code'])
        b3_price = float(df.at[0, 'b3_p'])
        if b3_price <= item['price'] and b3_price > 0:
            to_log('reach price by down_sell ins ')
            item['ins'] = 'sell_order'
            send_instruction(item)
            r = True
    if item['ins'] == 'up_warn':
        df = ts.get_realtime_quotes(item['code'])
        b3_price = float(df.at[0, 'b3_p'])
        if b3_price >= item['price']:
            to_log('reach price by up_warn ins ')
            send_email(dss, 'up_warn', str(item))
            r = True
    if item['ins'] == 'down_warn':
        df = ts.get_realtime_quotes(item['code'])
        b3_price = float(df.at[0, 'b3_p'])
        if b3_price <= item['price'] and b3_price > 0:
            to_log('reach price by down_warn ins ')
            send_email(dss, 'down_warn', str(item))
            r = True
    if item['ins'] in ['sell_order', 'buy_order']:
        to_log('send sell_order or buy_order ins ')
        send_instruction(item)
        r = True

    return r
Exemplo n.º 2
0
    def _bc_sendOrder(self, code, direction, offset, price, volume, portfolio):
        cost = int(price * volume)
        df = ts.get_realtime_quotes(code)
        name = df.at[0, 'name']
        ins_dict = {}

        if direction == DIRECTION_LONG:
            ins_dict = {
                'ins': 'buy_order',
                'portfolio': portfolio,
                'code': code,
                'num': volume,
                'price': price,
                'cost': cost,
                'agent': 'pingan',
                'name': name
            }
        if direction == DIRECTION_SHORT:
            ins_dict = {
                'ins': 'sell_order',
                'portfolio': portfolio,
                'code': code,
                'num': volume,
                'price': price,
                'cost': cost,
                'agent': 'pingan',
                'name': name
            }
        if ins_dict != {}:
            send_instruction(ins_dict)