Initial overhaul of websocket connection and feeds (#189)

* Initial overhaul of websocket connection and feeds
* Added proxy support
* Piped to routines.go

* Added new websocket file in exchanges
Refactored orderbook handling into exchange_websocket.go
Added better error responses for binance_websocket.go
General clean for binance_websocket.go

* General fixes - bitfinex_websocket.go
Refactored orderbook cache code - bitfinex_websocket.go
Removed fatal error with unhandled type - routines.go

* Added general improvements to bitmex_websocket.go
Refactored orderbook handling to exchange_websocket.go
Added variable in Item struct in orderbook.go for looking up orders by ID

* Fix issue when routines are blocked due to Data Handler not started
Updated traffic handler
General fixes for bitstamp_websocket.go

* General fixes for coinbasepro_websocket.go

* General fixes for coinut_websocket.go
Fixed error return in exchange_websocket.go

* Removed comments in coinut_wrapper.go
Refactor orderbook logic from hitbtc_websocket.go to exchange_websocket.go

* General fixes

* Removed comments
General fixes

* Updated routines.go

* After rebase fix

* Fixed update config pairs in okcoin.go

* fixed config currency issue in okcoin.go for okcoin China

* exchange_websocket.go
*Removed unused const dec
*Removed state change routine
*Improved trafficMonitor routine
*Increased verbosity for error returns
*Removed uneeded mutex locks

exchange_websocket_test.go
*Added new tests for websocket and orderbook updating

routines.go
*Removed string cased

* Fixed race conditions on sync.waitgroup in exchanges_websocket.go

* Changes variable name in config.go

* Removes unnecessary comment

* Removes indefinite lock on error return

* Removes unnecessary comment

* Adds support for BTCC websocket
Drops support for BTCC REST

* Rewords comment in exchange_websocket.go
Moves types to poloniex_types.go

* Moves types to coinut_types.go

* Removes uneeded range for accessing array variables for coinbase_websocket.go
Removes comments in coinut_types.go

* Adds verbosity flag to GCT
Suppresses verbose output from routines.go

* Fixes setting proxy for REST and Websocket per exchange
Upgrades error handling
Drops unused *url.Url variable in exchange type

* Adds test for setting proxy

* Fixes bug that closes connection due to incorrect timeout time through a proxy connection

* Clarify verbose flag message
This commit is contained in:
Ryan O'Hara-Reid
2018-10-24 14:22:41 +11:00
committed by Adrian Gallagher
parent 7315e6604c
commit d3c2800fe0
99 changed files with 6515 additions and 3031 deletions

View File

@@ -47,7 +47,6 @@ func (a *ANX) SetDefaults() {
a.TakerFee = 0.6
a.MakerFee = 0.3
a.Verbose = false
a.Websocket = false
a.RESTPollingDelay = 10
a.RequestCurrencyPairFormat.Delimiter = ""
a.RequestCurrencyPairFormat.Uppercase = true
@@ -64,6 +63,7 @@ func (a *ANX) SetDefaults() {
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
a.APIUrlDefault = anxAPIURL
a.APIUrl = a.APIUrlDefault
a.WebsocketInit()
}
//Setup is run on startup to setup exchange with config values
@@ -78,7 +78,6 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
a.SetHTTPClientUserAgent(exch.HTTPUserAgent)
a.RESTPollingDelay = exch.RESTPollingDelay
a.Verbose = exch.Verbose
a.Websocket = exch.Websocket
a.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
a.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
a.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
@@ -98,6 +97,10 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = a.SetClientProxyAddress(exch.ProxyAddress)
if err != nil {
log.Fatal(err)
}
}
}

View File

@@ -26,7 +26,7 @@ func TestSetDefaults(t *testing.T) {
if anx.Verbose != false {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if anx.Websocket != false {
if anx.Websocket.IsEnabled() != false {
t.Error("Test Failed - ANX SetDefaults() incorrect values set")
}
if anx.RESTPollingDelay != 10 {
@@ -61,7 +61,7 @@ func TestSetup(t *testing.T) {
if anx.Verbose != false {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if anx.Websocket != false {
if anx.Websocket.IsEnabled() != false {
t.Error("Test Failed - ANX Setup() incorrect values set")
}
if len(anx.BaseCurrencies) <= 0 {

View File

@@ -244,3 +244,8 @@ func (a *ANX) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float
func (a *ANX) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) {
return "", errors.New("not yet implemented")
}
// GetWebsocket returns a pointer to the exchange websocket
func (a *ANX) GetWebsocket() (*exchange.Websocket, error) {
return nil, errors.New("not yet implemented")
}