Implement Logger (#228)

* Added new base logger

* updated example and test configs

* updated exchange helpers restful router & server

* logPath is now passed to the logger to remove dependency on common package

* updated everything besides exchanges to use new logger

* alphapoint to bitmex done

* updated bitmex bitstamp bittrex btcc and also performance changes to logger

* btcmarkets coinbase coinut exmo gateio wrappers updated

* gateio and gemini logger updated

* hitbtc huobi itbit & kraken updated

* All exchanges updatd

* return correct error for disabled websocket

* don't disconnect client on invalid json

* updated router internal logging

* log.Fatal to t.Error for tests

* Changed from fatal to error failure to set maxprocs

* output ANSI codes for everything but windows for now due to lack of windows support

* added error handling to logger and unit tests

* clear wording on print -> log.print

* added benchmark test

* cleaned up import sections

* Updated logger based on PR requests (added default config options on failure/setting errors)

* ah this should fix travici enc config issue

* Load entire config and clear out logging to hopefully fix travisci issue

* wording & test error handling

* fixed formatting issues based on feedback

* fixed formatting issues based on feedback

* changed CheckDir to use mkdirall instead of mkdir and other changes based on feedback
This commit is contained in:
Andrew
2019-01-08 21:56:22 +11:00
committed by Adrian Gallagher
parent bfbd496c3a
commit d01e7bad72
103 changed files with 1028 additions and 657 deletions

View File

@@ -4,13 +4,12 @@ import (
"bytes"
"errors"
"fmt"
"log"
"strconv"
"time"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -191,7 +190,7 @@ func (a *Alphapoint) CreateAccount(firstName, lastName, email, phone, password s
err := a.SendAuthenticatedHTTPRequest("POST", alphapointCreateAccount, request, &response)
if err != nil {
log.Println(err)
return fmt.Errorf("Alphapoint Error - CreateAccount HTTPRequest - reason: %s", err)
}
if !response.IsAccepted {
return errors.New(response.RejectReason)

View File

@@ -1,11 +1,11 @@
package alphapoint
import (
"log"
"net/http"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -20,25 +20,25 @@ func (a *Alphapoint) WebsocketClient() {
a.WebsocketConn, _, err = Dialer.Dial(a.WebsocketURL, http.Header{})
if err != nil {
log.Printf("%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
log.Errorf("%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
continue
}
if a.Verbose {
log.Printf("%s Connected to Websocket.\n", a.Name)
log.Debugf("%s Connected to Websocket.\n", a.Name)
}
err = a.WebsocketConn.WriteMessage(websocket.TextMessage, []byte(`{"messageType": "logon"}`))
if err != nil {
log.Println(err)
log.Error(err)
return
}
for a.Enabled {
msgType, resp, err := a.WebsocketConn.ReadMessage()
if err != nil {
log.Println(err)
log.Error(err)
break
}
@@ -51,7 +51,7 @@ func (a *Alphapoint) WebsocketClient() {
msgType := MsgType{}
err := common.JSONDecode(resp, &msgType)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
@@ -60,13 +60,13 @@ func (a *Alphapoint) WebsocketClient() {
ticker := WebsocketTicker{}
err = common.JSONDecode(resp, &ticker)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
}
}
}
a.WebsocketConn.Close()
log.Printf("%s Websocket client disconnected.", a.Name)
log.Debugf("%s Websocket client disconnected.", a.Name)
}
}

View File

@@ -4,17 +4,16 @@ import (
"bytes"
"errors"
"fmt"
"log"
"strconv"
"time"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/currency/symbol"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -274,7 +273,7 @@ func (a *ANX) GetOrderList(isActiveOrdersOnly bool) ([]OrderResponse, error) {
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return nil, errors.New(response.ResultCode)
}
@@ -300,7 +299,7 @@ func (a *ANX) OrderInfo(orderID string) (OrderResponse, error) {
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return OrderResponse{}, errors.New(response.ResultCode)
}
return response.Order, nil
@@ -331,7 +330,7 @@ func (a *ANX) Send(currency, address, otp, amount string) (string, error) {
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return "", errors.New(response.ResultCode)
}
return response.TransactionID, nil
@@ -357,7 +356,7 @@ func (a *ANX) CreateNewSubAccount(currency, name string) (string, error) {
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return "", errors.New(response.ResultCode)
}
return response.SubAccount, nil
@@ -392,7 +391,7 @@ func (a *ANX) GetDepositAddressByCurrency(currency, name string, new bool) (stri
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return "", errors.New(response.ResultCode)
}
@@ -432,7 +431,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
}
if a.Verbose {
log.Printf("Request JSON: %s\n", PayloadJSON)
log.Debugf("Request JSON: %s\n", PayloadJSON)
}
hmac := common.GetHMAC(common.HashSHA512, []byte(path+string("\x00")+string(PayloadJSON)), []byte(a.APISecret))
@@ -497,7 +496,7 @@ func (a *ANX) GetAccountInformation() (AccountInformation, error) {
}
if response.ResultCode != "OK" {
log.Printf("Response code is not OK: %s\n", response.ResultCode)
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
return response, errors.New(response.ResultCode)
}
return response, nil
@@ -520,7 +519,7 @@ func (a *ANX) CheckAPIWithdrawPermission() (bool, error) {
}
if !apiAllowsWithdraw {
log.Printf("API key is missing withdrawal permissions")
log.Warn("API key is missing withdrawal permissions")
}
return apiAllowsWithdraw, nil

View File

@@ -2,15 +2,15 @@ package anx
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the ANX go routine
@@ -25,13 +25,13 @@ func (a *ANX) Start(wg *sync.WaitGroup) {
// Run implements the ANX wrapper
func (a *ANX) Run() {
if a.Verbose {
log.Printf("%s polling delay: %ds.\n", a.GetName(), a.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", a.GetName(), len(a.EnabledPairs), a.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", a.GetName(), a.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", a.GetName(), len(a.EnabledPairs), a.EnabledPairs)
}
exchangeProducts, err := a.GetTradablePairs()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", a.GetName())
log.Debugf("%s Failed to get available symbols.\n", a.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(a.EnabledPairs, "_") || !common.StringDataContains(a.AvailablePairs, "_") {
@@ -40,16 +40,16 @@ func (a *ANX) Run() {
if forceUpgrade {
enabledPairs := []string{"BTC_USD,BTC_HKD,BTC_EUR,BTC_CAD,BTC_AUD,BTC_SGD,BTC_JPY,BTC_GBP,BTC_NZD,LTC_BTC,DOG_EBTC,STR_BTC,XRP_BTC"}
log.Println("WARNING: Enabled pairs for ANX reset due to config upgrade, please enable the ones you would like again.")
log.Warn("Enabled pairs for ANX reset due to config upgrade, please enable the ones you would like again.")
err = a.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", a.GetName())
log.Errorf("%s Failed to get config.\n", a.GetName())
}
}
err = a.UpdateCurrencies(exchangeProducts, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", a.GetName())
log.Errorf("%s Failed to get config.\n", a.GetName())
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -15,6 +14,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Binance is the overarching type across the Bithumb package
@@ -609,7 +609,7 @@ func (b *Binance) SendAuthHTTPRequest(method, path string, params url.Values, re
headers["X-MBX-APIKEY"] = b.APIKey
if b.Verbose {
log.Printf("sent path: \n%s\n", path)
log.Debugf("sent path: \n%s\n", path)
}
path = common.EncodeURLValues(path, params)
@@ -741,7 +741,6 @@ func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string
return resp.ID, nil
}
//GetDepositAddressForCurrency retrieves the wallet address for a given currency
func (b *Binance) GetDepositAddressForCurrency(currency string) error {
path := fmt.Sprintf("%s%s", b.APIUrl, depositAddress)

View File

@@ -3,7 +3,6 @@ package binance
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
@@ -12,6 +11,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKEX go routine
@@ -26,7 +26,7 @@ func (b *Binance) Start(wg *sync.WaitGroup) {
// Run implements the OKEX wrapper
func (b *Binance) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n%s polling delay: %ds.\n%s %d currencies enabled: %s.\n",
log.Debugf("%s Websocket: %s. (url: %s).\n%s polling delay: %ds.\n%s %d currencies enabled: %s.\n",
b.GetName(),
common.IsEnabled(b.Websocket.IsEnabled()),
b.Websocket.GetWebsocketURL(),
@@ -39,7 +39,7 @@ func (b *Binance) Run() {
symbols, err := b.GetExchangeValidCurrencyPairs()
if err != nil {
log.Printf("%s Failed to get exchange info.\n", b.GetName())
log.Errorf("%s Failed to get exchange info.\n", b.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(b.EnabledPairs, "-") ||
@@ -49,16 +49,16 @@ func (b *Binance) Run() {
if forceUpgrade {
enabledPairs := []string{"BTC-USDT"}
log.Println("WARNING: Available pairs for Binance reset due to config upgrade, please enable the ones you would like again")
log.Warn("Available pairs for Binance reset due to config upgrade, please enable the ones you would like again")
err = b.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.\n", b.GetName())
}
}
err = b.UpdateCurrencies(symbols, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.\n", b.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package bitfinex
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -15,6 +14,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -906,7 +906,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
}
if b.Verbose {
log.Printf("Request JSON: %s\n", PayloadJSON)
log.Debugf("Request JSON: %s\n", PayloadJSON)
}
PayloadBase64 := common.Base64Encode(PayloadJSON)

View File

@@ -3,7 +3,6 @@ package bitfinex
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"reflect"
@@ -13,8 +12,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -116,7 +116,7 @@ func (b *Bitfinex) WsAddSubscriptionChannel(chanID int, channel, pair string) {
b.WebsocketSubdChannels[chanID] = chanInfo
if b.Verbose {
log.Printf("%s Subscribed to Channel: %s Pair: %s ChannelID: %d\n",
log.Debugf("%s Subscribed to Channel: %s Pair: %s ChannelID: %d\n",
b.GetName(),
channel,
pair,
@@ -160,7 +160,7 @@ func (b *Bitfinex) WsConnect() error {
if hs.Event == "info" {
if b.Verbose {
log.Printf("%s Connected to Websocket.\n", b.GetName())
log.Debugf("%s Connected to Websocket.\n", b.GetName())
}
}

View File

@@ -3,16 +3,16 @@ package bitfinex
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bitfinex go routine
@@ -27,18 +27,18 @@ func (b *Bitfinex) Start(wg *sync.WaitGroup) {
// Run implements the Bitfinex wrapper
func (b *Bitfinex) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
exchangeProducts, err := b.GetSymbols()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())
log.Errorf("%s Failed to get available symbols.\n", b.GetName())
} else {
err = b.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to update available symbols.\n", b.GetName())
log.Errorf("%s Failed to update available symbols.\n", b.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package bitflyer
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -14,6 +13,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -2,7 +2,6 @@ package bitflyer
import (
"errors"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
@@ -10,6 +9,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bitflyer go routine
@@ -24,9 +24,9 @@ func (b *Bitflyer) Start(wg *sync.WaitGroup) {
// Run implements the Bitflyer wrapper
func (b *Bitflyer) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
/*

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/url"
"reflect"
"strconv"
@@ -17,6 +16,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -2,7 +2,6 @@ package bithumb
import (
"fmt"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
@@ -10,6 +9,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKEX go routine
@@ -24,18 +24,18 @@ func (b *Bithumb) Start(wg *sync.WaitGroup) {
// Run implements the OKEX wrapper
func (b *Bithumb) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
exchangeProducts, err := b.GetTradingPairs()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())
log.Errorf("%s Failed to get available symbols.\n", b.GetName())
} else {
err = b.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to update available symbols.\n", b.GetName())
log.Errorf("%s Failed to update available symbols.\n", b.GetName())
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"log"
"strconv"
"time"
@@ -14,6 +13,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Bitmex is the overarching type across this package

View File

@@ -3,18 +3,17 @@ package bitmex
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
"time"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -98,7 +97,7 @@ func (b *Bitmex) WsConnector() error {
}
if b.Verbose {
log.Printf("Successfully connected to Bitmex %s at time: %s Limit: %d",
log.Debugf("Successfully connected to Bitmex %s at time: %s Limit: %d",
welcomeResp.Info,
welcomeResp.Timestamp,
welcomeResp.Limit.Remaining)
@@ -187,14 +186,14 @@ func (b *Bitmex) wsHandleIncomingData() {
quickCapture := make(map[string]interface{})
err := common.JSONDecode(resp.Raw, &quickCapture)
if err != nil {
log.Fatal(err)
log.Error(err)
}
var respError WebsocketErrorResponse
if _, ok := quickCapture["status"]; ok {
err = common.JSONDecode(resp.Raw, &respError)
if err != nil {
log.Fatal(err)
log.Error(err)
}
b.Websocket.DataHandler <- errors.New(respError.Error)
continue
@@ -204,16 +203,16 @@ func (b *Bitmex) wsHandleIncomingData() {
var decodedResp WebsocketSubscribeResp
err := common.JSONDecode(resp.Raw, &decodedResp)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if decodedResp.Success {
if b.Verbose {
if len(quickCapture) == 3 {
log.Printf("Bitmex Websocket: Successfully subscribed to %s",
log.Debugf("Bitmex Websocket: Successfully subscribed to %s",
decodedResp.Subscribe)
} else {
log.Println("Bitmex Websocket: Successfully authenticated websocket connection")
log.Debugf("Bitmex Websocket: Successfully authenticated websocket connection")
}
}
continue
@@ -226,7 +225,7 @@ func (b *Bitmex) wsHandleIncomingData() {
var decodedResp WebsocketMainResponse
err := common.JSONDecode(resp.Raw, &decodedResp)
if err != nil {
log.Fatal(err)
log.Error(err)
}
switch decodedResp.Table {
@@ -234,20 +233,20 @@ func (b *Bitmex) wsHandleIncomingData() {
var orderbooks OrderBookData
err = common.JSONDecode(resp.Raw, &orderbooks)
if err != nil {
log.Fatal(err)
log.Error(err)
}
p := pair.NewCurrencyPairFromString(orderbooks.Data[0].Symbol)
err = b.processOrderbook(orderbooks.Data, orderbooks.Action, p, "CONTRACT")
if err != nil {
log.Fatal(err)
log.Error(err)
}
case bitmexWSTrade:
var trades TradeData
err = common.JSONDecode(resp.Raw, &trades)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if trades.Action == bitmexActionInitialData {
@@ -257,7 +256,7 @@ func (b *Bitmex) wsHandleIncomingData() {
for _, trade := range trades.Data {
timestamp, err := time.Parse(time.RFC3339, trade.Timestamp)
if err != nil {
log.Fatal(err)
log.Error(err)
}
b.Websocket.DataHandler <- exchange.TradeData{
@@ -276,7 +275,7 @@ func (b *Bitmex) wsHandleIncomingData() {
err = common.JSONDecode(resp.Raw, &announcement)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if announcement.Action == bitmexActionInitialData {
@@ -286,7 +285,7 @@ func (b *Bitmex) wsHandleIncomingData() {
b.Websocket.DataHandler <- announcement.Data
default:
log.Fatal("Bitmex websocket error: Table unknown -", decodedResp.Table)
log.Errorf("Bitmex websocket error: Table unknown - %s", decodedResp.Table)
}
}
}

View File

@@ -2,7 +2,6 @@ package bitmex
import (
"errors"
"log"
"math"
"sync"
"time"
@@ -12,6 +11,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bitmex go routine
@@ -26,14 +26,14 @@ func (b *Bitmex) Start(wg *sync.WaitGroup) {
// Run implements the Bitmex wrapper
func (b *Bitmex) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
marketInfo, err := b.GetActiveInstruments(GenericRequestParams{})
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())
log.Errorf("%s Failed to get available symbols.\n", b.GetName())
} else {
var exchangeProducts []string
@@ -43,7 +43,7 @@ func (b *Bitmex) Run() {
err = b.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", b.GetName())
log.Errorf("%s Failed to update available currencies.\n", b.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package bitstamp
import (
"errors"
"fmt"
"log"
"net/url"
"reflect"
"strconv"
@@ -13,9 +12,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -254,12 +254,12 @@ func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
for _, x := range resp.Bids {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Bids = append(orderbook.Bids, OrderbookBase{price, amount})
@@ -268,12 +268,12 @@ func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error) {
for _, x := range resp.Asks {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Asks = append(orderbook.Asks, OrderbookBase{price, amount})
@@ -605,7 +605,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
}
if b.Verbose {
log.Println("Sending POST request to " + path)
log.Debugf("Sending POST request to " + path)
}
headers := make(map[string]string)

View File

@@ -3,16 +3,16 @@ package bitstamp
import (
"errors"
"fmt"
"log"
"strconv"
"strings"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/toorop/go-pusher"
log "github.com/thrasher-/gocryptotrader/logger"
pusher "github.com/toorop/go-pusher"
)
// WebsocketConn defins a pusher websocket connection
@@ -78,7 +78,7 @@ func (b *Bitstamp) WsConnect() error {
var err error
if b.Websocket.GetProxyAddress() != "" {
log.Println("bistamp_websocket.go warning - set proxy address error: proxy not supported")
log.Warn("bitstamp_websocket.go warning - set proxy address error: proxy not supported")
}
b.WebsocketConn.Client, err = pusher.NewClient(BitstampPusherKey)
@@ -147,7 +147,7 @@ func (b *Bitstamp) WsConnect() error {
strings.ToLower(p.Pair().String())))
if err != nil {
log.Println(err)
log.Error(err)
return fmt.Errorf("%s Websocket Trade subscription error: %s",
b.GetName(),
err)
@@ -157,7 +157,7 @@ func (b *Bitstamp) WsConnect() error {
strings.ToLower(p.Pair().String())))
if err != nil {
log.Println(err)
log.Error(err)
return fmt.Errorf("%s Websocket Trade subscription error: %s",
b.GetName(),
err)

View File

@@ -3,7 +3,6 @@ package bitstamp
import (
"errors"
"fmt"
"log"
"strconv"
"strings"
"sync"
@@ -13,6 +12,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bitstamp go routine
@@ -27,14 +27,14 @@ func (b *Bitstamp) Start(wg *sync.WaitGroup) {
// Run implements the Bitstamp wrapper
func (b *Bitstamp) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
pairs, err := b.GetTradingPairs()
if err != nil {
log.Printf("%s failed to get trading pairs. Err: %s", b.Name, err)
log.Errorf("%s failed to get trading pairs. Err: %s", b.Name, err)
} else {
var currencies []string
for x := range pairs {
@@ -46,7 +46,7 @@ func (b *Bitstamp) Run() {
}
err = b.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", b.Name)
log.Errorf("%s Failed to update available currencies.\n", b.Name)
}
}
}

View File

@@ -3,16 +3,16 @@ package bittrex
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -3,7 +3,6 @@ package bittrex
import (
"errors"
"fmt"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
@@ -11,6 +10,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Bittrex go routine
@@ -25,13 +25,13 @@ func (b *Bittrex) Start(wg *sync.WaitGroup) {
// Run implements the Bittrex wrapper
func (b *Bittrex) Run() {
if b.Verbose {
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
exchangeProducts, err := b.GetMarkets()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())
log.Errorf("%s Failed to get available symbols.\n", b.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(b.EnabledPairs, "-") || !common.StringDataContains(b.AvailablePairs, "-") {
@@ -47,16 +47,16 @@ func (b *Bittrex) Run() {
if forceUpgrade {
enabledPairs := []string{"USDT-BTC"}
log.Println("WARNING: Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
log.Warn("Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
err = b.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.", b.GetName())
}
}
err = b.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", b.GetName())
log.Errorf("%s Failed to get config.", b.GetName())
}
}
}

View File

@@ -1,15 +1,15 @@
package btcc
import (
"log"
"time"
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -3,7 +3,6 @@ package btcc
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
@@ -15,6 +14,7 @@ import (
"github.com/thrasher-/gocryptotrader/currency/pair"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -132,48 +132,37 @@ func (b *BTCC) WsHandleData() {
case msgTypeHeartBeat:
case msgTypeGetActiveContracts:
log.Println("Active Contracts")
log.Fatal(string(resp.Raw))
log.Debugf("Active Contracts: %s", resp.Raw)
case msgTypeQuote:
log.Println("Quotes")
log.Fatal(string(resp.Raw))
log.Debugf("Quotes: %s", resp.Raw)
case msgTypeLogin:
log.Println("Login")
log.Fatal(string(resp.Raw))
log.Debugf("Login: %s", resp.Raw)
case msgTypeAccountInfo:
log.Println("Account info")
log.Fatal(string(resp.Raw))
log.Debugf("Account info: %s", resp.Raw)
case msgTypeExecReport:
log.Println("Exec Report")
log.Fatal(string(resp.Raw))
log.Debugf("Exec Report: %s", resp.Raw)
case msgTypePlaceOrder:
log.Println("Place order")
log.Fatal(string(resp.Raw))
log.Debugf("Place order: %s", resp.Raw)
case msgTypeCancelAllOrders:
log.Println("Cancel All orders")
log.Fatal(string(resp.Raw))
log.Debugf("Cancel All orders: %s", resp.Raw)
case msgTypeCancelOrder:
log.Println("Cancel order")
log.Fatal(string(resp.Raw))
log.Debugf("Cancel order: %s", resp.Raw)
case msgTypeCancelReplaceOrder:
log.Println("Replace order")
log.Fatal(string(resp.Raw))
log.Debugf("Replace order: %s", resp.Raw)
case msgTypeGetAccountInfo:
log.Println("Account info")
log.Fatal(string(resp.Raw))
log.Debugf("Account info: %s", resp.Raw)
case msgTypeRetrieveOrder:
log.Println("Retrieve order")
log.Fatal(string(resp.Raw))
log.Debugf("Retrieve order: %s", resp.Raw)
case msgTypeGetTrades:
var trades WsTrades

View File

@@ -2,7 +2,6 @@ package btcc
import (
"errors"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
@@ -11,6 +10,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the BTCC go routine
@@ -25,18 +25,18 @@ func (b *BTCC) Start(wg *sync.WaitGroup) {
// Run implements the BTCC wrapper
func (b *BTCC) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
if common.StringDataContains(b.EnabledPairs, "CNY") || common.StringDataContains(b.AvailablePairs, "CNY") || common.StringDataContains(b.BaseCurrencies, "CNY") {
log.Println("WARNING: BTCC only supports BTCUSD now, upgrading available, enabled and base currencies to BTCUSD/USD")
log.Warn("BTCC only supports BTCUSD now, upgrading available, enabled and base currencies to BTCUSD/USD")
pairs := []string{"BTCUSD"}
cfg := config.GetConfig()
exchCfg, err := cfg.GetExchangeConfig(b.Name)
if err != nil {
log.Printf("%s failed to get exchange config. %s\n", b.Name, err)
log.Errorf("%s failed to get exchange config. %s\n", b.Name, err)
return
}
@@ -47,17 +47,17 @@ func (b *BTCC) Run() {
err = b.UpdateCurrencies(pairs, false, true)
if err != nil {
log.Printf("%s failed to update available currencies. %s\n", b.Name, err)
log.Errorf("%s failed to update available currencies. %s\n", b.Name, err)
}
err = b.UpdateCurrencies(pairs, true, true)
if err != nil {
log.Printf("%s failed to update enabled currencies. %s\n", b.Name, err)
log.Errorf("%s failed to update enabled currencies. %s\n", b.Name, err)
}
err = cfg.UpdateExchangeConfig(exchCfg)
if err != nil {
log.Printf("%s failed to update config. %s\n", b.Name, err)
log.Errorf("%s failed to update config. %s\n", b.Name, err)
return
}
}

View File

@@ -4,16 +4,16 @@ import (
"bytes"
"errors"
"fmt"
"log"
"net/url"
"time"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -442,7 +442,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data interfa
hmac := common.GetHMAC(common.HashSHA512, []byte(request), []byte(b.APISecret))
if b.Verbose {
log.Printf("Sending %s request to URL %s with params %s\n", reqType, b.APIUrl+path, request)
log.Debugf("Sending %s request to URL %s with params %s\n", reqType, b.APIUrl+path, request)
}
headers := make(map[string]string)

View File

@@ -3,16 +3,15 @@ package btcmarkets
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the BTC Markets go routine
@@ -27,13 +26,13 @@ func (b *BTCMarkets) Start(wg *sync.WaitGroup) {
// Run implements the BTC Markets wrapper
func (b *BTCMarkets) Run() {
if b.Verbose {
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
markets, err := b.GetMarkets()
if err != nil {
log.Printf("%s failed to get active market. Err: %s", b.Name, err)
log.Errorf("%s failed to get active market. Err: %s", b.Name, err)
} else {
forceUpgrade := false
if !common.StringDataContains(b.EnabledPairs, "-") || !common.StringDataContains(b.AvailablePairs, "-") {
@@ -47,16 +46,16 @@ func (b *BTCMarkets) Run() {
if forceUpgrade {
enabledPairs := []string{"BTC-AUD"}
log.Println("WARNING: Available pairs for BTC Makrets reset due to config upgrade, please enable the pairs you would like again.")
log.Warn("Available pairs for BTC Makrets reset due to config upgrade, please enable the pairs you would like again.")
err = b.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s failed to update currencies. Err: %s", b.Name, err)
log.Errorf("%s failed to update currencies. Err: %s", b.Name, err)
}
}
err = b.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s failed to update currencies. Err: %s", b.Name, err)
log.Errorf("%s failed to update currencies. Err: %s", b.Name, err)
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -14,9 +13,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -807,7 +807,7 @@ func (c *CoinbasePro) SendAuthenticatedHTTPRequest(method, path string, params m
}
if c.Verbose {
log.Printf("Request JSON: %s\n", payload)
log.Debugf("Request JSON: %s\n", payload)
}
}

View File

@@ -3,7 +3,6 @@ package coinbasepro
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
@@ -12,8 +11,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -2,14 +2,14 @@ package coinbasepro
import (
"errors"
"log"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the coinbasepro go routine
@@ -24,14 +24,14 @@ func (c *CoinbasePro) Start(wg *sync.WaitGroup) {
// Run implements the coinbasepro wrapper
func (c *CoinbasePro) Run() {
if c.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinbaseproWebsocketURL)
log.Printf("%s polling delay: %ds.\n", c.GetName(), c.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", c.GetName(), len(c.EnabledPairs), c.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinbaseproWebsocketURL)
log.Debugf("%s polling delay: %ds.\n", c.GetName(), c.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", c.GetName(), len(c.EnabledPairs), c.EnabledPairs)
}
exchangeProducts, err := c.GetProducts()
if err != nil {
log.Printf("%s Failed to get available products.\n", c.GetName())
log.Errorf("%s Failed to get available products.\n", c.GetName())
} else {
currencies := []string{}
for _, x := range exchangeProducts {
@@ -41,7 +41,7 @@ func (c *CoinbasePro) Run() {
}
err = c.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", c.GetName())
log.Errorf("%s Failed to update available currencies.\n", c.GetName())
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"log"
"time"
"github.com/gorilla/websocket"
@@ -12,9 +11,10 @@ import (
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -352,7 +352,7 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{
}
if c.Verbose {
log.Printf("Request JSON: %s\n", payload)
log.Debugf("Request JSON: %s", payload)
}
headers := make(map[string]string)

View File

@@ -3,7 +3,6 @@ package coinut
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"time"
@@ -11,8 +10,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const coinutWebsocketURL = "wss://wsapi.coinut.com"

View File

@@ -3,17 +3,16 @@ package coinut
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/currency/symbol"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the COINUT go routine
@@ -28,14 +27,14 @@ func (c *COINUT) Start(wg *sync.WaitGroup) {
// Run implements the COINUT wrapper
func (c *COINUT) Run() {
if c.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinutWebsocketURL)
log.Printf("%s polling delay: %ds.\n", c.GetName(), c.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", c.GetName(), len(c.EnabledPairs), c.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinutWebsocketURL)
log.Debugf("%s polling delay: %ds.\n", c.GetName(), c.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", c.GetName(), len(c.EnabledPairs), c.EnabledPairs)
}
exchangeProducts, err := c.GetInstruments()
if err != nil {
log.Printf("%s Failed to get available products.\n", c.GetName())
log.Debugf("%s Failed to get available products.\n", c.GetName())
return
}
@@ -48,7 +47,7 @@ func (c *COINUT) Run() {
err = c.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", c.GetName())
log.Errorf("%s Failed to update available currencies.\n", c.GetName())
}
}

View File

@@ -3,7 +3,6 @@ package exchange
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strings"
@@ -17,6 +16,7 @@ import (
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -654,7 +654,7 @@ func (e *Base) SetAPIKeys(APIKey, APISecret, ClientID string, b64Decode bool) {
result, err := common.Base64Decode(APISecret)
if err != nil {
e.AuthenticatedAPISupport = false
log.Printf(warningBase64DecryptSecretKeyFailed, e.Name)
log.Warn(warningBase64DecryptSecretKeyFailed, e.Name)
}
e.APISecret = string(result)
} else {
@@ -728,13 +728,13 @@ func (e *Base) UpdateCurrencies(exchangeProducts []string, enabled, force bool)
}
if force {
log.Printf("%s forced update of %s pairs.", e.Name, updateType)
log.Debugf("%s forced update of %s pairs.", e.Name, updateType)
} else {
if len(newPairs) > 0 {
log.Printf("%s Updating pairs - New: %s.\n", e.Name, newPairs)
log.Debugf("%s Updating pairs - New: %s.\n", e.Name, newPairs)
}
if len(removedPairs) > 0 {
log.Printf("%s Updating pairs - Removed: %s.\n", e.Name, removedPairs)
log.Debugf("%s Updating pairs - Removed: %s.\n", e.Name, removedPairs)
}
}

View File

@@ -167,8 +167,7 @@ func (w *Websocket) Connect() error {
defer w.m.Unlock()
if !w.IsEnabled() {
return fmt.Errorf("exchange_websocket.go %s error - websocket disabled",
w.GetName())
return errors.New(WebsocketNotEnabled)
}
if w.connected {

View File

@@ -3,7 +3,6 @@ package exmo
import (
"errors"
"fmt"
"log"
"net/url"
"reflect"
"strconv"
@@ -16,6 +15,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -274,7 +274,7 @@ func (e *EXMO) GetRequiredAmount(pair string, amount float64) (RequiredAmount, e
func (e *EXMO) GetCryptoDepositAddress() (map[string]string, error) {
result := make(map[string]string)
err := e.SendAuthenticatedHTTPRequest("POST", exmoDepositAddress, url.Values{}, &result)
log.Println(reflect.TypeOf(result).String())
log.Debug(reflect.TypeOf(result).String())
return result, err
}
@@ -376,7 +376,7 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va
hash := common.GetHMAC(common.HashSHA512, []byte(payload), []byte(e.APISecret))
if e.Verbose {
log.Printf("Sending %s request to %s with params %s\n", method, endpoint, payload)
log.Debugf("Sending %s request to %s with params %s\n", method, endpoint, payload)
}
headers := make(map[string]string)

View File

@@ -3,7 +3,6 @@ package exmo
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
@@ -12,6 +11,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the EXMO go routine
@@ -26,13 +26,13 @@ func (e *EXMO) Start(wg *sync.WaitGroup) {
// Run implements the EXMO wrapper
func (e *EXMO) Run() {
if e.Verbose {
log.Printf("%s polling delay: %ds.\n", e.GetName(), e.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", e.GetName(), len(e.EnabledPairs), e.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", e.GetName(), e.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", e.GetName(), len(e.EnabledPairs), e.EnabledPairs)
}
exchangeProducts, err := e.GetPairSettings()
if err != nil {
log.Printf("%s Failed to get available products.\n", e.GetName())
log.Errorf("%s Failed to get available products.\n", e.GetName())
} else {
var currencies []string
for x := range exchangeProducts {
@@ -40,7 +40,7 @@ func (e *EXMO) Run() {
}
err = e.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", e.GetName())
log.Errorf("%s Failed to update available currencies.\n", e.GetName())
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"strconv"
"strings"
"time"
@@ -14,6 +13,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -2,15 +2,15 @@ package gateio
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the GateIO go routine
@@ -25,18 +25,18 @@ func (g *Gateio) Start(wg *sync.WaitGroup) {
// Run implements the GateIO wrapper
func (g *Gateio) Run() {
if g.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", g.GetName(), common.IsEnabled(g.Websocket.IsEnabled()), g.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", g.GetName(), g.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", g.GetName(), len(g.EnabledPairs), g.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", g.GetName(), common.IsEnabled(g.Websocket.IsEnabled()), g.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", g.GetName(), g.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", g.GetName(), len(g.EnabledPairs), g.EnabledPairs)
}
symbols, err := g.GetSymbols()
if err != nil {
log.Printf("%s Unable to fetch symbols.\n", g.GetName())
log.Errorf("%s Unable to fetch symbols.\n", g.GetName())
} else {
err = g.UpdateCurrencies(symbols, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", g.GetName())
log.Errorf("%s Failed to update available currencies.\n", g.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package gemini
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -11,9 +10,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -494,7 +494,7 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st
}
if g.Verbose {
log.Printf("Request JSON: %s\n", PayloadJSON)
log.Debugf("Request JSON: %s", PayloadJSON)
}
PayloadBase64 := common.Base64Encode(PayloadJSON)

View File

@@ -3,16 +3,16 @@ package gemini
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Gemini go routine
@@ -27,17 +27,17 @@ func (g *Gemini) Start(wg *sync.WaitGroup) {
// Run implements the Gemini wrapper
func (g *Gemini) Run() {
if g.Verbose {
log.Printf("%s polling delay: %ds.\n", g.GetName(), g.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", g.GetName(), len(g.EnabledPairs), g.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", g.GetName(), g.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", g.GetName(), len(g.EnabledPairs), g.EnabledPairs)
}
exchangeProducts, err := g.GetSymbols()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", g.GetName())
log.Errorf("%s Failed to get available symbols.\n", g.GetName())
} else {
err = g.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", g.GetName())
log.Errorf("%s Failed to update available currencies.\n", g.GetName())
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -13,9 +12,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -3,7 +3,6 @@ package hitbtc
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"time"
@@ -11,8 +10,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -149,7 +149,7 @@ func (h *HitBTC) WsHandleData() {
var init capture
err := common.JSONDecode(resp.Raw, &init)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if init.Error.Message != "" || init.Error.Code != 0 {
@@ -168,12 +168,12 @@ func (h *HitBTC) WsHandleData() {
var ticker WsTicker
err := common.JSONDecode(resp.Raw, &ticker)
if err != nil {
log.Fatal(err)
log.Error(err)
}
ts, err := time.Parse(time.RFC3339, ticker.Params.Timestamp)
if err != nil {
log.Fatal(err)
log.Error(err)
}
h.Websocket.DataHandler <- exchange.TickerData{
@@ -191,19 +191,19 @@ func (h *HitBTC) WsHandleData() {
var obSnapshot WsOrderbook
err := common.JSONDecode(resp.Raw, &obSnapshot)
if err != nil {
log.Fatal(err)
log.Error(err)
}
err = h.WsProcessOrderbookSnapshot(obSnapshot)
if err != nil {
log.Fatal(err)
log.Error(err)
}
case "updateOrderbook":
var obUpdate WsOrderbook
err := common.JSONDecode(resp.Raw, &obUpdate)
if err != nil {
log.Fatal(err)
log.Error(err)
}
h.WsProcessOrderbookUpdate(obUpdate)
@@ -212,14 +212,14 @@ func (h *HitBTC) WsHandleData() {
var tradeSnapshot WsTrade
err := common.JSONDecode(resp.Raw, &tradeSnapshot)
if err != nil {
log.Fatal(err)
log.Error(err)
}
case "updateTrades":
var tradeUpdates WsTrade
err := common.JSONDecode(resp.Raw, &tradeUpdates)
if err != nil {
log.Fatal(err)
log.Error(err)
}
}
}

View File

@@ -2,15 +2,16 @@ package hitbtc
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the HitBTC go routine
@@ -25,14 +26,14 @@ func (h *HitBTC) Start(wg *sync.WaitGroup) {
// Run implements the HitBTC wrapper
func (h *HitBTC) Run() {
if h.Verbose {
log.Printf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), hitbtcWebsocketAddress)
log.Printf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
log.Debugf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), hitbtcWebsocketAddress)
log.Debugf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
}
exchangeProducts, err := h.GetSymbolsDetailed()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", h.GetName())
log.Errorf("%s Failed to get available symbols.\n", h.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(h.EnabledPairs, "-") || !common.StringDataContains(h.AvailablePairs, "-") {
@@ -45,16 +46,16 @@ func (h *HitBTC) Run() {
if forceUpgrade {
enabledPairs := []string{"BTC-USD"}
log.Println("WARNING: Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")
log.Warn("Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")
err = h.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to update enabled currencies.\n", h.GetName())
log.Errorf("%s Failed to update enabled currencies.\n", h.GetName())
}
}
err = h.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", h.GetName())
log.Errorf("%s Failed to update available currencies.\n", h.GetName())
}
}
}

View File

@@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strconv"
@@ -24,6 +23,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"math/big"
"net/http"
"net/url"
@@ -15,8 +14,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -81,7 +81,7 @@ func (h *HUOBI) WsReadData() {
default:
_, resp, err := h.WebsocketConn.ReadMessage()
if err != nil {
log.Fatal(err)
log.Error(err)
}
h.Websocket.TrafficAlert <- struct{}{}
@@ -89,12 +89,12 @@ func (h *HUOBI) WsReadData() {
b := bytes.NewReader(resp)
gReader, err := gzip.NewReader(b)
if err != nil {
log.Fatal(err)
log.Error(err)
}
unzipped, err := ioutil.ReadAll(gReader)
if err != nil {
log.Fatal(err)
log.Error(err)
}
gReader.Close()
@@ -115,7 +115,7 @@ func (h *HUOBI) WsHandleData() {
var init WsResponse
err := common.JSONDecode(resp.Raw, &init)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if init.Status == "error" {
@@ -132,7 +132,7 @@ func (h *HUOBI) WsHandleData() {
if init.Ping != 0 {
err = h.WebsocketConn.WriteJSON(`{"pong":1337}`)
if err != nil {
log.Fatal(err)
log.Error(err)
}
continue
}
@@ -142,7 +142,7 @@ func (h *HUOBI) WsHandleData() {
var depth WsDepth
err := common.JSONDecode(resp.Raw, &depth)
if err != nil {
log.Fatal(err)
log.Error(err)
}
data := common.SplitStrings(depth.Channel, ".")
@@ -153,7 +153,7 @@ func (h *HUOBI) WsHandleData() {
var kline WsKline
err := common.JSONDecode(resp.Raw, &kline)
if err != nil {
log.Fatal(err)
log.Error(err)
}
data := common.SplitStrings(kline.Channel, ".")
@@ -174,7 +174,7 @@ func (h *HUOBI) WsHandleData() {
var trade WsTrade
err := common.JSONDecode(resp.Raw, &trade)
if err != nil {
log.Fatal(err)
log.Error(err)
}
data := common.SplitStrings(trade.Channel, ".")

View File

@@ -3,16 +3,16 @@ package huobi
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the HUOBI go routine
@@ -27,14 +27,14 @@ func (h *HUOBI) Start(wg *sync.WaitGroup) {
// Run implements the HUOBI wrapper
func (h *HUOBI) Run() {
if h.Verbose {
log.Printf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), huobiSocketIOAddress)
log.Printf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
log.Debugf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), huobiSocketIOAddress)
log.Debugf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
}
exchangeProducts, err := h.GetSymbols()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", h.GetName())
log.Errorf("%s Failed to get available symbols.\n", h.GetName())
} else {
forceUpgrade := false
if common.StringDataContains(h.EnabledPairs, "CNY") || common.StringDataContains(h.AvailablePairs, "CNY") {
@@ -45,7 +45,7 @@ func (h *HUOBI) Run() {
cfg := config.GetConfig()
exchCfg, errCNY := cfg.GetExchangeConfig(h.Name)
if err != nil {
log.Printf("%s failed to get exchange config. %s\n", h.Name, errCNY)
log.Errorf("%s failed to get exchange config. %s\n", h.Name, errCNY)
return
}
exchCfg.BaseCurrencies = "USD"
@@ -53,7 +53,7 @@ func (h *HUOBI) Run() {
errCNY = cfg.UpdateExchangeConfig(exchCfg)
if errCNY != nil {
log.Printf("%s failed to update config. %s\n", h.Name, errCNY)
log.Errorf("%s failed to update config. %s\n", h.Name, errCNY)
return
}
}
@@ -66,16 +66,16 @@ func (h *HUOBI) Run() {
if forceUpgrade {
enabledPairs := []string{"btc-usdt"}
log.Println("WARNING: Available and enabled pairs for Huobi reset due to config upgrade, please enable the ones you would like again")
log.Warn("Available and enabled pairs for Huobi reset due to config upgrade, please enable the ones you would like again")
err = h.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to update enabled currencies.\n", h.GetName())
log.Errorf("%s Failed to update enabled currencies.\n", h.GetName())
}
}
err = h.UpdateCurrencies(currencies, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", h.GetName())
log.Errorf("%s Failed to update available currencies.\n", h.GetName())
}
}
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -13,9 +12,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -3,15 +3,15 @@ package huobihadax
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKEX go routine
@@ -26,14 +26,14 @@ func (h *HUOBIHADAX) Start(wg *sync.WaitGroup) {
// Run implements the OKEX wrapper
func (h *HUOBIHADAX) Run() {
if h.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), h.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), h.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", h.GetName(), h.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", h.GetName(), len(h.EnabledPairs), h.EnabledPairs)
}
exchangeProducts, err := h.GetSymbols()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", h.GetName())
log.Debugf("%s Failed to get available symbols.\n", h.GetName())
} else {
var currencies []string
for x := range exchangeProducts {
@@ -43,7 +43,7 @@ func (h *HUOBIHADAX) Run() {
err = h.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", h.GetName())
log.Debugf("%s Failed to update available currencies.\n", h.GetName())
}
}
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -13,9 +12,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -379,7 +379,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params
}
if i.Verbose {
log.Printf("Request JSON: %s\n", PayloadJSON)
log.Debugf("Request JSON: %s\n", PayloadJSON)
}
}

View File

@@ -2,16 +2,16 @@ package itbit
import (
"fmt"
"log"
"net/url"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the ItBit go routine
@@ -26,8 +26,8 @@ func (i *ItBit) Start(wg *sync.WaitGroup) {
// Run implements the ItBit wrapper
func (i *ItBit) Run() {
if i.Verbose {
log.Printf("%s polling delay: %ds.\n", i.GetName(), i.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", i.GetName(), len(i.EnabledPairs), i.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", i.GetName(), i.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", i.GetName(), len(i.EnabledPairs), i.EnabledPairs)
}
}
@@ -82,11 +82,11 @@ func (i *ItBit) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo
data := orderbookNew.Bids[x]
price, err := strconv.ParseFloat(data[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
}
amount, err := strconv.ParseFloat(data[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
}
orderBook.Bids = append(orderBook.Bids, orderbook.Item{Amount: amount, Price: price})
}
@@ -95,11 +95,11 @@ func (i *ItBit) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderboo
data := orderbookNew.Asks[x]
price, err := strconv.ParseFloat(data[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
}
amount, err := strconv.ParseFloat(data[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
}
orderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: amount, Price: price})
}

View File

@@ -2,7 +2,6 @@ package kraken
import (
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -10,9 +9,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -892,7 +892,7 @@ func GetError(errors []string) error {
for _, e := range errors {
switch e[0] {
case 'W':
log.Printf("Kraken API warning: %v\n", e[1:])
log.Warnf("Kraken API warning: %v\n", e[1:])
default:
return fmt.Errorf("Kraken API error: %v", e[1:])
}
@@ -931,7 +931,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values,
signature := common.Base64Encode(common.GetHMAC(common.HashSHA512, append([]byte(path), shasum...), secret))
if k.Verbose {
log.Printf("Sending POST request to %s, path: %s, params: %s", k.APIUrl, path, encoded)
log.Debugf("Sending POST request to %s, path: %s, params: %s", k.APIUrl, path, encoded)
}
headers := make(map[string]string)

View File

@@ -1,15 +1,15 @@
package kraken
import (
"log"
"strings"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Kraken go routine
@@ -24,13 +24,13 @@ func (k *Kraken) Start(wg *sync.WaitGroup) {
// Run implements the Kraken wrapper
func (k *Kraken) Run() {
if k.Verbose {
log.Printf("%s polling delay: %ds.\n", k.GetName(), k.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", k.GetName(), len(k.EnabledPairs), k.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", k.GetName(), k.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", k.GetName(), len(k.EnabledPairs), k.EnabledPairs)
}
assetPairs, err := k.GetAssetPairs()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", k.GetName())
log.Errorf("%s Failed to get available symbols.\n", k.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(k.EnabledPairs, "-") || !common.StringDataContains(k.AvailablePairs, "-") {
@@ -55,16 +55,16 @@ func (k *Kraken) Run() {
if forceUpgrade {
enabledPairs := []string{"XBT-USD"}
log.Println("WARNING: Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
log.Warn("Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
err = k.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", k.GetName())
log.Errorf("%s Failed to get config.\n", k.GetName())
}
}
err = k.UpdateCurrencies(exchangeProducts, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", k.GetName())
log.Errorf("%s Failed to get config.\n", k.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package lakebtc
import (
"errors"
"fmt"
"log"
"strconv"
"strings"
"time"
@@ -11,9 +10,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -175,12 +175,12 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
for _, x := range resp.Bids {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Bids = append(orderbook.Bids, OrderbookStructure{price, amount})
@@ -189,12 +189,12 @@ func (l *LakeBTC) GetOrderBook(currency string) (Orderbook, error) {
for _, x := range resp.Asks {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Asks = append(orderbook.Asks, OrderbookStructure{price, amount})
@@ -353,7 +353,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
hmac := common.GetHMAC(common.HashSHA1, []byte(req), []byte(l.APISecret))
if l.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n", l.APIUrl, method, req)
log.Debugf("Sending POST request to %s calling method %s with params %s\n", l.APIUrl, method, req)
}
postData := make(map[string]interface{})

View File

@@ -3,16 +3,16 @@ package lakebtc
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the LakeBTC go routine
@@ -27,17 +27,17 @@ func (l *LakeBTC) Start(wg *sync.WaitGroup) {
// Run implements the LakeBTC wrapper
func (l *LakeBTC) Run() {
if l.Verbose {
log.Printf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
}
exchangeProducts, err := l.GetTradablePairs()
if err != nil {
log.Printf("%s Failed to get available products.\n", l.GetName())
log.Errorf("%s Failed to get available products.\n", l.GetName())
} else {
err = l.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", l.GetName())
log.Errorf("%s Failed to update available currencies.\n", l.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package liqui
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -11,9 +10,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -299,7 +299,7 @@ func (l *Liqui) SendAuthenticatedHTTPRequest(method string, values url.Values, r
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(l.APISecret))
if l.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n",
log.Debugf("Sending POST request to %s calling method %s with params %s\n",
l.APIUrlSecondary, method, encoded)
}

View File

@@ -2,15 +2,15 @@ package liqui
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Liqui go routine
@@ -25,19 +25,19 @@ func (l *Liqui) Start(wg *sync.WaitGroup) {
// Run implements the Liqui wrapper
func (l *Liqui) Run() {
if l.Verbose {
log.Printf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
}
var err error
l.Info, err = l.GetInfo()
if err != nil {
log.Printf("%s Unable to fetch info.\n", l.GetName())
log.Errorf("%s Unable to fetch info.\n", l.GetName())
} else {
exchangeProducts := l.GetAvailablePairs(true)
err = l.UpdateCurrencies(exchangeProducts, false, false)
if err != nil {
log.Printf("%s Failed to get config.\n", l.GetName())
log.Errorf("%s Failed to get config.\n", l.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package localbitcoins
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -11,8 +10,9 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -677,12 +677,12 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
for _, x := range resp.Bids {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Bids = append(orderbook.Bids, Price{price, amount})
@@ -691,12 +691,12 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) {
for _, x := range resp.Asks {
price, err := strconv.ParseFloat(x[0], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
amount, err := strconv.ParseFloat(x[1], 64)
if err != nil {
log.Println(err)
log.Error(err)
continue
}
orderbook.Asks = append(orderbook.Asks, Price{price, amount})
@@ -734,7 +734,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
headers["Content-Type"] = "application/x-www-form-urlencoded"
if l.Verbose {
log.Printf("Sending POST request to `%s`, path: `%s`, params: `%s`.", l.APIUrl, path, encoded)
log.Debugf("Sending POST request to `%s`, path: `%s`, params: `%s`.", l.APIUrl, path, encoded)
}
if method == "GET" && len(encoded) > 0 {

View File

@@ -3,16 +3,16 @@ package localbitcoins
import (
"errors"
"fmt"
"log"
"math"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the LocalBitcoins go routine
@@ -27,13 +27,13 @@ func (l *LocalBitcoins) Start(wg *sync.WaitGroup) {
// Run implements the LocalBitcoins wrapper
func (l *LocalBitcoins) Run() {
if l.Verbose {
log.Printf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
log.Debugf("%s polling delay: %ds.\n", l.GetName(), l.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", l.GetName(), len(l.EnabledPairs), l.EnabledPairs)
}
currencies, err := l.GetTradableCurrencies()
if err != nil {
log.Printf("%s failed to obtain available tradable currencies. Err: %s", l.Name, err)
log.Errorf("%s failed to obtain available tradable currencies. Err: %s", l.Name, err)
return
}
@@ -44,7 +44,7 @@ func (l *LocalBitcoins) Run() {
err = l.UpdateCurrencies(pairs, false, false)
if err != nil {
log.Printf("%s failed to update available currencies. Err %s", l.Name, err)
log.Errorf("%s failed to update available currencies. Err %s", l.Name, err)
}
}

View File

@@ -3,7 +3,6 @@ package okcoin
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -14,9 +13,10 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -811,7 +811,7 @@ func (o *OKCoin) GetFuturesUserInfo() {
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesUserInfo, url.Values{}, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -823,7 +823,7 @@ func (o *OKCoin) GetFuturesPosition(symbol, contractType string) {
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesPosition, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -841,7 +841,7 @@ func (o *OKCoin) FuturesTrade(amount, price float64, matchPrice, leverage int64,
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesTrade, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -856,7 +856,7 @@ func (o *OKCoin) FuturesBatchTrade(orderData, symbol, contractType string, lever
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesTradeBatch, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -870,7 +870,7 @@ func (o *OKCoin) CancelFuturesOrder(orderID int64, symbol, contractType string)
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesCancel, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -887,7 +887,7 @@ func (o *OKCoin) GetFuturesOrderInfo(orderID, status, currentPage, pageLength in
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesOrderInfo, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -901,7 +901,7 @@ func (o *OKCoin) GetFutureOrdersInfo(orderID int64, contractType, symbol string)
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesOrdersInfo, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -912,7 +912,7 @@ func (o *OKCoin) GetFuturesUserInfo4Fix() {
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesUserInfo4Fix, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -926,7 +926,7 @@ func (o *OKCoin) GetFuturesUserPosition4Fix(symbol, contractType string) {
err := o.SendAuthenticatedHTTPRequest(okcoinFuturesUserInfo4Fix, v, nil)
if err != nil {
log.Println(err)
log.Error(err)
}
}
@@ -949,7 +949,7 @@ func (o *OKCoin) SendAuthenticatedHTTPRequest(method string, v url.Values, resul
path := o.APIUrl + method
if o.Verbose {
log.Printf("Sending POST request to %s with params %s\n", path, encoded)
log.Debugf("Sending POST request to %s with params %s\n", path, encoded)
}
headers := make(map[string]string)

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
@@ -13,7 +12,8 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -132,11 +132,11 @@ func (o *OKCoin) WsHandleData() {
var init []WsResponse
err := common.JSONDecode(resp.Raw, &init)
if err != nil {
log.Fatal(err)
log.Error(err)
}
if init[0].ErrorCode != "" {
log.Fatal(o.WebsocketErrors[init[0].ErrorCode])
log.Error(o.WebsocketErrors[init[0].ErrorCode])
}
if init[0].Success {
@@ -166,7 +166,7 @@ func (o *OKCoin) WsHandleData() {
err = common.JSONDecode(init[0].Data, &ticker)
if err != nil {
log.Fatal(err)
log.Error(err)
}
@@ -187,7 +187,7 @@ func (o *OKCoin) WsHandleData() {
err = common.JSONDecode(init[0].Data, &orderbook)
if err != nil {
log.Fatal(err)
log.Error(err)
}
o.Websocket.DataHandler <- exchange.WebsocketOrderbookUpdate{
@@ -201,7 +201,7 @@ func (o *OKCoin) WsHandleData() {
err = common.JSONDecode(init[0].Data, &klineData)
if err != nil {
log.Fatal(err)
log.Error(err)
}
var klines []WsKlines
@@ -237,7 +237,7 @@ func (o *OKCoin) WsHandleData() {
var dealsData [][]interface{}
err = common.JSONDecode(init[0].Data, &dealsData)
if err != nil {
log.Fatal(err)
log.Error(err)
}
var deals []WsDeals

View File

@@ -3,15 +3,15 @@ package okcoin
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKCoin go routine
@@ -26,9 +26,9 @@ func (o *OKCoin) Start(wg *sync.WaitGroup) {
// Run implements the OKCoin wrapper
func (o *OKCoin) Run() {
if o.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", o.GetName(), o.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", o.GetName(), len(o.EnabledPairs), o.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", o.GetName(), o.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", o.GetName(), len(o.EnabledPairs), o.EnabledPairs)
}
if o.APIUrl == okcoinAPIURL {
@@ -40,7 +40,7 @@ func (o *OKCoin) Run() {
prods, err := o.GetSpotInstruments()
if err != nil {
log.Printf("OKEX failed to obtain available spot instruments. Err: %d", err)
log.Errorf("OKEX failed to obtain available spot instruments. Err: %d", err)
} else {
var pairs []string
for x := range prods {
@@ -49,17 +49,17 @@ func (o *OKCoin) Run() {
err = o.UpdateCurrencies(pairs, false, forceUpgrade)
if err != nil {
log.Printf("OKEX failed to update available currencies. Err: %s", err)
log.Errorf("OKEX failed to update available currencies. Err: %s", err)
}
}
if forceUpgrade {
enabledPairs := []string{"btc_usd"}
log.Println("WARNING: Available pairs for OKCoin International reset due to config upgrade, please enable the pairs you would like again.")
log.Warn("Available pairs for OKCoin International reset due to config upgrade, please enable the pairs you would like again.")
err := o.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s failed to update currencies. Err: %s", o.Name, err)
log.Errorf("%s failed to update currencies. Err: %s", o.Name, err)
}
}
}

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/url"
"reflect"
"strconv"
@@ -18,6 +17,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -944,7 +944,7 @@ func (o *OKEX) SendAuthenticatedHTTPRequest(method string, values url.Values, re
path := o.APIUrl + apiVersion + method
if o.Verbose {
log.Printf("Sending POST request to %s with params %s\n", path, encoded)
log.Debugf("Sending POST request to %s with params %s\n", path, encoded)
}
headers := make(map[string]string)

View File

@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strconv"
@@ -16,7 +15,8 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -203,7 +203,8 @@ func (o *OKEX) WsHandleData() {
if strings.Contains(string(resp.Raw), "pong") {
continue
} else {
log.Fatal("okex.go error -", err)
log.Error(err)
return
}
}
@@ -212,7 +213,7 @@ func (o *OKEX) WsHandleData() {
if common.StringContains(string(resp.Raw), "error_msg") {
err = common.JSONDecode(resp.Raw, &errResponse)
if err != nil {
log.Fatal(err)
log.Error(err)
}
o.Websocket.DataHandler <- fmt.Errorf("okex.go error - %s resp: %s ",
errResponse.ErrorMsg,
@@ -233,7 +234,8 @@ func (o *OKEX) WsHandleData() {
err = common.JSONDecode(multiStreamData.Data, &ticker)
if err != nil {
log.Fatal("OKEX Ticker Decode Error:", err)
log.Errorf("OKEX Ticker Decode Error: %s", err)
return
}
o.Websocket.DataHandler <- exchange.TickerData{
@@ -247,7 +249,8 @@ func (o *OKEX) WsHandleData() {
err = common.JSONDecode(multiStreamData.Data, &deals)
if err != nil {
log.Fatal("OKEX Deals Decode Error:", err)
log.Errorf("OKEX Deals Decode Error: %s", err)
return
}
for _, trade := range deals {
@@ -271,7 +274,8 @@ func (o *OKEX) WsHandleData() {
err := common.JSONDecode(multiStreamData.Data, &klines)
if err != nil {
log.Fatal("OKEX Klines Decode Error:", err)
log.Errorf("OKEX Klines Decode Error: %s", err)
return
}
for _, kline := range klines {
@@ -300,7 +304,8 @@ func (o *OKEX) WsHandleData() {
err := common.JSONDecode(multiStreamData.Data, &depth)
if err != nil {
log.Fatal("OKEX Depth Decode Error:", err)
log.Errorf("OKEX Depth Decode Error: %s", err)
return
}
o.Websocket.DataHandler <- exchange.WebsocketOrderbookUpdate{

View File

@@ -3,7 +3,6 @@ package okex
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
@@ -12,6 +11,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKEX go routine
@@ -26,14 +26,14 @@ func (o *OKEX) Start(wg *sync.WaitGroup) {
// Run implements the OKEX wrapper
func (o *OKEX) Run() {
if o.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", o.GetName(), o.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", o.GetName(), len(o.EnabledPairs), o.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", o.GetName(), o.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", o.GetName(), len(o.EnabledPairs), o.EnabledPairs)
}
prods, err := o.GetSpotInstruments()
if err != nil {
log.Printf("OKEX failed to obtain available spot instruments. Err: %d", err)
log.Errorf("OKEX failed to obtain available spot instruments. Err: %d", err)
return
}
@@ -44,7 +44,8 @@ func (o *OKEX) Run() {
err = o.UpdateCurrencies(pairs, false, false)
if err != nil {
log.Printf("OKEX failed to update available currencies. Err: %s", err)
log.Errorf("OKEX failed to update available currencies. Err: %s", err)
return
}
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"time"
@@ -12,9 +11,10 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -168,7 +168,6 @@ func (p *Poloniex) GetOrderbook(currencyPair string, depth int) (OrderbookAll, e
return oba, err
}
if len(resp.Error) != 0 {
log.Println(resp.Error)
return oba, fmt.Errorf("Poloniex GetOrderbook() error: %s", resp.Error)
}
ob := Orderbook{}

View File

@@ -3,7 +3,6 @@ package poloniex
import (
"errors"
"fmt"
"log"
"net/http"
"net/url"
"strconv"
@@ -12,8 +11,9 @@ import (
"github.com/gorilla/websocket"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -132,7 +132,7 @@ func (p *Poloniex) WsHandleData() {
var check []interface{}
err := common.JSONDecode(resp.Raw, &check)
if err != nil {
log.Fatal("poloniex_websocket.go - ", err)
log.Errorf("poloniex websocket decode error - %s", err)
}
switch len(check) {
@@ -176,7 +176,7 @@ func (p *Poloniex) WsHandleData() {
err := p.WsProcessOrderbookUpdate(datalevel2,
CurrencyPairID[int64(check[0].(float64))])
if err != nil {
log.Fatal(err)
log.Error(err)
}
p.Websocket.DataHandler <- exchange.WebsocketOrderbookUpdate{
@@ -189,12 +189,12 @@ func (p *Poloniex) WsHandleData() {
datalevel3 := datalevel2[1].(map[string]interface{})
currencyPair, ok := datalevel3["currencyPair"].(string)
if !ok {
log.Fatal("poloniex.go error - could not find currency pair in map")
log.Error("poloniex.go error - could not find currency pair in map")
}
orderbookData, ok := datalevel3["orderBook"].([]interface{})
if !ok {
log.Fatal("poloniex.go error - could not find orderbook data in map")
log.Error("poloniex.go error - could not find orderbook data in map")
}
err := p.WsProcessOrderbookSnapshot(orderbookData, currencyPair)

View File

@@ -2,15 +2,15 @@ package poloniex
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the Poloniex go routine
@@ -25,24 +25,24 @@ func (p *Poloniex) Start(wg *sync.WaitGroup) {
// Run implements the Poloniex wrapper
func (p *Poloniex) Run() {
if p.Verbose {
log.Printf("%s Websocket: %s (url: %s).\n", p.GetName(), common.IsEnabled(p.Websocket.IsEnabled()), poloniexWebsocketAddress)
log.Printf("%s polling delay: %ds.\n", p.GetName(), p.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", p.GetName(), len(p.EnabledPairs), p.EnabledPairs)
log.Debugf("%s Websocket: %s (url: %s).\n", p.GetName(), common.IsEnabled(p.Websocket.IsEnabled()), poloniexWebsocketAddress)
log.Debugf("%s polling delay: %ds.\n", p.GetName(), p.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", p.GetName(), len(p.EnabledPairs), p.EnabledPairs)
}
exchangeCurrencies, err := p.GetExchangeCurrencies()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", p.GetName())
log.Errorf("%s Failed to get available symbols.\n", p.GetName())
} else {
forceUpdate := false
if common.StringDataCompare(p.AvailablePairs, "BTC_USDT") {
log.Printf("%s contains invalid pair, forcing upgrade of available currencies.\n",
log.Warnf("%s contains invalid pair, forcing upgrade of available currencies.\n",
p.GetName())
forceUpdate = true
}
err = p.UpdateCurrencies(exchangeCurrencies, false, forceUpdate)
if err != nil {
log.Printf("%s Failed to update available currencies %s.\n", p.GetName(), err)
log.Errorf("%s Failed to update available currencies %s.\n", p.GetName(), err)
}
}
}

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
@@ -13,6 +12,7 @@ import (
"time"
"github.com/thrasher-/gocryptotrader/common"
log "github.com/thrasher-/gocryptotrader/logger"
)
var supportedMethods = []string{"GET", "POST", "HEAD", "PUT", "DELETE", "OPTIONS", "CONNECT"}
@@ -257,11 +257,11 @@ func (r *Requester) checkRequest(method, path string, body io.Reader, headers ma
// DoRequest performs a HTTP/HTTPS request with the supplied params
func (r *Requester) DoRequest(req *http.Request, method, path string, headers map[string]string, body io.Reader, result interface{}, authRequest, verbose bool) error {
if verbose {
log.Printf("%s exchange request path: %s requires rate limiter: %v", r.Name, path, r.RequiresRateLimiter())
log.Debugf("%s exchange request path: %s requires rate limiter: %v", r.Name, path, r.RequiresRateLimiter())
for k, d := range headers {
log.Printf("%s exchange request header [%s]: %s", r.Name, k, d)
log.Debugf("%s exchange request header [%s]: %s", r.Name, k, d)
}
log.Println(body)
log.Debug(body)
}
var timeoutError error
@@ -270,7 +270,7 @@ func (r *Requester) DoRequest(req *http.Request, method, path string, headers ma
if err != nil {
if timeoutErr, ok := err.(net.Error); ok && timeoutErr.Timeout() {
if verbose {
log.Printf("%s request has timed-out retrying request, count %d",
log.Errorf("%s request has timed-out retrying request, count %d",
r.Name,
i)
}
@@ -308,8 +308,8 @@ func (r *Requester) DoRequest(req *http.Request, method, path string, headers ma
resp.Body.Close()
if verbose {
log.Printf("HTTP status: %s, Code: %v", resp.Status, resp.StatusCode)
log.Printf("%s exchange raw response: %s", r.Name, string(contents))
log.Debugf("HTTP status: %s, Code: %v", resp.Status, resp.StatusCode)
log.Debugf("%s exchange raw response: %s", r.Name, string(contents))
}
if result != nil {
@@ -337,7 +337,7 @@ func (r *Requester) worker() {
limit := r.GetRateLimit(x.AuthRequest)
diff := limit.GetDuration() - time.Since(r.Cycle)
if x.Verbose {
log.Printf("%s request. Rate limited! Sleeping for %v", r.Name, diff)
log.Debugf("%s request. Rate limited! Sleeping for %v", r.Name, diff)
}
time.Sleep(diff)
@@ -346,7 +346,7 @@ func (r *Requester) worker() {
r.IncrementRequests(x.AuthRequest)
if x.Verbose {
log.Printf("%s request. No longer rate limited! Doing request", r.Name)
log.Debugf("%s request. No longer rate limited! Doing request", r.Name)
}
err := r.DoRequest(x.Request, x.Method, x.Path, x.Headers, x.Body, x.Result, x.AuthRequest, x.Verbose)
@@ -412,17 +412,17 @@ func (r *Requester) SendPayload(method, path string, headers map[string]string,
}
if verbose {
log.Printf("%s request. Attaching new job.", r.Name)
log.Debugf("%s request. Attaching new job.", r.Name)
}
r.Jobs <- newJob
if verbose {
log.Printf("%s request. Waiting for job to complete.", r.Name)
log.Debugf("%s request. Waiting for job to complete.", r.Name)
}
resp := <-newJob.JobResult
if verbose {
log.Printf("%s request. Job complete.", r.Name)
log.Debugf("%s request. Job complete.", r.Name)
}
return resp.Error
}

View File

@@ -3,7 +3,6 @@ package wex
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -15,6 +14,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -377,7 +377,7 @@ func (w *WEX) SendAuthenticatedHTTPRequest(method string, values url.Values, res
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(w.APISecret))
if w.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n",
log.Debugf("Sending POST request to %s calling method %s with params %s\n",
w.APIUrlSecondary,
method,
encoded)

View File

@@ -2,7 +2,6 @@ package wex
import (
"fmt"
"log"
"strconv"
"sync"
@@ -11,6 +10,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the WEX go routine
@@ -25,14 +25,14 @@ func (w *WEX) Start(wg *sync.WaitGroup) {
// Run implements the WEX wrapper
func (w *WEX) Run() {
if w.Verbose {
log.Printf("%s Websocket: %s.", w.GetName(), common.IsEnabled(w.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", w.GetName(), w.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", w.GetName(), len(w.EnabledPairs), w.EnabledPairs)
log.Debugf("%s Websocket: %s.", w.GetName(), common.IsEnabled(w.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", w.GetName(), w.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", w.GetName(), len(w.EnabledPairs), w.EnabledPairs)
}
exchangeProducts, err := w.GetTradablePairs()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", w.GetName())
log.Errorf("%s Failed to get available symbols.\n", w.GetName())
} else {
forceUpgrade := false
if !common.StringDataContains(w.EnabledPairs, "_") || !common.StringDataContains(w.AvailablePairs, "_") {
@@ -41,16 +41,16 @@ func (w *WEX) Run() {
if forceUpgrade {
enabledPairs := []string{"BTC_USD", "LTC_USD", "LTC_BTC", "ETH_USD"}
log.Println("WARNING: Enabled pairs for WEX reset due to config upgrade, please enable the ones you would like again.")
log.Warn("Enabled pairs for WEX reset due to config upgrade, please enable the ones you would like again.")
err = w.UpdateCurrencies(enabledPairs, true, true)
if err != nil {
log.Printf("%s Failed to get config.\n", w.GetName())
log.Errorf("%s Failed to get config.\n", w.GetName())
}
}
err = w.UpdateCurrencies(exchangeProducts, false, forceUpgrade)
if err != nil {
log.Printf("%s Failed to get config.\n", w.GetName())
log.Errorf("%s Failed to get config.\n", w.GetName())
}
}
}

View File

@@ -3,7 +3,6 @@ package yobit
import (
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -12,9 +11,10 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
"github.com/thrasher-/gocryptotrader/currency/symbol"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (
@@ -345,7 +345,7 @@ func (y *Yobit) SendAuthenticatedHTTPRequest(path string, params url.Values, res
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(y.APISecret))
if y.Verbose {
log.Printf("Sending POST request to %s calling path %s with params %s\n", apiPrivateURL, path, encoded)
log.Debugf("Sending POST request to %s calling path %s with params %s\n", apiPrivateURL, path, encoded)
}
headers := make(map[string]string)

View File

@@ -3,7 +3,6 @@ package yobit
import (
"errors"
"fmt"
"log"
"strconv"
"sync"
@@ -12,6 +11,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the WEX go routine
@@ -26,9 +26,9 @@ func (y *Yobit) Start(wg *sync.WaitGroup) {
// Run implements the Yobit wrapper
func (y *Yobit) Run() {
if y.Verbose {
log.Printf("%s Websocket: %s.", y.GetName(), common.IsEnabled(y.Websocket.IsEnabled()))
log.Printf("%s polling delay: %ds.\n", y.GetName(), y.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", y.GetName(), len(y.EnabledPairs), y.EnabledPairs)
log.Debugf("%s Websocket: %s.", y.GetName(), common.IsEnabled(y.Websocket.IsEnabled()))
log.Debugf("%s polling delay: %ds.\n", y.GetName(), y.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", y.GetName(), len(y.EnabledPairs), y.EnabledPairs)
}
}

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"net/url"
"strconv"
"strings"
@@ -15,6 +14,7 @@ import (
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/request"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
const (

View File

@@ -2,15 +2,15 @@ package zb
import (
"fmt"
"log"
"strconv"
"sync"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency/pair"
"github.com/thrasher-/gocryptotrader/exchanges"
exchange "github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
log "github.com/thrasher-/gocryptotrader/logger"
)
// Start starts the OKEX go routine
@@ -25,14 +25,14 @@ func (z *ZB) Start(wg *sync.WaitGroup) {
// Run implements the OKEX wrapper
func (z *ZB) Run() {
if z.Verbose {
log.Printf("%s Websocket: %s. (url: %s).\n", z.GetName(), common.IsEnabled(z.Websocket.IsEnabled()), z.WebsocketURL)
log.Printf("%s polling delay: %ds.\n", z.GetName(), z.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", z.GetName(), len(z.EnabledPairs), z.EnabledPairs)
log.Debugf("%s Websocket: %s. (url: %s).\n", z.GetName(), common.IsEnabled(z.Websocket.IsEnabled()), z.WebsocketURL)
log.Debugf("%s polling delay: %ds.\n", z.GetName(), z.RESTPollingDelay)
log.Debugf("%s %d currencies enabled: %s.\n", z.GetName(), len(z.EnabledPairs), z.EnabledPairs)
}
markets, err := z.GetMarkets()
if err != nil {
log.Printf("%s Unable to fetch symbols.\n", z.GetName())
log.Errorf("%s Unable to fetch symbols.\n", z.GetName())
} else {
var currencies []string
for x := range markets {
@@ -41,7 +41,7 @@ func (z *ZB) Run() {
err = z.UpdateCurrencies(currencies, false, false)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", z.GetName())
log.Errorf("%s Failed to update available currencies.\n", z.GetName())
}
}
}