from huobi.connection.restapi_sync_client import RestApiSyncClient from huobi.constant import * from huobi.utils.json_parser import default_parse_data_as_long ''' https://huobiapi.github.io/docs/spot/v1/cn/#5ea2e0cde2-7 下单 API Key 权限:交易 限频值;100次/2s 发送一个新订单到火币以进行撮合。 请求参数: account-id 账户 ID,取值参考 GET /v1/account/accounts。现货交易使用 ‘spot’ 账户的 account-id;逐仓杠杆交易,请使用 ‘margin’ 账户的 account-id;全仓杠杆交易,请使用 ‘super-margin’ 账户的 account-id symbol 交易对,即btcusdt, ethbtc...(取值参考GET /v1/common/symbols) type 订单类型,包括buy-market, sell-market, buy-limit, sell-limit, buy-ioc, sell-ioc, buy-limit-maker, sell-limit-maker(说明见下文), buy-stop-limit, sell-stop-limit, buy-limit-fok, sell-limit-fok, buy-stop-limit-fok, sell-stop-limit-fok amount 订单交易量(市价买单为订单交易额) price 订单价格(对市价单无效) source 现货交易填写“spot-api”,逐仓杠杆交易填写“margin-api”,全仓杠杆交易填写“super-margin-api”, C2C杠杆交易填写"c2c-margin-api" client-order-id 用户自编订单号(最大长度64个字符,须在24小时内保持唯一性) stop-price 止盈止损订单触发价格 operator 止盈止损订单触发价运算符 gte – greater than and equal (>=), lte – less than and equal (<=) buy-limit-maker 当“下单价格”>=“市场最低卖出价”,订单提交后,系统将拒绝接受此订单; 当“下单价格”<“市场最低卖出价”,提交成功后,此订单将被系统接受。 sell-limit-maker 当“下单价格”<=“市场最高买入价”,订单提交后,系统将拒绝接受此订单; 当“下单价格”>“市场最高买入价”,提交成功后,此订单将被系统接受。 响应数据: { "account-id": "100009", "amount": "10.1", "price": "100.1", "source": "api", "symbol": "ethusdt", "type": "buy-limit", "client-order-id": "a0001" 如client order ID(在24小时内)被复用,节点将返回错误消息invalid.client.order.id。 } ''' class PostCreateOrderService: def __init__(self, params): self.params = params def request(self, **kwargs): channel = "/v1/order/orders/place" 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)