mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Add ANX Depth support
This commit is contained in:
@@ -26,6 +26,7 @@ const (
|
||||
ANX_RECEIVE_ADDRESS = "receive"
|
||||
ANX_CREATE_ADDRESS = "receive/create"
|
||||
ANX_TICKER = "money/ticker"
|
||||
ANX_DEPTH = "money/depth"
|
||||
)
|
||||
|
||||
type ANX struct {
|
||||
@@ -90,6 +91,15 @@ func (a *ANX) GetTicker(currency string) (ANXTicker, error) {
|
||||
return ticker, nil
|
||||
}
|
||||
|
||||
func (a *ANX) GetDepth(currency string) (Depth, error) {
|
||||
var depth Depth
|
||||
err := common.SendHTTPGetRequest(fmt.Sprintf("%sapi/2/%s/%s", ANX_API_URL, currency, ANX_TICKER), true, a.Verbose, &depth)
|
||||
if err != nil {
|
||||
return depth, err
|
||||
}
|
||||
return depth, nil
|
||||
}
|
||||
|
||||
func (a *ANX) GetAPIKey(username, password, otp, deviceID string) (string, string, error) {
|
||||
request := make(map[string]interface{})
|
||||
request["nonce"] = strconv.FormatInt(time.Now().UnixNano(), 10)[0:13]
|
||||
|
||||
@@ -100,6 +100,17 @@ func TestGetTicker(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDepth(t *testing.T) {
|
||||
a := ANX{}
|
||||
ticker, err := a.GetDepth("BTCUSD")
|
||||
if err != nil {
|
||||
t.Errorf("Test Failed - ANX GetDepth() error: %s", err)
|
||||
}
|
||||
if ticker.Result != "success" {
|
||||
t.Error("Test Failed - ANX GetDepth() unsuccessful")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAPIKey(t *testing.T) {
|
||||
getAPIKey := ANX{}
|
||||
apiKey, apiSecret, err := getAPIKey.GetAPIKey("userName", "passWord", "", "1337")
|
||||
|
||||
@@ -51,3 +51,20 @@ type ANXTicker struct {
|
||||
UpdateTime string `json:"dataUpdateTime"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type DepthItem struct {
|
||||
Price float64 `json:"price,string"`
|
||||
PriceInt float64 `json:"price_int,string"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
AmountInt int64 `json:"amount_int,string"`
|
||||
}
|
||||
|
||||
type Depth struct {
|
||||
Result string `json:"result"`
|
||||
Data struct {
|
||||
Now string `json:"now"`
|
||||
DataUpdateTime string `json:"dataUpdateTime"`
|
||||
Asks []DepthItem `json:"asks`
|
||||
Bids []DepthItem `json:"bids"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@@ -111,7 +111,21 @@ func (a *ANX) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.B
|
||||
// UpdateOrderbook updates and returns the orderbook for a currency pair
|
||||
func (a *ANX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {
|
||||
var orderBook orderbook.Base
|
||||
return orderBook, nil
|
||||
orderbookNew, err := a.GetDepth(exchange.FormatExchangeCurrency(a.GetName(), p).String())
|
||||
if err != nil {
|
||||
return orderBook, err
|
||||
}
|
||||
|
||||
for x := range orderbookNew.Data.Asks {
|
||||
orderBook.Asks = append(orderBook.Asks, orderbook.Item{Price: orderbookNew.Data.Asks[x].Price, Amount: orderbookNew.Data.Asks[x].Amount})
|
||||
}
|
||||
|
||||
for x := range orderbookNew.Data.Bids {
|
||||
orderBook.Bids = append(orderBook.Bids, orderbook.Item{Price: orderbookNew.Data.Bids[x].Price, Amount: orderbookNew.Data.Bids[x].Amount})
|
||||
}
|
||||
|
||||
orderbook.ProcessOrderbook(a.GetName(), p, orderBook, assetType)
|
||||
return orderbook.GetOrderbook(a.Name, p, assetType)
|
||||
}
|
||||
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the ANX exchange
|
||||
|
||||
@@ -230,11 +230,6 @@ func OrderbookUpdaterRoutine() {
|
||||
if bot.exchanges[x] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if bot.exchanges[x].GetName() == "ANX" {
|
||||
continue
|
||||
}
|
||||
|
||||
exchangeName := bot.exchanges[x].GetName()
|
||||
enabledCurrencies := bot.exchanges[x].GetEnabledCurrencies()
|
||||
var result orderbook.Base
|
||||
|
||||
Reference in New Issue
Block a user