mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
localbitcoins fixes (#177)
* General LocalBitcoin fixes * Added override variables to config for exchange packages to allow different API URL's
This commit is contained in:
@@ -58,7 +58,12 @@ func (a *ANX) SetDefaults() {
|
||||
a.AssetTypes = []string{ticker.Spot}
|
||||
a.SupportsAutoPairUpdating = true
|
||||
a.SupportsRESTTickerBatching = false
|
||||
a.Requester = request.New(a.Name, request.NewRateLimit(time.Second, anxAuthRate), request.NewRateLimit(time.Second, anxUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
a.Requester = request.New(a.Name,
|
||||
request.NewRateLimit(time.Second, anxAuthRate),
|
||||
request.NewRateLimit(time.Second, anxUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
a.APIUrlDefault = anxAPIURL
|
||||
a.APIUrl = a.APIUrlDefault
|
||||
}
|
||||
|
||||
//Setup is run on startup to setup exchange with config values
|
||||
@@ -89,6 +94,10 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = a.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +105,7 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
|
||||
// and cryptocurrencies)
|
||||
func (a *ANX) GetCurrencies() (CurrenciesStore, error) {
|
||||
var result CurrenciesStaticResponse
|
||||
path := fmt.Sprintf("%sapi/3/%s", anxAPIURL, anxCurrencies)
|
||||
path := fmt.Sprintf("%sapi/3/%s", a.APIUrl, anxCurrencies)
|
||||
|
||||
err := a.SendHTTPRequest(path, &result)
|
||||
if err != nil {
|
||||
@@ -117,7 +126,7 @@ func (a *ANX) GetFee(maker bool) float64 {
|
||||
// GetTicker returns the current ticker
|
||||
func (a *ANX) GetTicker(currency string) (Ticker, error) {
|
||||
var ticker Ticker
|
||||
path := fmt.Sprintf("%sapi/2/%s/%s", anxAPIURL, currency, anxTicker)
|
||||
path := fmt.Sprintf("%sapi/2/%s/%s", a.APIUrl, currency, anxTicker)
|
||||
|
||||
return ticker, a.SendHTTPRequest(path, &ticker)
|
||||
}
|
||||
@@ -125,7 +134,7 @@ func (a *ANX) GetTicker(currency string) (Ticker, error) {
|
||||
// GetDepth returns current orderbook depth.
|
||||
func (a *ANX) GetDepth(currency string) (Depth, error) {
|
||||
var depth Depth
|
||||
path := fmt.Sprintf("%sapi/2/%s/%s", anxAPIURL, currency, anxDepth)
|
||||
path := fmt.Sprintf("%sapi/2/%s/%s", a.APIUrl, currency, anxDepth)
|
||||
|
||||
return depth, a.SendHTTPRequest(path, &depth)
|
||||
}
|
||||
@@ -391,5 +400,5 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
|
||||
headers["Rest-Sign"] = common.Base64Encode([]byte(hmac))
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
return a.SendPayload("POST", anxAPIURL+path, headers, bytes.NewBuffer(PayloadJSON), result, true, a.Verbose)
|
||||
return a.SendPayload("POST", a.APIUrl+path, headers, bytes.NewBuffer(PayloadJSON), result, true, a.Verbose)
|
||||
}
|
||||
|
||||
@@ -71,7 +71,12 @@ func (b *Binance) SetDefaults() {
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = true
|
||||
b.SetValues()
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, binanceAuthRate), request.NewRateLimit(time.Second, binanceUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second, binanceAuthRate),
|
||||
request.NewRateLimit(time.Second, binanceUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = apiURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -102,6 +107,10 @@ func (b *Binance) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +136,7 @@ func (b *Binance) GetExchangeValidCurrencyPairs() ([]string, error) {
|
||||
// information
|
||||
func (b *Binance) GetExchangeInfo() (ExchangeInfo, error) {
|
||||
var resp ExchangeInfo
|
||||
path := apiURL + exchangeInfo
|
||||
path := b.APIUrl + exchangeInfo
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -151,7 +160,7 @@ func (b *Binance) GetOrderBook(obd OrderBookDataRequestParams) (OrderBook, error
|
||||
params.Set("symbol", common.StringToUpper(obd.Symbol))
|
||||
params.Set("limit", fmt.Sprintf("%d", obd.Limit))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, orderBookDepth, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, orderBookDepth, params.Encode())
|
||||
|
||||
if err := b.SendHTTPRequest(path, &resp); err != nil {
|
||||
return orderbook, err
|
||||
@@ -202,7 +211,7 @@ func (b *Binance) GetRecentTrades(rtr RecentTradeRequestParams) ([]RecentTrade,
|
||||
params.Set("symbol", common.StringToUpper(rtr.Symbol))
|
||||
params.Set("limit", fmt.Sprintf("%d", rtr.Limit))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, recentTrades, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, recentTrades, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -224,7 +233,7 @@ func (b *Binance) GetHistoricalTrades(symbol string, limit int, fromID int64) ([
|
||||
params.Set("limit", strconv.Itoa(limit))
|
||||
params.Set("fromid", strconv.FormatInt(fromID, 10))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, historicalTrades, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, historicalTrades, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -247,7 +256,7 @@ func (b *Binance) GetAggregatedTrades(symbol string, limit int) ([]AggregatedTra
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
params.Set("limit", strconv.Itoa(limit))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, aggregatedTrades, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, aggregatedTrades, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -277,7 +286,7 @@ func (b *Binance) GetSpotKline(arg KlinesRequestParams) ([]CandleStick, error) {
|
||||
params.Set("endTime", strconv.FormatInt(arg.EndTime, 10))
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, candleStick, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, candleStick, params.Encode())
|
||||
|
||||
if err := b.SendHTTPRequest(path, &resp); err != nil {
|
||||
return kline, err
|
||||
@@ -329,7 +338,7 @@ func (b *Binance) GetPriceChangeStats(symbol string) (PriceChangeStats, error) {
|
||||
params := url.Values{}
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, priceChange, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, priceChange, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -337,7 +346,7 @@ func (b *Binance) GetPriceChangeStats(symbol string) (PriceChangeStats, error) {
|
||||
// GetTickers returns the ticker data for the last 24 hrs
|
||||
func (b *Binance) GetTickers() ([]PriceChangeStats, error) {
|
||||
var resp []PriceChangeStats
|
||||
path := fmt.Sprintf("%s%s", apiURL, priceChange)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, priceChange)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
@@ -354,7 +363,7 @@ func (b *Binance) GetLatestSpotPrice(symbol string) (SymbolPrice, error) {
|
||||
params := url.Values{}
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, symbolPrice, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, symbolPrice, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -372,7 +381,7 @@ func (b *Binance) GetBestPrice(symbol string) (BestPrice, error) {
|
||||
params := url.Values{}
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
|
||||
path := fmt.Sprintf("%s%s?%s", apiURL, bestPrice, params.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, bestPrice, params.Encode())
|
||||
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -381,7 +390,7 @@ func (b *Binance) GetBestPrice(symbol string) (BestPrice, error) {
|
||||
func (b *Binance) NewOrderTest() (interface{}, error) {
|
||||
var resp interface{}
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, newOrderTest)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, newOrderTest)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", "BTCUSDT")
|
||||
@@ -396,7 +405,7 @@ func (b *Binance) NewOrderTest() (interface{}, error) {
|
||||
func (b *Binance) NewOrder(o NewOrderRequest) (NewOrderResponse, error) {
|
||||
var resp NewOrderResponse
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, newOrder)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, newOrder)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", o.Symbol)
|
||||
@@ -437,7 +446,7 @@ func (b *Binance) CancelOrder(symbol string, orderID int64, origClientOrderID st
|
||||
|
||||
var resp CancelOrderResponse
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, cancelOrder)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, cancelOrder)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", symbol)
|
||||
@@ -461,7 +470,7 @@ func (b *Binance) CancelOrder(symbol string, orderID int64, origClientOrderID st
|
||||
func (b *Binance) OpenOrders(symbol string) ([]QueryOrderData, error) {
|
||||
var resp []QueryOrderData
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, openOrders)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, openOrders)
|
||||
|
||||
params := url.Values{}
|
||||
if symbol != "" {
|
||||
@@ -480,7 +489,7 @@ func (b *Binance) OpenOrders(symbol string) ([]QueryOrderData, error) {
|
||||
func (b *Binance) AllOrders(symbol, orderID, limit string) ([]QueryOrderData, error) {
|
||||
var resp []QueryOrderData
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, allOrders)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, allOrders)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
@@ -501,7 +510,7 @@ func (b *Binance) AllOrders(symbol, orderID, limit string) ([]QueryOrderData, er
|
||||
func (b *Binance) QueryOrder(symbol, origClientOrderID string, orderID int64) (QueryOrderData, error) {
|
||||
var resp QueryOrderData
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, queryOrder)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, queryOrder)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", common.StringToUpper(symbol))
|
||||
@@ -531,7 +540,7 @@ func (b *Binance) GetAccount() (*Account, error) {
|
||||
|
||||
var resp response
|
||||
|
||||
path := fmt.Sprintf("%s%s", apiURL, accountInfo)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, accountInfo)
|
||||
params := url.Values{}
|
||||
|
||||
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
|
||||
|
||||
@@ -17,9 +17,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
bitfinexAPIURL = "https://api.bitfinex.com/v1/"
|
||||
bitfinexAPIURLBase = "https://api.bitfinex.com"
|
||||
bitfinexAPIVersion = "1"
|
||||
bitfinexAPIVersion = "/v1/"
|
||||
bitfinexAPIVersion2 = "2"
|
||||
bitfinexTickerV2 = "ticker"
|
||||
bitfinexTickersV2 = "tickers"
|
||||
@@ -102,7 +101,12 @@ func (b *Bitfinex) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = true
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second*60, bitfinexAuthRate), request.NewRateLimit(time.Second*60, bitfinexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second*60, bitfinexAuthRate),
|
||||
request.NewRateLimit(time.Second*60, bitfinexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = bitfinexAPIURLBase
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -133,13 +137,17 @@ func (b *Bitfinex) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetPlatformStatus returns the Bifinex platform status
|
||||
func (b *Bitfinex) GetPlatformStatus() (int, error) {
|
||||
var response []interface{}
|
||||
path := fmt.Sprintf("%s/v%s/%s", bitfinexAPIURLBase, bitfinexAPIVersion2,
|
||||
path := fmt.Sprintf("%s/v%s/%s", b.APIUrl, bitfinexAPIVersion2,
|
||||
bitfinexPlatformStatus)
|
||||
|
||||
err := b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
@@ -168,7 +176,7 @@ func (b *Bitfinex) GetLatestSpotPrice(symbol string) (float64, error) {
|
||||
// GetTicker returns ticker information
|
||||
func (b *Bitfinex) GetTicker(symbol string) (Ticker, error) {
|
||||
response := Ticker{}
|
||||
path := common.EncodeURLValues(bitfinexAPIURL+bitfinexTicker+symbol, url.Values{})
|
||||
path := common.EncodeURLValues(b.APIUrl+bitfinexAPIVersion+bitfinexTicker+symbol, url.Values{})
|
||||
|
||||
if err := b.SendHTTPRequest(path, &response, b.Verbose); err != nil {
|
||||
return response, err
|
||||
@@ -186,7 +194,7 @@ func (b *Bitfinex) GetTickerV2(symbol string) (Tickerv2, error) {
|
||||
var response []interface{}
|
||||
var ticker Tickerv2
|
||||
|
||||
path := fmt.Sprintf("%s/v%s/%s/%s", bitfinexAPIURLBase, bitfinexAPIVersion2, bitfinexTickerV2, symbol)
|
||||
path := fmt.Sprintf("%s/v%s/%s/%s", b.APIUrl, bitfinexAPIVersion2, bitfinexTickerV2, symbol)
|
||||
err := b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
if err != nil {
|
||||
return ticker, err
|
||||
@@ -229,7 +237,11 @@ func (b *Bitfinex) GetTickersV2(symbols string) ([]Tickersv2, error) {
|
||||
v := url.Values{}
|
||||
v.Set("symbols", symbols)
|
||||
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s", bitfinexAPIURLBase, bitfinexAPIVersion2, bitfinexTickersV2), v)
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s",
|
||||
b.APIUrl,
|
||||
bitfinexAPIVersion2,
|
||||
bitfinexTickersV2), v)
|
||||
|
||||
err := b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -274,7 +286,7 @@ func (b *Bitfinex) GetTickersV2(symbols string) ([]Tickersv2, error) {
|
||||
// GetStats returns various statistics about the requested pair
|
||||
func (b *Bitfinex) GetStats(symbol string) ([]Stat, error) {
|
||||
response := []Stat{}
|
||||
path := fmt.Sprint(bitfinexAPIURL + bitfinexStats + symbol)
|
||||
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexStats + symbol)
|
||||
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
}
|
||||
@@ -284,7 +296,7 @@ func (b *Bitfinex) GetStats(symbol string) ([]Stat, error) {
|
||||
// symbol - example "USD"
|
||||
func (b *Bitfinex) GetFundingBook(symbol string) (FundingBook, error) {
|
||||
response := FundingBook{}
|
||||
path := fmt.Sprint(bitfinexAPIURL + bitfinexLendbook + symbol)
|
||||
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexLendbook + symbol)
|
||||
|
||||
if err := b.SendHTTPRequest(path, &response, b.Verbose); err != nil {
|
||||
return response, err
|
||||
@@ -305,7 +317,7 @@ func (b *Bitfinex) GetFundingBook(symbol string) (FundingBook, error) {
|
||||
func (b *Bitfinex) GetOrderbook(currencyPair string, values url.Values) (Orderbook, error) {
|
||||
response := Orderbook{}
|
||||
path := common.EncodeURLValues(
|
||||
bitfinexAPIURL+bitfinexOrderbook+currencyPair,
|
||||
b.APIUrl+bitfinexAPIVersion+bitfinexOrderbook+currencyPair,
|
||||
values,
|
||||
)
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
@@ -320,7 +332,7 @@ func (b *Bitfinex) GetOrderbook(currencyPair string, values url.Values) (Orderbo
|
||||
func (b *Bitfinex) GetOrderbookV2(symbol, precision string, values url.Values) (OrderbookV2, error) {
|
||||
var response [][]interface{}
|
||||
var book OrderbookV2
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s/%s/%s", bitfinexAPIURLBase,
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/v%s/%s/%s/%s", b.APIUrl,
|
||||
bitfinexAPIVersion2, bitfinexOrderbookV2, symbol, precision), values)
|
||||
err := b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
if err != nil {
|
||||
@@ -367,7 +379,7 @@ func (b *Bitfinex) GetOrderbookV2(symbol, precision string, values url.Values) (
|
||||
func (b *Bitfinex) GetTrades(currencyPair string, values url.Values) ([]TradeStructure, error) {
|
||||
response := []TradeStructure{}
|
||||
path := common.EncodeURLValues(
|
||||
bitfinexAPIURL+bitfinexTrades+currencyPair,
|
||||
b.APIUrl+bitfinexAPIVersion+bitfinexTrades+currencyPair,
|
||||
values,
|
||||
)
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
@@ -432,7 +444,7 @@ func (b *Bitfinex) GetLendbook(symbol string, values url.Values) (Lendbook, erro
|
||||
if len(symbol) == 6 {
|
||||
symbol = symbol[:3]
|
||||
}
|
||||
path := common.EncodeURLValues(bitfinexAPIURL+bitfinexLendbook+symbol, values)
|
||||
path := common.EncodeURLValues(b.APIUrl+bitfinexAPIVersion+bitfinexLendbook+symbol, values)
|
||||
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
}
|
||||
@@ -443,7 +455,7 @@ func (b *Bitfinex) GetLendbook(symbol string, values url.Values) (Lendbook, erro
|
||||
// Symbol - example "USD"
|
||||
func (b *Bitfinex) GetLends(symbol string, values url.Values) ([]Lends, error) {
|
||||
response := []Lends{}
|
||||
path := common.EncodeURLValues(bitfinexAPIURL+bitfinexLends+symbol, values)
|
||||
path := common.EncodeURLValues(b.APIUrl+bitfinexAPIVersion+bitfinexLends+symbol, values)
|
||||
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
}
|
||||
@@ -451,7 +463,7 @@ func (b *Bitfinex) GetLends(symbol string, values url.Values) ([]Lends, error) {
|
||||
// GetSymbols returns the available currency pairs on the exchange
|
||||
func (b *Bitfinex) GetSymbols() ([]string, error) {
|
||||
products := []string{}
|
||||
path := fmt.Sprint(bitfinexAPIURL + bitfinexSymbols)
|
||||
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexSymbols)
|
||||
|
||||
return products, b.SendHTTPRequest(path, &products, b.Verbose)
|
||||
}
|
||||
@@ -459,7 +471,7 @@ func (b *Bitfinex) GetSymbols() ([]string, error) {
|
||||
// GetSymbolsDetails a list of valid symbol IDs and the pair details
|
||||
func (b *Bitfinex) GetSymbolsDetails() ([]SymbolDetails, error) {
|
||||
response := []SymbolDetails{}
|
||||
path := fmt.Sprint(bitfinexAPIURL + bitfinexSymbolsDetails)
|
||||
path := fmt.Sprint(b.APIUrl + bitfinexAPIVersion + bitfinexSymbolsDetails)
|
||||
|
||||
return response, b.SendHTTPRequest(path, &response, b.Verbose)
|
||||
}
|
||||
@@ -904,7 +916,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
|
||||
headers["X-BFX-PAYLOAD"] = PayloadBase64
|
||||
headers["X-BFX-SIGNATURE"] = common.HexEncodeToString(hmac)
|
||||
|
||||
err = b.SendPayload(method, bitfinexAPIURL+path, headers, nil, result, true, b.Verbose)
|
||||
err = b.SendPayload(method, b.APIUrl+bitfinexAPIVersion+path, headers, nil, result, true, b.Verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,14 @@ func (b *Bitflyer) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = false
|
||||
b.SupportsRESTTickerBatching = false
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Minute, bitflyerAuthRate), request.NewRateLimit(time.Minute, bitflyerUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Minute, bitflyerAuthRate),
|
||||
request.NewRateLimit(time.Minute, bitflyerUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = japanURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
b.APIUrlSecondaryDefault = chainAnalysis
|
||||
b.APIUrlSecondary = b.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -104,7 +111,6 @@ func (b *Bitflyer) Setup(exch config.ExchangeConfig) {
|
||||
b.RESTPollingDelay = exch.RESTPollingDelay
|
||||
b.Verbose = exch.Verbose
|
||||
b.Websocket = exch.Websocket
|
||||
b.APIUrl = japanURL
|
||||
b.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
|
||||
b.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
|
||||
b.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
|
||||
@@ -120,6 +126,10 @@ func (b *Bitflyer) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,45 +137,45 @@ func (b *Bitflyer) Setup(exch config.ExchangeConfig) {
|
||||
// analysis system
|
||||
func (b *Bitflyer) GetLatestBlockCA() (ChainAnalysisBlock, error) {
|
||||
var resp ChainAnalysisBlock
|
||||
path := fmt.Sprintf("%s%s", chainAnalysis, latestBlock)
|
||||
path := fmt.Sprintf("%s%s", b.APIUrlSecondary, latestBlock)
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetBlockCA returns block information by blockhash from bitflyer chain
|
||||
// analysis system
|
||||
func (b *Bitflyer) GetBlockCA(blockhash string) (ChainAnalysisBlock, error) {
|
||||
var resp ChainAnalysisBlock
|
||||
path := fmt.Sprintf("%s%s%s", chainAnalysis, blockByBlockHash, blockhash)
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrlSecondary, blockByBlockHash, blockhash)
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetBlockbyHeightCA returns the block information by height from bitflyer chain
|
||||
// analysis system
|
||||
func (b *Bitflyer) GetBlockbyHeightCA(height int64) (ChainAnalysisBlock, error) {
|
||||
var resp ChainAnalysisBlock
|
||||
path := fmt.Sprintf("%s%s%s", chainAnalysis, blockByBlockHeight, strconv.FormatInt(height, 10))
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrlSecondary, blockByBlockHeight, strconv.FormatInt(height, 10))
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetTransactionByHashCA returns transaction information by txHash from
|
||||
// bitflyer chain analysis system
|
||||
func (b *Bitflyer) GetTransactionByHashCA(txHash string) (ChainAnalysisTransaction, error) {
|
||||
var resp ChainAnalysisTransaction
|
||||
path := fmt.Sprintf("%s%s%s", chainAnalysis, transaction, txHash)
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrlSecondary, transaction, txHash)
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetAddressInfoCA returns balance information for address by addressln string
|
||||
// from bitflyer chain analysis system
|
||||
func (b *Bitflyer) GetAddressInfoCA(addressln string) (ChainAnalysisAddress, error) {
|
||||
var resp ChainAnalysisAddress
|
||||
path := fmt.Sprintf("%s%s%s", chainAnalysis, address, addressln)
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrlSecondary, address, addressln)
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetMarkets returns market information
|
||||
@@ -173,7 +183,7 @@ func (b *Bitflyer) GetMarkets() ([]MarketInfo, error) {
|
||||
var resp []MarketInfo
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, pubGetMarkets)
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetOrderBook returns market orderbook depth
|
||||
@@ -181,9 +191,9 @@ func (b *Bitflyer) GetOrderBook(symbol string) (Orderbook, error) {
|
||||
var resp Orderbook
|
||||
v := url.Values{}
|
||||
v.Set("product_code", symbol)
|
||||
path := fmt.Sprintf("%s%s?%s", japanURL, pubGetBoard, v.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, pubGetBoard, v.Encode())
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetTicker returns ticker information
|
||||
@@ -191,9 +201,9 @@ func (b *Bitflyer) GetTicker(symbol string) (Ticker, error) {
|
||||
var resp Ticker
|
||||
v := url.Values{}
|
||||
v.Set("product_code", symbol)
|
||||
path := fmt.Sprintf("%s%s?%s", japanURL, pubGetTicker, v.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, pubGetTicker, v.Encode())
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetExecutionHistory returns past trades that were executed on the market
|
||||
@@ -201,9 +211,9 @@ func (b *Bitflyer) GetExecutionHistory(symbol string) ([]ExecutedTrade, error) {
|
||||
var resp []ExecutedTrade
|
||||
v := url.Values{}
|
||||
v.Set("product_code", symbol)
|
||||
path := fmt.Sprintf("%s%s?%s", japanURL, pubGetExecutionHistory, v.Encode())
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, pubGetExecutionHistory, v.Encode())
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetExchangeStatus returns exchange status information
|
||||
@@ -212,7 +222,7 @@ func (b *Bitflyer) GetExchangeStatus() (string, error) {
|
||||
|
||||
path := fmt.Sprintf("%s%s", b.APIUrl, pubGetHealth)
|
||||
|
||||
err := b.SendHTTPREquest(path, &resp)
|
||||
err := b.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -239,7 +249,7 @@ func (b *Bitflyer) GetChats(FromDate string) ([]ChatLog, error) {
|
||||
v.Set("from_date", FromDate)
|
||||
path := fmt.Sprintf("%s%s?%s", b.APIUrl, pubGetChats, v.Encode())
|
||||
|
||||
return resp, b.SendHTTPREquest(path, &resp)
|
||||
return resp, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
// GetPermissions returns current permissions for associated with your API
|
||||
@@ -358,8 +368,8 @@ func (b *Bitflyer) GetTradingCommission() {
|
||||
// Needs to be updated
|
||||
}
|
||||
|
||||
// SendHTTPREquest sends an unauthenticated request
|
||||
func (b *Bitflyer) SendHTTPREquest(path string, result interface{}) error {
|
||||
// SendHTTPRequest sends an unauthenticated request
|
||||
func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error {
|
||||
return b.SendPayload("GET", path, nil, nil, result, false, b.Verbose)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,12 @@ func (b *Bithumb) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = true
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, bithumbAuthRate), request.NewRateLimit(time.Second, bithumbUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second, bithumbAuthRate),
|
||||
request.NewRateLimit(time.Second, bithumbUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = apiURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -101,6 +106,10 @@ func (b *Bithumb) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +132,7 @@ func (b *Bithumb) GetTradablePairs() ([]string, error) {
|
||||
// symbol e.g. "btc"
|
||||
func (b *Bithumb) GetTicker(symbol string) (Ticker, error) {
|
||||
response := Ticker{}
|
||||
path := fmt.Sprintf("%s%s%s", apiURL, publicTicker, common.StringToUpper(symbol))
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrl, publicTicker, common.StringToUpper(symbol))
|
||||
|
||||
err := b.SendHTTPRequest(path, &response)
|
||||
if err != nil {
|
||||
@@ -145,7 +154,7 @@ func (b *Bithumb) GetAllTickers() (map[string]Ticker, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
path := fmt.Sprintf("%s%s%s", apiURL, publicTicker, "all")
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrl, publicTicker, "all")
|
||||
|
||||
err := b.SendHTTPRequest(path, &response)
|
||||
if err != nil {
|
||||
@@ -185,7 +194,7 @@ func (b *Bithumb) GetAllTickers() (map[string]Ticker, error) {
|
||||
// symbol e.g. "btc"
|
||||
func (b *Bithumb) GetOrderBook(symbol string) (Orderbook, error) {
|
||||
response := Orderbook{}
|
||||
path := fmt.Sprintf("%s%s%s", apiURL, publicOrderBook, common.StringToUpper(symbol))
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrl, publicOrderBook, common.StringToUpper(symbol))
|
||||
|
||||
err := b.SendHTTPRequest(path, &response)
|
||||
if err != nil {
|
||||
@@ -204,7 +213,7 @@ func (b *Bithumb) GetOrderBook(symbol string) (Orderbook, error) {
|
||||
// symbol e.g. "btc"
|
||||
func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, error) {
|
||||
response := TransactionHistory{}
|
||||
path := fmt.Sprintf("%s%s%s", apiURL, publicTransactionHistory, common.StringToUpper(symbol))
|
||||
path := fmt.Sprintf("%s%s%s", b.APIUrl, publicTransactionHistory, common.StringToUpper(symbol))
|
||||
|
||||
err := b.SendHTTPRequest(path, &response)
|
||||
if err != nil {
|
||||
@@ -549,5 +558,5 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r
|
||||
headers["Api-Nonce"] = b.Nonce.String()
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
return b.SendPayload("POST", apiURL+path, headers, bytes.NewBufferString(payload), result, true, b.Verbose)
|
||||
return b.SendPayload("POST", b.APIUrl+path, headers, bytes.NewBufferString(payload), result, true, b.Verbose)
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ func (b *Bitmex) SetDefaults() {
|
||||
request.NewRateLimit(time.Second, bitmexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.shutdown = b.NewRoutineManagement()
|
||||
b.APIUrlDefault = bitmexAPIURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -150,6 +152,14 @@ func (b *Bitmex) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAutoPairDefaults()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +807,7 @@ func (b *Bitmex) GetWalletSummary(currency string) ([]TransactionInfo, error) {
|
||||
// SendHTTPRequest sends an unauthenticated HTTP request
|
||||
func (b *Bitmex) SendHTTPRequest(path string, params Parameter, result interface{}) error {
|
||||
var respCheck interface{}
|
||||
path = bitmexAPIURL + path
|
||||
path = b.APIUrl + path
|
||||
if params != nil {
|
||||
if !params.IsNil() {
|
||||
encodedPath, err := params.ToURLVals(path)
|
||||
@@ -856,7 +866,7 @@ func (b *Bitmex) SendAuthenticatedHTTPRequest(verb, path string, params Paramete
|
||||
var respCheck interface{}
|
||||
|
||||
err := b.SendPayload(verb,
|
||||
bitmexAPIURL+path,
|
||||
b.APIUrl+path,
|
||||
headers,
|
||||
bytes.NewBuffer([]byte(payload)),
|
||||
&respCheck,
|
||||
|
||||
@@ -73,7 +73,12 @@ func (b *Bitstamp) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = false
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Minute*10, bitstampAuthRate), request.NewRateLimit(time.Minute*10, bitstampUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Minute*10, bitstampAuthRate),
|
||||
request.NewRateLimit(time.Minute*10, bitstampUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = bitstampAPIURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets configuration values to bitstamp
|
||||
@@ -104,6 +109,10 @@ func (b *Bitstamp) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +145,7 @@ func (b *Bitstamp) GetTicker(currency string, hourly bool) (Ticker, error) {
|
||||
|
||||
path := fmt.Sprintf(
|
||||
"%s/v%s/%s/%s/",
|
||||
bitstampAPIURL,
|
||||
b.APIUrl,
|
||||
bitstampAPIVersion,
|
||||
tickerEndpoint,
|
||||
common.StringToLower(currency),
|
||||
@@ -157,7 +166,7 @@ func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
|
||||
|
||||
path := fmt.Sprintf(
|
||||
"%s/v%s/%s/%s/",
|
||||
bitstampAPIURL,
|
||||
b.APIUrl,
|
||||
bitstampAPIVersion,
|
||||
bitstampAPIOrderbook,
|
||||
common.StringToLower(currency),
|
||||
@@ -206,7 +215,12 @@ func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
|
||||
// currently supports
|
||||
func (b *Bitstamp) GetTradingPairs() ([]TradingPair, error) {
|
||||
var result []TradingPair
|
||||
path := fmt.Sprintf("%s/v%s/%s", bitstampAPIURL, bitstampAPIVersion, bitstampAPITradingPairsInfo)
|
||||
|
||||
path := fmt.Sprintf("%s/v%s/%s",
|
||||
b.APIUrl,
|
||||
bitstampAPIVersion,
|
||||
bitstampAPITradingPairsInfo)
|
||||
|
||||
return result, b.SendHTTPRequest(path, &result)
|
||||
}
|
||||
|
||||
@@ -218,7 +232,7 @@ func (b *Bitstamp) GetTransactions(currencyPair string, values url.Values) ([]Tr
|
||||
path := common.EncodeURLValues(
|
||||
fmt.Sprintf(
|
||||
"%s/v%s/%s/%s/",
|
||||
bitstampAPIURL,
|
||||
b.APIUrl,
|
||||
bitstampAPIVersion,
|
||||
bitstampAPITransactions,
|
||||
common.StringToLower(currencyPair),
|
||||
@@ -232,7 +246,7 @@ func (b *Bitstamp) GetTransactions(currencyPair string, values url.Values) ([]Tr
|
||||
// GetEURUSDConversionRate returns the conversion rate between Euro and USD
|
||||
func (b *Bitstamp) GetEURUSDConversionRate() (EURUSDConversionRate, error) {
|
||||
rate := EURUSDConversionRate{}
|
||||
path := fmt.Sprintf("%s/%s", bitstampAPIURL, bitstampAPIEURUSD)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bitstampAPIEURUSD)
|
||||
|
||||
return rate, b.SendHTTPRequest(path, &rate)
|
||||
}
|
||||
@@ -240,7 +254,7 @@ func (b *Bitstamp) GetEURUSDConversionRate() (EURUSDConversionRate, error) {
|
||||
// GetBalance returns full balance of currency held on the exchange
|
||||
func (b *Bitstamp) GetBalance() (Balances, error) {
|
||||
balance := Balances{}
|
||||
path := fmt.Sprintf("%s/%s", bitstampAPIURL, bitstampAPIBalance)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bitstampAPIBalance)
|
||||
|
||||
return balance, b.SendHTTPRequest(path, &balance)
|
||||
}
|
||||
@@ -519,9 +533,9 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
|
||||
values.Set("signature", common.StringToUpper(common.HexEncodeToString(hmac)))
|
||||
|
||||
if v2 {
|
||||
path = fmt.Sprintf("%s/v%s/%s/", bitstampAPIURL, bitstampAPIVersion, path)
|
||||
path = fmt.Sprintf("%s/v%s/%s/", b.APIUrl, bitstampAPIVersion, path)
|
||||
} else {
|
||||
path = fmt.Sprintf("%s/%s/", bitstampAPIURL, path)
|
||||
path = fmt.Sprintf("%s/%s/", b.APIUrl, path)
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
|
||||
@@ -76,7 +76,12 @@ func (b *Bittrex) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = true
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, bittrexAuthRate), request.NewRateLimit(time.Second, bittrexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second, bittrexAuthRate),
|
||||
request.NewRateLimit(time.Second, bittrexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = bittrexAPIURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup method sets current configuration details if enabled
|
||||
@@ -107,6 +112,10 @@ func (b *Bittrex) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +123,7 @@ func (b *Bittrex) Setup(exch config.ExchangeConfig) {
|
||||
// along with other meta data.
|
||||
func (b *Bittrex) GetMarkets() (Market, error) {
|
||||
var markets Market
|
||||
path := fmt.Sprintf("%s/%s/", bittrexAPIURL, bittrexAPIGetMarkets)
|
||||
path := fmt.Sprintf("%s/%s/", b.APIUrl, bittrexAPIGetMarkets)
|
||||
|
||||
if err := b.SendHTTPRequest(path, &markets); err != nil {
|
||||
return markets, err
|
||||
@@ -129,7 +138,7 @@ func (b *Bittrex) GetMarkets() (Market, error) {
|
||||
// GetCurrencies is used to get all supported currencies at Bittrex
|
||||
func (b *Bittrex) GetCurrencies() (Currency, error) {
|
||||
var currencies Currency
|
||||
path := fmt.Sprintf("%s/%s/", bittrexAPIURL, bittrexAPIGetCurrencies)
|
||||
path := fmt.Sprintf("%s/%s/", b.APIUrl, bittrexAPIGetCurrencies)
|
||||
|
||||
if err := b.SendHTTPRequest(path, ¤cies); err != nil {
|
||||
return currencies, err
|
||||
@@ -145,7 +154,7 @@ func (b *Bittrex) GetCurrencies() (Currency, error) {
|
||||
// on the supplied currency. Example currency input param "btc-ltc".
|
||||
func (b *Bittrex) GetTicker(currencyPair string) (Ticker, error) {
|
||||
ticker := Ticker{}
|
||||
path := fmt.Sprintf("%s/%s?market=%s", bittrexAPIURL, bittrexAPIGetTicker,
|
||||
path := fmt.Sprintf("%s/%s?market=%s", b.APIUrl, bittrexAPIGetTicker,
|
||||
common.StringToUpper(currencyPair),
|
||||
)
|
||||
|
||||
@@ -163,7 +172,7 @@ func (b *Bittrex) GetTicker(currencyPair string) (Ticker, error) {
|
||||
// exchanges
|
||||
func (b *Bittrex) GetMarketSummaries() (MarketSummary, error) {
|
||||
var summaries MarketSummary
|
||||
path := fmt.Sprintf("%s/%s/", bittrexAPIURL, bittrexAPIGetMarketSummaries)
|
||||
path := fmt.Sprintf("%s/%s/", b.APIUrl, bittrexAPIGetMarketSummaries)
|
||||
|
||||
if err := b.SendHTTPRequest(path, &summaries); err != nil {
|
||||
return summaries, err
|
||||
@@ -179,7 +188,7 @@ func (b *Bittrex) GetMarketSummaries() (MarketSummary, error) {
|
||||
// exchanges by currency pair (btc-ltc).
|
||||
func (b *Bittrex) GetMarketSummary(currencyPair string) (MarketSummary, error) {
|
||||
var summary MarketSummary
|
||||
path := fmt.Sprintf("%s/%s?market=%s", bittrexAPIURL,
|
||||
path := fmt.Sprintf("%s/%s?market=%s", b.APIUrl,
|
||||
bittrexAPIGetMarketSummary, common.StringToLower(currencyPair),
|
||||
)
|
||||
|
||||
@@ -202,7 +211,7 @@ func (b *Bittrex) GetMarketSummary(currencyPair string) (MarketSummary, error) {
|
||||
// it returns full depth. So depth default is 50.
|
||||
func (b *Bittrex) GetOrderbook(currencyPair string) (OrderBooks, error) {
|
||||
var orderbooks OrderBooks
|
||||
path := fmt.Sprintf("%s/%s?market=%s&type=both&depth=50", bittrexAPIURL,
|
||||
path := fmt.Sprintf("%s/%s?market=%s&type=both&depth=50", b.APIUrl,
|
||||
bittrexAPIGetOrderbook, common.StringToUpper(currencyPair),
|
||||
)
|
||||
|
||||
@@ -220,7 +229,7 @@ func (b *Bittrex) GetOrderbook(currencyPair string) (OrderBooks, error) {
|
||||
// market
|
||||
func (b *Bittrex) GetMarketHistory(currencyPair string) (MarketHistory, error) {
|
||||
var marketHistoriae MarketHistory
|
||||
path := fmt.Sprintf("%s/%s?market=%s", bittrexAPIURL,
|
||||
path := fmt.Sprintf("%s/%s?market=%s", b.APIUrl,
|
||||
bittrexAPIGetMarketHistory, common.StringToUpper(currencyPair),
|
||||
)
|
||||
|
||||
@@ -246,7 +255,7 @@ func (b *Bittrex) PlaceBuyLimit(currencyPair string, quantity, rate float64) (UU
|
||||
values.Set("market", currencyPair)
|
||||
values.Set("quantity", strconv.FormatFloat(quantity, 'E', -1, 64))
|
||||
values.Set("rate", strconv.FormatFloat(rate, 'E', -1, 64))
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIBuyLimit)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIBuyLimit)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &id); err != nil {
|
||||
return id, err
|
||||
@@ -270,7 +279,7 @@ func (b *Bittrex) PlaceSellLimit(currencyPair string, quantity, rate float64) (U
|
||||
values.Set("market", currencyPair)
|
||||
values.Set("quantity", strconv.FormatFloat(quantity, 'E', -1, 64))
|
||||
values.Set("rate", strconv.FormatFloat(rate, 'E', -1, 64))
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPISellLimit)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPISellLimit)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &id); err != nil {
|
||||
return id, err
|
||||
@@ -290,7 +299,7 @@ func (b *Bittrex) GetOpenOrders(currencyPair string) (Order, error) {
|
||||
if !(currencyPair == "" || currencyPair == " ") {
|
||||
values.Set("market", currencyPair)
|
||||
}
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetOpenOrders)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetOpenOrders)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &orders); err != nil {
|
||||
return orders, err
|
||||
@@ -307,7 +316,7 @@ func (b *Bittrex) CancelOrder(uuid string) (Balances, error) {
|
||||
var balances Balances
|
||||
values := url.Values{}
|
||||
values.Set("uuid", uuid)
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPICancel)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPICancel)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &balances); err != nil {
|
||||
return balances, err
|
||||
@@ -322,7 +331,7 @@ func (b *Bittrex) CancelOrder(uuid string) (Balances, error) {
|
||||
// GetAccountBalances is used to retrieve all balances from your account
|
||||
func (b *Bittrex) GetAccountBalances() (Balances, error) {
|
||||
var balances Balances
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetBalances)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetBalances)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, url.Values{}, &balances); err != nil {
|
||||
return balances, err
|
||||
@@ -340,7 +349,7 @@ func (b *Bittrex) GetAccountBalanceByCurrency(currency string) (Balance, error)
|
||||
var balance Balance
|
||||
values := url.Values{}
|
||||
values.Set("currency", currency)
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetBalance)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetBalance)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &balance); err != nil {
|
||||
return balance, err
|
||||
@@ -359,7 +368,7 @@ func (b *Bittrex) GetDepositAddress(currency string) (DepositAddress, error) {
|
||||
var address DepositAddress
|
||||
values := url.Values{}
|
||||
values.Set("currency", currency)
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetDepositAddress)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetDepositAddress)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &address); err != nil {
|
||||
return address, err
|
||||
@@ -379,7 +388,7 @@ func (b *Bittrex) Withdraw(currency, paymentID, address string, quantity float64
|
||||
values.Set("currency", currency)
|
||||
values.Set("quantity", strconv.FormatFloat(quantity, 'E', -1, 64))
|
||||
values.Set("address", address)
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIWithdraw)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIWithdraw)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &id); err != nil {
|
||||
return id, err
|
||||
@@ -396,7 +405,7 @@ func (b *Bittrex) GetOrder(uuid string) (Order, error) {
|
||||
var order Order
|
||||
values := url.Values{}
|
||||
values.Set("uuid", uuid)
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetOrder)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetOrder)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &order); err != nil {
|
||||
return order, err
|
||||
@@ -417,7 +426,7 @@ func (b *Bittrex) GetOrderHistory(currencyPair string) (Order, error) {
|
||||
if !(currencyPair == "" || currencyPair == " ") {
|
||||
values.Set("market", currencyPair)
|
||||
}
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetOrderHistory)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetOrderHistory)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &orders); err != nil {
|
||||
return orders, err
|
||||
@@ -438,7 +447,7 @@ func (b *Bittrex) GetWithdrawalHistory(currency string) (WithdrawalHistory, erro
|
||||
if !(currency == "" || currency == " ") {
|
||||
values.Set("currency", currency)
|
||||
}
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetWithdrawalHistory)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetWithdrawalHistory)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &history); err != nil {
|
||||
return history, err
|
||||
@@ -459,7 +468,7 @@ func (b *Bittrex) GetDepositHistory(currency string) (WithdrawalHistory, error)
|
||||
if !(currency == "" || currency == " ") {
|
||||
values.Set("currency", currency)
|
||||
}
|
||||
path := fmt.Sprintf("%s/%s", bittrexAPIURL, bittrexAPIGetDepositHistory)
|
||||
path := fmt.Sprintf("%s/%s", b.APIUrl, bittrexAPIGetDepositHistory)
|
||||
|
||||
if err := b.SendAuthenticatedHTTPRequest(path, values, &history); err != nil {
|
||||
return history, err
|
||||
|
||||
@@ -67,7 +67,12 @@ func (b *BTCC) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = false
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, btccAuthRate), request.NewRateLimit(time.Second, btccUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second, btccAuthRate),
|
||||
request.NewRateLimit(time.Second, btccUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = btccAPIUrl
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup is run on startup to setup exchange with config values
|
||||
@@ -98,6 +103,10 @@ func (b *BTCC) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +119,7 @@ func (b *BTCC) GetFee() float64 {
|
||||
// currencyPair - Example "btccny", "ltccny" or "ltcbtc"
|
||||
func (b *BTCC) GetTicker(currencyPair string) (Ticker, error) {
|
||||
resp := Response{}
|
||||
path := fmt.Sprintf("%s/data/pro/ticker?symbol=%s", btccAPIUrl, currencyPair)
|
||||
path := fmt.Sprintf("%s/data/pro/ticker?symbol=%s", b.APIUrl, currencyPair)
|
||||
return resp.Ticker, b.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
|
||||
@@ -121,7 +130,7 @@ func (b *BTCC) GetTicker(currencyPair string) (Ticker, error) {
|
||||
// time - returns trade records starting from unix time 1406794449
|
||||
func (b *BTCC) GetTradeHistory(currencyPair string, limit, sinceTid int64, time time.Time) ([]Trade, error) {
|
||||
trades := []Trade{}
|
||||
path := fmt.Sprintf("%s/data/pro/historydata?symbol=%s", btccAPIUrl, currencyPair)
|
||||
path := fmt.Sprintf("%s/data/pro/historydata?symbol=%s", b.APIUrl, currencyPair)
|
||||
v := url.Values{}
|
||||
|
||||
if limit > 0 {
|
||||
@@ -144,9 +153,9 @@ func (b *BTCC) GetTradeHistory(currencyPair string, limit, sinceTid int64, time
|
||||
// orderbook
|
||||
func (b *BTCC) GetOrderBook(currencyPair string, limit int) (Orderbook, error) {
|
||||
result := Orderbook{}
|
||||
path := fmt.Sprintf("%s/data/pro/orderbook?symbol=%s&limit=%d", btccAPIUrl, currencyPair, limit)
|
||||
path := fmt.Sprintf("%s/data/pro/orderbook?symbol=%s&limit=%d", b.APIUrl, currencyPair, limit)
|
||||
if limit == 0 {
|
||||
path = fmt.Sprintf("%s/data/pro/orderbook?symbol=%s", btccAPIUrl, currencyPair)
|
||||
path = fmt.Sprintf("%s/data/pro/orderbook?symbol=%s", b.APIUrl, currencyPair)
|
||||
}
|
||||
|
||||
return result, b.SendHTTPRequest(path, &result)
|
||||
@@ -612,7 +621,7 @@ func (b *BTCC) SendAuthenticatedHTTPRequest(method string, params []interface{})
|
||||
postData["params"] = params
|
||||
postData["id"] = 1
|
||||
|
||||
apiURL := fmt.Sprintf("%s/%s", btccAPIUrl, btccAPIAuthenticatedMethod)
|
||||
apiURL := fmt.Sprintf("%s/%s", b.APIUrl, btccAPIAuthenticatedMethod)
|
||||
|
||||
data, err := common.JSONEncode(postData)
|
||||
if err != nil {
|
||||
|
||||
@@ -64,7 +64,12 @@ func (b *BTCMarkets) SetDefaults() {
|
||||
b.AssetTypes = []string{ticker.Spot}
|
||||
b.SupportsAutoPairUpdating = true
|
||||
b.SupportsRESTTickerBatching = false
|
||||
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second*10, btcmarketsAuthLimit), request.NewRateLimit(time.Second*10, btcmarketsUnauthLimit), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.Requester = request.New(b.Name,
|
||||
request.NewRateLimit(time.Second*10, btcmarketsAuthLimit),
|
||||
request.NewRateLimit(time.Second*10, btcmarketsUnauthLimit),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
b.APIUrlDefault = btcMarketsAPIURL
|
||||
b.APIUrl = b.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in an exchange configuration and sets all parameters
|
||||
@@ -95,6 +100,10 @@ func (b *BTCMarkets) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = b.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +117,7 @@ func (b *BTCMarkets) GetFee() float64 {
|
||||
func (b *BTCMarkets) GetTicker(firstPair, secondPair string) (Ticker, error) {
|
||||
ticker := Ticker{}
|
||||
path := fmt.Sprintf("%s/market/%s/%s/tick",
|
||||
btcMarketsAPIURL,
|
||||
b.APIUrl,
|
||||
common.StringToUpper(firstPair),
|
||||
common.StringToUpper(secondPair))
|
||||
|
||||
@@ -120,7 +129,7 @@ func (b *BTCMarkets) GetTicker(firstPair, secondPair string) (Ticker, error) {
|
||||
func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, error) {
|
||||
orderbook := Orderbook{}
|
||||
path := fmt.Sprintf("%s/market/%s/%s/orderbook",
|
||||
btcMarketsAPIURL,
|
||||
b.APIUrl,
|
||||
common.StringToUpper(firstPair),
|
||||
common.StringToUpper(secondPair))
|
||||
|
||||
@@ -133,7 +142,7 @@ func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, erro
|
||||
func (b *BTCMarkets) GetTrades(firstPair, secondPair string, values url.Values) ([]Trade, error) {
|
||||
trades := []Trade{}
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/market/%s/%s/trades",
|
||||
btcMarketsAPIURL, common.StringToUpper(firstPair),
|
||||
b.APIUrl, common.StringToUpper(firstPair),
|
||||
common.StringToUpper(secondPair)), values)
|
||||
|
||||
return trades, b.SendHTTPRequest(path, &trades)
|
||||
@@ -395,7 +404,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data interfa
|
||||
hmac := common.GetHMAC(common.HashSHA512, []byte(request), []byte(b.APISecret))
|
||||
|
||||
if b.Verbose {
|
||||
log.Printf("Sending %s request to URL %s with params %s\n", reqType, btcMarketsAPIURL+path, request)
|
||||
log.Printf("Sending %s request to URL %s with params %s\n", reqType, b.APIUrl+path, request)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
@@ -406,5 +415,5 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data interfa
|
||||
headers["timestamp"] = b.Nonce.String()[0:13]
|
||||
headers["signature"] = common.Base64Encode(hmac)
|
||||
|
||||
return b.SendPayload(reqType, btcMarketsAPIURL+path, headers, bytes.NewBuffer(payload), result, true, b.Verbose)
|
||||
return b.SendPayload(reqType, b.APIUrl+path, headers, bytes.NewBuffer(payload), result, true, b.Verbose)
|
||||
}
|
||||
|
||||
@@ -72,10 +72,14 @@ func (c *CoinbasePro) SetDefaults() {
|
||||
c.ConfigCurrencyPairFormat.Delimiter = ""
|
||||
c.ConfigCurrencyPairFormat.Uppercase = true
|
||||
c.AssetTypes = []string{ticker.Spot}
|
||||
c.APIUrl = coinbaseproAPIURL
|
||||
c.SupportsAutoPairUpdating = true
|
||||
c.SupportsRESTTickerBatching = false
|
||||
c.Requester = request.New(c.Name, request.NewRateLimit(time.Second, coinbaseproAuthRate), request.NewRateLimit(time.Second, coinbaseproUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
c.Requester = request.New(c.Name,
|
||||
request.NewRateLimit(time.Second, coinbaseproAuthRate),
|
||||
request.NewRateLimit(time.Second, coinbaseproUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
c.APIUrlDefault = coinbaseproAPIURL
|
||||
c.APIUrl = c.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup initialises the exchange parameters with the current configuration
|
||||
@@ -109,6 +113,10 @@ func (c *CoinbasePro) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = c.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,12 @@ func (c *COINUT) SetDefaults() {
|
||||
c.AssetTypes = []string{ticker.Spot}
|
||||
c.SupportsAutoPairUpdating = true
|
||||
c.SupportsRESTTickerBatching = false
|
||||
c.Requester = request.New(c.Name, request.NewRateLimit(time.Second, coinutAuthRate), request.NewRateLimit(time.Second, coinutUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
c.Requester = request.New(c.Name,
|
||||
request.NewRateLimit(time.Second, coinutAuthRate),
|
||||
request.NewRateLimit(time.Second, coinutUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
c.APIUrlDefault = coinutAPIURL
|
||||
c.APIUrl = c.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets the current exchange configuration
|
||||
@@ -93,6 +98,10 @@ func (c *COINUT) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = c.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,5 +316,5 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{
|
||||
}
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
return c.SendPayload("POST", coinutAPIURL, headers, bytes.NewBuffer(payload), result, authenticated, c.Verbose)
|
||||
return c.SendPayload("POST", c.APIUrl, headers, bytes.NewBuffer(payload), result, authenticated, c.Verbose)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
@@ -105,6 +106,9 @@ type Base struct {
|
||||
HTTPUserAgent string
|
||||
WebsocketURL string
|
||||
APIUrl string
|
||||
APIUrlDefault string
|
||||
APIUrlSecondary string
|
||||
APIUrlSecondaryDefault string
|
||||
RequestCurrencyPairFormat config.CurrencyPairFormatConfig
|
||||
ConfigCurrencyPairFormat config.CurrencyPairFormatConfig
|
||||
*request.Requester
|
||||
@@ -624,3 +628,37 @@ func OrderSideBuy() OrderSide {
|
||||
func OrderSideSell() OrderSide {
|
||||
return "Sell"
|
||||
}
|
||||
|
||||
// SetAPIURL sets configuration API URL for an exchange
|
||||
func (e *Base) SetAPIURL(ec config.ExchangeConfig) error {
|
||||
if ec.APIURL == "" || ec.APIURLSecondary == "" {
|
||||
return errors.New("SetAPIURL error variable zero value")
|
||||
}
|
||||
if ec.APIURL != config.APIURLDefaultMessage {
|
||||
e.APIUrl = ec.APIURL
|
||||
}
|
||||
if ec.APIURLSecondary != config.APIURLDefaultMessage {
|
||||
e.APIUrlSecondary = ec.APIURLSecondary
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAPIURL returns the set API URL
|
||||
func (e *Base) GetAPIURL() string {
|
||||
return e.APIUrl
|
||||
}
|
||||
|
||||
// GetSecondaryAPIURL returns the set Secondary API URL
|
||||
func (e *Base) GetSecondaryAPIURL() string {
|
||||
return e.APIUrlSecondary
|
||||
}
|
||||
|
||||
// GetAPIURLDefault returns exchange default URL
|
||||
func (e *Base) GetAPIURLDefault() string {
|
||||
return e.APIUrlDefault
|
||||
}
|
||||
|
||||
// GetAPIURLSecondaryDefault returns exchange default secondary URL
|
||||
func (e *Base) GetAPIURLSecondaryDefault() string {
|
||||
return e.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
@@ -744,3 +744,46 @@ func TestUpdateCurrencies(t *testing.T) {
|
||||
t.Errorf("Test Failed - Forced Exchange UpdateCurrencies() error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAPIURL(t *testing.T) {
|
||||
testURL := "https://api.something.com"
|
||||
testURLSecondary := "https://api.somethingelse.com"
|
||||
testURLDefault := "https://api.defaultsomething.com"
|
||||
testURLSecondaryDefault := "https://api.defaultsomethingelse.com"
|
||||
|
||||
tester := Base{Name: "test"}
|
||||
|
||||
test := config.ExchangeConfig{}
|
||||
|
||||
err := tester.SetAPIURL(test)
|
||||
if err == nil {
|
||||
t.Error("test failed - setting zero value config")
|
||||
}
|
||||
|
||||
test.APIURL = testURL
|
||||
test.APIURLSecondary = testURLSecondary
|
||||
|
||||
tester.APIUrlDefault = testURLDefault
|
||||
tester.APIUrlSecondaryDefault = testURLSecondaryDefault
|
||||
|
||||
err = tester.SetAPIURL(test)
|
||||
if err != nil {
|
||||
t.Error("test failed", err)
|
||||
}
|
||||
|
||||
if tester.GetAPIURL() != testURL {
|
||||
t.Error("test failed - incorrect return URL")
|
||||
}
|
||||
|
||||
if tester.GetSecondaryAPIURL() != testURLSecondary {
|
||||
t.Error("test failed - incorrect return URL")
|
||||
}
|
||||
|
||||
if tester.GetAPIURLDefault() != testURLDefault {
|
||||
t.Error("test failed - incorrect return URL")
|
||||
}
|
||||
|
||||
if tester.GetAPIURLSecondaryDefault() != testURLSecondaryDefault {
|
||||
t.Error("test failed - incorrect return URL")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,12 @@ func (e *EXMO) SetDefaults() {
|
||||
e.AssetTypes = []string{ticker.Spot}
|
||||
e.SupportsAutoPairUpdating = true
|
||||
e.SupportsRESTTickerBatching = true
|
||||
e.Requester = request.New(e.Name, request.NewRateLimit(time.Minute, exmoAuthRate), request.NewRateLimit(time.Minute, exmoUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
e.Requester = request.New(e.Name,
|
||||
request.NewRateLimit(time.Minute, exmoAuthRate),
|
||||
request.NewRateLimit(time.Minute, exmoUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
e.APIUrlDefault = exmoAPIURL
|
||||
e.APIUrl = e.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup takes in the supplied exchange configuration details and sets params
|
||||
@@ -96,6 +101,10 @@ func (e *EXMO) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = e.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +113,7 @@ func (e *EXMO) GetTrades(symbol string) (map[string][]Trades, error) {
|
||||
v := url.Values{}
|
||||
v.Set("pair", symbol)
|
||||
result := make(map[string][]Trades)
|
||||
url := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, exmoTrades)
|
||||
url := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoTrades)
|
||||
|
||||
return result, e.SendHTTPRequest(common.EncodeURLValues(url, v), &result)
|
||||
}
|
||||
@@ -114,7 +123,7 @@ func (e *EXMO) GetOrderbook(symbol string) (map[string]Orderbook, error) {
|
||||
v := url.Values{}
|
||||
v.Set("pair", symbol)
|
||||
result := make(map[string]Orderbook)
|
||||
url := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, exmoOrderbook)
|
||||
url := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoOrderbook)
|
||||
|
||||
return result, e.SendHTTPRequest(common.EncodeURLValues(url, v), &result)
|
||||
}
|
||||
@@ -124,7 +133,7 @@ func (e *EXMO) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
v := url.Values{}
|
||||
v.Set("pair", symbol)
|
||||
result := make(map[string]Ticker)
|
||||
url := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, exmoTicker)
|
||||
url := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoTicker)
|
||||
|
||||
return result, e.SendHTTPRequest(common.EncodeURLValues(url, v), &result)
|
||||
}
|
||||
@@ -132,7 +141,7 @@ func (e *EXMO) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
// GetPairSettings returns the pair settings for a symbol or symbols
|
||||
func (e *EXMO) GetPairSettings() (map[string]PairSettings, error) {
|
||||
result := make(map[string]PairSettings)
|
||||
url := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, exmoPairSettings)
|
||||
url := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoPairSettings)
|
||||
|
||||
return result, e.SendHTTPRequest(url, &result)
|
||||
}
|
||||
@@ -140,7 +149,7 @@ func (e *EXMO) GetPairSettings() (map[string]PairSettings, error) {
|
||||
// GetCurrency returns a list of currencies
|
||||
func (e *EXMO) GetCurrency() ([]string, error) {
|
||||
result := []string{}
|
||||
url := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, exmoCurrency)
|
||||
url := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, exmoCurrency)
|
||||
|
||||
return result, e.SendHTTPRequest(url, &result)
|
||||
}
|
||||
@@ -347,7 +356,7 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va
|
||||
headers["Sign"] = common.HexEncodeToString(hash)
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
path := fmt.Sprintf("%s/v%s/%s", exmoAPIURL, exmoAPIVersion, endpoint)
|
||||
path := fmt.Sprintf("%s/v%s/%s", e.APIUrl, exmoAPIVersion, endpoint)
|
||||
|
||||
return e.SendPayload(method, path, headers, strings.NewReader(payload), result, true, e.Verbose)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,14 @@ func (g *Gateio) SetDefaults() {
|
||||
g.AssetTypes = []string{ticker.Spot}
|
||||
g.SupportsAutoPairUpdating = true
|
||||
g.SupportsRESTTickerBatching = true
|
||||
g.Requester = request.New(g.Name, request.NewRateLimit(time.Second*10, gateioAuthRate), request.NewRateLimit(time.Second*10, gateioUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
g.Requester = request.New(g.Name,
|
||||
request.NewRateLimit(time.Second*10, gateioAuthRate),
|
||||
request.NewRateLimit(time.Second*10, gateioUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
g.APIUrlDefault = gateioTradeURL
|
||||
g.APIUrl = g.APIUrlDefault
|
||||
g.APIUrlSecondaryDefault = gateioMarketURL
|
||||
g.APIUrlSecondary = g.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup sets user configuration
|
||||
@@ -86,6 +93,10 @@ func (g *Gateio) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = g.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +104,7 @@ func (g *Gateio) Setup(exch config.ExchangeConfig) {
|
||||
func (g *Gateio) GetSymbols() ([]string, error) {
|
||||
var result []string
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%s", gateioMarketURL, gateioAPIVersion, gateioSymbol)
|
||||
url := fmt.Sprintf("%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioSymbol)
|
||||
|
||||
err := g.SendHTTPRequest(url, &result)
|
||||
if err != nil {
|
||||
@@ -110,7 +121,7 @@ func (g *Gateio) GetMarketInfo() (MarketInfoResponse, error) {
|
||||
Pairs []interface{} `json:"pairs"`
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%s", gateioMarketURL, gateioAPIVersion, gateioMarketInfo)
|
||||
url := fmt.Sprintf("%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioMarketInfo)
|
||||
|
||||
var res response
|
||||
var result MarketInfoResponse
|
||||
@@ -151,7 +162,7 @@ func (g *Gateio) GetLatestSpotPrice(symbol string) (float64, error) {
|
||||
// GetTicker returns a ticker for the supplied symbol
|
||||
// updated every 10 seconds
|
||||
func (g *Gateio) GetTicker(symbol string) (TickerResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s/%s", gateioMarketURL, gateioAPIVersion, gateioTicker, symbol)
|
||||
url := fmt.Sprintf("%s/%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioTicker, symbol)
|
||||
|
||||
var res TickerResponse
|
||||
err := g.SendHTTPRequest(url, &res)
|
||||
@@ -163,7 +174,7 @@ func (g *Gateio) GetTicker(symbol string) (TickerResponse, error) {
|
||||
|
||||
// GetTickers returns tickers for all symbols
|
||||
func (g *Gateio) GetTickers() (map[string]TickerResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s", gateioMarketURL, gateioAPIVersion, gateioTickers)
|
||||
url := fmt.Sprintf("%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioTickers)
|
||||
|
||||
resp := make(map[string]TickerResponse)
|
||||
err := g.SendHTTPRequest(url, &resp)
|
||||
@@ -175,7 +186,7 @@ func (g *Gateio) GetTickers() (map[string]TickerResponse, error) {
|
||||
|
||||
// GetOrderbook returns the orderbook data for a suppled symbol
|
||||
func (g *Gateio) GetOrderbook(symbol string) (Orderbook, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s/%s", gateioMarketURL, gateioAPIVersion, gateioOrderbook, symbol)
|
||||
url := fmt.Sprintf("%s/%s/%s/%s", g.APIUrlSecondary, gateioAPIVersion, gateioOrderbook, symbol)
|
||||
|
||||
var resp OrderbookResponse
|
||||
err := g.SendHTTPRequest(url, &resp)
|
||||
@@ -229,7 +240,14 @@ func (g *Gateio) GetOrderbook(symbol string) (Orderbook, error) {
|
||||
|
||||
// GetSpotKline returns kline data for the most recent time period
|
||||
func (g *Gateio) GetSpotKline(arg KlinesRequestParams) ([]*KLineResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s/%s?group_sec=%d&range_hour=%d", gateioMarketURL, gateioAPIVersion, gateioKline, arg.Symbol, arg.GroupSec, arg.HourSize)
|
||||
url := fmt.Sprintf("%s/%s/%s/%s?group_sec=%d&range_hour=%d",
|
||||
g.APIUrlSecondary,
|
||||
gateioAPIVersion,
|
||||
gateioKline,
|
||||
arg.Symbol,
|
||||
arg.GroupSec,
|
||||
arg.HourSize)
|
||||
|
||||
var rawKlines map[string]interface{}
|
||||
err := g.SendHTTPRequest(url, &rawKlines)
|
||||
if err != nil {
|
||||
@@ -370,7 +388,7 @@ func (g *Gateio) SendAuthenticatedHTTPRequest(method, endpoint, param string, re
|
||||
hmac := common.GetHMAC(common.HashSHA512, []byte(param), []byte(g.APISecret))
|
||||
headers["sign"] = common.ByteArrayToString(hmac)
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%s", gateioTradeURL, gateioAPIVersion, endpoint)
|
||||
url := fmt.Sprintf("%s/%s/%s", g.APIUrl, gateioAPIVersion, endpoint)
|
||||
|
||||
return g.SendPayload(method, url, headers, strings.NewReader(param), result, true, g.Verbose)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,12 @@ func (g *Gemini) SetDefaults() {
|
||||
g.AssetTypes = []string{ticker.Spot}
|
||||
g.SupportsAutoPairUpdating = true
|
||||
g.SupportsRESTTickerBatching = false
|
||||
g.Requester = request.New(g.Name, request.NewRateLimit(time.Minute, geminiAuthRate), request.NewRateLimit(time.Minute, geminiUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
g.Requester = request.New(g.Name,
|
||||
request.NewRateLimit(time.Minute, geminiAuthRate),
|
||||
request.NewRateLimit(time.Minute, geminiUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
g.APIUrlDefault = geminiAPIURL
|
||||
g.APIUrl = g.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration parameters
|
||||
@@ -128,11 +133,7 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) {
|
||||
g.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
|
||||
g.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
|
||||
g.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
|
||||
if exch.UseSandbox {
|
||||
g.APIUrl = geminiSandboxAPIURL
|
||||
} else {
|
||||
g.APIUrl = geminiAPIURL
|
||||
}
|
||||
|
||||
err := g.SetCurrencyPairFormat()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -145,6 +146,13 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = g.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if exch.UseSandbox {
|
||||
g.APIUrl = geminiSandboxAPIURL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,12 @@ func (p *HitBTC) SetDefaults() {
|
||||
p.AssetTypes = []string{ticker.Spot}
|
||||
p.SupportsAutoPairUpdating = true
|
||||
p.SupportsRESTTickerBatching = true
|
||||
p.Requester = request.New(p.Name, request.NewRateLimit(time.Second, hitbtcAuthRate), request.NewRateLimit(time.Second, hitbtcUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
p.Requester = request.New(p.Name,
|
||||
request.NewRateLimit(time.Second, hitbtcAuthRate),
|
||||
request.NewRateLimit(time.Second, hitbtcUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
p.APIUrlDefault = apiURL
|
||||
p.APIUrl = p.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets user exchange configuration settings
|
||||
@@ -97,6 +102,10 @@ func (p *HitBTC) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = p.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +124,7 @@ func (p *HitBTC) GetCurrencies(currency string) (map[string]Currencies, error) {
|
||||
Data []Currencies
|
||||
}
|
||||
resp := Response{}
|
||||
path := fmt.Sprintf("%s/%s/%s", apiURL, apiV2Currency, currency)
|
||||
path := fmt.Sprintf("%s/%s/%s", p.APIUrl, apiV2Currency, currency)
|
||||
|
||||
ret := make(map[string]Currencies)
|
||||
err := p.SendHTTPRequest(path, &resp.Data)
|
||||
@@ -136,7 +145,7 @@ func (p *HitBTC) GetCurrencies(currency string) (map[string]Currencies, error) {
|
||||
// of the base currency.
|
||||
func (p *HitBTC) GetSymbols(symbol string) ([]string, error) {
|
||||
resp := []Symbol{}
|
||||
path := fmt.Sprintf("%s/%s/%s", apiURL, apiV2Symbol, symbol)
|
||||
path := fmt.Sprintf("%s/%s/%s", p.APIUrl, apiV2Symbol, symbol)
|
||||
|
||||
ret := make([]string, 0, len(resp))
|
||||
err := p.SendHTTPRequest(path, &resp)
|
||||
@@ -154,7 +163,7 @@ func (p *HitBTC) GetSymbols(symbol string) ([]string, error) {
|
||||
// all their details.
|
||||
func (p *HitBTC) GetSymbolsDetailed() ([]Symbol, error) {
|
||||
resp := []Symbol{}
|
||||
path := fmt.Sprintf("%s/%s", apiURL, apiV2Symbol)
|
||||
path := fmt.Sprintf("%s/%s", p.APIUrl, apiV2Symbol)
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -165,7 +174,7 @@ func (p *HitBTC) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
resp2 := TickerResponse{}
|
||||
ret := make(map[string]TickerResponse)
|
||||
result := make(map[string]Ticker)
|
||||
path := fmt.Sprintf("%s/%s/%s", apiURL, apiV2Ticker, symbol)
|
||||
path := fmt.Sprintf("%s/%s/%s", p.APIUrl, apiV2Ticker, symbol)
|
||||
var err error
|
||||
|
||||
if symbol == "" {
|
||||
@@ -256,7 +265,7 @@ func (p *HitBTC) GetTrades(currencyPair, from, till, limit, offset, by, sort str
|
||||
}
|
||||
|
||||
resp := []TradeHistory{}
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", apiURL, apiV2Trades, currencyPair, vals.Encode())
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", p.APIUrl, apiV2Trades, currencyPair, vals.Encode())
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -272,7 +281,7 @@ func (p *HitBTC) GetOrderbook(currencyPair string, limit int) (Orderbook, error)
|
||||
}
|
||||
|
||||
resp := OrderbookResponse{}
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", apiURL, apiV2Orderbook, currencyPair, vals.Encode())
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", p.APIUrl, apiV2Orderbook, currencyPair, vals.Encode())
|
||||
|
||||
err := p.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -306,7 +315,7 @@ func (p *HitBTC) GetCandles(currencyPair, limit, period string) ([]ChartData, er
|
||||
}
|
||||
|
||||
resp := []ChartData{}
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", apiURL, apiV2Candles, currencyPair, vals.Encode())
|
||||
path := fmt.Sprintf("%s/%s/%s?%s", p.APIUrl, apiV2Candles, currencyPair, vals.Encode())
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -547,7 +556,7 @@ func (p *HitBTC) SendAuthenticatedHTTPRequest(method, endpoint string, values ur
|
||||
headers := make(map[string]string)
|
||||
headers["Authorization"] = "Basic " + common.Base64Encode([]byte(p.APIKey+":"+p.APISecret))
|
||||
|
||||
path := fmt.Sprintf("%s/%s", apiURL, endpoint)
|
||||
path := fmt.Sprintf("%s/%s", p.APIUrl, endpoint)
|
||||
|
||||
return p.SendPayload(method, path, headers, bytes.NewBufferString(values.Encode()), result, true, p.Verbose)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,12 @@ func (h *HUOBI) SetDefaults() {
|
||||
h.AssetTypes = []string{ticker.Spot}
|
||||
h.SupportsAutoPairUpdating = true
|
||||
h.SupportsRESTTickerBatching = false
|
||||
h.Requester = request.New(h.Name, request.NewRateLimit(time.Second*10, huobiAuthRate), request.NewRateLimit(time.Second*10, huobiUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
h.Requester = request.New(h.Name,
|
||||
request.NewRateLimit(time.Second*10, huobiAuthRate),
|
||||
request.NewRateLimit(time.Second*10, huobiUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
h.APIUrlDefault = huobiAPIURL
|
||||
h.APIUrl = h.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets user configuration
|
||||
@@ -109,6 +114,10 @@ func (h *HUOBI) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = h.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +143,7 @@ func (h *HUOBI) GetSpotKline(arg KlinesRequestParams) ([]KlineItem, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketHistoryKline)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketHistoryKline)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -154,7 +163,7 @@ func (h *HUOBI) GetMarketDetailMerged(symbol string) (DetailMerged, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketDetailMerged)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketDetailMerged)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -178,7 +187,7 @@ func (h *HUOBI) GetDepth(obd OrderBookDataRequestParams) (Orderbook, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketDepth)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketDepth)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -200,7 +209,7 @@ func (h *HUOBI) GetTrades(symbol string) ([]Trade, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketTrade)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketTrade)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -240,7 +249,7 @@ func (h *HUOBI) GetTradeHistory(symbol, size string) ([]TradeHistory, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketTradeHistory)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketTradeHistory)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -260,7 +269,7 @@ func (h *HUOBI) GetMarketDetail(symbol string) (Detail, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobiAPIURL, huobiMarketDetail)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobiMarketDetail)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -277,7 +286,7 @@ func (h *HUOBI) GetSymbols() ([]Symbol, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobiAPIURL, huobiAPIVersion, huobiSymbols)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobiAPIVersion, huobiSymbols)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -294,7 +303,7 @@ func (h *HUOBI) GetCurrencies() ([]string, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobiAPIURL, huobiAPIVersion, huobiCurrencies)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobiAPIVersion, huobiCurrencies)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -311,7 +320,7 @@ func (h *HUOBI) GetTimestamp() (int64, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobiAPIURL, huobiAPIVersion, huobiTimestamp)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobiAPIVersion, huobiTimestamp)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -774,7 +783,7 @@ func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url
|
||||
privSig = append(privSig, s.Bytes()...)
|
||||
values.Set("PrivateSignature", common.Base64Encode(privSig))
|
||||
|
||||
url := fmt.Sprintf("%s%s", huobiAPIURL, endpoint)
|
||||
url := fmt.Sprintf("%s%s", h.APIUrl, endpoint)
|
||||
url = common.EncodeURLValues(url, values)
|
||||
|
||||
return h.SendPayload(method, url, headers, bytes.NewBufferString(""), result, true, h.Verbose)
|
||||
|
||||
@@ -72,7 +72,12 @@ func (h *HUOBIHADAX) SetDefaults() {
|
||||
h.AssetTypes = []string{ticker.Spot}
|
||||
h.SupportsAutoPairUpdating = true
|
||||
h.SupportsRESTTickerBatching = false
|
||||
h.Requester = request.New(h.Name, request.NewRateLimit(time.Second*10, huobihadaxAuthRate), request.NewRateLimit(time.Second*10, huobihadaxUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
h.Requester = request.New(h.Name,
|
||||
request.NewRateLimit(time.Second*10, huobihadaxAuthRate),
|
||||
request.NewRateLimit(time.Second*10, huobihadaxUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
h.APIUrlDefault = huobihadaxAPIURL
|
||||
h.APIUrl = h.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets user configuration
|
||||
@@ -104,6 +109,10 @@ func (h *HUOBIHADAX) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = h.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +138,7 @@ func (h *HUOBIHADAX) GetSpotKline(arg KlinesRequestParams) ([]KlineItem, error)
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketHistoryKline)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketHistoryKline)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -149,7 +158,7 @@ func (h *HUOBIHADAX) GetMarketDetailMerged(symbol string) (DetailMerged, error)
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketDetailMerged)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketDetailMerged)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -173,7 +182,7 @@ func (h *HUOBIHADAX) GetDepth(symbol, depthType string) (Orderbook, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketDepth)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketDepth)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -195,7 +204,7 @@ func (h *HUOBIHADAX) GetTrades(symbol string) ([]Trade, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketTrade)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketTrade)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -235,7 +244,7 @@ func (h *HUOBIHADAX) GetTradeHistory(symbol, size string) ([]TradeHistory, error
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketTradeHistory)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketTradeHistory)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -255,7 +264,7 @@ func (h *HUOBIHADAX) GetMarketDetail(symbol string) (Detail, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/%s", huobihadaxAPIURL, huobihadaxMarketDetail)
|
||||
url := fmt.Sprintf("%s/%s", h.APIUrl, huobihadaxMarketDetail)
|
||||
|
||||
err := h.SendHTTPRequest(common.EncodeURLValues(url, vals), &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -272,7 +281,7 @@ func (h *HUOBIHADAX) GetSymbols() ([]Symbol, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobihadaxAPIURL, huobihadaxAPIVersion, huobihadaxSymbols)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobihadaxAPIVersion, huobihadaxSymbols)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -289,7 +298,7 @@ func (h *HUOBIHADAX) GetCurrencies() ([]string, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobihadaxAPIURL, huobihadaxAPIVersion, huobihadaxCurrencies)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobihadaxAPIVersion, huobihadaxCurrencies)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -306,7 +315,7 @@ func (h *HUOBIHADAX) GetTimestamp() (int64, error) {
|
||||
}
|
||||
|
||||
var result response
|
||||
url := fmt.Sprintf("%s/v%s/%s", huobihadaxAPIURL, huobihadaxAPIVersion, huobihadaxTimestamp)
|
||||
url := fmt.Sprintf("%s/v%s/%s", h.APIUrl, huobihadaxAPIVersion, huobihadaxTimestamp)
|
||||
|
||||
err := h.SendHTTPRequest(url, &result)
|
||||
if result.ErrorMessage != "" {
|
||||
@@ -762,7 +771,7 @@ func (h *HUOBIHADAX) SendAuthenticatedHTTPPostRequest(method, endpoint, postBody
|
||||
hmac := common.GetHMAC(common.HashSHA256, []byte(payload), []byte(h.APISecret))
|
||||
signatureParams.Set("Signature", common.Base64Encode(hmac))
|
||||
|
||||
url := fmt.Sprintf("%s%s", huobihadaxAPIURL, endpoint)
|
||||
url := fmt.Sprintf("%s%s", h.APIUrl, endpoint)
|
||||
url = common.EncodeURLValues(url, signatureParams)
|
||||
|
||||
return h.SendPayload(method, url, headers, bytes.NewBufferString(postBodyValues), result, true, h.Verbose)
|
||||
@@ -789,7 +798,7 @@ func (h *HUOBIHADAX) SendAuthenticatedHTTPRequest(method, endpoint string, value
|
||||
hmac := common.GetHMAC(common.HashSHA256, []byte(payload), []byte(h.APISecret))
|
||||
values.Set("Signature", common.Base64Encode(hmac))
|
||||
|
||||
url := fmt.Sprintf("%s%s", huobihadaxAPIURL, endpoint)
|
||||
url := fmt.Sprintf("%s%s", h.APIUrl, endpoint)
|
||||
url = common.EncodeURLValues(url, values)
|
||||
|
||||
return h.SendPayload(method, url, headers, bytes.NewBufferString(""), result, true, h.Verbose)
|
||||
|
||||
@@ -55,7 +55,12 @@ func (i *ItBit) SetDefaults() {
|
||||
i.AssetTypes = []string{ticker.Spot}
|
||||
i.SupportsAutoPairUpdating = false
|
||||
i.SupportsRESTTickerBatching = false
|
||||
i.Requester = request.New(i.Name, request.NewRateLimit(time.Second, itbitAuthRate), request.NewRateLimit(time.Second, itbitUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
i.Requester = request.New(i.Name,
|
||||
request.NewRateLimit(time.Second, itbitAuthRate),
|
||||
request.NewRateLimit(time.Second, itbitUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
i.APIUrlDefault = itbitAPIURL
|
||||
i.APIUrl = i.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets the exchange parameters from exchange config
|
||||
@@ -86,6 +91,10 @@ func (i *ItBit) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = i.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +110,7 @@ func (i *ItBit) GetFee(maker bool) float64 {
|
||||
// currencyPair - example "XBTUSD" "XBTSGD" "XBTEUR"
|
||||
func (i *ItBit) GetTicker(currencyPair string) (Ticker, error) {
|
||||
var response Ticker
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", itbitAPIURL, itbitMarkets, currencyPair, itbitTicker)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", i.APIUrl, itbitMarkets, currencyPair, itbitTicker)
|
||||
|
||||
return response, i.SendHTTPRequest(path, &response)
|
||||
}
|
||||
@@ -110,7 +119,7 @@ func (i *ItBit) GetTicker(currencyPair string) (Ticker, error) {
|
||||
// currencyPair - example "XBTUSD" "XBTSGD" "XBTEUR"
|
||||
func (i *ItBit) GetOrderbook(currencyPair string) (OrderbookResponse, error) {
|
||||
response := OrderbookResponse{}
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", itbitAPIURL, itbitMarkets, currencyPair, itbitOrderbook)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", i.APIUrl, itbitMarkets, currencyPair, itbitOrderbook)
|
||||
|
||||
return response, i.SendHTTPRequest(path, &response)
|
||||
}
|
||||
@@ -122,7 +131,7 @@ func (i *ItBit) GetOrderbook(currencyPair string) (OrderbookResponse, error) {
|
||||
func (i *ItBit) GetTradeHistory(currencyPair, timestamp string) (Trades, error) {
|
||||
response := Trades{}
|
||||
req := "trades?since=" + timestamp
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", itbitAPIURL, itbitMarkets, currencyPair, req)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", i.APIUrl, itbitMarkets, currencyPair, req)
|
||||
|
||||
return response, i.SendHTTPRequest(path, &response)
|
||||
}
|
||||
@@ -321,7 +330,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params
|
||||
}
|
||||
|
||||
request := make(map[string]interface{})
|
||||
url := itbitAPIURL + path
|
||||
url := i.APIUrl + path
|
||||
|
||||
if params != nil {
|
||||
for key, value := range params {
|
||||
|
||||
@@ -69,7 +69,12 @@ func (k *Kraken) SetDefaults() {
|
||||
k.AssetTypes = []string{ticker.Spot}
|
||||
k.SupportsAutoPairUpdating = true
|
||||
k.SupportsRESTTickerBatching = true
|
||||
k.Requester = request.New(k.Name, request.NewRateLimit(time.Second, krakenAuthRate), request.NewRateLimit(time.Second, krakenUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
k.Requester = request.New(k.Name,
|
||||
request.NewRateLimit(time.Second, krakenAuthRate),
|
||||
request.NewRateLimit(time.Second, krakenUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
k.APIUrlDefault = krakenAPIURL
|
||||
k.APIUrl = k.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets current exchange configuration
|
||||
@@ -100,6 +105,10 @@ func (k *Kraken) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = k.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +122,7 @@ func (k *Kraken) GetFee(cryptoTrade bool) float64 {
|
||||
|
||||
// GetServerTime returns current server time
|
||||
func (k *Kraken) GetServerTime() (TimeResponse, error) {
|
||||
path := fmt.Sprintf("%s/%s/public/%s", krakenAPIURL, krakenAPIVersion, krakenServerTime)
|
||||
path := fmt.Sprintf("%s/%s/public/%s", k.APIUrl, krakenAPIVersion, krakenServerTime)
|
||||
|
||||
var response struct {
|
||||
Error []string `json:"error"`
|
||||
@@ -129,7 +138,7 @@ func (k *Kraken) GetServerTime() (TimeResponse, error) {
|
||||
|
||||
// GetAssets returns a full asset list
|
||||
func (k *Kraken) GetAssets() (map[string]Asset, error) {
|
||||
path := fmt.Sprintf("%s/%s/public/%s", krakenAPIURL, krakenAPIVersion, krakenAssets)
|
||||
path := fmt.Sprintf("%s/%s/public/%s", k.APIUrl, krakenAPIVersion, krakenAssets)
|
||||
|
||||
var response struct {
|
||||
Error []string `json:"error"`
|
||||
@@ -145,7 +154,7 @@ func (k *Kraken) GetAssets() (map[string]Asset, error) {
|
||||
|
||||
// GetAssetPairs returns a full asset pair list
|
||||
func (k *Kraken) GetAssetPairs() (map[string]AssetPairs, error) {
|
||||
path := fmt.Sprintf("%s/%s/public/%s", krakenAPIURL, krakenAPIVersion, krakenAssetPairs)
|
||||
path := fmt.Sprintf("%s/%s/public/%s", k.APIUrl, krakenAPIVersion, krakenAssetPairs)
|
||||
|
||||
var response struct {
|
||||
Error []string `json:"error"`
|
||||
@@ -171,7 +180,7 @@ func (k *Kraken) GetTicker(symbol string) (Ticker, error) {
|
||||
}
|
||||
|
||||
resp := Response{}
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", krakenAPIURL, krakenAPIVersion, krakenTicker, values.Encode())
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", k.APIUrl, krakenAPIVersion, krakenTicker, values.Encode())
|
||||
|
||||
err := k.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -209,7 +218,7 @@ func (k *Kraken) GetOHLC(symbol string) ([]OpenHighLowClose, error) {
|
||||
var OHLC []OpenHighLowClose
|
||||
var result Response
|
||||
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", krakenAPIURL, krakenAPIVersion, krakenOHLC, values.Encode())
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", k.APIUrl, krakenAPIVersion, krakenOHLC, values.Encode())
|
||||
|
||||
err := k.SendHTTPRequest(path, &result)
|
||||
if err != nil {
|
||||
@@ -255,7 +264,7 @@ func (k *Kraken) GetDepth(symbol string) (Orderbook, error) {
|
||||
var result interface{}
|
||||
var orderBook Orderbook
|
||||
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", krakenAPIURL, krakenAPIVersion, krakenDepth, values.Encode())
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", k.APIUrl, krakenAPIVersion, krakenDepth, values.Encode())
|
||||
|
||||
err := k.SendHTTPRequest(path, &result)
|
||||
if err != nil {
|
||||
@@ -314,7 +323,7 @@ func (k *Kraken) GetTrades(symbol string) ([]RecentTrades, error) {
|
||||
var recentTrades []RecentTrades
|
||||
var result interface{}
|
||||
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", krakenAPIURL, krakenAPIVersion, krakenTrades, values.Encode())
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", k.APIUrl, krakenAPIVersion, krakenTrades, values.Encode())
|
||||
|
||||
err := k.SendHTTPRequest(path, &result)
|
||||
if err != nil {
|
||||
@@ -355,7 +364,7 @@ func (k *Kraken) GetSpread(symbol string) ([]Spread, error) {
|
||||
var peanutButter []Spread
|
||||
var response interface{}
|
||||
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", krakenAPIURL, krakenAPIVersion, krakenSpread, values.Encode())
|
||||
path := fmt.Sprintf("%s/%s/public/%s?%s", k.APIUrl, krakenAPIVersion, krakenSpread, values.Encode())
|
||||
|
||||
err := k.SendHTTPRequest(path, &response)
|
||||
if err != nil {
|
||||
@@ -831,12 +840,12 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values,
|
||||
signature := common.Base64Encode(common.GetHMAC(common.HashSHA512, append([]byte(path), shasum...), secret))
|
||||
|
||||
if k.Verbose {
|
||||
log.Printf("Sending POST request to %s, path: %s, params: %s", krakenAPIURL, path, encoded)
|
||||
log.Printf("Sending POST request to %s, path: %s, params: %s", k.APIUrl, path, encoded)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
headers["API-Key"] = k.APIKey
|
||||
headers["API-Sign"] = signature
|
||||
|
||||
return k.SendPayload("POST", krakenAPIURL+path, headers, strings.NewReader(encoded), result, true, k.Verbose)
|
||||
return k.SendPayload("POST", k.APIUrl+path, headers, strings.NewReader(encoded), result, true, k.Verbose)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,12 @@ func (l *LakeBTC) SetDefaults() {
|
||||
l.AssetTypes = []string{ticker.Spot}
|
||||
l.SupportsAutoPairUpdating = true
|
||||
l.SupportsRESTTickerBatching = true
|
||||
l.Requester = request.New(l.Name, request.NewRateLimit(time.Second, lakeBTCAuthRate), request.NewRateLimit(time.Second, lakeBTCUnauth), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.Requester = request.New(l.Name,
|
||||
request.NewRateLimit(time.Second, lakeBTCAuthRate),
|
||||
request.NewRateLimit(time.Second, lakeBTCUnauth),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.APIUrlDefault = lakeBTCAPIURL
|
||||
l.APIUrl = l.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration profile
|
||||
@@ -87,6 +92,10 @@ func (l *LakeBTC) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = l.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +125,7 @@ func (l *LakeBTC) GetFee(maker bool) float64 {
|
||||
// GetTicker returns the current ticker from lakeBTC
|
||||
func (l *LakeBTC) GetTicker() (map[string]Ticker, error) {
|
||||
response := make(map[string]TickerResponse)
|
||||
path := fmt.Sprintf("%s/%s", lakeBTCAPIURL, lakeBTCTicker)
|
||||
path := fmt.Sprintf("%s/%s", l.APIUrl, lakeBTCTicker)
|
||||
|
||||
if err := l.SendHTTPRequest(path, &response); err != nil {
|
||||
return nil, err
|
||||
@@ -158,7 +167,7 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
|
||||
Bids [][]string `json:"bids"`
|
||||
Asks [][]string `json:"asks"`
|
||||
}
|
||||
path := fmt.Sprintf("%s/%s?symbol=%s", lakeBTCAPIURL, lakeBTCOrderbook, common.StringToLower(currency))
|
||||
path := fmt.Sprintf("%s/%s?symbol=%s", l.APIUrl, lakeBTCOrderbook, common.StringToLower(currency))
|
||||
resp := Response{}
|
||||
err := l.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -198,7 +207,7 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
|
||||
|
||||
// GetTradeHistory returns the trade history for a given currency pair
|
||||
func (l *LakeBTC) GetTradeHistory(currency string) ([]TradeHistory, error) {
|
||||
path := fmt.Sprintf("%s/%s?symbol=%s", lakeBTCAPIURL, lakeBTCTrades, common.StringToLower(currency))
|
||||
path := fmt.Sprintf("%s/%s?symbol=%s", l.APIUrl, lakeBTCTrades, common.StringToLower(currency))
|
||||
resp := []TradeHistory{}
|
||||
|
||||
return resp, l.SendHTTPRequest(path, &resp)
|
||||
@@ -320,7 +329,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
|
||||
hmac := common.GetHMAC(common.HashSHA1, []byte(req), []byte(l.APISecret))
|
||||
|
||||
if l.Verbose {
|
||||
log.Printf("Sending POST request to %s calling method %s with params %s\n", lakeBTCAPIURL, method, req)
|
||||
log.Printf("Sending POST request to %s calling method %s with params %s\n", l.APIUrl, method, req)
|
||||
}
|
||||
|
||||
postData := make(map[string]interface{})
|
||||
@@ -338,5 +347,5 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
|
||||
headers["Authorization"] = "Basic " + common.Base64Encode([]byte(l.APIKey+":"+common.HexEncodeToString(hmac)))
|
||||
headers["Content-Type"] = "application/json-rpc"
|
||||
|
||||
return l.SendPayload("POST", lakeBTCAPIURL, headers, strings.NewReader(string(data)), result, true, l.Verbose)
|
||||
return l.SendPayload("POST", l.APIUrl, headers, strings.NewReader(string(data)), result, true, l.Verbose)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,14 @@ func (l *Liqui) SetDefaults() {
|
||||
l.AssetTypes = []string{ticker.Spot}
|
||||
l.SupportsAutoPairUpdating = true
|
||||
l.SupportsRESTTickerBatching = true
|
||||
l.Requester = request.New(l.Name, request.NewRateLimit(time.Second, liquiAuthRate), request.NewRateLimit(time.Second, liquiUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.Requester = request.New(l.Name,
|
||||
request.NewRateLimit(time.Second, liquiAuthRate),
|
||||
request.NewRateLimit(time.Second, liquiUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.APIUrlDefault = liquiAPIPublicURL
|
||||
l.APIUrl = l.APIUrlDefault
|
||||
l.APIUrlSecondaryDefault = liquiAPIPrivateURL
|
||||
l.APIUrlSecondary = l.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration parameters for liqui
|
||||
@@ -92,6 +99,10 @@ func (l *Liqui) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = l.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +134,7 @@ func (l *Liqui) GetAvailablePairs(nonHidden bool) []string {
|
||||
// commission for each pair.
|
||||
func (l *Liqui) GetInfo() (Info, error) {
|
||||
resp := Info{}
|
||||
req := fmt.Sprintf("%s/%s/%s/", liquiAPIPublicURL, liquiAPIPublicVersion, liquiInfo)
|
||||
req := fmt.Sprintf("%s/%s/%s/", l.APIUrl, liquiAPIPublicVersion, liquiInfo)
|
||||
|
||||
return resp, l.SendHTTPRequest(req, &resp)
|
||||
}
|
||||
@@ -142,7 +153,7 @@ func (l *Liqui) GetTicker(currencyPair string) (map[string]Ticker, error) {
|
||||
}
|
||||
|
||||
response := Response{Data: make(map[string]Ticker)}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", liquiAPIPublicURL, liquiAPIPublicVersion, liquiTicker, currencyPair)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", l.APIUrl, liquiAPIPublicVersion, liquiTicker, currencyPair)
|
||||
|
||||
return response.Data, l.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -158,7 +169,7 @@ func (l *Liqui) GetDepth(currencyPair string) (Orderbook, error) {
|
||||
}
|
||||
|
||||
response := Response{Data: make(map[string]Orderbook)}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", liquiAPIPublicURL, liquiAPIPublicVersion, liquiDepth, currencyPair)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", l.APIUrl, liquiAPIPublicVersion, liquiDepth, currencyPair)
|
||||
|
||||
return response.Data[currencyPair], l.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -174,7 +185,7 @@ func (l *Liqui) GetTrades(currencyPair string) ([]Trades, error) {
|
||||
}
|
||||
|
||||
response := Response{Data: make(map[string][]Trades)}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", liquiAPIPublicURL, liquiAPIPublicVersion, liquiTrades, currencyPair)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", l.APIUrl, liquiAPIPublicVersion, liquiTrades, currencyPair)
|
||||
|
||||
return response.Data[currencyPair], l.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -285,7 +296,8 @@ func (l *Liqui) SendAuthenticatedHTTPRequest(method string, values url.Values, r
|
||||
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(l.APISecret))
|
||||
|
||||
if l.Verbose {
|
||||
log.Printf("Sending POST request to %s calling method %s with params %s\n", liquiAPIPrivateURL, method, encoded)
|
||||
log.Printf("Sending POST request to %s calling method %s with params %s\n",
|
||||
l.APIUrlSecondary, method, encoded)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
@@ -293,5 +305,10 @@ func (l *Liqui) SendAuthenticatedHTTPRequest(method string, values url.Values, r
|
||||
headers["Sign"] = common.HexEncodeToString(hmac)
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
return l.SendPayload("POST", liquiAPIPrivateURL, headers, strings.NewReader(encoded), result, true, l.Verbose)
|
||||
return l.SendPayload("POST",
|
||||
l.APIUrlSecondary, headers,
|
||||
strings.NewReader(encoded),
|
||||
result,
|
||||
true,
|
||||
l.Verbose)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package localbitcoins
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
@@ -124,7 +124,12 @@ func (l *LocalBitcoins) SetDefaults() {
|
||||
l.ConfigCurrencyPairFormat.Uppercase = true
|
||||
l.SupportsAutoPairUpdating = false
|
||||
l.SupportsRESTTickerBatching = true
|
||||
l.Requester = request.New(l.Name, request.NewRateLimit(time.Second*0, localbitcoinsAuthRate), request.NewRateLimit(time.Second*0, localbitcoinsUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.Requester = request.New(l.Name,
|
||||
request.NewRateLimit(time.Second*0, localbitcoinsAuthRate),
|
||||
request.NewRateLimit(time.Second*0, localbitcoinsUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
l.APIUrlDefault = localbitcoinsAPIURL
|
||||
l.APIUrl = l.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration parameters
|
||||
@@ -151,6 +156,10 @@ func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = l.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +186,7 @@ func (l *LocalBitcoins) GetAccountInfo(username string, self bool) (AccountInfo,
|
||||
return resp.Data, err
|
||||
}
|
||||
} else {
|
||||
path := fmt.Sprintf("%s/%s/%s/", localbitcoinsAPIURL, localbitcoinsAPIAccountInfo, username)
|
||||
path := fmt.Sprintf("%s/%s/%s/", l.APIUrl, localbitcoinsAPIAccountInfo, username)
|
||||
err := l.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return resp.Data, err
|
||||
@@ -191,19 +200,18 @@ func (l *LocalBitcoins) GetAccountInfo(username string, self bool) (AccountInfo,
|
||||
// adID omitted.
|
||||
//
|
||||
// adID - [optional] string if omitted returns all ads
|
||||
func (l *LocalBitcoins) Getads(adID string) (AdData, error) {
|
||||
type response struct {
|
||||
func (l *LocalBitcoins) Getads(args ...string) (AdData, error) {
|
||||
var resp struct {
|
||||
Data AdData `json:"data"`
|
||||
}
|
||||
resp := response{}
|
||||
|
||||
if len(adID) > 0 {
|
||||
return resp.Data,
|
||||
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAdGet+adID+"/", nil, &resp)
|
||||
if len(args) == 0 {
|
||||
return resp.Data, l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAds, nil, &resp)
|
||||
}
|
||||
|
||||
return resp.Data,
|
||||
l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAds, nil, &resp)
|
||||
params := url.Values{"ads": {strings.Join(args, ",")}}
|
||||
|
||||
return resp.Data, l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPIAdGet, params, &resp)
|
||||
}
|
||||
|
||||
// EditAd updates set advertisements
|
||||
@@ -319,20 +327,21 @@ func (l *LocalBitcoins) InitiateTrade(amount int, message, adID string) error {
|
||||
|
||||
// GetTradeInfo returns information about a single trade that the token owner is
|
||||
// part in.
|
||||
func (l *LocalBitcoins) GetTradeInfo(contactID string) error {
|
||||
return l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPITradeInfo+contactID, nil, nil)
|
||||
func (l *LocalBitcoins) GetTradeInfo(contactID string) (dbi DashBoardInfo, err error) {
|
||||
err = l.SendAuthenticatedHTTPRequest("GET", localbitcoinsAPITradeInfo+contactID+"/", nil, &dbi)
|
||||
return
|
||||
}
|
||||
|
||||
// GetCountryCodes returns a list of valid and recognized countrycodes
|
||||
func (l *LocalBitcoins) GetCountryCodes() error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPICountryCodes, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPICountryCodes, nil)
|
||||
}
|
||||
|
||||
// GetCurrencies returns a list of valid and recognized fiat currencies. Also
|
||||
// contains human readable name for every currency and boolean that tells if
|
||||
// currency is an altcoin.
|
||||
func (l *LocalBitcoins) GetCurrencies() error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPICurrencies, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPICurrencies, nil)
|
||||
}
|
||||
|
||||
// GetDashboardInfo returns a list of trades on the data key contact_list. This
|
||||
@@ -455,13 +464,13 @@ func (l *LocalBitcoins) MarkNotifications(notificationID string) error {
|
||||
// and code for payment methods, and possible limitations in currencies and bank
|
||||
// name choices.
|
||||
func (l *LocalBitcoins) GetPaymentMethods() error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPIPaymentMethods, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIPaymentMethods, nil)
|
||||
}
|
||||
|
||||
// GetPaymentMethodsByCountry returns a list of valid payment methods filtered
|
||||
// by countrycodes.
|
||||
func (l *LocalBitcoins) GetPaymentMethodsByCountry(countryCode string) error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPIPaymentMethods+countryCode, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIPaymentMethods+countryCode, nil)
|
||||
}
|
||||
|
||||
// CheckPincode checks the given PIN code against the token owners currently
|
||||
@@ -495,7 +504,7 @@ func (l *LocalBitcoins) CheckPincode(pin int) (bool, error) {
|
||||
// GetPlaces Looks up places near lat, lon and provides full URLs to buy and
|
||||
// sell listings for each.
|
||||
func (l *LocalBitcoins) GetPlaces(lat, lon int, location, countryCode string) error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPIPlaces, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIPlaces, nil)
|
||||
}
|
||||
|
||||
// VerifyUsername returns list of real name verifiers for the user. Returns a
|
||||
@@ -610,25 +619,25 @@ func (l *LocalBitcoins) GetWalletAddress() (string, error) {
|
||||
|
||||
// GetBitcoinsWithCashAd returns buy or sell as cash local advertisements.
|
||||
func (l *LocalBitcoins) GetBitcoinsWithCashAd(locationID, locationSlug string, BuySide bool) error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPICashBuy, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPICashBuy, nil)
|
||||
}
|
||||
|
||||
// GetBitcoinsOnlineAd this API returns buy or sell Bitcoin online ads.
|
||||
func (l *LocalBitcoins) GetBitcoinsOnlineAd(countryCode, countryName, paymentMethod string, BuySide bool) error {
|
||||
return l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPIOnlineBuy, nil)
|
||||
return l.SendHTTPRequest(l.APIUrl+localbitcoinsAPIOnlineBuy, nil)
|
||||
}
|
||||
|
||||
// GetTicker returns list of all completed trades.
|
||||
func (l *LocalBitcoins) GetTicker() (map[string]Ticker, error) {
|
||||
result := make(map[string]Ticker)
|
||||
|
||||
return result, l.SendHTTPRequest(localbitcoinsAPIURL+localbitcoinsAPITicker, &result)
|
||||
return result, l.SendHTTPRequest(l.APIUrl+localbitcoinsAPITicker, &result)
|
||||
}
|
||||
|
||||
// GetTrades returns all closed trades in online buy and online sell categories,
|
||||
// updated every 15 minutes.
|
||||
func (l *LocalBitcoins) GetTrades(currency string, values url.Values) ([]Trade, error) {
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/%s/trades.json", localbitcoinsAPIURL+localbitcoinsAPIBitcoincharts, currency), values)
|
||||
path := common.EncodeURLValues(fmt.Sprintf("%s/%s/trades.json", l.APIUrl+localbitcoinsAPIBitcoincharts, currency), values)
|
||||
result := []Trade{}
|
||||
|
||||
return result, l.SendHTTPRequest(path, &result)
|
||||
@@ -644,7 +653,7 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
|
||||
Asks [][]string `json:"asks"`
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s/%s/orderbook.json", localbitcoinsAPIURL+localbitcoinsAPIBitcoincharts, currency)
|
||||
path := fmt.Sprintf("%s/%s/orderbook.json", l.APIUrl+localbitcoinsAPIBitcoincharts, currency)
|
||||
resp := response{}
|
||||
err := l.SendHTTPRequest(path, &resp)
|
||||
|
||||
@@ -692,7 +701,7 @@ func (l *LocalBitcoins) SendHTTPRequest(path string, result interface{}) error {
|
||||
|
||||
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to
|
||||
// localbitcoins
|
||||
func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, values url.Values, result interface{}) (err error) {
|
||||
func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params url.Values, result interface{}) (err error) {
|
||||
if !l.AuthenticatedAPISupport {
|
||||
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, l.Name)
|
||||
}
|
||||
@@ -703,14 +712,9 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, values
|
||||
l.Nonce.Inc()
|
||||
}
|
||||
|
||||
payload := ""
|
||||
path = "/api/" + path
|
||||
|
||||
if len(values) > 0 {
|
||||
payload = values.Encode()
|
||||
}
|
||||
|
||||
message := l.Nonce.String() + l.APIKey + path + payload
|
||||
encoded := params.Encode()
|
||||
message := l.Nonce.String() + l.APIKey + path + encoded
|
||||
hmac := common.GetHMAC(common.HashSHA256, []byte(message), []byte(l.APISecret))
|
||||
headers := make(map[string]string)
|
||||
headers["Apiauth-Key"] = l.APIKey
|
||||
@@ -719,8 +723,12 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, values
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
if l.Verbose {
|
||||
log.Printf("Raw Path: \n%s\n", path)
|
||||
log.Printf("Sending POST request to `%s`, path: `%s`, params: `%s`.", l.APIUrl, path, encoded)
|
||||
}
|
||||
|
||||
return l.SendPayload(method, localbitcoinsAPIURL+path, headers, bytes.NewBuffer([]byte(payload)), result, true, l.Verbose)
|
||||
if method == "GET" && len(encoded) > 0 {
|
||||
path += "?" + encoded
|
||||
}
|
||||
|
||||
return l.SendPayload(method, l.APIUrl+path, headers, strings.NewReader(encoded), result, true, l.Verbose)
|
||||
}
|
||||
|
||||
@@ -221,24 +221,19 @@ type DashBoardInfo struct {
|
||||
LastOnline string `json:"last_online"`
|
||||
} `json:"advertiser"`
|
||||
} `json:"advertisement"`
|
||||
ContactID int `json:"contact_id"`
|
||||
CanceledAt string `json:"canceled_at"`
|
||||
EscrowedAt string `json:"escrowed_at"`
|
||||
FundedAt string `json:"funded_at"`
|
||||
PaymentCompletedAt string `json:"payment_completed_at"`
|
||||
DisputedAt string `json:"disputed_at"`
|
||||
ClosedAt string `json:"closed_at"`
|
||||
ReleasedAt string `json:"released_at"`
|
||||
IsBuying bool `json:"is_buying"`
|
||||
IsSelling bool `json:"is_selling"`
|
||||
AccountDetails struct {
|
||||
ReceiverName string `json:"receiver_name"`
|
||||
IBAN string `json:"iban"`
|
||||
SwiftBIC string `json:"swift_bic"`
|
||||
Reference string `json:"reference"`
|
||||
} `json:"account_details"`
|
||||
AccountInfo string `json:"account_info"`
|
||||
Floating bool `json:"floating"`
|
||||
ContactID int `json:"contact_id"`
|
||||
CanceledAt string `json:"canceled_at"`
|
||||
EscrowedAt string `json:"escrowed_at"`
|
||||
FundedAt string `json:"funded_at"`
|
||||
PaymentCompletedAt string `json:"payment_completed_at"`
|
||||
DisputedAt string `json:"disputed_at"`
|
||||
ClosedAt string `json:"closed_at"`
|
||||
ReleasedAt string `json:"released_at"`
|
||||
IsBuying bool `json:"is_buying"`
|
||||
IsSelling bool `json:"is_selling"`
|
||||
AccountDetails interface{} `json:"account_details"`
|
||||
AccountInfo string `json:"account_info"`
|
||||
Floating bool `json:"floating"`
|
||||
} `json:"data"`
|
||||
Actions struct {
|
||||
MarkAsPaidURL string `json:"mark_as_paid_url"`
|
||||
|
||||
@@ -108,18 +108,26 @@ func (o *OKCoin) SetDefaults() {
|
||||
|
||||
if okcoinDefaultsSet {
|
||||
o.AssetTypes = append(o.AssetTypes, o.FuturesValues...)
|
||||
o.APIUrl = okcoinAPIURL
|
||||
o.APIUrlDefault = okcoinAPIURL
|
||||
o.APIUrl = o.APIUrlDefault
|
||||
o.Name = "OKCOIN International"
|
||||
o.WebsocketURL = okcoinWebsocketURL
|
||||
o.setCurrencyPairFormats()
|
||||
o.Requester = request.New(o.Name, request.NewRateLimit(time.Second, okcoinAuthRate), request.NewRateLimit(time.Second, okcoinUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
o.Requester = request.New(o.Name,
|
||||
request.NewRateLimit(time.Second, okcoinAuthRate),
|
||||
request.NewRateLimit(time.Second, okcoinUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
} else {
|
||||
o.APIUrl = okcoinAPIURLChina
|
||||
o.APIUrlDefault = okcoinAPIURLChina
|
||||
o.APIUrl = o.APIUrlDefault
|
||||
o.Name = "OKCOIN China"
|
||||
o.WebsocketURL = okcoinWebsocketURLChina
|
||||
okcoinDefaultsSet = true
|
||||
o.setCurrencyPairFormats()
|
||||
o.Requester = request.New(o.Name, request.NewRateLimit(time.Second, okcoinAuthRate), request.NewRateLimit(time.Second, okcoinUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
o.Requester = request.New(o.Name,
|
||||
request.NewRateLimit(time.Second, okcoinAuthRate),
|
||||
request.NewRateLimit(time.Second, okcoinUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +159,10 @@ func (o *OKCoin) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = o.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,12 @@ func (o *OKEX) SetDefaults() {
|
||||
o.ConfigCurrencyPairFormat.Uppercase = false
|
||||
o.SupportsAutoPairUpdating = false
|
||||
o.SupportsRESTTickerBatching = false
|
||||
o.Requester = request.New(o.Name, request.NewRateLimit(time.Second, okexAuthRate), request.NewRateLimit(time.Second, okexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
o.Requester = request.New(o.Name,
|
||||
request.NewRateLimit(time.Second, okexAuthRate),
|
||||
request.NewRateLimit(time.Second, okexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
o.APIUrlDefault = apiURL
|
||||
o.APIUrl = o.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup method sets current configuration details if enabled
|
||||
@@ -139,6 +144,10 @@ func (o *OKEX) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = o.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +169,7 @@ func (o *OKEX) GetContractPrice(symbol, contractType string) (ContractPrice, err
|
||||
values.Set("symbol", common.StringToLower(symbol))
|
||||
values.Set("contract_type", common.StringToLower(contractType))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractPrice, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractPrice, values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -194,7 +203,7 @@ func (o *OKEX) GetContractMarketDepth(symbol, contractType string) (ActualContra
|
||||
values.Set("symbol", common.StringToLower(symbol))
|
||||
values.Set("contract_type", common.StringToLower(contractType))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractFutureDepth, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureDepth, values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -258,7 +267,7 @@ func (o *OKEX) GetContractTradeHistory(symbol, contractType string) ([]ActualCon
|
||||
values.Set("symbol", common.StringToLower(symbol))
|
||||
values.Set("contract_type", common.StringToLower(contractType))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractTradeHistory, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractTradeHistory, values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -294,7 +303,7 @@ func (o *OKEX) GetContractIndexPrice(symbol string) (float64, error) {
|
||||
|
||||
values := url.Values{}
|
||||
values.Set("symbol", common.StringToLower(symbol))
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractFutureIndex, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureIndex, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
@@ -317,7 +326,7 @@ func (o *OKEX) GetContractIndexPrice(symbol string) (float64, error) {
|
||||
// pair
|
||||
// USD-CNY exchange rate used by OKEX, updated weekly
|
||||
func (o *OKEX) GetContractExchangeRate() (float64, error) {
|
||||
path := fmt.Sprintf("%s%s%s.do?", apiURL, apiVersion, contractExchangeRate)
|
||||
path := fmt.Sprintf("%s%s%s.do?", o.APIUrl, apiVersion, contractExchangeRate)
|
||||
var resp interface{}
|
||||
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
@@ -345,7 +354,7 @@ func (o *OKEX) GetContractFutureEstimatedPrice(symbol string) (float64, error) {
|
||||
|
||||
values := url.Values{}
|
||||
values.Set("symbol", symbol)
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractFutureIndex, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureIndex, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
@@ -389,7 +398,7 @@ func (o *OKEX) GetContractCandlestickData(symbol, typeInput, contractType string
|
||||
values.Set("size", strconv.FormatInt(int64(size), 10))
|
||||
values.Set("since", strconv.FormatInt(int64(since), 10))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractCandleStick, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractCandleStick, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
@@ -443,7 +452,7 @@ func (o *OKEX) GetContractHoldingsNumber(symbol, contractType string) (number fl
|
||||
values.Set("symbol", symbol)
|
||||
values.Set("contract_type", contractType)
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractFutureHoldAmount, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureHoldAmount, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err = o.SendHTTPRequest(path, &resp); err != nil {
|
||||
@@ -479,7 +488,7 @@ func (o *OKEX) GetContractlimit(symbol, contractType string) (map[string]float64
|
||||
values.Set("symbol", symbol)
|
||||
values.Set("contract_type", contractType)
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, contractFutureLimits, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, contractFutureLimits, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
@@ -501,7 +510,7 @@ func (o *OKEX) GetContractlimit(symbol, contractType string) (map[string]float64
|
||||
func (o *OKEX) GetContractUserInfo() error {
|
||||
//Still figuring this one out Wrong API interface
|
||||
var resp interface{}
|
||||
path := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, contractFutureUserInfo)
|
||||
path := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, contractFutureUserInfo)
|
||||
|
||||
if err := o.SendAuthenticatedHTTPRequest(path, url.Values{}, &resp); err != nil {
|
||||
return err
|
||||
@@ -530,7 +539,7 @@ func (o *OKEX) GetContractPosition(symbol, contractType string) error {
|
||||
values.Set("symbol", symbol)
|
||||
values.Set("contract_type", contractType)
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, "future_position")
|
||||
path := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, "future_position")
|
||||
|
||||
if err := o.SendAuthenticatedHTTPRequest(path, values, &resp); err != nil {
|
||||
return err
|
||||
@@ -574,7 +583,7 @@ func (o *OKEX) PlaceContractOrders(symbol, contractType, position string, levera
|
||||
}
|
||||
values.Set("lever_rate", strconv.FormatInt(int64(leverageRate), 10))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, "future_trade")
|
||||
path := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, "future_trade")
|
||||
|
||||
if err := o.SendAuthenticatedHTTPRequest(path, values, &resp); err != nil {
|
||||
return 0, err
|
||||
@@ -600,7 +609,7 @@ func (o *OKEX) GetContractFuturesTradeHistory(symbol, date string, since int) er
|
||||
values.Set("date", date)
|
||||
values.Set("since", strconv.FormatInt(int64(since), 10))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, "future_trades_history")
|
||||
path := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, "future_trades_history")
|
||||
|
||||
if err := o.SendAuthenticatedHTTPRequest(path, values, &resp); err != nil {
|
||||
return err
|
||||
@@ -616,7 +625,7 @@ func (o *OKEX) GetContractFuturesTradeHistory(symbol, date string, since int) er
|
||||
// GetUserInfo returns the user info
|
||||
func (o *OKEX) GetUserInfo() (SpotUserInfo, error) {
|
||||
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, spotUserInfo)
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, spotUserInfo)
|
||||
|
||||
var res SpotUserInfo
|
||||
err := o.SendAuthenticatedHTTPRequest(strRequestURL, url.Values{}, &res)
|
||||
@@ -634,7 +643,7 @@ func (o *OKEX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
|
||||
}
|
||||
|
||||
var res response
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, spotTrade)
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, spotTrade)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", arg.Symbol)
|
||||
@@ -662,7 +671,7 @@ func (o *OKEX) SpotCancelOrder(symbol string, argOrderID int64) (int64, error) {
|
||||
}
|
||||
|
||||
var res response
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", apiURL, apiVersion, spotCancelTrade)
|
||||
strRequestURL := fmt.Sprintf("%s%s%s.do", o.APIUrl, apiVersion, spotCancelTrade)
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("symbol", symbol)
|
||||
@@ -700,7 +709,7 @@ func (o *OKEX) GetSpotTicker(symbol string) (SpotPrice, error) {
|
||||
|
||||
values := url.Values{}
|
||||
values.Set("symbol", symbol)
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "ticker", values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, "ticker", values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -722,7 +731,7 @@ func (o *OKEX) GetSpotMarketDepth(asd ActualSpotDepthRequestParams) (ActualSpotD
|
||||
values.Set("symbol", asd.Symbol)
|
||||
values.Set("size", fmt.Sprintf("%d", asd.Size))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "depth", values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, "depth", values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -779,7 +788,7 @@ func (o *OKEX) GetSpotRecentTrades(ast ActualSpotTradeHistoryRequestParams) ([]A
|
||||
values.Set("symbol", ast.Symbol)
|
||||
values.Set("since", fmt.Sprintf("%d", ast.Since))
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "trades", values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, "trades", values.Encode())
|
||||
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -819,7 +828,7 @@ func (o *OKEX) GetSpotKline(arg KlinesRequestParams) ([]CandleStickData, error)
|
||||
values.Set("since", strconv.FormatInt(int64(arg.Since), 10))
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, spotKline, values.Encode())
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", o.APIUrl, apiVersion, spotKline, values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
|
||||
@@ -72,7 +72,12 @@ func (p *Poloniex) SetDefaults() {
|
||||
p.AssetTypes = []string{ticker.Spot}
|
||||
p.SupportsAutoPairUpdating = true
|
||||
p.SupportsRESTTickerBatching = true
|
||||
p.Requester = request.New(p.Name, request.NewRateLimit(time.Second, poloniexAuthRate), request.NewRateLimit(time.Second, poloniexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
p.Requester = request.New(p.Name,
|
||||
request.NewRateLimit(time.Second, poloniexAuthRate),
|
||||
request.NewRateLimit(time.Second, poloniexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
p.APIUrlDefault = poloniexAPIURL
|
||||
p.APIUrl = p.APIUrlDefault
|
||||
}
|
||||
|
||||
// Setup sets user exchange configuration settings
|
||||
@@ -103,6 +108,10 @@ func (p *Poloniex) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = p.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +127,7 @@ func (p *Poloniex) GetTicker() (map[string]Ticker, error) {
|
||||
}
|
||||
|
||||
resp := response{}
|
||||
path := fmt.Sprintf("%s/public?command=returnTicker", poloniexAPIURL)
|
||||
path := fmt.Sprintf("%s/public?command=returnTicker", p.APIUrl)
|
||||
|
||||
return resp.Data, p.SendHTTPRequest(path, &resp.Data)
|
||||
}
|
||||
@@ -126,7 +135,7 @@ func (p *Poloniex) GetTicker() (map[string]Ticker, error) {
|
||||
// GetVolume returns a list of currencies with associated volume
|
||||
func (p *Poloniex) GetVolume() (interface{}, error) {
|
||||
var resp interface{}
|
||||
path := fmt.Sprintf("%s/public?command=return24hVolume", poloniexAPIURL)
|
||||
path := fmt.Sprintf("%s/public?command=return24hVolume", p.APIUrl)
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -143,7 +152,7 @@ func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (OrderbookAll, e
|
||||
if currencyPair != "" {
|
||||
vals.Set("currencyPair", currencyPair)
|
||||
resp := OrderbookResponse{}
|
||||
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", poloniexAPIURL, vals.Encode())
|
||||
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", p.APIUrl, vals.Encode())
|
||||
err := p.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return oba, err
|
||||
@@ -176,7 +185,7 @@ func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (OrderbookAll, e
|
||||
} else {
|
||||
vals.Set("currencyPair", "all")
|
||||
resp := OrderbookResponseAll{}
|
||||
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", poloniexAPIURL, vals.Encode())
|
||||
path := fmt.Sprintf("%s/public?command=returnOrderBook&%s", p.APIUrl, vals.Encode())
|
||||
err := p.SendHTTPRequest(path, &resp.Data)
|
||||
if err != nil {
|
||||
return oba, err
|
||||
@@ -222,7 +231,7 @@ func (p *Poloniex) GetTradeHistory(currencyPair, start, end string) ([]TradeHist
|
||||
}
|
||||
|
||||
resp := []TradeHistory{}
|
||||
path := fmt.Sprintf("%s/public?command=returnTradeHistory&%s", poloniexAPIURL, vals.Encode())
|
||||
path := fmt.Sprintf("%s/public?command=returnTradeHistory&%s", p.APIUrl, vals.Encode())
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -245,7 +254,7 @@ func (p *Poloniex) GetChartData(currencyPair, start, end, period string) ([]Char
|
||||
}
|
||||
|
||||
resp := []ChartData{}
|
||||
path := fmt.Sprintf("%s/public?command=returnChartData&%s", poloniexAPIURL, vals.Encode())
|
||||
path := fmt.Sprintf("%s/public?command=returnChartData&%s", p.APIUrl, vals.Encode())
|
||||
|
||||
err := p.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
@@ -261,7 +270,7 @@ func (p *Poloniex) GetCurrencies() (map[string]Currencies, error) {
|
||||
Data map[string]Currencies
|
||||
}
|
||||
resp := Response{}
|
||||
path := fmt.Sprintf("%s/public?command=returnCurrencies", poloniexAPIURL)
|
||||
path := fmt.Sprintf("%s/public?command=returnCurrencies", p.APIUrl)
|
||||
|
||||
return resp.Data, p.SendHTTPRequest(path, &resp.Data)
|
||||
}
|
||||
@@ -286,7 +295,7 @@ func (p *Poloniex) GetExchangeCurrencies() ([]string, error) {
|
||||
// currency, specified by the "currency" GET parameter.
|
||||
func (p *Poloniex) GetLoanOrders(currency string) (LoanOrders, error) {
|
||||
resp := LoanOrders{}
|
||||
path := fmt.Sprintf("%s/public?command=returnLoanOrders¤cy=%s", poloniexAPIURL, currency)
|
||||
path := fmt.Sprintf("%s/public?command=returnLoanOrders¤cy=%s", p.APIUrl, currency)
|
||||
|
||||
return resp, p.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -864,7 +873,7 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values
|
||||
hmac := common.GetHMAC(common.HashSHA512, []byte(values.Encode()), []byte(p.APISecret))
|
||||
headers["Sign"] = common.HexEncodeToString(hmac)
|
||||
|
||||
path := fmt.Sprintf("%s/%s", poloniexAPIURL, poloniexAPITradingEndpoint)
|
||||
path := fmt.Sprintf("%s/%s", p.APIUrl, poloniexAPITradingEndpoint)
|
||||
|
||||
return p.SendPayload(method, path, headers, bytes.NewBufferString(values.Encode()), result, true, p.Verbose)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,14 @@ func (w *WEX) SetDefaults() {
|
||||
w.AssetTypes = []string{ticker.Spot}
|
||||
w.SupportsAutoPairUpdating = true
|
||||
w.SupportsRESTTickerBatching = true
|
||||
w.Requester = request.New(w.Name, request.NewRateLimit(time.Second, wexAuthRate), request.NewRateLimit(time.Second, wexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
w.Requester = request.New(w.Name,
|
||||
request.NewRateLimit(time.Second, wexAuthRate),
|
||||
request.NewRateLimit(time.Second, wexUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
w.APIUrlDefault = wexAPIPublicURL
|
||||
w.APIUrl = w.APIUrlDefault
|
||||
w.APIUrlSecondaryDefault = wexAPIPrivateURL
|
||||
w.APIUrlSecondary = w.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration parameters for WEX
|
||||
@@ -95,6 +102,10 @@ func (w *WEX) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = w.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +132,7 @@ func (w *WEX) GetFee() float64 {
|
||||
// GetInfo returns the WEX info
|
||||
func (w *WEX) GetInfo() (Info, error) {
|
||||
resp := Info{}
|
||||
req := fmt.Sprintf("%s/%s/%s/", wexAPIPublicURL, wexAPIPublicVersion, wexInfo)
|
||||
req := fmt.Sprintf("%s/%s/%s/", w.APIUrl, wexAPIPublicVersion, wexInfo)
|
||||
|
||||
return resp, w.SendHTTPRequest(req, &resp)
|
||||
}
|
||||
@@ -133,7 +144,7 @@ func (w *WEX) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexTicker, symbol)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", w.APIUrl, wexAPIPublicVersion, wexTicker, symbol)
|
||||
|
||||
return response.Data, w.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -145,7 +156,7 @@ func (w *WEX) GetDepth(symbol string) (Orderbook, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexDepth, symbol)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", w.APIUrl, wexAPIPublicVersion, wexDepth, symbol)
|
||||
|
||||
return response.Data[symbol], w.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -157,7 +168,7 @@ func (w *WEX) GetTrades(symbol string) ([]Trades, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", wexAPIPublicURL, wexAPIPublicVersion, wexTrades, symbol)
|
||||
req := fmt.Sprintf("%s/%s/%s/%s", w.APIUrl, wexAPIPublicVersion, wexTrades, symbol)
|
||||
|
||||
return response.Data[symbol], w.SendHTTPRequest(req, &response.Data)
|
||||
}
|
||||
@@ -350,7 +361,8 @@ func (w *WEX) SendHTTPRequest(path string, result interface{}) error {
|
||||
// SendAuthenticatedHTTPRequest sends an authenticated HTTP request to WEX
|
||||
func (w *WEX) SendAuthenticatedHTTPRequest(method string, values url.Values, result interface{}) (err error) {
|
||||
if !w.AuthenticatedAPISupport {
|
||||
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, w.Name)
|
||||
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet,
|
||||
w.Name)
|
||||
}
|
||||
|
||||
if w.Nonce.Get() == 0 {
|
||||
@@ -366,7 +378,7 @@ func (w *WEX) SendAuthenticatedHTTPRequest(method string, values url.Values, res
|
||||
|
||||
if w.Verbose {
|
||||
log.Printf("Sending POST request to %s calling method %s with params %s\n",
|
||||
wexAPIPrivateURL,
|
||||
w.APIUrlSecondary,
|
||||
method,
|
||||
encoded)
|
||||
}
|
||||
@@ -376,5 +388,11 @@ func (w *WEX) SendAuthenticatedHTTPRequest(method string, values url.Values, res
|
||||
headers["Sign"] = common.HexEncodeToString(hmac)
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
return w.SendPayload("POST", wexAPIPrivateURL, headers, strings.NewReader(encoded), result, true, w.Verbose)
|
||||
return w.SendPayload("POST",
|
||||
w.APIUrlSecondary,
|
||||
headers,
|
||||
strings.NewReader(encoded),
|
||||
result,
|
||||
true,
|
||||
w.Verbose)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ func (y *Yobit) SetDefaults() {
|
||||
y.Verbose = false
|
||||
y.Websocket = false
|
||||
y.RESTPollingDelay = 10
|
||||
y.APIUrl = apiPublicURL
|
||||
y.AuthenticatedAPISupport = true
|
||||
y.Ticker = make(map[string]Ticker)
|
||||
y.RequestCurrencyPairFormat.Delimiter = "_"
|
||||
@@ -64,7 +63,14 @@ func (y *Yobit) SetDefaults() {
|
||||
y.AssetTypes = []string{ticker.Spot}
|
||||
y.SupportsAutoPairUpdating = false
|
||||
y.SupportsRESTTickerBatching = true
|
||||
y.Requester = request.New(y.Name, request.NewRateLimit(time.Second, yobitAuthRate), request.NewRateLimit(time.Second, yobitUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
y.Requester = request.New(y.Name,
|
||||
request.NewRateLimit(time.Second, yobitAuthRate),
|
||||
request.NewRateLimit(time.Second, yobitUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
y.APIUrlDefault = apiPublicURL
|
||||
y.APIUrl = y.APIUrlDefault
|
||||
y.APIUrlSecondaryDefault = apiPrivateURL
|
||||
y.APIUrlSecondary = y.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup sets exchange configuration parameters for Yobit
|
||||
@@ -95,6 +101,10 @@ func (y *Yobit) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = y.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +116,7 @@ func (y *Yobit) GetFee() float64 {
|
||||
// GetInfo returns the Yobit info
|
||||
func (y *Yobit) GetInfo() (Info, error) {
|
||||
resp := Info{}
|
||||
path := fmt.Sprintf("%s/%s/%s/", apiPublicURL, apiPublicVersion, publicInfo)
|
||||
path := fmt.Sprintf("%s/%s/%s/", y.APIUrl, apiPublicVersion, publicInfo)
|
||||
|
||||
return resp, y.SendHTTPRequest(path, &resp)
|
||||
}
|
||||
@@ -118,7 +128,7 @@ func (y *Yobit) GetTicker(symbol string) (map[string]Ticker, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", apiPublicURL, apiPublicVersion, publicTicker, symbol)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", y.APIUrl, apiPublicVersion, publicTicker, symbol)
|
||||
|
||||
return response.Data, y.SendHTTPRequest(path, &response.Data)
|
||||
}
|
||||
@@ -130,7 +140,7 @@ func (y *Yobit) GetDepth(symbol string) (Orderbook, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", apiPublicURL, apiPublicVersion, publicDepth, symbol)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", y.APIUrl, apiPublicVersion, publicDepth, symbol)
|
||||
|
||||
return response.Data[symbol],
|
||||
y.SendHTTPRequest(path, &response.Data)
|
||||
@@ -143,7 +153,7 @@ func (y *Yobit) GetTrades(symbol string) ([]Trades, error) {
|
||||
}
|
||||
|
||||
response := Response{}
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", apiPublicURL, apiPublicVersion, publicTrades, symbol)
|
||||
path := fmt.Sprintf("%s/%s/%s/%s", y.APIUrl, apiPublicVersion, publicTrades, symbol)
|
||||
|
||||
return response.Data[symbol], y.SendHTTPRequest(path, &response.Data)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,14 @@ func (z *ZB) SetDefaults() {
|
||||
z.AssetTypes = []string{ticker.Spot}
|
||||
z.SupportsAutoPairUpdating = true
|
||||
z.SupportsRESTTickerBatching = true
|
||||
z.Requester = request.New(z.Name, request.NewRateLimit(time.Second*10, zbAuthRate), request.NewRateLimit(time.Second*10, zbUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
z.Requester = request.New(z.Name,
|
||||
request.NewRateLimit(time.Second*10, zbAuthRate),
|
||||
request.NewRateLimit(time.Second*10, zbUnauthRate),
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
z.APIUrlDefault = zbTradeURL
|
||||
z.APIUrl = z.APIUrlDefault
|
||||
z.APIUrlSecondaryDefault = zbMarketURL
|
||||
z.APIUrlSecondary = z.APIUrlSecondaryDefault
|
||||
}
|
||||
|
||||
// Setup sets user configuration
|
||||
@@ -89,6 +96,10 @@ func (z *ZB) Setup(exch config.ExchangeConfig) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = z.SetAPIURL(exch)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +173,7 @@ func (z *ZB) GetAccountInfo() (AccountsResponse, error) {
|
||||
// GetMarkets returns market information including pricing, symbols and
|
||||
// each symbols decimal precision
|
||||
func (z *ZB) GetMarkets() (map[string]MarketResponseItem, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s", zbTradeURL, zbAPIVersion, zbMarkets)
|
||||
url := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbMarkets)
|
||||
|
||||
var res interface{}
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
@@ -198,7 +209,7 @@ func (z *ZB) GetLatestSpotPrice(symbol string) (float64, error) {
|
||||
|
||||
// GetTicker returns a ticker for a given symbol
|
||||
func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", zbTradeURL, zbAPIVersion, zbTicker, symbol)
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbTicker, symbol)
|
||||
var res TickerResponse
|
||||
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
@@ -211,7 +222,7 @@ func (z *ZB) GetTicker(symbol string) (TickerResponse, error) {
|
||||
|
||||
// GetTickers returns ticker data for all supported symbols
|
||||
func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s", zbTradeURL, zbAPIVersion, zbTickers)
|
||||
url := fmt.Sprintf("%s/%s/%s", z.APIUrl, zbAPIVersion, zbTickers)
|
||||
resp := make(map[string]TickerChildResponse)
|
||||
|
||||
err := z.SendHTTPRequest(url, &resp)
|
||||
@@ -224,7 +235,7 @@ func (z *ZB) GetTickers() (map[string]TickerChildResponse, error) {
|
||||
|
||||
// GetOrderbook returns the orderbook for a given symbol
|
||||
func (z *ZB) GetOrderbook(symbol string) (OrderbookResponse, error) {
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", zbTradeURL, zbAPIVersion, zbDepth, symbol)
|
||||
url := fmt.Sprintf("%s/%s/%s?market=%s", z.APIUrl, zbAPIVersion, zbDepth, symbol)
|
||||
var res OrderbookResponse
|
||||
|
||||
err := z.SendHTTPRequest(url, &res)
|
||||
@@ -254,7 +265,7 @@ func (z *ZB) GetSpotKline(arg KlinesRequestParams) (KLineResponse, error) {
|
||||
vals.Set("size", fmt.Sprintf("%d", arg.Size))
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%s?%s", zbTradeURL, zbAPIVersion, zbKline, vals.Encode())
|
||||
url := fmt.Sprintf("%s/%s/%s?%s", z.APIUrl, zbAPIVersion, zbKline, vals.Encode())
|
||||
|
||||
var res KLineResponse
|
||||
var rawKlines map[string]interface{}
|
||||
@@ -307,10 +318,24 @@ func (z *ZB) SendAuthenticatedHTTPRequest(method, endpoint string, values url.Va
|
||||
mapParams2Sign := url.Values{}
|
||||
mapParams2Sign.Set("accesskey", z.APIKey)
|
||||
mapParams2Sign.Set("method", values.Get("method"))
|
||||
values.Set("sign", common.HexEncodeToString(common.GetHMAC(common.HashMD5, []byte(values.Encode()), []byte(common.Sha1ToHex(z.APISecret)))))
|
||||
|
||||
values.Set("sign",
|
||||
common.HexEncodeToString(common.GetHMAC(common.HashMD5,
|
||||
[]byte(values.Encode()),
|
||||
[]byte(common.Sha1ToHex(z.APISecret)))))
|
||||
|
||||
values.Set("reqTime", fmt.Sprintf("%d", time.Now().UnixNano()/1e6))
|
||||
|
||||
url := fmt.Sprintf("%s/%s?%s", zbMarketURL, endpoint, values.Encode())
|
||||
url := fmt.Sprintf("%s/%s?%s",
|
||||
z.APIUrlSecondaryDefault,
|
||||
endpoint,
|
||||
values.Encode())
|
||||
|
||||
return z.SendPayload(method, url, nil, strings.NewReader(""), result, true, z.Verbose)
|
||||
return z.SendPayload(method,
|
||||
url,
|
||||
nil,
|
||||
strings.NewReader(""),
|
||||
result,
|
||||
true,
|
||||
z.Verbose)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user