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:
Adrian Gallagher
2018-05-04 13:20:19 +10:00
parent 8eef67339d
commit ac41a7cfad
73 changed files with 1327 additions and 742 deletions

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"log"
"net/http"
"strconv"
"time"
@@ -31,14 +30,13 @@ const (
anxDepth = "money/depth/full"
// ANX rate limites for authenticated and unauthenticated requests
anxAuthRate = 1000
anxUnauthRate = 1000
anxAuthRate = 0
anxUnauthRate = 0
)
// ANX is the overarching type across the alphapoint package
type ANX struct {
exchange.Base
*request.Handler
}
// SetDefaults sets current default settings
@@ -58,8 +56,8 @@ func (a *ANX) SetDefaults() {
a.ConfigCurrencyPairFormat.Index = "BTC"
a.AssetTypes = []string{ticker.Spot}
a.SupportsAutoPairUpdating = false
a.Handler = new(request.Handler)
a.SetRequestHandler(a.Name, anxAuthRate, anxUnauthRate, new(http.Client))
a.SupportsRESTTickerBatching = false
a.Requester = request.New(a.Name, request.NewRateLimit(time.Second, anxAuthRate), request.NewRateLimit(time.Second, anxUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
}
//Setup is run on startup to setup exchange with config values
@@ -70,6 +68,7 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
a.Enabled = true
a.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
a.SetAPIKeys(exch.APIKey, exch.APISecret, "", true)
a.SetHTTPClientTimeout(exch.HTTPTimeout)
a.RESTPollingDelay = exch.RESTPollingDelay
a.Verbose = exch.Verbose
a.Websocket = exch.Websocket

View File

@@ -4,6 +4,7 @@ import (
"errors"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
@@ -12,8 +13,12 @@ import (
)
// Start starts the ANX go routine
func (a *ANX) Start() {
go a.Run()
func (a *ANX) Start(wg *sync.WaitGroup) {
wg.Add(1)
go func() {
a.Run()
wg.Done()
}()
}
// Run implements the ANX wrapper