You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from huobi.connection.restapi_sync_client import RestApiSyncClient
from huobi.constant.system import HttpMethod
from huobi.utils.json_parser import default_parse_data_as_long
'''
https://huobiapi.github.io/docs/usdt_swap/v1/cn/#136259e73a
该接口仅支持逐仓模式。
请求参数
参数名称 是否必须 类型 描述 取值范围
contract_code true string 合约代码 "BTC-USDT" ...
page_index false int 页码不填默认第1页
page_size false int 页长不填默认20不得多于50
返回参数
参数名称 是否必须 类型 描述 取值范围
status true string 请求处理结果
<data>
<orders>
symbol true string 品种代码
contract_code true string 合约代码 "BTC-USDT" ...
volume true decimal 委托数量
price true decimal 委托价格
order_price_type true string 订单报价类型 "limit":限价,"opponent":对手价,"post_only":只做maker单,post only下单只受用户持仓数量限制"lightning":闪电平仓,"optimal_5":最优5档"optimal_10":最优10档"optimal_20":最优20档"fok":FOK订单"ioc":IOC订单, "opponent_ioc": 对手价-IOC下单"lightning_ioc": 闪电平仓-IOC下单"optimal_5_ioc": 最优5档-IOC下单"optimal_10_ioc": 最优10档-IOC下单"optimal_20_ioc"最优20档-IOC下单"opponent_fok" 对手价-FOK下单"lightning_fok":闪电平仓-FOK下单"optimal_5_fok"最优5档-FOK下单"optimal_10_fok"最优10档-FOK下单"optimal_20_fok"最优20档-FOK下单
order_type true int 订单类型 1:报单 、 2:撤单 、 3:强平、4:交割
direction true string "buy":买 "sell":卖
offset true string "open":开 "close":平
lever_rate true int 杠杆倍数
order_id true long 订单ID
order_id_str true string 订单ID字符串类型
client_order_id true long 客户订单ID
created_at true long 订单创建时间
trade_volume true decimal 成交数量
trade_turnover true decimal 成交总金额
fee true decimal 手续费
fee_asset true string 手续费币种 "BTC","ETH"...
trade_avg_price true decimal 成交均价
margin_frozen true decimal 冻结保证金
margin_asset true string 保证金币种(计价币种)
profit true decimal 收益
status true int 订单状态 (3未成交 4部分成交 5部分成交已撤单 6全部成交 7已撤单)
order_source true string 订单来源 system:系统、web:用户网页、api:用户API、m:用户M站、risk:风控系统、settlement:交割结算、iosios客户端、android安卓客户端、windowswindows客户端、macmac客户端、trigger计划委托触发、tpsl:止盈止损触发)
liquidation_type true string 强平类型
canceled_at true long 撤单时间
margin_mode true string 保证金模式 isolated逐仓模式
margin_account true string 保证金账户 比如“BTC-USDT”
is_tpsl true int 是否设置止盈止损 10
</orders>
total_page true int 总页数
current_page true int 当前页
total_size true int 总条数
</data>
ts true long 时间戳
'''
class PostSwapOpenOrdersService:
def __init__(self, params):
self.params = params
def request(self, **kwargs):
channel = "/linear-swap-api/v1/swap_openorders"
def parse(dict_data):
return default_parse_data_as_long(dict_data, None)
return RestApiSyncClient(**kwargs).request_process(HttpMethod.POST_SIGN, channel, self.params, parse)