mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 07:26:49 +00:00
Merge branch 'master' into engine
This commit is contained in:
@@ -250,7 +250,7 @@ func (b *Binance) WsHandleData() {
|
||||
|
||||
b.Websocket.DataHandler <- exchange.TradeData{
|
||||
CurrencyPair: currency.NewPairFromString(trade.Symbol),
|
||||
Timestamp: time.Unix(0, trade.TimeStamp),
|
||||
Timestamp: time.Unix(0, trade.TimeStamp*int64(time.Millisecond)),
|
||||
Price: price,
|
||||
Amount: amount,
|
||||
Exchange: b.GetName(),
|
||||
|
||||
@@ -379,7 +379,7 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
|
||||
var bids, asks []orderbook.Item
|
||||
|
||||
for _, orderbookItem := range data {
|
||||
if orderbookItem.Side == exchange.SellOrderSide.ToString() {
|
||||
if strings.EqualFold(orderbookItem.Side, exchange.SellOrderSide.ToString()) {
|
||||
asks = append(asks, orderbook.Item{
|
||||
Price: orderbookItem.Price,
|
||||
Amount: float64(orderbookItem.Size),
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
huobiTimestamp = "common/timestamp"
|
||||
huobiAccounts = "account/accounts"
|
||||
huobiAccountBalance = "account/accounts/%s/balance"
|
||||
huobiAggregatedBalance = "subuser/aggregate-balance"
|
||||
huobiOrderPlace = "order/orders/place"
|
||||
huobiOrderCancel = "order/orders/%s/submitcancel"
|
||||
huobiOrderCancelBatch = "order/orders/batchcancel"
|
||||
@@ -310,6 +311,29 @@ func (h *HUOBI) GetAccountBalance(accountID string) ([]AccountBalanceDetail, err
|
||||
return result.AccountBalanceData.AccountBalanceDetails, err
|
||||
}
|
||||
|
||||
// GetAggregatedBalance returns the balances of all the sub-account aggregated.
|
||||
func (h *HUOBI) GetAggregatedBalance() ([]AggregatedBalance, error) {
|
||||
type response struct {
|
||||
Response
|
||||
AggregatedBalances []AggregatedBalance `json:"data"`
|
||||
}
|
||||
|
||||
var result response
|
||||
|
||||
err := h.SendAuthenticatedHTTPRequest(
|
||||
http.MethodGet,
|
||||
huobiAggregatedBalance,
|
||||
nil,
|
||||
nil,
|
||||
&result,
|
||||
)
|
||||
|
||||
if result.ErrorMessage != "" {
|
||||
return nil, errors.New(result.ErrorMessage)
|
||||
}
|
||||
return result.AggregatedBalances, err
|
||||
}
|
||||
|
||||
// SpotNewOrder submits an order to Huobi
|
||||
func (h *HUOBI) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
|
||||
data := struct {
|
||||
|
||||
@@ -211,6 +211,19 @@ func TestGetAccountBalance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAggregatedBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if h.APIKey == "" || h.APISecret == "" || h.APIAuthPEMKey == "" {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
_, err := h.GetAggregatedBalance()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Huobi GetAggregatedBalance: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpotNewOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -131,6 +131,12 @@ type AccountBalanceDetail struct {
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// AggregatedBalance stores balances of all the sub-account
|
||||
type AggregatedBalance struct {
|
||||
Currency string `json:"currency"`
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// CancelOrderBatch stores the cancel order batch data
|
||||
type CancelOrderBatch struct {
|
||||
Success []string `json:"success"`
|
||||
|
||||
@@ -35,6 +35,7 @@ const (
|
||||
huobihadaxCurrencies = "common/currencys"
|
||||
huobihadaxTimestamp = "common/timestamp"
|
||||
huobihadaxAccounts = "account/accounts"
|
||||
huobihadaxAggregatedBalance = "subuser/aggregate-balance"
|
||||
huobihadaxAccountBalance = "account/accounts/%s/balance"
|
||||
huobihadaxOrderPlace = "order/orders/place"
|
||||
huobihadaxOrderCancel = "order/orders/%s/submitcancel"
|
||||
@@ -303,6 +304,28 @@ func (h *HUOBIHADAX) GetAccountBalance(accountID string) ([]AccountBalanceDetail
|
||||
return result.AccountBalanceData.AccountBalanceDetails, err
|
||||
}
|
||||
|
||||
// GetAggregatedBalance returns the balances of all the sub-account aggregated.
|
||||
func (h *HUOBIHADAX) GetAggregatedBalance() ([]AggregatedBalance, error) {
|
||||
type response struct {
|
||||
Response
|
||||
AggregatedBalances []AggregatedBalance `json:"data"`
|
||||
}
|
||||
|
||||
var result response
|
||||
|
||||
err := h.SendAuthenticatedHTTPRequest(
|
||||
http.MethodGet,
|
||||
huobihadaxAggregatedBalance,
|
||||
url.Values{},
|
||||
&result,
|
||||
)
|
||||
|
||||
if result.ErrorMessage != "" {
|
||||
return nil, errors.New(result.ErrorMessage)
|
||||
}
|
||||
return result.AggregatedBalances, err
|
||||
}
|
||||
|
||||
// SpotNewOrder submits an order to Huobi
|
||||
func (h *HUOBIHADAX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
|
||||
vals := make(map[string]string)
|
||||
|
||||
@@ -256,6 +256,18 @@ func TestGetAccountBalance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAggregatedBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
if h.APIKey == "" || h.APISecret == "" || h.APIAuthPEMKey == "" {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
_, err := h.GetAggregatedBalance()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Huobi GetAggregatedBalance: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpotNewOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -113,6 +113,12 @@ type AccountBalanceDetail struct {
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// AggregatedBalance stores balances of all the sub-account
|
||||
type AggregatedBalance struct {
|
||||
Currency string `json:"currency"`
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// CancelOrderBatch stores the cancel order batch data
|
||||
type CancelOrderBatch struct {
|
||||
Success []string `json:"success"`
|
||||
|
||||
@@ -456,7 +456,7 @@ func (o *OKGroup) wsProcessTrades(response *WebsocketDataResponse) {
|
||||
for i := range response.Data {
|
||||
instrument := currency.NewPairDelimiter(response.Data[i].InstrumentID, "-")
|
||||
o.Websocket.DataHandler <- exchange.TradeData{
|
||||
Amount: response.Data[i].Qty,
|
||||
Amount: response.Data[i].Size,
|
||||
AssetType: o.GetAssetTypeFromTableName(response.Table),
|
||||
CurrencyPair: instrument,
|
||||
EventTime: time.Now().Unix(),
|
||||
|
||||
Reference in New Issue
Block a user