Exemple #1
0
 def order_action(self, orderref):
     reqid = self.get_requestid()
     req   = ApiStruct.InputOrderAction(BrokerID=self.broker_id,\
                                        InvestorID=self.investor_id,\
                                        OrderRef=orderref,\
                                        ActionFlag=ApiStruct.AF_Delete,\
                                        RequestID=reqid)
     print("OrderAction: ", req)
     self.ReqOrderAction(req, reqid)
Exemple #2
0
 def refer(self, instrument_id, exchange_id, order_sys_id):
     order_action = ApiStruct.InputOrderAction(
         BrokerID=self.broker_id,
         InvestorID=self.user_id,
         InstrumentID=instrument_id,
         ActionFlag=ApiStruct.AF_Delete,
         ExchangeID=exchange_id,
         OrderSysID=order_sys_id)
     self.request_id += 1
     return self.api.ReqOrderAction(order_action, self.request_id) == 0
Exemple #3
0
 def refer_local(self, instrument_id, order_ref):
     order_action = ApiStruct.InputOrderAction(
         BrokerID=self.broker_id,
         InvestorID=self.user_id,
         InstrumentID=instrument_id,
         ActionFlag=ApiStruct.AF_Delete,
         FrontID=self.front_id,
         SessionID=self.session_id,
         OrderRef=order_ref)
     self.request_id += 1
     return self.api.ReqOrderAction(order_action, self.request_id) == 0
Exemple #4
0
def get_col_type(col_value):
    val_type = type(col_value)
    if val_type == bytes:
        col_type = VARBINARY(20)
    elif val_type == float:
        col_type = Float
    elif val_type == int:
        col_type = Integer
    else:
        raise TypeError('unsupported type of %s' % val_type)
    return col_type


def create_table(metadata, base_struct_obj):
    logger.debug(base_struct_obj.__class__.__name__)
    table_name = base_struct_obj.__class__.__name__
    # [print(col_name, getattr( base_struct_obj, col_name)) for col_name, col_type in base_struct_obj._fields_]
    col_attr = (Column(col_name,
                       get_col_type(getattr(base_struct_obj, col_name)))
                for col_name, col_value in base_struct_obj._fields_)
    table_obj = Table(table_name, metadata, *col_attr)


if __name__ == "__main__":
    engine = Config.get_db_engine(Config.DB_SCHEMA_MD)
    metadata = MetaData()
    create_table(metadata, ApiStruct.InputOrderAction())
    create_table(metadata, ApiStruct.DepthMarketData())
    metadata.create_all(engine)  # 创建表结构