コード例 #1
0
 def get_orders(self,
                sec_type=SecurityType.ALL,
                market=Market.ALL,
                symbol=None,
                start_time=None,
                end_time=None,
                limit=100,
                is_brief=False):
     params = OrdersParams()
     params.account = self._account
     params.sec_type = sec_type.value
     params.market = market.value
     params.symbol = symbol
     params.start_data = start_time
     params.end_date = end_time
     params.limit = limit
     params.is_brief = is_brief
     request = OpenApiRequest(ORDERS, biz_model=params)
     response_content = self.__fetch_data(request)
     if response_content:
         response = OrdersResponse()
         response.parse_response_content(response_content)
         if response.is_success():
             return response.orders
         else:
             raise ApiException(response.code, response.message)
     return None
コード例 #2
0
 def get_open_orders(self,
                     account=None,
                     sec_type=None,
                     market=Market.ALL,
                     symbol=None,
                     start_time=None,
                     end_time=None,
                     parent_id=None):
     """
     获取待成交订单列表. 参数同 get_orders
     :param parent_id: 主订单 order_id
     """
     params = OrdersParams()
     params.account = account if account else self._account
     params.secret_key = self._secret_key
     params.sec_type = get_enum_value(sec_type)
     params.market = get_enum_value(market)
     params.symbol = symbol
     params.start_date = start_time
     params.end_date = end_time
     params.parent_id = parent_id
     request = OpenApiRequest(ACTIVE_ORDERS, biz_model=params)
     response_content = self.__fetch_data(request)
     if response_content:
         response = OrdersResponse()
         response.parse_response_content(response_content,
                                         secret_key=params.secret_key)
         if response.is_success():
             return response.orders
         else:
             raise ApiException(response.code, response.message)
     return None
コード例 #3
0
 def get_open_orders(self,
                     account=None,
                     sec_type=None,
                     market=Market.ALL,
                     symbol=None,
                     start_time=None,
                     end_time=None):
     """
     获取待成交订单列表
     :param account:
     :param sec_type:
     :param market:
     :param symbol:
     :param start_time:
     :param end_time:
     :return:
     """
     params = OrdersParams()
     params.account = account if account else self._account
     if sec_type:
         params.sec_type = sec_type.value
     params.market = market.value
     params.symbol = symbol
     params.start_date = start_time
     params.end_date = end_time
     request = OpenApiRequest(ACTIVE_ORDERS, biz_model=params)
     response_content = self.__fetch_data(request)
     if response_content:
         response = OrdersResponse()
         response.parse_response_content(response_content)
         if response.is_success():
             return response.orders
         else:
             raise ApiException(response.code, response.message)
     return None
コード例 #4
0
 def get_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None,
                limit=100, is_brief=False, states=None):
     """
     获取订单列表
     :param account:
     :param sec_type:
     :param market:
     :param symbol:
     :param start_time: 开始时间. 若是时间戳需要精确到毫秒, 为13位整数;
                                 或是日期时间格式的字符串,如"2017-01-01"和 "2017-01-01 12:00:00"
     :param end_time: 截至时间. 格式同 start_time
     :param limit: 每次获取订单的数量
     :param is_brief: 是否返回精简的订单数据
     :param states: 订单状态枚举对象列表, 可选, 若传递则按状态筛选
     :return: Order 对象构成的列表
     """
     params = OrdersParams()
     params.account = account if account else self._account
     if sec_type:
         params.sec_type = sec_type.value
     params.market = market.value
     params.symbol = symbol
     params.start_date = start_time
     params.end_date = end_time
     params.limit = limit
     params.is_brief = is_brief
     params.states = [state.value for state in states] if states else None
     request = OpenApiRequest(ORDERS, biz_model=params)
     response_content = self.__fetch_data(request)
     if response_content:
         response = OrdersResponse()
         response.parse_response_content(response_content)
         if response.is_success():
             return response.orders
         else:
             raise ApiException(response.code, response.message)
     return None