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:
soxipy
2018-08-27 07:19:29 +03:00
committed by Ryan O'Hara-Reid
parent ca0c22f422
commit fb4e2d1452
35 changed files with 885 additions and 355 deletions

View File

@@ -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)