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

@@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"strings"
@@ -51,7 +50,6 @@ const (
// BTCC is the main overaching type across the BTCC package
type BTCC struct {
exchange.Base
*request.Handler
}
// SetDefaults sets default values for the exchange
@@ -68,8 +66,8 @@ func (b *BTCC) SetDefaults() {
b.ConfigCurrencyPairFormat.Uppercase = true
b.AssetTypes = []string{ticker.Spot}
b.SupportsAutoPairUpdating = true
b.Handler = new(request.Handler)
b.SetRequestHandler(b.Name, btccAuthRate, btccUnauthRate, new(http.Client))
b.SupportsRESTTickerBatching = false
b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, btccAuthRate), request.NewRateLimit(time.Second, btccUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
}
// Setup is run on startup to setup exchange with config values
@@ -80,6 +78,7 @@ func (b *BTCC) Setup(exch config.ExchangeConfig) {
b.Enabled = true
b.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
b.SetAPIKeys(exch.APIKey, exch.APISecret, "", false)
b.SetHTTPClientTimeout(exch.HTTPTimeout)
b.RESTPollingDelay = exch.RESTPollingDelay
b.Verbose = exch.Verbose
b.Websocket = exch.Websocket

View File

@@ -3,6 +3,7 @@ package btcc
import (
"errors"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
@@ -13,8 +14,12 @@ import (
)
// Start starts the BTCC go routine
func (b *BTCC) Start() {
go b.Run()
func (b *BTCC) Start(wg *sync.WaitGroup) {
wg.Add(1)
go func() {
b.Run()
wg.Done()
}()
}
// Run implements the BTCC wrapper
@@ -44,12 +49,12 @@ func (b *BTCC) Run() {
exchCfg.EnabledPairs = pairs[0]
b.BaseCurrencies = []string{"USD"}
err = b.UpdateAvailableCurrencies(pairs, true)
err = b.UpdateCurrencies(pairs, false, true)
if err != nil {
log.Printf("%s failed to update available currencies. %s\n", b.Name, err)
}
err = b.UpdateEnabledCurrencies(pairs, true)
err = b.UpdateCurrencies(pairs, true, true)
if err != nil {
log.Printf("%s failed to update enabled currencies. %s\n", b.Name, err)
}