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,9 +5,9 @@ import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
@@ -49,7 +49,6 @@ const (
// HitBTC is the overarching type across the hitbtc package
type HitBTC struct {
exchange.Base
*request.Handler
}
// SetDefaults sets default settings for hitbtc
@@ -66,8 +65,8 @@ func (p *HitBTC) SetDefaults() {
p.ConfigCurrencyPairFormat.Uppercase = true
p.AssetTypes = []string{ticker.Spot}
p.SupportsAutoPairUpdating = true
p.Handler = new(request.Handler)
p.SetRequestHandler(p.Name, hitbtcAuthRate, hitbtcUnauthRate, new(http.Client))
p.SupportsRESTTickerBatching = true
p.Requester = request.New(p.Name, request.NewRateLimit(time.Second, hitbtcAuthRate), request.NewRateLimit(time.Second, hitbtcUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
}
// Setup sets user exchange configuration settings
@@ -78,6 +77,7 @@ func (p *HitBTC) Setup(exch config.ExchangeConfig) {
p.Enabled = true
p.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
p.SetAPIKeys(exch.APIKey, exch.APISecret, "", false)
p.SetHTTPClientTimeout(exch.HTTPTimeout)
p.RESTPollingDelay = exch.RESTPollingDelay // Max 60000ms
p.Verbose = exch.Verbose
p.Websocket = exch.Websocket

View File

@@ -3,6 +3,7 @@ package hitbtc
import (
"errors"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
@@ -12,8 +13,12 @@ import (
)
// Start starts the HitBTC go routine
func (h *HitBTC) Start() {
go h.Run()
func (h *HitBTC) Start(wg *sync.WaitGroup) {
wg.Add(1)
go func() {
h.Run()
wg.Done()
}()
}
// Run implements the HitBTC wrapper
@@ -45,12 +50,12 @@ func (h *HitBTC) Run() {
enabledPairs := []string{"BTC-USD"}
log.Println("WARNING: Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")
err = h.UpdateEnabledCurrencies(enabledPairs, true)
err = h.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to update enabled currencies.\n", h.GetName())
}
}
err = h.UpdateAvailableCurrencies(currencies, forceUpgrade)
err = h.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", h.GetName())
}