mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user