Optimisation: Large struct pointer conversion (final part) (#265)

Completes large struct pointer optomisations over the entire codebase and enables hugeParams linter by default
This commit is contained in:
Andrew
2019-04-04 15:31:49 +11:00
committed by Adrian Gallagher
parent 107cf76373
commit ca55f2f965
97 changed files with 195 additions and 195 deletions

View File

@@ -56,7 +56,7 @@ func (a *Alphapoint) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri
tickerPrice.Volume = tick.Volume
tickerPrice.Last = tick.Last
err = ticker.ProcessTicker(a.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(a.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -76,7 +76,7 @@ func (a *ANX) SetDefaults() {
}
// Setup is run on startup to setup exchange with config values
func (a *ANX) Setup(exch config.ExchangeConfig) {
func (a *ANX) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
a.SetEnabled(false)
} else {
@@ -102,7 +102,7 @@ func (a *ANX) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = a.SetAPIURL(&exch)
err = a.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -53,7 +53,7 @@ func TestSetup(t *testing.T) {
if err != nil {
t.Error("Test Failed - ANX Setup() init error")
}
a.Setup(anxConfig)
a.Setup(&anxConfig)
a.APIKey = testAPIKey
a.APISecret = testAPISecret
a.AuthenticatedAPISupport = true

View File

@@ -150,7 +150,7 @@ func (a *ANX) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, err
tickerPrice.High = 0
}
err = ticker.ProcessTicker(a.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(a.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -101,7 +101,7 @@ func (b *Binance) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Binance) Setup(exch config.ExchangeConfig) {
func (b *Binance) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -127,7 +127,7 @@ func (b *Binance) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -33,7 +33,7 @@ func TestSetup(t *testing.T) {
binanceConfig.AuthenticatedAPISupport = true
binanceConfig.APIKey = testAPIKey
binanceConfig.APISecret = testAPISecret
b.Setup(binanceConfig)
b.Setup(&binanceConfig)
}
func TestGetExchangeValidCurrencyPairs(t *testing.T) {

View File

@@ -98,7 +98,7 @@ func (b *Binance) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.Last = tick[y].LastPrice
tickerPrice.Low = tick[y].LowPrice
tickerPrice.Volume = tick[y].Volume
ticker.ProcessTicker(b.Name, tickerPrice, assetType)
ticker.ProcessTicker(b.Name, &tickerPrice, assetType)
}
}
return ticker.GetTicker(b.Name, p, assetType)

View File

@@ -118,7 +118,7 @@ func (b *Bitfinex) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bitfinex) Setup(exch config.ExchangeConfig) {
func (b *Bitfinex) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -145,7 +145,7 @@ func (b *Bitfinex) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -29,7 +29,7 @@ func TestSetup(t *testing.T) {
if err != nil {
t.Error("Test Failed - Bitfinex Setup() init error")
}
b.Setup(bfxConfig)
b.Setup(&bfxConfig)
b.APIKey = testAPIKey
b.APISecret = testAPISecret
if !b.Enabled || b.AuthenticatedAPISupport || b.RESTPollingDelay != time.Duration(10) ||

View File

@@ -79,7 +79,7 @@ func (b *Bitfinex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price
tick.Volume = tickerNew[x].Volume
tick.High = tickerNew[x].High
err = ticker.ProcessTicker(b.Name, tick, assetType)
err = ticker.ProcessTicker(b.Name, &tick, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -103,7 +103,7 @@ func (b *Bitflyer) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bitflyer) Setup(exch config.ExchangeConfig) {
func (b *Bitflyer) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -130,7 +130,7 @@ func (b *Bitflyer) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -35,7 +35,7 @@ func TestSetup(t *testing.T) {
bitflyerConfig.APIKey = testAPIKey
bitflyerConfig.APISecret = testAPISecret
b.Setup(bitflyerConfig)
b.Setup(&bitflyerConfig)
}
func TestGetLatestBlockCA(t *testing.T) {

View File

@@ -66,7 +66,7 @@ func (b *Bitflyer) UpdateTicker(p currency.Pair, assetType string) (ticker.Price
tickerPrice.Last = tickerNew.Last
tickerPrice.Volume = tickerNew.Volume
// tickerPrice.High
err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -85,7 +85,7 @@ func (b *Bithumb) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bithumb) Setup(exch config.ExchangeConfig) {
func (b *Bithumb) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -112,7 +112,7 @@ func (b *Bithumb) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
bitConfig.APIKey = testAPIKey
bitConfig.APISecret = testAPISecret
b.Setup(bitConfig)
b.Setup(&bitConfig)
}
func TestGetTradablePairs(t *testing.T) {

View File

@@ -84,7 +84,7 @@ func (b *Bithumb) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tp.Volume = tickers[currency].Volume1Day
tp.High = tickers[currency].MaxPrice
err = ticker.ProcessTicker(b.Name, tp, assetType)
err = ticker.ProcessTicker(b.Name, &tp, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -139,7 +139,7 @@ func (b *Bitmex) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *Bitmex) Setup(exch config.ExchangeConfig) {
func (b *Bitmex) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -164,7 +164,7 @@ func (b *Bitmex) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}
@@ -218,7 +218,7 @@ func (b *Bitmex) RemoveAPIKey(params APIKeyParams) (bool, error) {
return keyDeleted, b.SendAuthenticatedHTTPRequest(http.MethodDelete,
bitmexEndpointAPIkeys,
params,
&params,
&keyDeleted)
}
@@ -228,7 +228,7 @@ func (b *Bitmex) DisableAPIKey(params APIKeyParams) (APIKey, error) {
return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointDisableAPIkey,
params,
&params,
&keyInfo)
}
@@ -238,7 +238,7 @@ func (b *Bitmex) EnableAPIKey(params APIKeyParams) (APIKey, error) {
return keyInfo, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointEnableAPIkey,
params,
&params,
&keyInfo)
}
@@ -246,7 +246,7 @@ func (b *Bitmex) EnableAPIKey(params APIKeyParams) (APIKey, error) {
func (b *Bitmex) GetTrollboxMessages(params ChatGetParams) ([]Chat, error) {
var messages []Chat
return messages, b.SendHTTPRequest(bitmexEndpointTrollbox, params, &messages)
return messages, b.SendHTTPRequest(bitmexEndpointTrollbox, &params, &messages)
}
// SendTrollboxMessage sends a message to the bitmex trollbox
@@ -255,7 +255,7 @@ func (b *Bitmex) SendTrollboxMessage(params ChatSendParams) ([]Chat, error) {
return messages, b.SendAuthenticatedHTTPRequest(http.MethodPost,
bitmexEndpointTrollboxSend,
params,
&params,
&messages)
}

View File

@@ -91,7 +91,7 @@ type APIKeyParams struct {
}
// VerifyData verifies outgoing data sets
func (p APIKeyParams) VerifyData() error {
func (p *APIKeyParams) VerifyData() error {
if p.APIKeyID == "" {
return errors.New("verifydata APIKeyParams error - APIKeyID not set")
}
@@ -100,7 +100,7 @@ func (p APIKeyParams) VerifyData() error {
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p APIKeyParams) ToURLVals(path string) (string, error) {
func (p *APIKeyParams) ToURLVals(path string) (string, error) {
values, err := StructValsToURLVals(&p)
if err != nil {
return "", err
@@ -109,8 +109,8 @@ func (p APIKeyParams) ToURLVals(path string) (string, error) {
}
// IsNil checks to see if any values has been set for the paramater
func (p APIKeyParams) IsNil() bool {
return p == (APIKeyParams{})
func (p *APIKeyParams) IsNil() bool {
return (APIKeyParams{}) == *p
}
// ChatGetParams contains all the parameters to send to the API endpoint
@@ -129,14 +129,14 @@ type ChatGetParams struct {
}
// VerifyData verifies outgoing data sets
func (p ChatGetParams) VerifyData() error {
func (p *ChatGetParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p ChatGetParams) ToURLVals(path string) (string, error) {
values, err := StructValsToURLVals(&p)
func (p *ChatGetParams) ToURLVals(path string) (string, error) {
values, err := StructValsToURLVals(p)
if err != nil {
return "", err
}
@@ -144,8 +144,8 @@ func (p ChatGetParams) ToURLVals(path string) (string, error) {
}
// IsNil checks to see if any values has been set for the paramater
func (p ChatGetParams) IsNil() bool {
return p == (ChatGetParams{})
func (p *ChatGetParams) IsNil() bool {
return *p == (ChatGetParams{})
}
// ChatSendParams contains all the parameters to send to the API endpoint
@@ -172,8 +172,8 @@ func (p ChatSendParams) ToURLVals(path string) (string, error) {
}
// IsNil checks to see if any values has been set for the paramater
func (p ChatSendParams) IsNil() bool {
return p == (ChatSendParams{})
func (p *ChatSendParams) IsNil() bool {
return *p == (ChatSendParams{})
}
// GenericRequestParams contains all the parameters for some general functions
@@ -214,14 +214,14 @@ type GenericRequestParams struct {
}
// VerifyData verifies outgoing data sets
func (p GenericRequestParams) VerifyData() error {
func (p *GenericRequestParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p GenericRequestParams) ToURLVals(path string) (string, error) {
values, err := StructValsToURLVals(&p)
func (p *GenericRequestParams) ToURLVals(path string) (string, error) {
values, err := StructValsToURLVals(p)
if err != nil {
return "", err
}
@@ -229,8 +229,8 @@ func (p GenericRequestParams) ToURLVals(path string) (string, error) {
}
// IsNil checks to see if any values has been set for the paramater
func (p GenericRequestParams) IsNil() bool {
return p == (GenericRequestParams{})
func (p *GenericRequestParams) IsNil() bool {
return *p == (GenericRequestParams{})
}
// LeaderboardGetParams contains all the parameters to send to the API endpoint
@@ -332,19 +332,19 @@ type OrderNewParams struct {
}
// VerifyData verifies outgoing data sets
func (p OrderNewParams) VerifyData() error {
func (p *OrderNewParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p OrderNewParams) ToURLVals(path string) (string, error) {
func (p *OrderNewParams) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p OrderNewParams) IsNil() bool {
return p == (OrderNewParams{})
func (p *OrderNewParams) IsNil() bool {
return *p == (OrderNewParams{})
}
// OrderAmendParams contains all the parameters to send to the API endpoint
@@ -394,7 +394,7 @@ type OrderAmendParams struct {
}
// VerifyData verifies outgoing data sets
func (p OrderAmendParams) VerifyData() error {
func (p *OrderAmendParams) VerifyData() error {
if p.OrderID == "" {
return errors.New("verifydata() OrderNewParams error - OrderID not set")
}
@@ -403,13 +403,13 @@ func (p OrderAmendParams) VerifyData() error {
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p OrderAmendParams) ToURLVals(path string) (string, error) {
func (p *OrderAmendParams) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p OrderAmendParams) IsNil() bool {
return p == (OrderAmendParams{})
func (p *OrderAmendParams) IsNil() bool {
return *p == (OrderAmendParams{})
}
// OrderCancelParams contains all the parameters to send to the API endpoint
@@ -773,19 +773,19 @@ type QuoteGetBucketedParams struct {
}
// VerifyData verifies outgoing data sets
func (p QuoteGetBucketedParams) VerifyData() error {
func (p *QuoteGetBucketedParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p QuoteGetBucketedParams) ToURLVals(path string) (string, error) {
func (p *QuoteGetBucketedParams) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p QuoteGetBucketedParams) IsNil() bool {
return p == (QuoteGetBucketedParams{})
func (p *QuoteGetBucketedParams) IsNil() bool {
return *p == (QuoteGetBucketedParams{})
}
// TradeGetBucketedParams contains all the parameters to send to the API
@@ -834,19 +834,19 @@ type TradeGetBucketedParams struct {
}
// VerifyData verifies outgoing data sets
func (p TradeGetBucketedParams) VerifyData() error {
func (p *TradeGetBucketedParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p TradeGetBucketedParams) ToURLVals(path string) (string, error) {
func (p *TradeGetBucketedParams) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p TradeGetBucketedParams) IsNil() bool {
return p == (TradeGetBucketedParams{})
func (p *TradeGetBucketedParams) IsNil() bool {
return *p == (TradeGetBucketedParams{})
}
// UserUpdateParams contains all the parameters to send to the API endpoint
@@ -871,19 +871,19 @@ type UserUpdateParams struct {
}
// VerifyData verifies outgoing data sets
func (p UserUpdateParams) VerifyData() error {
func (p *UserUpdateParams) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p UserUpdateParams) ToURLVals(path string) (string, error) {
func (p *UserUpdateParams) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p UserUpdateParams) IsNil() bool {
return p == (UserUpdateParams{})
func (p *UserUpdateParams) IsNil() bool {
return *p == (UserUpdateParams{})
}
// UserTokenParams contains all the parameters to send to the API endpoint
@@ -1051,17 +1051,17 @@ type OrdersRequest struct {
}
// VerifyData verifies parameter data during SendAuthenticatedHTTPRequest
func (p OrdersRequest) VerifyData() error {
func (p *OrdersRequest) VerifyData() error {
return nil
}
// ToURLVals converts struct values to url.values and encodes it on the supplied
// path
func (p OrdersRequest) ToURLVals(path string) (string, error) {
func (p *OrdersRequest) ToURLVals(path string) (string, error) {
return "", nil
}
// IsNil checks to see if any values has been set for the paramater
func (p OrdersRequest) IsNil() bool {
return p == (OrdersRequest{})
func (p *OrdersRequest) IsNil() bool {
return *p == (OrdersRequest{})
}

View File

@@ -35,7 +35,7 @@ func TestSetup(t *testing.T) {
bitmexConfig.APIKey = testAPIKey
bitmexConfig.APISecret = testAPISecret
b.Setup(bitmexConfig)
b.Setup(&bitmexConfig)
}
func TestStart(t *testing.T) {

View File

@@ -76,7 +76,7 @@ func (b *Bitmex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.Pair = p
tickerPrice.Last = tick[0].Price
tickerPrice.Volume = float64(tick[0].Size)
return tickerPrice, ticker.ProcessTicker(b.Name, tickerPrice, assetType)
return tickerPrice, ticker.ProcessTicker(b.Name, &tickerPrice, assetType)
}
// GetTickerPrice returns the ticker for a currency pair

View File

@@ -92,7 +92,7 @@ func (b *Bitstamp) SetDefaults() {
}
// Setup sets configuration values to bitstamp
func (b *Bitstamp) Setup(exch config.ExchangeConfig) {
func (b *Bitstamp) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -123,7 +123,7 @@ func (b *Bitstamp) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -51,7 +51,7 @@ func TestSetup(t *testing.T) {
bConfig.APISecret = apiSecret
bConfig.ClientID = customerID
b.Setup(bConfig)
b.Setup(&bConfig)
b.ClientID = customerID
if !b.IsEnabled() || b.RESTPollingDelay != time.Duration(10) ||

View File

@@ -75,7 +75,7 @@ func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType string) (ticker.Price
tickerPrice.Volume = tick.Volume
tickerPrice.High = tick.High
err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -89,7 +89,7 @@ func (b *Bittrex) SetDefaults() {
}
// Setup method sets current configuration details if enabled
func (b *Bittrex) Setup(exch config.ExchangeConfig) {
func (b *Bittrex) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -115,7 +115,7 @@ func (b *Bittrex) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -37,7 +37,7 @@ func TestSetup(t *testing.T) {
bConfig.APISecret = apiSecret
bConfig.AuthenticatedAPISupport = true
b.Setup(bConfig)
b.Setup(&bConfig)
if !b.IsEnabled() ||
b.RESTPollingDelay != time.Duration(10) || b.Verbose ||

View File

@@ -121,7 +121,7 @@ func (b *Bittrex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.Bid = tick.Result[y].Bid
tickerPrice.Last = tick.Result[y].Last
tickerPrice.Volume = tick.Result[y].Volume
ticker.ProcessTicker(b.GetName(), tickerPrice, assetType)
ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType)
}
}
return ticker.GetTicker(b.Name, p, assetType)

View File

@@ -49,7 +49,7 @@ func (b *BTCC) SetDefaults() {
}
// Setup is run on startup to setup exchange with config values
func (b *BTCC) Setup(exch config.ExchangeConfig) {
func (b *BTCC) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -76,7 +76,7 @@ func (b *BTCC) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -30,7 +30,7 @@ func TestSetup(t *testing.T) {
if err != nil {
t.Error("Test Failed - BTCC Setup() init error")
}
b.Setup(bConfig)
b.Setup(&bConfig)
if !b.IsEnabled() || b.AuthenticatedAPISupport ||
b.RESTPollingDelay != time.Duration(10) || b.Verbose ||

View File

@@ -78,7 +78,7 @@ func (b *BTCMarkets) SetDefaults() {
}
// Setup takes in an exchange configuration and sets all parameters
func (b *BTCMarkets) Setup(exch config.ExchangeConfig) {
func (b *BTCMarkets) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -104,7 +104,7 @@ func (b *BTCMarkets) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
bConfig.APISecret = apiSecret
bConfig.AuthenticatedAPISupport = true
b.Setup(bConfig)
b.Setup(&bConfig)
}
func TestGetMarkets(t *testing.T) {

View File

@@ -79,7 +79,7 @@ func (b *BTCMarkets) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri
tickerPrice.Bid = tick.BestBID
tickerPrice.Last = tick.LastPrice
err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -70,7 +70,7 @@ func (b *BTSE) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (b *BTSE) Setup(exch config.ExchangeConfig) {
func (b *BTSE) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
b.SetEnabled(false)
} else {
@@ -97,7 +97,7 @@ func (b *BTSE) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = b.SetAPIURL(&exch)
err = b.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
btseConfig.APIKey = apiKey
btseConfig.APISecret = apiSecret
b.Setup(btseConfig)
b.Setup(&btseConfig)
}
func TestGetMarkets(t *testing.T) {

View File

@@ -73,7 +73,7 @@ func (b *BTSE) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, er
tickerPrice.Volume = s.Volume
tickerPrice.High = s.High
err = ticker.ProcessTicker(b.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(b.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -92,7 +92,7 @@ func (c *CoinbasePro) SetDefaults() {
}
// Setup initialises the exchange parameters with the current configuration
func (c *CoinbasePro) Setup(exch config.ExchangeConfig) {
func (c *CoinbasePro) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
c.SetEnabled(false)
} else {
@@ -122,7 +122,7 @@ func (c *CoinbasePro) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = c.SetAPIURL(&exch)
err = c.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
gdxConfig.APIKey = apiKey
gdxConfig.APISecret = apiSecret
gdxConfig.AuthenticatedAPISupport = true
c.Setup(gdxConfig)
c.Setup(&gdxConfig)
}
func TestGetProducts(t *testing.T) {

View File

@@ -103,7 +103,7 @@ func (c *CoinbasePro) UpdateTicker(p currency.Pair, assetType string) (ticker.Pr
tickerPrice.High = stats.High
tickerPrice.Low = stats.Low
err = ticker.ProcessTicker(c.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(c.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -81,7 +81,7 @@ func (c *COINUT) SetDefaults() {
}
// Setup sets the current exchange configuration
func (c *COINUT) Setup(exch config.ExchangeConfig) {
func (c *COINUT) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
c.SetEnabled(false)
} else {
@@ -108,7 +108,7 @@ func (c *COINUT) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = c.SetAPIURL(&exch)
err = c.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -32,7 +32,7 @@ func TestSetup(t *testing.T) {
}
bConfig.AuthenticatedAPISupport = true
bConfig.APIKey = apiKey
c.Setup(bConfig)
c.Setup(&bConfig)
c.ClientID = clientID
if !c.IsEnabled() ||

View File

@@ -147,7 +147,7 @@ func (c *COINUT) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.High = tick.HighestBuy
tickerPrice.Low = tick.LowestSell
err = ticker.ProcessTicker(c.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(c.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -289,7 +289,7 @@ type Base struct {
// IBotExchange enforces standard functions for all exchanges supported in
// GoCryptoTrader
type IBotExchange interface {
Setup(exch config.ExchangeConfig)
Setup(exch *config.ExchangeConfig)
Start(wg *sync.WaitGroup)
SetDefaults()
GetName() string

View File

@@ -77,7 +77,7 @@ func (e *EXMO) SetDefaults() {
}
// Setup takes in the supplied exchange configuration details and sets params
func (e *EXMO) Setup(exch config.ExchangeConfig) {
func (e *EXMO) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
e.SetEnabled(false)
} else {
@@ -103,7 +103,7 @@ func (e *EXMO) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = e.SetAPIURL(&exch)
err = e.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
exmoConf.APIKey = APIKey
exmoConf.APISecret = APISecret
e.Setup(exmoConf)
e.Setup(&exmoConf)
e.AuthenticatedAPISupport = true
e.APIKey = APIKey

View File

@@ -79,7 +79,7 @@ func (e *EXMO) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, er
tickerPrice.Low = result[currency].Low
tickerPrice.Volume = result[currency].Volume
err = ticker.ProcessTicker(e.Name, tickerPrice, assetType)
err = ticker.ProcessTicker(e.Name, &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -82,7 +82,7 @@ func (g *Gateio) SetDefaults() {
}
// Setup sets user configuration
func (g *Gateio) Setup(exch config.ExchangeConfig) {
func (g *Gateio) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
g.SetEnabled(false)
} else {
@@ -109,7 +109,7 @@ func (g *Gateio) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = g.SetAPIURL(&exch)
err = g.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
gateioConfig.APIKey = apiKey
gateioConfig.APISecret = apiSecret
g.Setup(gateioConfig)
g.Setup(&gateioConfig)
}
func TestGetSymbols(t *testing.T) {

View File

@@ -68,7 +68,7 @@ func (g *Gateio) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tp.Low = result[currency].Low
tp.Volume = result[currency].Volume
err = ticker.ProcessTicker(g.Name, tp, assetType)
err = ticker.ProcessTicker(g.Name, &tp, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -127,7 +127,7 @@ func (g *Gemini) SetDefaults() {
}
// Setup sets exchange configuration parameters
func (g *Gemini) Setup(exch config.ExchangeConfig) {
func (g *Gemini) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
g.SetEnabled(false)
} else {
@@ -154,7 +154,7 @@ func (g *Gemini) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = g.SetAPIURL(&exch)
err = g.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -63,8 +63,8 @@ func TestSetup(t *testing.T) {
geminiConfig.AuthenticatedAPISupport = true
Session[1].Setup(geminiConfig)
Session[2].Setup(geminiConfig)
Session[1].Setup(&geminiConfig)
Session[2].Setup(&geminiConfig)
Session[1].APIKey = apiKey1
Session[1].APISecret = apiSecret1

View File

@@ -89,7 +89,7 @@ func (g *Gemini) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.Last = tick.Last
tickerPrice.Volume = tick.Volume.USD
err = ticker.ProcessTicker(g.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(g.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -84,7 +84,7 @@ func (h *HitBTC) SetDefaults() {
}
// Setup sets user exchange configuration settings
func (h *HitBTC) Setup(exch config.ExchangeConfig) {
func (h *HitBTC) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
h.SetEnabled(false)
} else {
@@ -111,7 +111,7 @@ func (h *HitBTC) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = h.SetAPIURL(&exch)
err = h.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -33,7 +33,7 @@ func TestSetup(t *testing.T) {
hitbtcConfig.APIKey = apiKey
hitbtcConfig.APISecret = apiSecret
h.Setup(hitbtcConfig)
h.Setup(&hitbtcConfig)
}
func TestGetOrderbook(t *testing.T) {

View File

@@ -91,7 +91,7 @@ func (h *HitBTC) UpdateTicker(currencyPair currency.Pair, assetType string) (tic
tp.Low = tick[curr].Low
tp.Volume = tick[curr].Volume
err = ticker.ProcessTicker(h.GetName(), tp, assetType)
err = ticker.ProcessTicker(h.GetName(), &tp, assetType)
if err != nil {
return ticker.Price{}, err
}

View File

@@ -99,7 +99,7 @@ func (h *HUOBI) SetDefaults() {
}
// Setup sets user configuration
func (h *HUOBI) Setup(exch config.ExchangeConfig) {
func (h *HUOBI) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
h.SetEnabled(false)
} else {
@@ -128,7 +128,7 @@ func (h *HUOBI) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = h.SetAPIURL(&exch)
err = h.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -69,7 +69,7 @@ func TestSetup(t *testing.T) {
hConfig.APIKey = apiKey
hConfig.APISecret = apiSecret
h.Setup(hConfig)
h.Setup(&hConfig)
}
func TestGetSpotKline(t *testing.T) {

View File

@@ -117,7 +117,7 @@ func (h *HUOBI) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e
tickerPrice.Bid = tick.Bid[0]
}
err = ticker.ProcessTicker(h.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(h.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -94,7 +94,7 @@ func (h *HUOBIHADAX) SetDefaults() {
}
// Setup sets user configuration
func (h *HUOBIHADAX) Setup(exch config.ExchangeConfig) {
func (h *HUOBIHADAX) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
h.SetEnabled(false)
} else {
@@ -122,7 +122,7 @@ func (h *HUOBIHADAX) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = h.SetAPIURL(&exch)
err = h.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -65,7 +65,7 @@ func TestSetup(t *testing.T) {
hadaxConfig.APIKey = apiKey
hadaxConfig.APISecret = apiSecret
h.Setup(hadaxConfig)
h.Setup(&hadaxConfig)
}
func TestGetSpotKline(t *testing.T) {

View File

@@ -74,7 +74,7 @@ func (h *HUOBIHADAX) UpdateTicker(p currency.Pair, assetType string) (ticker.Pri
tickerPrice.Bid = tick.Bid[0]
}
err = ticker.ProcessTicker(h.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(h.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -69,7 +69,7 @@ func (i *ItBit) SetDefaults() {
}
// Setup sets the exchange parameters from exchange config
func (i *ItBit) Setup(exch config.ExchangeConfig) {
func (i *ItBit) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
i.SetEnabled(false)
} else {
@@ -95,7 +95,7 @@ func (i *ItBit) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = i.SetAPIURL(&exch)
err = i.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -36,7 +36,7 @@ func TestSetup(t *testing.T) {
itbitConfig.APISecret = apiSecret
itbitConfig.ClientID = clientID
i.Setup(itbitConfig)
i.Setup(&itbitConfig)
}
func TestGetTicker(t *testing.T) {

View File

@@ -50,7 +50,7 @@ func (i *ItBit) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e
tickerPrice.Low = tick.Low24h
tickerPrice.Volume = tick.Volume24h
err = ticker.ProcessTicker(i.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(i.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -99,7 +99,7 @@ func (k *Kraken) SetDefaults() {
}
// Setup sets current exchange configuration
func (k *Kraken) Setup(exch config.ExchangeConfig) {
func (k *Kraken) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
k.SetEnabled(false)
} else {
@@ -126,7 +126,7 @@ func (k *Kraken) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = k.SetAPIURL(&exch)
err = k.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -36,7 +36,7 @@ func TestSetup(t *testing.T) {
krakenConfig.APISecret = apiSecret
krakenConfig.ClientID = clientID
krakenConfig.WebsocketURL = k.WebsocketURL
k.Setup(krakenConfig)
k.Setup(&krakenConfig)
}
// TestGetServerTime API endpoint test

View File

@@ -109,7 +109,7 @@ func (k *Kraken) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tp.High = z.High
tp.Low = z.Low
tp.Volume = z.Volume
ticker.ProcessTicker(k.GetName(), tp, assetType)
ticker.ProcessTicker(k.GetName(), &tp, assetType)
}
}
return ticker.GetTicker(k.GetName(), p, assetType)

View File

@@ -69,7 +69,7 @@ func (l *LakeBTC) SetDefaults() {
}
// Setup sets exchange configuration profile
func (l *LakeBTC) Setup(exch config.ExchangeConfig) {
func (l *LakeBTC) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
l.SetEnabled(false)
} else {
@@ -95,7 +95,7 @@ func (l *LakeBTC) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = l.SetAPIURL(&exch)
err = l.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -33,7 +33,7 @@ func TestSetup(t *testing.T) {
lakebtcConfig.APIKey = apiKey
lakebtcConfig.APISecret = apiSecret
l.Setup(lakebtcConfig)
l.Setup(&lakebtcConfig)
}
func TestGetTradablePairs(t *testing.T) {

View File

@@ -67,7 +67,7 @@ func (l *LakeBTC) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
tickerPrice.Low = tick[currency].Low
tickerPrice.Last = tick[currency].Last
err = ticker.ProcessTicker(l.GetName(), tickerPrice, assetType)
err = ticker.ProcessTicker(l.GetName(), &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -138,7 +138,7 @@ func (l *LocalBitcoins) SetDefaults() {
}
// Setup sets exchange configuration parameters
func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) {
func (l *LocalBitcoins) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
l.SetEnabled(false)
} else {
@@ -160,7 +160,7 @@ func (l *LocalBitcoins) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = l.SetAPIURL(&exch)
err = l.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
localbitcoinsConfig.APIKey = apiKey
localbitcoinsConfig.APISecret = apiSecret
l.Setup(localbitcoinsConfig)
l.Setup(&localbitcoinsConfig)
}
func TestGetTicker(t *testing.T) {

View File

@@ -72,7 +72,7 @@ func (l *LocalBitcoins) UpdateTicker(p currency.Pair, assetType string) (ticker.
tp.Last = tick[currency].Avg24h
tp.Volume = tick[currency].VolumeBTC
err = ticker.ProcessTicker(l.GetName(), tp, assetType)
err = ticker.ProcessTicker(l.GetName(), &tp, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -67,7 +67,7 @@ func TestSetup(t *testing.T) {
okcoinConfig.APISecret = apiSecret
okcoinConfig.ClientID = passphrase
okcoinConfig.WebsocketURL = o.WebsocketURL
o.Setup(okcoinConfig)
o.Setup(&okcoinConfig)
testSetupRan = true
}

View File

@@ -68,7 +68,7 @@ func TestSetup(t *testing.T) {
okexConfig.APISecret = apiSecret
okexConfig.ClientID = passphrase
okexConfig.WebsocketURL = o.WebsocketURL
o.Setup(okexConfig)
o.Setup(&okexConfig)
testSetupRan = true
}

View File

@@ -103,7 +103,7 @@ type OKGroup struct {
}
// Setup method sets current configuration details if enabled
func (o *OKGroup) Setup(exch config.ExchangeConfig) {
func (o *OKGroup) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
o.SetEnabled(false)
} else {
@@ -131,7 +131,7 @@ func (o *OKGroup) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = o.SetAPIURL(&exch)
err = o.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -70,7 +70,7 @@ func (o *OKGroup) UpdateTicker(p currency.Pair, assetType string) (tickerData ti
Volume: resp.BaseVolume24h,
}
err = ticker.ProcessTicker(o.Name, tickerData, assetType)
err = ticker.ProcessTicker(o.Name, &tickerData, assetType)
return
}

View File

@@ -137,7 +137,7 @@ func QuoteCurrencyExists(exchange string, p currency.Pair) bool {
}
// CreateNewOrderbook creates a new orderbook
func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType string) *Orderbook {
func CreateNewOrderbook(exchangeName string, orderbookNew *Base, orderbookType string) *Orderbook {
m.Lock()
defer m.Unlock()
orderbook := Orderbook{}
@@ -145,7 +145,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st
orderbook.Orderbook = make(map[*currency.Item]map[*currency.Item]map[string]Base)
a := make(map[*currency.Item]map[string]Base)
b := make(map[string]Base)
b[orderbookType] = orderbookNew
b[orderbookType] = *orderbookNew
a[orderbookNew.Pair.Quote.Item] = b
orderbook.Orderbook[orderbookNew.Pair.Base.Item] = a
Orderbooks = append(Orderbooks, orderbook)
@@ -154,7 +154,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st
// Process processes incoming orderbooks, creating or updating the orderbook
// list
func (o Base) Process() error {
func (o *Base) Process() error {
if o.Pair.IsEmpty() {
return errors.New("orderbook currency pair not populated")
}
@@ -176,7 +176,7 @@ func (o Base) Process() error {
if BaseCurrencyExists(o.ExchangeName, o.Pair.Base) {
m.Lock()
a := make(map[string]Base)
a[o.AssetType] = o
a[o.AssetType] = *o
orderbook.Orderbook[o.Pair.Base.Item][o.Pair.Quote.Item] = a
m.Unlock()
return nil
@@ -185,7 +185,7 @@ func (o Base) Process() error {
m.Lock()
a := make(map[*currency.Item]map[string]Base)
b := make(map[string]Base)
b[o.AssetType] = o
b[o.AssetType] = *o
a[o.Pair.Quote.Item] = b
orderbook.Orderbook[o.Pair.Base.Item] = a
m.Unlock()

View File

@@ -79,7 +79,7 @@ func TestGetOrderbook(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
result, err := Get("Exchange", c, Spot)
if err != nil {
@@ -116,7 +116,7 @@ func TestGetOrderbookByExchange(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
_, err := GetByExchange("Exchange")
if err != nil {
@@ -138,7 +138,7 @@ func TestFirstCurrencyExists(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
if !BaseCurrencyExists("Exchange", c.Base) {
t.Fatal("Test failed. TestFirstCurrencyExists expected first currency doesn't exist")
@@ -158,7 +158,7 @@ func TestSecondCurrencyExists(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
if !QuoteCurrencyExists("Exchange", c) {
t.Fatal("Test failed. TestSecondCurrencyExists expected first currency doesn't exist")
@@ -178,7 +178,7 @@ func TestCreateNewOrderbook(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
result, err := Get("Exchange", c, Spot)
if err != nil {

View File

@@ -90,7 +90,7 @@ func (p *Poloniex) SetDefaults() {
}
// Setup sets user exchange configuration settings
func (p *Poloniex) Setup(exch config.ExchangeConfig) {
func (p *Poloniex) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
p.SetEnabled(false)
} else {
@@ -117,7 +117,7 @@ func (p *Poloniex) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = p.SetAPIURL(&exch)
err = p.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
poloniexConfig.APIKey = apiKey
poloniexConfig.APISecret = apiSecret
p.Setup(poloniexConfig)
p.Setup(&poloniexConfig)
}
func TestGetTicker(t *testing.T) {

View File

@@ -75,7 +75,7 @@ func (p *Poloniex) UpdateTicker(currencyPair currency.Pair, assetType string) (t
tp.Low = tick[curr].Low24Hr
tp.Volume = tick[curr].BaseVolume
err = ticker.ProcessTicker(p.GetName(), tp, assetType)
err = ticker.ProcessTicker(p.GetName(), &tp, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -131,7 +131,7 @@ func SecondCurrencyExists(exchange string, p currency.Pair) bool {
}
// CreateNewTicker creates a new Ticker
func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ticker {
func CreateNewTicker(exchangeName string, tickerNew *Price, tickerType string) Ticker {
m.Lock()
defer m.Unlock()
ticker := Ticker{}
@@ -139,7 +139,7 @@ func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ti
ticker.Price = make(map[string]map[string]map[string]Price)
a := make(map[string]map[string]Price)
b := make(map[string]Price)
b[tickerType] = tickerNew
b[tickerType] = *tickerNew
a[tickerNew.Pair.Quote.Upper().String()] = b
ticker.Price[tickerNew.Pair.Base.Upper().String()] = a
Tickers = append(Tickers, ticker)
@@ -148,7 +148,7 @@ func CreateNewTicker(exchangeName string, tickerNew Price, tickerType string) Ti
// ProcessTicker processes incoming tickers, creating or updating the Tickers
// list
func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) error {
func ProcessTicker(exchangeName string, tickerNew *Price, tickerType string) error {
if tickerNew.Pair.String() == "" {
return errors.New("")
}
@@ -164,7 +164,7 @@ func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) erro
if FirstCurrencyExists(exchangeName, tickerNew.Pair.Base) {
m.Lock()
a := make(map[string]Price)
a[tickerType] = tickerNew
a[tickerType] = *tickerNew
ticker.Price[tickerNew.Pair.Base.Upper().String()][tickerNew.Pair.Quote.Upper().String()] = a
m.Unlock()
return nil
@@ -173,7 +173,7 @@ func ProcessTicker(exchangeName string, tickerNew Price, tickerType string) erro
m.Lock()
a := make(map[string]map[string]Price)
b := make(map[string]Price)
b[tickerType] = tickerNew
b[tickerType] = *tickerNew
a[tickerNew.Pair.Quote.Upper().String()] = b
ticker.Price[tickerNew.Pair.Base.Upper().String()] = a
m.Unlock()

View File

@@ -25,7 +25,7 @@ func TestPriceToString(t *testing.T) {
PriceATH: 1337,
}
newTicker := CreateNewTicker("ANX", priceStruct, Spot)
newTicker := CreateNewTicker("ANX", &priceStruct, Spot)
if newTicker.PriceToString(newPair, "last", Spot) != "1200" {
t.Error("Test Failed - ticker PriceToString last value is incorrect")
@@ -66,7 +66,7 @@ func TestGetTicker(t *testing.T) {
PriceATH: 1337,
}
err := ProcessTicker("bitfinex", priceStruct, Spot)
err := ProcessTicker("bitfinex", &priceStruct, Spot)
if err != nil {
t.Fatal("Test failed. ProcessTicker error", err)
}
@@ -98,7 +98,7 @@ func TestGetTicker(t *testing.T) {
priceStruct.PriceATH = 9001
priceStruct.Pair.Base = currency.ETH
err = ProcessTicker("bitfinex", priceStruct, "futures_3m")
err = ProcessTicker("bitfinex", &priceStruct, "futures_3m")
if err != nil {
t.Fatal("Test failed. ProcessTicker error", err)
}
@@ -126,7 +126,7 @@ func TestGetTickerByExchange(t *testing.T) {
PriceATH: 1337,
}
anxTicker := CreateNewTicker("ANX", priceStruct, Spot)
anxTicker := CreateNewTicker("ANX", &priceStruct, Spot)
Tickers = append(Tickers, anxTicker)
tickerPtr, err := GetTickerByExchange("ANX")
@@ -151,7 +151,7 @@ func TestFirstCurrencyExists(t *testing.T) {
PriceATH: 1337,
}
alphaTicker := CreateNewTicker("alphapoint", priceStruct, Spot)
alphaTicker := CreateNewTicker("alphapoint", &priceStruct, Spot)
Tickers = append(Tickers, alphaTicker)
if !FirstCurrencyExists("alphapoint", currency.BTC) {
@@ -177,7 +177,7 @@ func TestSecondCurrencyExists(t *testing.T) {
PriceATH: 1337,
}
bitstampTicker := CreateNewTicker("bitstamp", priceStruct, "SPOT")
bitstampTicker := CreateNewTicker("bitstamp", &priceStruct, "SPOT")
Tickers = append(Tickers, bitstampTicker)
if !SecondCurrencyExists("bitstamp", newPair) {
@@ -204,7 +204,7 @@ func TestCreateNewTicker(t *testing.T) {
PriceATH: 1337,
}
newTicker := CreateNewTicker("ANX", priceStruct, Spot)
newTicker := CreateNewTicker("ANX", &priceStruct, Spot)
if reflect.ValueOf(newTicker).NumField() != 2 {
t.Error("Test Failed - ticker CreateNewTicker struct change/or updated")
@@ -259,12 +259,12 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
PriceATH: 1337,
}
err := ProcessTicker("btcc", Price{}, Spot)
err := ProcessTicker("btcc", &Price{}, Spot)
if err == nil {
t.Fatal("Test failed. ProcessTicker error cannot be nil")
}
err = ProcessTicker("btcc", priceStruct, Spot)
err = ProcessTicker("btcc", &priceStruct, Spot)
if err != nil {
t.Fatal("Test failed. ProcessTicker error", err)
}
@@ -280,7 +280,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
secondPair := currency.NewPairFromStrings("BTC", "AUD")
priceStruct.Pair = secondPair
err = ProcessTicker("btcc", priceStruct, Spot)
err = ProcessTicker("btcc", &priceStruct, Spot)
if err != nil {
t.Fatal("Test failed. ProcessTicker error", err)
}
@@ -326,7 +326,7 @@ func TestProcessTicker(t *testing.T) { // non-appending function to tickers
}
sm.Lock()
err = ProcessTicker(newName, tp, Spot)
err = ProcessTicker(newName, &tp, Spot)
if err != nil {
log.Error(err)
catastrophicFailure = true

View File

@@ -78,7 +78,7 @@ func (y *Yobit) SetDefaults() {
}
// Setup sets exchange configuration parameters for Yobit
func (y *Yobit) Setup(exch config.ExchangeConfig) {
func (y *Yobit) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
y.SetEnabled(false)
} else {
@@ -105,7 +105,7 @@ func (y *Yobit) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = y.SetAPIURL(&exch)
err = y.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -35,7 +35,7 @@ func TestSetup(t *testing.T) {
conf.APISecret = apiSecret
conf.AuthenticatedAPISupport = true
y.Setup(conf)
y.Setup(&conf)
}
func TestGetInfo(t *testing.T) {

View File

@@ -59,7 +59,7 @@ func (y *Yobit) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, e
tickerPrice.Low = result[currency].Low
tickerPrice.Volume = result[currency].VolumeCurrent
err = ticker.ProcessTicker(y.Name, tickerPrice, assetType)
err = ticker.ProcessTicker(y.Name, &tickerPrice, assetType)
if err != nil {
return tickerPrice, err
}

View File

@@ -82,7 +82,7 @@ func (z *ZB) SetDefaults() {
}
// Setup sets user configuration
func (z *ZB) Setup(exch config.ExchangeConfig) {
func (z *ZB) Setup(exch *config.ExchangeConfig) {
if !exch.Enabled {
z.SetEnabled(false)
} else {
@@ -110,7 +110,7 @@ func (z *ZB) Setup(exch config.ExchangeConfig) {
if err != nil {
log.Fatal(err)
}
err = z.SetAPIURL(&exch)
err = z.SetAPIURL(exch)
if err != nil {
log.Fatal(err)
}

View File

@@ -34,7 +34,7 @@ func TestSetup(t *testing.T) {
zbConfig.APIKey = apiKey
zbConfig.APISecret = apiSecret
z.Setup(zbConfig)
z.Setup(&zbConfig)
}
func TestSpotNewOrder(t *testing.T) {

View File

@@ -76,7 +76,7 @@ func (z *ZB) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, erro
tp.Low = result[currency].Low
tp.Volume = result[currency].Vol
err = ticker.ProcessTicker(z.Name, tp, assetType)
err = ticker.ProcessTicker(z.Name, &tp, assetType)
if err != nil {
return tickerPrice, err
}