def get_history_orders(self, symbol, page_index=None, page_size=None, create_date=1): """ symbol true string 品种代码 "BTC","ETH"... trade_type true int 交易类型 0:全部,1:买入开多,2: 卖出开空,3: 买入平空,4: 卖出平多,5: 卖出强平,6: 买入强平 create_date true int 日期 可随意输入正整数,如果参数超过90则默认查询90天的数据 contract_code false string 合约code page_index false int 页码,不填默认第1页 1 page_size false int 不填默认20,不得多于50 20 """ params = {} if symbol: params['symbol'] = symbol #if contract_code: # params["contract_code"] = contract_code if page_index: params["page_index"] = page_index params["page_size"] = 50 params["trade_type"] = 0 if create_date: params["create_date"] = int(create_date) request_path = '/api/v1/contract_matchresults' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_history_orders(self, symbol, trade_type, type, status, create_date, page_index=None, page_size=None): """ 参数名称 是否必须 类型 描述 取值范围 symbol true string 品种代码 "BTC","ETH"... trade_type true int 交易类型 0:全部,1:买入开多,2: 卖出开空,3: 买入平空,4: 卖出平多,5: 卖出强平,6: 买入强平,7:交割平多,8: 交割平空 type true int 类型 1:所有订单、2:结束汏订单 status true int 订单状态 0:全部,3:未成交, 4: 部分成交,5: 部分成交已撤单,6: 全部成交,7:已撤单 create_date true int 日期 7,90(7天或者90天) page_index false int 页码,不填默认第1页 page_size false int 不填默认20,不得多于50 """ params = { "symbol": symbol, "trade_type": trade_type, "type": type, "status": status, "create_date": create_date } if page_index: params["page_index"] = page_index if page_size: params["page_size"] = page_size request_path = '/api/v1/contract_hisorders' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_order_detail(self, symbol, order_id, order_type, created_at, page_index=None, page_size=None): """ 参数名称 是否必须 类型 描述 symbol true string "BTC","ETH"... order_id true long 订单id order_type true int 订单类型。1:报单, 2:撤单, 3:爆仓, 4:交割 created_at true number 订单创建时间 page_index false int 第几页,不填第一页 page_size false int 不填默认20,不得多于50 """ params = { "symbol": symbol, "order_id": order_id, "order_type": order_type, "created_at": created_at } if page_index: params["page_index"] = page_index if page_size: params["page_size"] = page_size request_path = '/api/v1/contract_order_detail' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def contract_account_position_info(self, symbol): params = {} if symbol: params["symbol"] = symbol request_path = '/api/v1/contract_account_position_info' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_account_info(self, symbol=''): """ :param symbol: "BTC","ETH"...如果缺省,默认返回所有品种 :return: """ params = {} if symbol: params["symbol"] = symbol request_path = '/api/v1/contract_account_info' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_order_info(self, symbol, order_id='', client_order_id=''): """ 参数名称 是否必须 类型 描述 symbol true string BTC, ETH, ... order_id false string 订单ID( 多个订单ID中间以","分隔,一次最多允许查询20个订单 ) client_order_id false string 客户订单ID(多个订单ID中间以","分隔,一次最多允许查询20个订单) 备注:order_id和client_order_id都可以用来查询,同时只可以设置其中一种,如果设置了两种,默认以order_id来查询。 """ params = {"symbol": symbol} if order_id: params["order_id"] = order_id if client_order_id: params["client_order_id"] = client_order_id request_path = '/api/v1/contract_order_info' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_open_orders(self, symbol=None, page_index=None, page_size=50): """ 参数名称 是否必须 类型 描述 symbol false string "BTC","ETH"... page_index false int 第几页,不填第一页 page_size false int 不填默认20,不得多于50 """ params = {} if symbol: params["symbol"] = symbol if page_index: params["page_index"] = page_index if page_size: params["page_size"] = page_size request_path = '/api/v1/contract_openorders' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def send_contract_order(self, symbol, contract_type, contract_code, client_order_id, price, volume, direction, offset, lever_rate, order_price_type): """ :symbol: "BTC","ETH".. :contract_type: "this_week", "next_week", "quarter" :contract_code: "BTC181228" :client_order_id: 客户自己填写和维护,这次一定要大于上一次 :price 必填 价格 :volume 必填 委托数量(张) :direction 必填 "buy" "sell" :offset 必填 "open", "close" :lever_rate 必填 杠杆倍数 :order_price_type 必填 "limit"限价, "opponent" 对手价 备注:如果contract_code填了值,那就按照contract_code去下单,如果contract_code没有填值,则按照symbol+contract_type去下单。 : """ params = { "price": price, "volume": volume, "direction": direction, "offset": offset, "lever_rate": lever_rate, "order_price_type": order_price_type } if symbol: params["symbol"] = symbol if contract_type: params['contract_type'] = contract_type if contract_code: params['contract_code'] = contract_code if client_order_id: params['client_order_id'] = client_order_id request_path = '/api/v1/contract_order' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)
def get_contract_account_info(self): request_path = '/api/v1/subuser/aggregate-balance' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key)