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.

58 lines
2.5 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 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)