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:
@@ -4,11 +4,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
@@ -87,8 +87,6 @@ type OKEX struct {
|
||||
CurrencyPairs []string
|
||||
ContractPosition []string
|
||||
Types []string
|
||||
|
||||
*request.Handler
|
||||
}
|
||||
|
||||
// SetDefaults method assignes the default values for Bittrex
|
||||
@@ -105,8 +103,8 @@ func (o *OKEX) SetDefaults() {
|
||||
o.ConfigCurrencyPairFormat.Delimiter = "_"
|
||||
o.ConfigCurrencyPairFormat.Uppercase = false
|
||||
o.SupportsAutoPairUpdating = false
|
||||
o.Handler = new(request.Handler)
|
||||
o.SetRequestHandler(o.Name, okexAuthRate, okexUnauthRate, new(http.Client))
|
||||
o.SupportsRESTTickerBatching = false
|
||||
o.Requester = request.New(o.Name, request.NewRateLimit(time.Second, okexAuthRate), request.NewRateLimit(time.Second, okexUnauthRate), common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
}
|
||||
|
||||
// Setup method sets current configuration details if enabled
|
||||
@@ -117,6 +115,7 @@ func (o *OKEX) Setup(exch config.ExchangeConfig) {
|
||||
o.Enabled = true
|
||||
o.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
|
||||
o.SetAPIKeys(exch.APIKey, exch.APISecret, exch.ClientID, false)
|
||||
o.SetHTTPClientTimeout(exch.HTTPTimeout)
|
||||
o.RESTPollingDelay = exch.RESTPollingDelay
|
||||
o.Verbose = exch.Verbose
|
||||
o.Websocket = exch.Websocket
|
||||
@@ -618,7 +617,7 @@ func (o *OKEX) GetSpotTicker(symbol string) (SpotPrice, error) {
|
||||
values.Set("symbol", symbol)
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "ticker", values.Encode())
|
||||
|
||||
err := common.SendHTTPGetRequest(path, true, o.Verbose, &resp)
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
@@ -640,7 +639,7 @@ func (o *OKEX) GetSpotMarketDepth(symbol, size string) (ActualSpotDepth, error)
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "depth", values.Encode())
|
||||
|
||||
err := common.SendHTTPGetRequest(path, true, o.Verbose, &resp)
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return fullDepth, err
|
||||
}
|
||||
@@ -697,7 +696,7 @@ func (o *OKEX) GetSpotRecentTrades(symbol, since string) ([]ActualSpotTradeHisto
|
||||
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "trades", values.Encode())
|
||||
|
||||
err := common.SendHTTPGetRequest(path, true, o.Verbose, &resp)
|
||||
err := o.SendHTTPRequest(path, &resp)
|
||||
if err != nil {
|
||||
return actualTradeHistory, err
|
||||
}
|
||||
@@ -735,7 +734,7 @@ func (o *OKEX) GetSpotCandleStick(symbol, typeInput string, size, since int) ([]
|
||||
path := fmt.Sprintf("%s%s%s.do?%s", apiURL, apiVersion, "kline", values.Encode())
|
||||
var resp interface{}
|
||||
|
||||
if err := common.SendHTTPGetRequest(path, true, o.Verbose, &resp); err != nil {
|
||||
if err := o.SendHTTPRequest(path, &resp); err != nil {
|
||||
return candleData, err
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package okex
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/currency/pair"
|
||||
@@ -12,8 +13,12 @@ import (
|
||||
)
|
||||
|
||||
// Start starts the OKEX go routine
|
||||
func (o *OKEX) Start() {
|
||||
go o.Run()
|
||||
func (o *OKEX) Start(wg *sync.WaitGroup) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
o.Run()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
// Run implements the OKEX wrapper
|
||||
|
||||
Reference in New Issue
Block a user