HuobiRDCenter / huobi_Golang

Go SDK for Huobi Spot API
https://www.htx.com/zh-cn/opend/newApiPages/
Apache License 2.0
176 stars 86 forks source link

Changes by the Optimization of “Search Past Orders” Interface on API #49

Closed cdkagaya closed 2 years ago

cdkagaya commented 2 years ago

https://www.huobi.com/support/en-us/detail/64892083374346 This update involves the below: github.com\huobirdcenter\huobi_golang\pkg\client\orderclient.go

// Returns orders based on a specific searching criteria.
func (p *OrderClient) GetHistoryOrders(request *model.GetRequest) (*order.GetHistoryOrdersResponse, error) {
    url := p.privateUrlBuilder.Build("GET", "/v1/order/orders", request)
    getResp, getErr := internal.HttpGet(url)
    if getErr != nil {
        return nil, getErr
    }

    result := order.GetHistoryOrdersResponse{}
    jsonErr := json.Unmarshal([]byte(getResp), &result)
    if jsonErr != nil {
        return nil, jsonErr
    }

    return &result, nil
}

to be: /v1/order/openOrders

order state: created: The order is created, and not in the matching queue yet. submitted: The order is submitted, and already in the matching queue, waiting for deal. partial-filled: The order is already in the matching queue and partially traded, and is waiting for further matching and trade. filled: The order is already traded and not in the matching queue any more. partial-canceled: The order is not in the matching queue any more. The status is transferred from 'partial-filled', the order is partially trade, but remaining is canceled. canceling: The order is under canceling, but haven't been removed from matching queue yet. canceled: The order is not in the matching queue any more, and completely canceled. There is no trade associated with this order.

or make a new:

// Returns all open orders based on a specific searching criteria.
// https://www.huobi.com/support/en-us/detail/64892083374346
func (p *OrderClient) GetAllOpenOrders(request *model.GetRequest) (*order.GetHistoryOrdersResponse, error) {
    url := p.privateUrlBuilder.Build("GET", "/v1/order/openOrders", request)
    getResp, getErr := internal.HttpGet(url)
    if getErr != nil {
        return nil, getErr
    }

    result := order.GetHistoryOrdersResponse{}
    jsonErr := json.Unmarshal([]byte(getResp), &result)
    if jsonErr != nil {
        return nil, jsonErr
    }

    return &result, nil
}