Ejemplo n.º 1
0
 def __init__(self, symbol, by_ctp_instrument=False, info=None, rd=None):
     Future.__init__(self,
                     symbol=symbol,
                     by_ctp_instrument=by_ctp_instrument,
                     info=info)
     self.rd = rd
     self.run = True
     self.t = None
     print('init ' + self.ctp_symbol)
Ejemplo n.º 2
0
                       MONGDB_IP='192.168.2.201',
                       MONGDB_USER='******',
                       DATASOURCE_DEFAULT=global_variable.DATASOURCE_REMOTE,
                       logging_level=global_variable.logging.INFO)
    rd = redis.Redis('192.168.1.36')
    long_margin = 50000
    short_margin = 50000
    level = 10
    long_value = long_margin * level
    short_value = short_margin * level
    long_code_lst = ['SC2005']
    short_code_lst = ['L2009', 'PP2009', 'TA2009', 'BU2009']
    long_cost_lst = [251]
    short_cost_lst = [5765, 5999]
    long_contract = [
        Future(symbol=i[:-4]).contract_size for i in long_code_lst
    ]
    short_contract = [
        Future(symbol=i[:-4]).contract_size for i in short_code_lst
    ]
    for x in range(1000000000):

        lst = []
        for i in range(len(long_code_lst)):
            index_code = long_code_lst[i]
            contract = long_contract[i]
            data = Future_ex(symbol=index_code, rd=rd).pub()
            if data is None:
                continue
            else:
                price_now = data['LastPrice']
Ejemplo n.º 3
0
    long_value = long_margin * level
    short_value = short_margin * level

    start_day = '2020-03-27'
    end_day = datetime.date.today().strftime('%Y-%m-%d')
    long_code_lst = ['SC2006']
    short_code_lst = ['PP2009']
    long_code_dict = get_normal_future_contract_code(long_code_lst)
    short_code_dict = get_normal_future_contract_code(short_code_lst)
    lst = []
    for index_code in long_code_lst:
        symble = long_code_dict[index_code]
        data_daily = stock_price(symble, start_day, end_day)[[
            'date_time', 'open', 'high', 'low', 'close'
        ]]
        contract = Future(symbol=index_code[:-4]).contract_size
        price_now = data_daily.close.tolist()[-1]
        long_volume = long_value / len(long_code_lst) / price_now / contract

        row = []
        row.append(index_code)
        row.append(long_volume)
        row.append(price_now)
        row.append(contract)
        lst.append(row)
    for index_code in short_code_lst:
        symble = short_code_dict[index_code]
        data_daily = stock_price(symble, start_day, end_day)[[
            'date_time', 'open', 'high', 'low', 'close'
        ]]
        contract = Future(symbol=index_code[:-4]).contract_size