mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 15:11:03 +00:00
New features and bug fixes
- Modifications made to the request package. Planned improvements will be sending requests on intervals, rate limiter back off support, dynamic tuning and requests packaged into a request job group. - Can modify each exchanges individual HTTP client (e.g timeout and transport settings). - Bot now uses an exchange config HTTP timeout value. - Bot now uses a global HTTP timeout (configurable). - Batched ticker request support for exchanges. - Ticker and Orderbook fetching now are spanned accross multiple go routines and regulated by a sync wait group. - Fixes hack used to load exchanges, now uses a sync wait group. - Ticker and Orderbook storage and fetching now uses mutex locks. - New pair function for finding different pairs between two supplied pair arrays. This is used for currency pair updates for exchange which support dynamic updating. - Shows removal/additions of dynamic updates currencies.
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
@@ -49,8 +49,8 @@ const (
|
||||
gdaxCoinbaseAccounts = "coinbase-accounts"
|
||||
gdaxTrailingVolume = "users/self/trailing-volume"
|
||||
|
||||
gdaxAuthRate = 0
|
||||
gdaxUnauthRate = 0
|
||||
gdaxAuthRate = 5
|
||||
gdaxUnauthRate = 3
|
||||
)
|
||||
|
||||
var sometin []string
|
||||
@@ -58,7 +58,6 @@ var sometin []string
|
||||
// GDAX is the overarching type across the GDAX package
|
||||
type GDAX struct {
|
||||
exchange.Base
|
||||
*request.Handler
|
||||
}
|
||||
|
||||
// SetDefaults sets default values for the exchange
|
||||
@@ -77,8 +76,8 @@ func (g *GDAX) SetDefaults() {
|
||||
g.AssetTypes = []string{ticker.Spot}
|
||||
g.APIUrl = gdaxAPIURL
|
||||
g.SupportsAutoPairUpdating = true
|
||||
g.Handler = new(request.Handler)
|
||||
g.SetRequestHandler(g.Name, gdaxAuthRate, gdaxUnauthRate, new(http.Client))
|
||||
g.SupportsRESTTickerBatching = false
|
||||
g.Requester = request.New(g.Name, request.NewRateLimit(time.Second, gdaxAuthRate), request.NewRateLimit(time.Second, gdaxUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
}
|
||||
|
||||
// Setup initialises the exchange parameters with the current configuration
|
||||
@@ -89,6 +88,7 @@ func (g *GDAX) Setup(exch config.ExchangeConfig) {
|
||||
g.Enabled = true
|
||||
g.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
|
||||
g.SetAPIKeys(exch.APIKey, exch.APISecret, exch.ClientID, true)
|
||||
g.SetHTTPClientTimeout(exch.HTTPTimeout)
|
||||
g.RESTPollingDelay = exch.RESTPollingDelay
|
||||
g.Verbose = exch.Verbose
|
||||
g.Websocket = exch.Websocket
|
||||
|
||||
@@ -3,6 +3,7 @@ package gdax
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
@@ -12,8 +13,12 @@ import (
|
||||
)
|
||||
|
||||
// Start starts the GDAX go routine
|
||||
func (g *GDAX) Start() {
|
||||
go g.Run()
|
||||
func (g *GDAX) Start(wg *sync.WaitGroup) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
g.Run()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
// Run implements the GDAX wrapper
|
||||
@@ -38,9 +43,9 @@ func (g *GDAX) Run() {
|
||||
currencies = append(currencies, x.ID[0:3]+x.ID[4:])
|
||||
}
|
||||
}
|
||||
err = g.UpdateAvailableCurrencies(currencies, false)
|
||||
err = g.UpdateCurrencies(currencies, false, false)
|
||||
if err != nil {
|
||||
log.Printf("%s Failed to get config.\n", g.GetName())
|
||||
log.Printf("%s Failed to update available currencies.\n", g.GetName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user