mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
New logging system (#319)
* First pass at adding new logging system * NewLogger * NewLogger * WIP * silly bug fix * :D removed files * removed old logging interface * added tests * added tests * Started to add new lines to all f calls * Added subsystem log types * Logger improvements * Further performance improvements * changes to logger and sublogger creation * Renamed Logging types * removed old print statement * changes based on feedback * moved sublogger types to own file * :) * added console as output type * added get level command * added get/set log level via grpc command * added check for output being empty for migration support * first pass at log rotation * added log rotation * :D derp fixed * added tests * changes based on feedback * changed log type * comments * renamed file -> fileSettings * typo fix * changes based on feedback * gofmt ran on additional files * gofmt ran on additional files
This commit is contained in:
@@ -24,9 +24,9 @@ func ({{.Variable}} *{{.CapitalName}}) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the {{.CapitalName}} wrapper
|
||||
func ({{.Variable}} *{{.CapitalName}}) Run() {
|
||||
if {{.Variable}}.Verbose {
|
||||
{{if .WS}} log.Debugf("%s Websocket: %s. (url: %s).\n", {{.Variable}}.GetName(), common.IsEnabled({{.Variable}}.Websocket.IsEnabled()), {{.Variable}}.Websocket.GetWebsocketURL()) {{end}}
|
||||
log.Debugf("%s polling delay: %ds.\n", {{.Variable}}.GetName(), {{.Variable}}.RESTPollingDelay)
|
||||
log.Debugf("%s %d currencies enabled: %s.\n", {{.Variable}}.GetName(), len({{.Variable}}.EnabledPairs), {{.Variable}}.EnabledPairs)
|
||||
{{if .WS}} log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", {{.Variable}}.GetName(), common.IsEnabled({{.Variable}}.Websocket.IsEnabled()), {{.Variable}}.Websocket.GetWebsocketURL()) {{end}}
|
||||
log.Debugf(log.ExchangeSys, "%s polling delay: %ds.\n", {{.Variable}}.GetName(), {{.Variable}}.RESTPollingDelay)
|
||||
log.Debugf(log.ExchangeSys, "%s %d currencies enabled: %s.\n", {{.Variable}}.GetName(), len({{.Variable}}.EnabledPairs), {{.Variable}}.EnabledPairs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1948,3 +1948,104 @@ var withdrawFiatFundsCommand = cli.Command{
|
||||
func withdrawFiatFunds(_ *cli.Context) error {
|
||||
return common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
var getLoggerDetailsCommand = cli.Command{
|
||||
Name: "getloggerdetails",
|
||||
Action: getLoggerDetails,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "logger",
|
||||
Usage: "logger to get level details of",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func getLoggerDetails(c *cli.Context) error {
|
||||
if c.NArg() == 0 && c.NumFlags() == 0 {
|
||||
cli.ShowCommandHelp(c, "getloggerdetails")
|
||||
return nil
|
||||
}
|
||||
|
||||
var logger string
|
||||
if c.IsSet("logger") {
|
||||
logger = c.String("logger")
|
||||
} else {
|
||||
logger = c.Args().First()
|
||||
}
|
||||
|
||||
conn, err := setupClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
client := gctrpc.NewGoCryptoTraderClient(conn)
|
||||
|
||||
result, err := client.GetLoggerDetails(context.Background(),
|
||||
&gctrpc.GetLoggerDetailsRequest{
|
||||
Logger: logger,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jsonOutput(result)
|
||||
return nil
|
||||
}
|
||||
|
||||
var setLoggerDetailsCommand = cli.Command{
|
||||
Name: "setloggerdetails",
|
||||
Action: setLoggerDetails,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "logger",
|
||||
Usage: "logger to get level details of",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "flags",
|
||||
Usage: "pipe separated value of loggers e.g INFO|WARN",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func setLoggerDetails(c *cli.Context) error {
|
||||
if c.NArg() == 0 && c.NumFlags() == 0 {
|
||||
cli.ShowCommandHelp(c, "setloggerdetails")
|
||||
return nil
|
||||
}
|
||||
|
||||
var logger string
|
||||
var level string
|
||||
|
||||
if c.IsSet("logger") {
|
||||
logger = c.String("logger")
|
||||
} else {
|
||||
logger = c.Args().First()
|
||||
}
|
||||
|
||||
if c.IsSet("level") {
|
||||
level = c.String("level")
|
||||
} else {
|
||||
level = c.Args().Get(1)
|
||||
}
|
||||
|
||||
conn, err := setupClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
client := gctrpc.NewGoCryptoTraderClient(conn)
|
||||
|
||||
result, err := client.SetLoggerDetails(context.Background(),
|
||||
&gctrpc.SetLoggerDetailsRequest{
|
||||
Logger: logger,
|
||||
Level: level,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jsonOutput(result)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ func main() {
|
||||
getCryptocurrencyDepositAddressCommand,
|
||||
withdrawCryptocurrencyFundsCommand,
|
||||
withdrawFiatFundsCommand,
|
||||
getLoggerDetailsCommand,
|
||||
setLoggerDetailsCommand,
|
||||
}
|
||||
|
||||
err := app.Run(os.Args)
|
||||
|
||||
@@ -3,11 +3,12 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/bitfinex"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
"github.com/thrasher-/gocryptotrader/portfolio"
|
||||
)
|
||||
|
||||
@@ -25,7 +26,7 @@ func printSummary(msg string, amount float64) {
|
||||
currency.USD,
|
||||
displayCurrency)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Println(err)
|
||||
} else {
|
||||
symb, err := currency.GetSymbolByCurrencyName(displayCurrency)
|
||||
if err != nil {
|
||||
@@ -64,7 +65,8 @@ func main() {
|
||||
|
||||
defaultCfg, err := config.GetFilePath("")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
flag.StringVar(&inFile, "infile", defaultCfg, "The config input file to process.")
|
||||
@@ -76,7 +78,8 @@ func main() {
|
||||
var cfg config.Config
|
||||
err = cfg.LoadConfig(inFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Println("Loaded config file.")
|
||||
|
||||
@@ -105,7 +108,8 @@ func main() {
|
||||
}
|
||||
err = currency.SeedForeignExchangeData(fiatCurrencies)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.Println("Fetched currency data.")
|
||||
|
||||
@@ -42,8 +42,8 @@ type WebsocketEventResponse struct {
|
||||
// WebsocketOrderbookTickerRequest is a struct used for ticker and orderbook
|
||||
// requests
|
||||
type WebsocketOrderbookTickerRequest struct {
|
||||
Exchange string `json:"exchangeName"`
|
||||
Currency string `json:"currency"`
|
||||
Exchange string `json:"exchangeName"`
|
||||
Currency string `json:"currency"`
|
||||
AssetType asset.Item `json:"assetType"`
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ func SendHTTPRequest(method, urlPath string, headers map[string]string, body io.
|
||||
// on failure.
|
||||
func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result interface{}) error {
|
||||
if isVerbose {
|
||||
log.Debugf("Raw URL: %s", urlPath)
|
||||
log.Debugf(log.Global, "Raw URL: %s\n", urlPath)
|
||||
}
|
||||
|
||||
initialiseHTTPClient()
|
||||
@@ -221,7 +221,7 @@ func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result inter
|
||||
}
|
||||
|
||||
if isVerbose {
|
||||
log.Debugf("Raw Resp: %s", string(contents))
|
||||
log.Debugf(log.Global, "Raw Resp: %s\n", string(contents))
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
@@ -336,7 +336,7 @@ func GetDefaultDataDir(env string) string {
|
||||
|
||||
dir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Warn("Environment variable unset, defaulting to current directory")
|
||||
log.Warnln(log.Global, "Environment variable unset, defaulting to current directory")
|
||||
dir = "."
|
||||
}
|
||||
return filepath.Join(dir, ".gocryptotrader")
|
||||
@@ -349,7 +349,7 @@ func CreateDir(dir string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warnf("Directory %s does not exist.. creating.", dir)
|
||||
log.Warnf(log.Global, "Directory %s does not exist.. creating.\n", dir)
|
||||
return os.MkdirAll(dir, 0770)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ func (c IComm) Setup() {
|
||||
if c[i].IsEnabled() && !c[i].IsConnected() {
|
||||
err := c[i].Connect()
|
||||
if err != nil {
|
||||
log.Errorf("Communications: %s failed to connect. Err: %s", c[i].GetName(), err)
|
||||
log.Errorf(log.CommunicationMgr, "Communications: %s failed to connect. Err: %s", c[i].GetName(), err)
|
||||
continue
|
||||
}
|
||||
log.Debugf("Communications: %v is enabled and online.", c[i].GetName())
|
||||
log.Debugf(log.CommunicationMgr, "Communications: %v is enabled and online.", c[i].GetName())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func (c IComm) PushEvent(event Event) {
|
||||
if c[i].IsEnabled() && c[i].IsConnected() {
|
||||
err := c[i].PushEvent(event)
|
||||
if err != nil {
|
||||
log.Errorf("Communications error - PushEvent() in package %s with %v. Err %s",
|
||||
log.Errorf(log.CommunicationMgr, "Communications error - PushEvent() in package %s with %v. Err %s",
|
||||
c[i].GetName(), event, err)
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func (c IComm) GetEnabledCommunicationMediums() error {
|
||||
var count int
|
||||
for i := range c {
|
||||
if c[i].IsEnabled() && c[i].IsConnected() {
|
||||
log.Debugf("Communications: Medium %s is enabled.", c[i].GetName())
|
||||
log.Debugf(log.CommunicationMgr, "Communications: Medium %s is enabled.", c[i].GetName())
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,13 +162,13 @@ func (s *Slack) NewConnection() error {
|
||||
}
|
||||
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: %s [%s] connected to %s [%s] \nWebsocket URL: %s.\n",
|
||||
log.Debugf(log.CommunicationMgr, "Slack: %s [%s] connected to %s [%s] \nWebsocket URL: %s.\n",
|
||||
s.Details.Self.Name,
|
||||
s.Details.Self.ID,
|
||||
s.Details.Team.Domain,
|
||||
s.Details.Team.ID,
|
||||
s.Details.URL)
|
||||
log.Debugf("Slack: Public channels: %s", s.GetChannelsString())
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Public channels: %s\n", s.GetChannelsString())
|
||||
}
|
||||
|
||||
s.TargetChannelID, err = s.GetIDByName(s.TargetChannel)
|
||||
@@ -176,7 +176,7 @@ func (s *Slack) NewConnection() error {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Slack: Target channel ID: %v [#%v]", s.TargetChannelID,
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Target channel ID: %v [#%v]\n", s.TargetChannelID,
|
||||
s.TargetChannel)
|
||||
return s.WebsocketConnect()
|
||||
}
|
||||
@@ -208,13 +208,13 @@ func (s *Slack) WebsocketReader() {
|
||||
for {
|
||||
_, resp, err := s.WebsocketConn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
}
|
||||
|
||||
var data WebsocketResponse
|
||||
err = common.JSONDecode(resp, &data)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -249,10 +249,10 @@ func (s *Slack) WebsocketReader() {
|
||||
|
||||
case "pong":
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: Pong received from server")
|
||||
log.Debugln(log.CommunicationMgr, "Slack: Pong received from server")
|
||||
}
|
||||
default:
|
||||
log.Debugf(string(resp))
|
||||
log.Debugln(log.CommunicationMgr, string(resp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ func (s *Slack) handlePresenceChange(resp []byte) error {
|
||||
return err
|
||||
}
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: Presence change. User %s [%s] changed status to %s\n",
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Presence change. User %s [%s] changed status to %s\n",
|
||||
s.GetUsernameByID(pres.User),
|
||||
pres.User, pres.Presence)
|
||||
}
|
||||
@@ -281,7 +281,7 @@ func (s *Slack) handleMessageResponse(resp []byte, data WebsocketResponse) error
|
||||
return err
|
||||
}
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: Message received by %s [%s] with text: %s\n",
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Message received by %s [%s] with text: %s\n",
|
||||
s.GetUsernameByID(msg.User),
|
||||
msg.User, msg.Text)
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func (s *Slack) handleMessageResponse(resp []byte, data WebsocketResponse) error
|
||||
func (s *Slack) handleErrorResponse(data WebsocketResponse) error {
|
||||
if data.Error.Msg == "Socket URL has expired" {
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack websocket URL has expired.. Reconnecting")
|
||||
log.Debugln(log.CommunicationMgr, "Slack websocket URL has expired.. Reconnecting")
|
||||
}
|
||||
|
||||
if s.WebsocketConn == nil {
|
||||
@@ -301,7 +301,7 @@ func (s *Slack) handleErrorResponse(data WebsocketResponse) error {
|
||||
}
|
||||
|
||||
if err := s.WebsocketConn.Close(); err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
}
|
||||
|
||||
s.ReconnectURL = ""
|
||||
@@ -313,7 +313,7 @@ func (s *Slack) handleErrorResponse(data WebsocketResponse) error {
|
||||
|
||||
func (s *Slack) handleHelloResponse() {
|
||||
if s.Verbose {
|
||||
log.Debugln("Slack: Websocket connected successfully.")
|
||||
log.Debugln(log.CommunicationMgr, "Slack: Websocket connected successfully.")
|
||||
}
|
||||
s.Connected = true
|
||||
go s.WebsocketKeepAlive()
|
||||
@@ -330,7 +330,7 @@ func (s *Slack) handleReconnectResponse(resp []byte) error {
|
||||
}
|
||||
s.ReconnectURL = recURL.URL
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: Reconnect URL set to %s\n", s.ReconnectURL)
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Reconnect URL set to %s\n", s.ReconnectURL)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -343,7 +343,7 @@ func (s *Slack) WebsocketKeepAlive() {
|
||||
for {
|
||||
<-ticker.C
|
||||
if err := s.WebsocketSend("ping", ""); err != nil {
|
||||
log.Debugf("Slack: WebsocketKeepAlive() error %s", err)
|
||||
log.Errorf(log.CommunicationMgr, "Slack: WebsocketKeepAlive() error %s\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ func (s *Slack) WebsocketSend(eventType, text string) error {
|
||||
}
|
||||
|
||||
if s.Verbose {
|
||||
log.Debugf("Slack: Sending websocket message: %s", string(data))
|
||||
log.Debugf(log.CommunicationMgr, "Slack: Sending websocket message: %s\n", string(data))
|
||||
}
|
||||
|
||||
if s.WebsocketConn == nil {
|
||||
|
||||
@@ -51,7 +51,7 @@ func (s *SMSGlobal) Setup(cfg *config.CommunicationsConfig) {
|
||||
Enabled: cfg.SMSGlobalConfig.Contacts[x].Enabled,
|
||||
},
|
||||
)
|
||||
log.Debugf("SMSGlobal: SMS Contact: %s. Number: %s. Enabled: %v",
|
||||
log.Debugf(log.CommunicationMgr, "SMSGlobal: SMS Contact: %s. Number: %s. Enabled: %v\n",
|
||||
cfg.SMSGlobalConfig.Contacts[x].Name,
|
||||
cfg.SMSGlobalConfig.Contacts[x].Number,
|
||||
cfg.SMSGlobalConfig.Contacts[x].Enabled)
|
||||
@@ -151,7 +151,7 @@ func (s *SMSGlobal) SendMessageToAll(message string) error {
|
||||
for x := range s.Contacts {
|
||||
if s.Contacts[x].Enabled {
|
||||
if s.Verbose {
|
||||
log.Debugf("SMSGlobal: Sending SMS to %s. Number: %s. Message: %s [From: %s]",
|
||||
log.Debugf(log.CommunicationMgr, "SMSGlobal: Sending SMS to %s. Number: %s. Message: %s [From: %s]\n",
|
||||
s.Contacts[x].Name, s.Contacts[x].Number, message, s.SendFrom)
|
||||
}
|
||||
err := s.SendMessage(s.Contacts[x].Number, message)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (s *SMTPservice) Setup(cfg *config.CommunicationsConfig) {
|
||||
s.AccountPassword = cfg.SMTPConfig.AccountPassword
|
||||
s.From = cfg.SMTPConfig.From
|
||||
s.RecipientList = cfg.SMTPConfig.RecipientList
|
||||
log.Debugf("SMTP: Setup - From: %v. To: %s. Server: %s.", s.From, s.RecipientList, s.Host)
|
||||
log.Debugf(log.CommunicationMgr, "SMTP: Setup - From: %v. To: %s. Server: %s.\n", s.From, s.RecipientList, s.Host)
|
||||
}
|
||||
|
||||
// IsConnected returns whether or not the connection is connected
|
||||
@@ -65,7 +65,7 @@ func (s *SMTPservice) Send(subject, msg string) error {
|
||||
return errors.New("STMPservice Send() please add subject and alert")
|
||||
}
|
||||
|
||||
log.Debugf("SMTP: Sending email to %v. Subject: %s Message: %s [From: %s]", s.RecipientList,
|
||||
log.Debugf(log.CommunicationMgr, "SMTP: Sending email to %v. Subject: %s Message: %s [From: %s]\n", s.RecipientList,
|
||||
subject, msg, s.From)
|
||||
messageToSend := fmt.Sprintf(
|
||||
msgSMTP,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
@@ -86,7 +87,7 @@ func (t *Telegram) PollerStart() {
|
||||
for {
|
||||
resp, err := t.GetUpdates()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
}
|
||||
|
||||
for i := range resp.Result {
|
||||
@@ -94,7 +95,7 @@ func (t *Telegram) PollerStart() {
|
||||
if string(resp.Result[i].Message.Text[0]) == "/" {
|
||||
err = t.HandleMessages(resp.Result[i].Message.Text, resp.Result[i].Message.From.ID)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
}
|
||||
}
|
||||
t.Offset = resp.Result[i].UpdateID
|
||||
@@ -108,11 +109,13 @@ func (t *Telegram) PollerStart() {
|
||||
func (t *Telegram) InitialConnect() {
|
||||
resp, err := t.GetUpdates()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !resp.Ok {
|
||||
log.Fatal(resp.Description)
|
||||
log.Errorln(log.CommunicationMgr, resp.Description)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
warmWelcomeList := make(map[string]int64)
|
||||
@@ -125,7 +128,8 @@ func (t *Telegram) InitialConnect() {
|
||||
for userName, ID := range warmWelcomeList {
|
||||
err = t.SendMessage(fmt.Sprintf("GoCryptoTrader bot has connected: Hello, %s!", userName), ID)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Errorln(log.CommunicationMgr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if len(resp.Result) == 0 {
|
||||
|
||||
132
config/config.go
132
config/config.go
@@ -184,20 +184,20 @@ func (c *Config) CheckClientBankAccounts() {
|
||||
if c.BankAccounts[i].Enabled {
|
||||
if c.BankAccounts[i].BankName == "" || c.BankAccounts[i].BankAddress == "" {
|
||||
c.BankAccounts[i].Enabled = false
|
||||
log.Warnf("banking details for %s is enabled but variables not set correctly",
|
||||
log.Warnf(log.ConfigMgr, "banking details for %s is enabled but variables not set correctly\n",
|
||||
c.BankAccounts[i].BankName)
|
||||
continue
|
||||
}
|
||||
|
||||
if c.BankAccounts[i].AccountName == "" || c.BankAccounts[i].AccountNumber == "" {
|
||||
c.BankAccounts[i].Enabled = false
|
||||
log.Warnf("banking account details for %s variables not set correctly",
|
||||
log.Warnf(log.ConfigMgr, "banking account details for %s variables not set correctly\n",
|
||||
c.BankAccounts[i].BankName)
|
||||
continue
|
||||
}
|
||||
if c.BankAccounts[i].IBAN == "" && c.BankAccounts[i].SWIFTCode == "" && c.BankAccounts[i].BSBNumber == "" {
|
||||
c.BankAccounts[i].Enabled = false
|
||||
log.Warnf("critical banking numbers not set for %s in %s account",
|
||||
log.Warnf(log.ConfigMgr, "critical banking numbers not set for %s in %s account\n",
|
||||
c.BankAccounts[i].BankName,
|
||||
c.BankAccounts[i].AccountName)
|
||||
continue
|
||||
@@ -335,7 +335,7 @@ func (c *Config) CheckCommunicationsConfig() {
|
||||
}
|
||||
|
||||
if len(c.Communications.SMSGlobalConfig.From) > 11 {
|
||||
log.Warnf("SMSGlobal config supplied from name exceeds 11 characters, trimming.")
|
||||
log.Warnf(log.ConfigMgr, "SMSGlobal config supplied from name exceeds 11 characters, trimming.\n")
|
||||
c.Communications.SMSGlobalConfig.From = c.Communications.SMSGlobalConfig.From[:11]
|
||||
}
|
||||
|
||||
@@ -367,14 +367,14 @@ func (c *Config) CheckCommunicationsConfig() {
|
||||
c.Communications.SMSGlobalConfig.Name != "SMSGlobal" ||
|
||||
c.Communications.SMTPConfig.Name != "SMTP" ||
|
||||
c.Communications.TelegramConfig.Name != "Telegram" {
|
||||
log.Warn("Communications config name/s not set correctly")
|
||||
log.Warnln(log.ConfigMgr, "Communications config name/s not set correctly")
|
||||
}
|
||||
if c.Communications.SlackConfig.Enabled {
|
||||
if c.Communications.SlackConfig.TargetChannel == "" ||
|
||||
c.Communications.SlackConfig.VerificationToken == "" ||
|
||||
c.Communications.SlackConfig.VerificationToken == "testtest" {
|
||||
c.Communications.SlackConfig.Enabled = false
|
||||
log.Warn("Slack enabled in config but variable data not set, disabling.")
|
||||
log.Warnln(log.ConfigMgr, "Slack enabled in config but variable data not set, disabling.")
|
||||
}
|
||||
}
|
||||
if c.Communications.SMSGlobalConfig.Enabled {
|
||||
@@ -382,7 +382,7 @@ func (c *Config) CheckCommunicationsConfig() {
|
||||
c.Communications.SMSGlobalConfig.Password == "" ||
|
||||
len(c.Communications.SMSGlobalConfig.Contacts) == 0 {
|
||||
c.Communications.SMSGlobalConfig.Enabled = false
|
||||
log.Warn("SMSGlobal enabled in config but variable data not set, disabling.")
|
||||
log.Warnln(log.ConfigMgr, "SMSGlobal enabled in config but variable data not set, disabling.")
|
||||
}
|
||||
}
|
||||
if c.Communications.SMTPConfig.Enabled {
|
||||
@@ -391,13 +391,13 @@ func (c *Config) CheckCommunicationsConfig() {
|
||||
c.Communications.SMTPConfig.AccountName == "" ||
|
||||
c.Communications.SMTPConfig.AccountPassword == "" {
|
||||
c.Communications.SMTPConfig.Enabled = false
|
||||
log.Warn("SMTP enabled in config but variable data not set, disabling.")
|
||||
log.Warnln(log.ConfigMgr, "SMTP enabled in config but variable data not set, disabling.")
|
||||
}
|
||||
}
|
||||
if c.Communications.TelegramConfig.Enabled {
|
||||
if c.Communications.TelegramConfig.VerificationToken == "" {
|
||||
c.Communications.TelegramConfig.Enabled = false
|
||||
log.Warn("Telegram enabled in config but variable data not set, disabling.")
|
||||
log.Warnln(log.ConfigMgr, "Telegram enabled in config but variable data not set, disabling.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,7 +454,7 @@ func (c *Config) CheckExchangeAssetsConsistency(exchName string) {
|
||||
storedAssetTypes := exchCfg.CurrencyPairs.GetAssetTypes()
|
||||
for x := range storedAssetTypes {
|
||||
if !exchangeAssetTypes.Contains(storedAssetTypes[x]) {
|
||||
log.Warnf("%s has non-needed stored asset type %v. Removing..", exchName, storedAssetTypes[x])
|
||||
log.Warnf(log.ConfigMgr, "%s has non-needed stored asset type %v. Removing..\n", exchName, storedAssetTypes[x])
|
||||
exchCfg.CurrencyPairs.Delete(storedAssetTypes[x])
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ func (c *Config) CheckPairConsistency(exchName string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("exchange %s failed to set pairs: %v", exchName, err)
|
||||
}
|
||||
log.Warnf("Exchange %s: [%v] No enabled pairs found in available pairs, randomly added %v pair.\n",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s: [%v] No enabled pairs found in available pairs, randomly added %v pair.\n",
|
||||
exchName, assetTypes[x], newPair)
|
||||
continue
|
||||
} else {
|
||||
@@ -629,7 +629,7 @@ func (c *Config) CheckPairConsistency(exchName string) error {
|
||||
return fmt.Errorf("exchange %s failed to set pairs: %v", exchName, err)
|
||||
}
|
||||
}
|
||||
log.Warnf("Exchange %s: [%v] Removing enabled pair(s) %v from enabled pairs as it isn't an available pair.",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s: [%v] Removing enabled pair(s) %v from enabled pairs as it isn't an available pair.\n",
|
||||
exchName, assetTypes[x], pairsRemoved.Strings())
|
||||
}
|
||||
return nil
|
||||
@@ -952,7 +952,7 @@ func (c *Config) CheckExchangeConfigValues() error {
|
||||
|
||||
if c.Exchanges[i].Enabled {
|
||||
if c.Exchanges[i].Name == "" {
|
||||
log.Error(ErrExchangeNameEmpty, i)
|
||||
log.Error(log.ConfigMgr, ErrExchangeNameEmpty, i)
|
||||
c.Exchanges[i].Enabled = false
|
||||
continue
|
||||
}
|
||||
@@ -973,46 +973,46 @@ func (c *Config) CheckExchangeConfigValues() error {
|
||||
if failed {
|
||||
c.Exchanges[i].API.AuthenticatedSupport = false
|
||||
c.Exchanges[i].API.AuthenticatedWebsocketSupport = false
|
||||
log.Warnf(WarningExchangeAuthAPIDefaultOrEmptyValues, c.Exchanges[i].Name)
|
||||
log.Warnf(log.ExchangeSys, WarningExchangeAuthAPIDefaultOrEmptyValues, c.Exchanges[i].Name)
|
||||
}
|
||||
}
|
||||
if !c.Exchanges[i].Features.Supports.RESTCapabilities.AutoPairUpdates && !c.Exchanges[i].Features.Supports.WebsocketCapabilities.AutoPairUpdates {
|
||||
lastUpdated := convert.UnixTimestampToTime(c.Exchanges[i].CurrencyPairs.LastUpdated)
|
||||
lastUpdated = lastUpdated.AddDate(0, 0, configPairsLastUpdatedWarningThreshold)
|
||||
if lastUpdated.Unix() <= time.Now().Unix() {
|
||||
log.Warnf(WarningPairsLastUpdatedThresholdExceeded, c.Exchanges[i].Name, configPairsLastUpdatedWarningThreshold)
|
||||
log.Warnf(log.ExchangeSys, WarningPairsLastUpdatedThresholdExceeded, c.Exchanges[i].Name, configPairsLastUpdatedWarningThreshold)
|
||||
}
|
||||
}
|
||||
if c.Exchanges[i].HTTPTimeout <= 0 {
|
||||
log.Warnf("Exchange %s HTTP Timeout value not set, defaulting to %v.", c.Exchanges[i].Name, configDefaultHTTPTimeout)
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s HTTP Timeout value not set, defaulting to %v.\n", c.Exchanges[i].Name, configDefaultHTTPTimeout)
|
||||
c.Exchanges[i].HTTPTimeout = configDefaultHTTPTimeout
|
||||
}
|
||||
|
||||
if c.Exchanges[i].HTTPRateLimiter != nil {
|
||||
if c.Exchanges[i].HTTPRateLimiter.Authenticated.Duration < 0 {
|
||||
log.Warnf("Exchange %s HTTP Rate Limiter authenticated duration set to negative value, defaulting to 0", c.Exchanges[i].Name)
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s HTTP Rate Limiter authenticated duration set to negative value, defaulting to 0\n", c.Exchanges[i].Name)
|
||||
c.Exchanges[i].HTTPRateLimiter.Authenticated.Duration = 0
|
||||
}
|
||||
|
||||
if c.Exchanges[i].HTTPRateLimiter.Authenticated.Rate < 0 {
|
||||
log.Warnf("Exchange %s HTTP Rate Limiter authenticated rate set to negative value, defaulting to 0", c.Exchanges[i].Name)
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s HTTP Rate Limiter authenticated rate set to negative value, defaulting to 0\n", c.Exchanges[i].Name)
|
||||
c.Exchanges[i].HTTPRateLimiter.Authenticated.Rate = 0
|
||||
}
|
||||
|
||||
if c.Exchanges[i].HTTPRateLimiter.Unauthenticated.Duration < 0 {
|
||||
log.Warnf("Exchange %s HTTP Rate Limiter unauthenticated duration set to negative value, defaulting to 0", c.Exchanges[i].Name)
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s HTTP Rate Limiter unauthenticated duration set to negative value, defaulting to 0\n", c.Exchanges[i].Name)
|
||||
c.Exchanges[i].HTTPRateLimiter.Unauthenticated.Duration = 0
|
||||
}
|
||||
|
||||
if c.Exchanges[i].HTTPRateLimiter.Unauthenticated.Rate < 0 {
|
||||
log.Warnf("Exchange %s HTTP Rate Limiter unauthenticated rate set to negative value, defaulting to 0", c.Exchanges[i].Name)
|
||||
log.Warnf(log.ExchangeSys, "Exchange %s HTTP Rate Limiter unauthenticated rate set to negative value, defaulting to 0\n", c.Exchanges[i].Name)
|
||||
c.Exchanges[i].HTTPRateLimiter.Unauthenticated.Rate = 0
|
||||
}
|
||||
}
|
||||
|
||||
err := c.CheckPairConsistency(c.Exchanges[i].Name)
|
||||
if err != nil {
|
||||
log.Errorf("Exchange %s: CheckPairConsistency error: %s", c.Exchanges[i].Name, err)
|
||||
log.Errorf(log.ExchangeSys, "Exchange %s: CheckPairConsistency error: %s\n", c.Exchanges[i].Name, err)
|
||||
c.Exchanges[i].Enabled = false
|
||||
continue
|
||||
}
|
||||
@@ -1026,26 +1026,26 @@ func (c *Config) CheckExchangeConfigValues() error {
|
||||
}
|
||||
bankError := false
|
||||
if c.Exchanges[i].BankAccounts[x].BankName == "" || c.Exchanges[i].BankAccounts[x].BankAddress == "" {
|
||||
log.Warnf("banking details for %s is enabled but variables not set",
|
||||
log.Warnf(log.ExchangeSys, "banking details for %s is enabled but variables not set\n",
|
||||
c.Exchanges[i].Name)
|
||||
bankError = true
|
||||
}
|
||||
|
||||
if c.Exchanges[i].BankAccounts[x].AccountName == "" || c.Exchanges[i].BankAccounts[x].AccountNumber == "" {
|
||||
log.Warnf("banking account details for %s variables not set",
|
||||
log.Warnf(log.ExchangeSys, "banking account details for %s variables not set\n",
|
||||
c.Exchanges[i].Name)
|
||||
bankError = true
|
||||
}
|
||||
|
||||
if c.Exchanges[i].BankAccounts[x].SupportedCurrencies == "" {
|
||||
log.Warnf("banking account details for %s acceptable funding currencies not set",
|
||||
log.Warnf(log.ExchangeSys, "banking account details for %s acceptable funding currencies not set\n",
|
||||
c.Exchanges[i].Name)
|
||||
bankError = true
|
||||
}
|
||||
|
||||
if c.Exchanges[i].BankAccounts[x].BSBNumber == "" && c.Exchanges[i].BankAccounts[x].IBAN == "" &&
|
||||
c.Exchanges[i].BankAccounts[x].SWIFTCode == "" {
|
||||
log.Warnf("banking account details for %s critical banking numbers not set",
|
||||
log.Warnf(log.ExchangeSys, "banking account details for %s critical banking numbers not set\n",
|
||||
c.Exchanges[i].Name)
|
||||
bankError = true
|
||||
}
|
||||
@@ -1075,7 +1075,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
for x := range fxProviders {
|
||||
_, err := c.GetForexProviderConfig(fxProviders[x])
|
||||
if err != nil {
|
||||
log.Warnf("%s forex provider not found, adding to config..", fxProviders[x])
|
||||
log.Warnf(log.Global, "%s forex provider not found, adding to config..\n", fxProviders[x])
|
||||
c.Currency.ForexProviders = append(c.Currency.ForexProviders, base.Settings{
|
||||
Name: fxProviders[x],
|
||||
RESTPollingDelay: 600,
|
||||
@@ -1090,7 +1090,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
for i := range c.Currency.ForexProviders {
|
||||
if c.Currency.ForexProviders[i].Enabled {
|
||||
if c.Currency.ForexProviders[i].APIKey == DefaultUnsetAPIKey && c.Currency.ForexProviders[i].Name != DefaultForexProviderExchangeRatesAPI {
|
||||
log.Warnf("%s enabled forex provider API key not set. Please set this in your config.json file", c.Currency.ForexProviders[i].Name)
|
||||
log.Warnf(log.Global, "%s enabled forex provider API key not set. Please set this in your config.json file\n", c.Currency.ForexProviders[i].Name)
|
||||
c.Currency.ForexProviders[i].Enabled = false
|
||||
c.Currency.ForexProviders[i].PrimaryProvider = false
|
||||
continue
|
||||
@@ -1101,7 +1101,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
c.Currency.ForexProviders[i].PrimaryProvider &&
|
||||
(c.Currency.ForexProviders[i].APIKey == "" ||
|
||||
c.Currency.ForexProviders[i].APIKey == DefaultUnsetAPIKey) {
|
||||
log.Warnf("CurrencyConverter forex provider no longer supports unset API key requests. Switching to ExchangeRates FX provider..")
|
||||
log.Warnln(log.Global, "CurrencyConverter forex provider no longer supports unset API key requests. Switching to ExchangeRates FX provider..")
|
||||
c.Currency.ForexProviders[i].Enabled = false
|
||||
c.Currency.ForexProviders[i].PrimaryProvider = false
|
||||
c.Currency.ForexProviders[i].APIKey = DefaultUnsetAPIKey
|
||||
@@ -1111,7 +1111,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
}
|
||||
|
||||
if c.Currency.ForexProviders[i].APIKeyLvl == -1 && c.Currency.ForexProviders[i].Name != DefaultForexProviderExchangeRatesAPI {
|
||||
log.Warnf("%s APIKey Level not set, functions limited. Please set this in your config.json file",
|
||||
log.Warnf(log.Global, "%s APIKey Level not set, functions limited. Please set this in your config.json file\n",
|
||||
c.Currency.ForexProviders[i].Name)
|
||||
}
|
||||
count++
|
||||
@@ -1123,7 +1123,7 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
if c.Currency.ForexProviders[x].Name == DefaultForexProviderExchangeRatesAPI {
|
||||
c.Currency.ForexProviders[x].Enabled = true
|
||||
c.Currency.ForexProviders[x].PrimaryProvider = true
|
||||
log.Warn("Using ExchangeRatesAPI for default forex provider.")
|
||||
log.Warnln(log.ConfigMgr, "Using ExchangeRatesAPI for default forex provider.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1139,11 +1139,11 @@ func (c *Config) CheckCurrencyConfigValues() error {
|
||||
if c.Currency.CryptocurrencyProvider.Enabled {
|
||||
if c.Currency.CryptocurrencyProvider.APIkey == "" ||
|
||||
c.Currency.CryptocurrencyProvider.APIkey == DefaultUnsetAPIKey {
|
||||
log.Warnf("CryptocurrencyProvider enabled but api key is unset please set this in your config.json file")
|
||||
log.Warnln(log.ConfigMgr, "CryptocurrencyProvider enabled but api key is unset please set this in your config.json file")
|
||||
}
|
||||
if c.Currency.CryptocurrencyProvider.AccountPlan == "" ||
|
||||
c.Currency.CryptocurrencyProvider.AccountPlan == DefaultUnsetAccountPlan {
|
||||
log.Warnf("CryptocurrencyProvider enabled but account plan is unset please set this in your config.json file")
|
||||
log.Warnln(log.ConfigMgr, "CryptocurrencyProvider enabled but account plan is unset please set this in your config.json file")
|
||||
}
|
||||
} else {
|
||||
if c.Currency.CryptocurrencyProvider.APIkey == "" {
|
||||
@@ -1248,34 +1248,34 @@ func (c *Config) CheckLoggerConfig() error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
// check if enabled is nil or level is a blank string
|
||||
if c.Logging.Enabled == nil || c.Logging.Level == "" {
|
||||
// Creates a new pointer to bool and sets it as true
|
||||
t := func(t bool) *bool { return &t }(true)
|
||||
|
||||
log.Warn("Missing or invalid config settings using safe defaults")
|
||||
|
||||
// Set logger to safe defaults
|
||||
c.Logging = log.Logging{
|
||||
Enabled: t,
|
||||
Level: "DEBUG|INFO|WARN|ERROR|FATAL",
|
||||
ColourOutput: false,
|
||||
File: "debug.txt",
|
||||
Rotate: false,
|
||||
}
|
||||
log.Logger = &c.Logging
|
||||
} else {
|
||||
log.Logger = &c.Logging
|
||||
if c.Logging.Enabled == nil || c.Logging.Output == "" {
|
||||
c.Logging = log.GenDefaultSettings()
|
||||
}
|
||||
|
||||
if len(c.Logging.File) > 0 {
|
||||
logPath := filepath.Join(common.GetDefaultDataDir(runtime.GOOS), "logs")
|
||||
err := common.CreateDir(logPath)
|
||||
if err != nil {
|
||||
return err
|
||||
f := func(f bool) *bool { return &f }(false)
|
||||
|
||||
if c.Logging.LoggerFileConfig != nil {
|
||||
if c.Logging.LoggerFileConfig.FileName == "" {
|
||||
c.Logging.LoggerFileConfig.FileName = "log.txt"
|
||||
}
|
||||
log.LogPath = logPath
|
||||
if c.Logging.LoggerFileConfig.Rotate == nil {
|
||||
c.Logging.LoggerFileConfig.Rotate = f
|
||||
}
|
||||
if c.Logging.LoggerFileConfig.MaxSize < 0 {
|
||||
c.Logging.LoggerFileConfig.MaxSize = 100
|
||||
}
|
||||
log.FileLoggingConfiguredCorrectly = true
|
||||
}
|
||||
|
||||
log.GlobalLogConfig = &c.Logging
|
||||
|
||||
logPath := filepath.Join(common.GetDefaultDataDir(runtime.GOOS), "logs")
|
||||
err := common.CreateDir(logPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.LogPath = logPath
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1295,7 +1295,7 @@ func (c *Config) CheckNTPConfig() {
|
||||
}
|
||||
|
||||
if len(c.NTPClient.Pool) < 1 {
|
||||
log.Warn("NTPClient enabled with no servers configured, enabling default pool.")
|
||||
log.Warnln(log.ConfigMgr, "NTPClient enabled with no servers configured, enabling default pool.")
|
||||
c.NTPClient.Pool = []string{"pool.ntp.org:123"}
|
||||
}
|
||||
}
|
||||
@@ -1306,8 +1306,8 @@ func (c *Config) DisableNTPCheck(input io.Reader) (string, error) {
|
||||
defer m.Unlock()
|
||||
|
||||
reader := bufio.NewReader(input)
|
||||
log.Warn("Your system time is out of sync, this may cause issues with trading.")
|
||||
log.Warn("How would you like to show future notifications? (a)lert / (w)arn / (d)isable. \n")
|
||||
log.Warnln(log.ConfigMgr, "Your system time is out of sync, this may cause issues with trading.")
|
||||
log.Warnln(log.ConfigMgr, "How would you like to show future notifications? (a)lert / (w)arn / (d)isable.")
|
||||
|
||||
var answered = false
|
||||
for ok := true; ok; ok = (!answered) {
|
||||
@@ -1395,13 +1395,13 @@ func GetFilePath(file string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Debugf("Renamed old config file %s to %s", oldDirs[x], newDirs[0])
|
||||
log.Debugf(log.ConfigMgr, "Renamed old config file %s to %s\n", oldDirs[x], newDirs[0])
|
||||
} else {
|
||||
err = os.Rename(oldDirs[x], newDirs[1])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Debugf("Renamed old config file %s to %s", oldDirs[x], newDirs[1])
|
||||
log.Debugf(log.ConfigMgr, "Renamed old config file %s to %s\n", oldDirs[x], newDirs[1])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1484,7 +1484,7 @@ func (c *Config) ReadConfig(configPath string) error {
|
||||
}
|
||||
key, err := PromptForConfigKey(IsInitialSetup)
|
||||
if err != nil {
|
||||
log.Errorf("PromptForConfigKey err: %s", err)
|
||||
log.Errorf(log.ConfigMgr, "PromptForConfigKey err: %s", err)
|
||||
errCounter++
|
||||
continue
|
||||
}
|
||||
@@ -1493,7 +1493,7 @@ func (c *Config) ReadConfig(configPath string) error {
|
||||
f = append(f, file...)
|
||||
data, err := DecryptConfigFile(f, key)
|
||||
if err != nil {
|
||||
log.Errorf("DecryptConfigFile err: %s", err)
|
||||
log.Errorf(log.ConfigMgr, "DecryptConfigFile err: %s", err)
|
||||
errCounter++
|
||||
continue
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ func (c *Config) ReadConfig(configPath string) error {
|
||||
err = ConfirmConfigJSON(data, &c)
|
||||
if err != nil {
|
||||
if errCounter < configMaxAuthFailures {
|
||||
log.Errorf("Invalid password.")
|
||||
log.Error(log.ConfigMgr, "Invalid password.")
|
||||
}
|
||||
errCounter++
|
||||
continue
|
||||
@@ -1591,7 +1591,7 @@ func (c *Config) CheckRemoteControlConfig() {
|
||||
func (c *Config) CheckConfig() error {
|
||||
err := c.CheckLoggerConfig()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to configure logger. Err: %s", err)
|
||||
log.Errorf(log.ConfigMgr, "Failed to configure logger, some logging features unavailable: %s\n", err)
|
||||
}
|
||||
|
||||
err = c.CheckExchangeConfigValues()
|
||||
@@ -1610,7 +1610,7 @@ func (c *Config) CheckConfig() error {
|
||||
}
|
||||
|
||||
if c.GlobalHTTPTimeout <= 0 {
|
||||
log.Warnf("Global HTTP Timeout value not set, defaulting to %v.", configDefaultHTTPTimeout)
|
||||
log.Warnf(log.ConfigMgr, "Global HTTP Timeout value not set, defaulting to %v.\n", configDefaultHTTPTimeout)
|
||||
c.GlobalHTTPTimeout = configDefaultHTTPTimeout
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
gctcrypto "github.com/thrasher-/gocryptotrader/common/crypto"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
"golang.org/x/crypto/scrypt"
|
||||
)
|
||||
|
||||
@@ -34,7 +33,7 @@ var (
|
||||
|
||||
// PromptForConfigEncryption asks for encryption key
|
||||
func (c *Config) PromptForConfigEncryption() bool {
|
||||
log.Infof("Would you like to encrypt your config file (y/n)?")
|
||||
fmt.Println("Would you like to encrypt your config file (y/n)?")
|
||||
|
||||
input := ""
|
||||
_, err := fmt.Scanln(&input)
|
||||
@@ -55,7 +54,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
|
||||
var cryptoKey []byte
|
||||
|
||||
for {
|
||||
log.Println("Please enter in your password: ")
|
||||
fmt.Println("Please enter in your password: ")
|
||||
pwPrompt := func(i *[]byte) error {
|
||||
_, err := fmt.Scanln(i)
|
||||
return err
|
||||
@@ -73,7 +72,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
|
||||
}
|
||||
|
||||
var p2 []byte
|
||||
log.Println("Please re-enter your password: ")
|
||||
fmt.Println("Please re-enter your password: ")
|
||||
err = pwPrompt(&p2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
|
||||
cryptoKey = p1
|
||||
break
|
||||
}
|
||||
log.Printf("Passwords did not match, please try again.")
|
||||
fmt.Printf("Passwords did not match, please try again.")
|
||||
}
|
||||
return cryptoKey, nil
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ func TestCheckLoggerConfig(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.Logging = log.Logging{}
|
||||
c.Logging = log.Config{}
|
||||
err = c.CheckLoggerConfig()
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create default logger reason: %v", err)
|
||||
|
||||
@@ -16,7 +16,7 @@ type Config struct {
|
||||
Name string `json:"name"`
|
||||
EncryptConfig int `json:"encryptConfig"`
|
||||
GlobalHTTPTimeout time.Duration `json:"globalHTTPTimeout"`
|
||||
Logging log.Logging `json:"logging"`
|
||||
Logging log.Config `json:"logging"`
|
||||
ConnectionMonitor ConnectionMonitorConfig `json:"connectionMonitor"`
|
||||
Profiler ProfilerConfig `json:"profiler"`
|
||||
NTPClient NTPClientConfig `json:"ntpclient"`
|
||||
|
||||
@@ -4,10 +4,24 @@
|
||||
"globalHTTPTimeout": 15000000000,
|
||||
"logging": {
|
||||
"enabled": true,
|
||||
"file": "debug.txt",
|
||||
"colour": false,
|
||||
"level": "DEBUG|WARN|INFO|ERROR|FATAL",
|
||||
"rotate": false
|
||||
"level": "INFO|WARN|DEBUG|ERROR",
|
||||
"output": "console",
|
||||
"fileSettings": {
|
||||
"filename": "log.txt",
|
||||
"rotate": true,
|
||||
"maxsize": 250
|
||||
},
|
||||
"advancedSettings": {
|
||||
"spacer": " | ",
|
||||
"timeStampFormat": "02/01/2006 15:04:05",
|
||||
"headers": {
|
||||
"info": "[INFO] ",
|
||||
"warn": "[WARN] ",
|
||||
"debug": "[DEBUG]",
|
||||
"error": "[ERROR]"
|
||||
}
|
||||
},
|
||||
"subloggers": []
|
||||
},
|
||||
"profiler": {
|
||||
"enabled": false
|
||||
@@ -1322,4 +1336,4 @@
|
||||
"checkInterval": 1000000000
|
||||
},
|
||||
"fiatDispayCurrency": ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ func New(dnsList, domainList []string, checkInterval time.Duration) (*Checker, e
|
||||
}
|
||||
|
||||
if c.connected {
|
||||
log.Debug(ConnFound)
|
||||
log.Debugln(log.Global, ConnFound)
|
||||
} else {
|
||||
log.Warnf(ConnNotFound)
|
||||
log.Warnln(log.Global, ConnNotFound)
|
||||
}
|
||||
|
||||
c.shutdown = make(chan struct{}, 1)
|
||||
@@ -137,7 +137,7 @@ func (c *Checker) connectionTest() {
|
||||
if err == nil {
|
||||
c.Lock()
|
||||
if !c.connected {
|
||||
log.Debug(ConnRe)
|
||||
log.Debugln(log.Global, ConnRe)
|
||||
c.connected = true
|
||||
}
|
||||
c.Unlock()
|
||||
@@ -150,7 +150,7 @@ func (c *Checker) connectionTest() {
|
||||
if err == nil {
|
||||
c.Lock()
|
||||
if !c.connected {
|
||||
log.Debug(ConnRe)
|
||||
log.Debugln(log.Global, ConnRe)
|
||||
c.connected = true
|
||||
}
|
||||
c.Unlock()
|
||||
@@ -160,7 +160,7 @@ func (c *Checker) connectionTest() {
|
||||
|
||||
c.Lock()
|
||||
if c.connected {
|
||||
log.Warn(ConnLost)
|
||||
log.Warnln(log.Global, ConnLost)
|
||||
c.connected = false
|
||||
}
|
||||
c.Unlock()
|
||||
|
||||
@@ -86,7 +86,7 @@ func (c *Coinmarketcap) Setup(conf Settings) {
|
||||
} else {
|
||||
err := c.SetAccountPlan(conf.AccountPlan)
|
||||
if err != nil {
|
||||
log.Errorf("CoinMarketCap enabled but SetAccountPlan failed. Err: %s", err)
|
||||
log.Errorf(log.Global, "CoinMarketCap enabled but SetAccountPlan failed. Err: %s\n", err)
|
||||
return
|
||||
}
|
||||
c.Enabled = true
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
func areAPICredtionalsSet(minAllowable uint8) bool {
|
||||
if apiAccountPlanLevel != "" && apikey != "" {
|
||||
if err := c.CheckAccountPlan(minAllowable); err != nil {
|
||||
log.Warn("coinmarketpcap test suite - account plan not allowed for function, please review or upgrade plan to test")
|
||||
log.Warn(log.Global, "coinmarketpcap test suite - account plan not allowed for function, please review or upgrade plan to test")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -76,13 +76,15 @@ func (c *ConversionRates) Register(from, to Code) (Conversion, error) {
|
||||
|
||||
p, ok := c.m[from.Item][to.Item]
|
||||
if !ok {
|
||||
log.Errorf("currency conversion rate not found from %s to %s", from, to)
|
||||
log.Errorf(log.Global,
|
||||
"currency conversion rate not found from %s to %s\n", from, to)
|
||||
return Conversion{}, errors.New("no rate found")
|
||||
}
|
||||
|
||||
i, ok := c.m[to.Item][from.Item]
|
||||
if !ok {
|
||||
log.Errorf("currency conversion inversion rate not found from %s to %s",
|
||||
log.Errorf(log.Global,
|
||||
"currency conversion inversion rate not found from %s to %s\n",
|
||||
to,
|
||||
from)
|
||||
return Conversion{}, errors.New("no rate found")
|
||||
@@ -100,7 +102,7 @@ func (c *ConversionRates) Update(m map[string]float64) error {
|
||||
}
|
||||
|
||||
if storage.IsVerbose() {
|
||||
log.Debug("Conversion rates are being updated.")
|
||||
log.Debugln(log.Global, "Conversion rates are being updated.")
|
||||
}
|
||||
|
||||
solidvalues := make(map[Code]map[Code]float64)
|
||||
@@ -197,7 +199,8 @@ func (c *ConversionRates) Update(m map[string]float64) error {
|
||||
crossRate = 1 / v
|
||||
}
|
||||
if storage.IsVerbose() {
|
||||
log.Debugf("Conversion from %s to %s deriving cross rate value %f",
|
||||
log.Debugf(log.Global,
|
||||
"Conversion from %s to %s deriving cross rate value %f\n",
|
||||
base,
|
||||
term,
|
||||
crossRate)
|
||||
|
||||
@@ -76,7 +76,7 @@ func (c *CurrencyConverter) GetRates(baseCurrency, symbols string) (map[string]f
|
||||
batch := completedStrings[i : i+2]
|
||||
result, err := c.ConvertMany(batch)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get batch err: %s", err)
|
||||
log.Errorf(log.Global, "Failed to get batch err: %s\n", err)
|
||||
continue
|
||||
}
|
||||
for k, v := range result {
|
||||
|
||||
@@ -57,7 +57,8 @@ type CurrencyLayer struct {
|
||||
// Setup sets appropriate values for CurrencyLayer
|
||||
func (c *CurrencyLayer) Setup(config base.Settings) error {
|
||||
if config.APIKeyLvl < 0 || config.APIKeyLvl > 3 {
|
||||
log.Errorf("apikey incorrectly set in config.json for %s, please set appropriate account levels",
|
||||
log.Errorf(log.Global,
|
||||
"apikey incorrectly set in config.json for %s, please set appropriate account levels\n",
|
||||
config.Name)
|
||||
return errors.New("apikey set failure")
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ func cleanCurrencies(baseCurrency, symbols string) string {
|
||||
|
||||
// remove and warn about any unsupported currencies
|
||||
if !strings.Contains(exchangeRatesSupportedCurrencies, x) { // nolint:gocritic
|
||||
log.Warnf("Forex provider ExchangeRatesAPI does not support currency %s, removing from forex rates query.", x)
|
||||
log.Warnf(log.Global,
|
||||
"Forex provider ExchangeRatesAPI does not support currency %s, removing from forex rates query.\n", x)
|
||||
continue
|
||||
}
|
||||
cleanedCurrencies = append(cleanedCurrencies, x)
|
||||
|
||||
@@ -51,7 +51,8 @@ type Fixer struct {
|
||||
// Setup sets appropriate values for fixer object
|
||||
func (f *Fixer) Setup(config base.Settings) error {
|
||||
if config.APIKeyLvl < 0 || config.APIKeyLvl > 4 {
|
||||
log.Errorf("apikey incorrectly set in config.json for %s, please set appropriate account levels",
|
||||
log.Errorf(log.Global,
|
||||
"apikey incorrectly set in config.json for %s, please set appropriate account levels\n",
|
||||
config.Name)
|
||||
return errors.New("apikey set failure")
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@ type OXR struct {
|
||||
// Setup sets values for the OXR object
|
||||
func (o *OXR) Setup(config base.Settings) error {
|
||||
if config.APIKeyLvl < 0 || config.APIKeyLvl > 2 {
|
||||
log.Errorf("apikey incorrectly set in config.json for %s, please set appropriate account levels",
|
||||
log.Errorf(log.Global,
|
||||
"apikey incorrectly set in config.json for %s, please set appropriate account levels\n",
|
||||
config.Name)
|
||||
return errors.New("apikey set failure")
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ func (p Pairs) Format(delimiter, index string, uppercase bool) Pairs {
|
||||
if index != "" {
|
||||
newP, err := NewPairFromIndex(p[i].String(), index)
|
||||
if err != nil {
|
||||
log.Errorf("failed to create NewPairFromIndex. Err: %s", err)
|
||||
log.Errorf(log.Global,
|
||||
"failed to create NewPairFromIndex. Err: %s\n", err)
|
||||
continue
|
||||
}
|
||||
formattedPair.Base = newP.Base
|
||||
|
||||
@@ -113,10 +113,13 @@ func (s *Storage) RunUpdater(overrides BotOverrides, settings *MainConfiguration
|
||||
return errors.New("currency storage error, no fiat display currency set in config")
|
||||
}
|
||||
s.baseCurrency = settings.FiatDisplayCurrency
|
||||
log.Debugf("Fiat display currency: %s.", s.baseCurrency)
|
||||
log.Debugf(log.Global,
|
||||
"Fiat display currency: %s.\n", s.baseCurrency)
|
||||
|
||||
if settings.CryptocurrencyProvider.Enabled {
|
||||
log.Debugf("Setting up currency analysis system with Coinmarketcap...")
|
||||
log.Debugln(
|
||||
log.Global,
|
||||
"Setting up currency analysis system with Coinmarketcap...")
|
||||
c := &coinmarketcap.Coinmarketcap{}
|
||||
c.SetDefaults()
|
||||
c.Setup(coinmarketcap.Settings{
|
||||
@@ -200,11 +203,13 @@ func (s *Storage) RunUpdater(overrides BotOverrides, settings *MainConfiguration
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Primary foreign exchange conversion provider %s enabled",
|
||||
log.Debugf(log.Global,
|
||||
"Primary foreign exchange conversion provider %s enabled\n",
|
||||
s.fiatExchangeMarkets.Primary.Provider.GetName())
|
||||
|
||||
for i := range s.fiatExchangeMarkets.Support {
|
||||
log.Debugf("Support forex conversion provider %s enabled",
|
||||
log.Debugf(log.Global,
|
||||
"Support forex conversion provider %s enabled\n",
|
||||
s.fiatExchangeMarkets.Support[i].Provider.GetName())
|
||||
}
|
||||
|
||||
@@ -212,7 +217,8 @@ func (s *Storage) RunUpdater(overrides BotOverrides, settings *MainConfiguration
|
||||
// until this system initially updates
|
||||
go s.ForeignExchangeUpdater()
|
||||
} else {
|
||||
log.Warnf("No foreign exchange providers enabled in config.json")
|
||||
log.Warnln(log.Global,
|
||||
"No foreign exchange providers enabled in config.json")
|
||||
s.mtx.Unlock()
|
||||
}
|
||||
|
||||
@@ -258,19 +264,20 @@ func (s *Storage) SetupForexProviders(setting ...base.Settings) error {
|
||||
// ForeignExchangeUpdater is a routine that seeds foreign exchange rate and keeps
|
||||
// updated as fast as possible
|
||||
func (s *Storage) ForeignExchangeUpdater() {
|
||||
log.Debugf("Foreign exchange updater started, seeding FX rate list..")
|
||||
log.Debugln(log.Global,
|
||||
"Foreign exchange updater started, seeding FX rate list..")
|
||||
|
||||
s.wg.Add(1)
|
||||
defer s.wg.Done()
|
||||
|
||||
err := s.SeedCurrencyAnalysisData()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.Global, err)
|
||||
}
|
||||
|
||||
err = s.SeedForeignExchangeRates()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.Global, err)
|
||||
}
|
||||
|
||||
// Unlock main rate retrieval mutex so all routines waiting can get access
|
||||
@@ -291,13 +298,13 @@ func (s *Storage) ForeignExchangeUpdater() {
|
||||
case <-SeedForeignExchangeTick.C:
|
||||
err := s.SeedForeignExchangeRates()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.Global, err)
|
||||
}
|
||||
|
||||
case <-SeedCurrencyAnalysisTick.C:
|
||||
err := s.SeedCurrencyAnalysisData()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorln(log.Global, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +351,8 @@ func (s *Storage) SeedCurrencyAnalysisData() error {
|
||||
// loads it into memory
|
||||
func (s *Storage) FetchCurrencyAnalysisData() error {
|
||||
if s.currencyAnalysis == nil {
|
||||
log.Warn("Currency analysis system offline, please set api keys for coinmarketcap if you wish to use this feature.")
|
||||
log.Warnln(log.Global,
|
||||
"Currency analysis system offline, please set api keys for coinmarketcap if you wish to use this feature.")
|
||||
return errors.New("currency analysis system offline")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
)
|
||||
|
||||
const (
|
||||
testBTCAddress = "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX"
|
||||
)
|
||||
|
||||
func TestSeed(t *testing.T) {
|
||||
var d DepositAddressStore
|
||||
u := map[string]map[string]string{
|
||||
"BITSTAMP": map[string]string{
|
||||
"BTC": testBTCAddress,
|
||||
},
|
||||
}
|
||||
|
||||
d.Seed(u)
|
||||
r, err := d.GetDepositAddress("BITSTAMP", currency.BTC)
|
||||
if err != nil {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
|
||||
if r != testBTCAddress {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDepositAddress(t *testing.T) {
|
||||
var d DepositAddressStore
|
||||
_, err := d.GetDepositAddress("", currency.BTC)
|
||||
if err != ErrDepositAddressStoreIsNil {
|
||||
t.Error("non-error on non-existent exchange")
|
||||
}
|
||||
|
||||
d.Store = map[string]map[string]string{
|
||||
"BITSTAMP": map[string]string{
|
||||
"BTC": testBTCAddress,
|
||||
},
|
||||
}
|
||||
|
||||
_, err = d.GetDepositAddress("", currency.BTC)
|
||||
if err != ErrExchangeNotFound {
|
||||
t.Error("non-error on non-existent exchange")
|
||||
}
|
||||
|
||||
var r string
|
||||
r, err = d.GetDepositAddress("BiTStAmP", currency.NewCode("bTC"))
|
||||
if err != nil {
|
||||
t.Error("unexpected err: ", err)
|
||||
}
|
||||
|
||||
if r != testBTCAddress {
|
||||
t.Error("unexpected BTC address: ", r)
|
||||
}
|
||||
|
||||
_, err = d.GetDepositAddress("BiTStAmP", currency.LTC)
|
||||
if err != ErrDepositAddressNotFound {
|
||||
t.Error("unexpected err: ", err)
|
||||
}
|
||||
}
|
||||
package engine
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
)
|
||||
|
||||
const (
|
||||
testBTCAddress = "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX"
|
||||
)
|
||||
|
||||
func TestSeed(t *testing.T) {
|
||||
var d DepositAddressStore
|
||||
u := map[string]map[string]string{
|
||||
"BITSTAMP": {
|
||||
"BTC": testBTCAddress,
|
||||
},
|
||||
}
|
||||
|
||||
d.Seed(u)
|
||||
r, err := d.GetDepositAddress("BITSTAMP", currency.BTC)
|
||||
if err != nil {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
|
||||
if r != testBTCAddress {
|
||||
t.Error("unexpected result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDepositAddress(t *testing.T) {
|
||||
var d DepositAddressStore
|
||||
_, err := d.GetDepositAddress("", currency.BTC)
|
||||
if err != ErrDepositAddressStoreIsNil {
|
||||
t.Error("non-error on non-existent exchange")
|
||||
}
|
||||
|
||||
d.Store = map[string]map[string]string{
|
||||
"BITSTAMP": {
|
||||
"BTC": testBTCAddress,
|
||||
},
|
||||
}
|
||||
|
||||
_, err = d.GetDepositAddress("", currency.BTC)
|
||||
if err != ErrExchangeNotFound {
|
||||
t.Error("non-error on non-existent exchange")
|
||||
}
|
||||
|
||||
var r string
|
||||
r, err = d.GetDepositAddress("BiTStAmP", currency.NewCode("bTC"))
|
||||
if err != nil {
|
||||
t.Error("unexpected err: ", err)
|
||||
}
|
||||
|
||||
if r != testBTCAddress {
|
||||
t.Error("unexpected BTC address: ", r)
|
||||
}
|
||||
|
||||
_, err = d.GetDepositAddress("BiTStAmP", currency.LTC)
|
||||
if err != ErrDepositAddressNotFound {
|
||||
t.Error("unexpected err: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (c *commsManager) Start() (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debugln("Communications manager starting...")
|
||||
log.Debugln(log.CommunicationMgr, "Communications manager starting...")
|
||||
commsCfg := Bot.Config.GetCommunicationsConfig()
|
||||
c.comms, err = communications.NewComm(&commsCfg)
|
||||
if err != nil {
|
||||
@@ -43,7 +43,7 @@ func (c *commsManager) Start() (err error) {
|
||||
c.shutdown = make(chan struct{})
|
||||
c.relayMsg = make(chan base.Event)
|
||||
go c.run()
|
||||
log.Debugln("Communications manager started.")
|
||||
log.Debugln(log.CommunicationMgr, "Communications manager started.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (c *commsManager) Stop() error {
|
||||
}
|
||||
|
||||
close(c.shutdown)
|
||||
log.Debugln("Communications manager shutting down...")
|
||||
log.Debugln(log.CommunicationMgr, "Communications manager shutting down...")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (c *commsManager) run() {
|
||||
// TO-DO shutdown comms connections for connected services (Slack etc)
|
||||
atomic.CompareAndSwapInt32(&c.stopped, 1, 0)
|
||||
atomic.CompareAndSwapInt32(&c.started, 1, 0)
|
||||
log.Debugln("Communications manager shutdown.")
|
||||
log.Debugln(log.CommunicationMgr, "Communications manager shutdown.")
|
||||
}()
|
||||
|
||||
for {
|
||||
|
||||
@@ -24,7 +24,7 @@ func (c *connectionManager) Start() error {
|
||||
return errors.New("connection manager already started")
|
||||
}
|
||||
|
||||
log.Debugln("Connection manager starting...")
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager starting...")
|
||||
var err error
|
||||
c.conn, err = connchecker.New(Bot.Config.ConnectionMonitor.DNSList,
|
||||
Bot.Config.ConnectionMonitor.PublicDomainList,
|
||||
@@ -34,7 +34,7 @@ func (c *connectionManager) Start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugln("Connection manager started.")
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager started.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -47,17 +47,17 @@ func (c *connectionManager) Stop() error {
|
||||
return errors.New("connection manager is already stopped")
|
||||
}
|
||||
|
||||
log.Debugln("Connection manager shutting down...")
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager shutting down...")
|
||||
c.conn.Shutdown()
|
||||
atomic.CompareAndSwapInt32(&c.stopped, 1, 0)
|
||||
atomic.CompareAndSwapInt32(&c.started, 1, 0)
|
||||
log.Debugln("Connection manager stopped.")
|
||||
log.Debugln(log.ConnectionMgr, "Connection manager stopped.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *connectionManager) IsOnline() bool {
|
||||
if c.conn == nil {
|
||||
log.Warnf("Connection manager: IsOnline called but conn is nil")
|
||||
log.Warnln(log.ConnectionMgr, "Connection manager: IsOnline called but conn is nil")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
163
engine/engine.go
163
engine/engine.go
@@ -72,7 +72,8 @@ func NewFromSettings(settings *Settings) (*Engine, error) {
|
||||
|
||||
var b Engine
|
||||
b.Config = &config.Cfg
|
||||
log.Debugf("Loading config file %s...\n", settings.ConfigFile)
|
||||
|
||||
log.Debugf(log.Global, "Loading config file %s..\n", settings.ConfigFile)
|
||||
err := b.Config.LoadConfig(settings.ConfigFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load config. Err: %s", err)
|
||||
@@ -83,19 +84,14 @@ func NewFromSettings(settings *Settings) (*Engine, error) {
|
||||
return nil, fmt.Errorf("failed to open/create data directory: %s. Err: %s", settings.DataDir, err)
|
||||
}
|
||||
|
||||
err = log.SetupLogger()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to setup logger. Err: %s", err)
|
||||
if *b.Config.Logging.Enabled {
|
||||
log.SetupGlobalLogger()
|
||||
log.SetupSubLoggers(b.Config.Logging.SubLoggers)
|
||||
}
|
||||
|
||||
b.Settings.ConfigFile = settings.ConfigFile
|
||||
b.Settings.DataDir = settings.DataDir
|
||||
|
||||
if *log.Logger.Enabled {
|
||||
b.Settings.LogFile = log.LogPath
|
||||
log.Debugf("Using log file: %s.\n", log.LogPath)
|
||||
}
|
||||
|
||||
err = utils.AdjustGoMaxProcs(settings.GoMaxProcs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to adjust runtime GOMAXPROCS value. Err: %s", err)
|
||||
@@ -209,100 +205,101 @@ func ValidateSettings(b *Engine, s *Settings) {
|
||||
|
||||
// PrintSettings returns the engine settings
|
||||
func PrintSettings(s *Settings) {
|
||||
log.Debugln()
|
||||
log.Debugf("ENGINE SETTINGS")
|
||||
log.Debugf("- CORE SETTINGS:")
|
||||
log.Debugf("\t Verbose mode: %v", s.Verbose)
|
||||
log.Debugf("\t Enable dry run mode: %v", s.EnableDryRun)
|
||||
log.Debugf("\t Enable all exchanges: %v", s.EnableAllExchanges)
|
||||
log.Debugf("\t Enable all pairs: %v", s.EnableAllPairs)
|
||||
log.Debugf("\t Enable coinmarketcap analaysis: %v", s.EnableCoinmarketcapAnalysis)
|
||||
log.Debugf("\t Enable portfolio manager: %v", s.EnablePortfolioManager)
|
||||
log.Debugf("\t Enable gPRC: %v", s.EnableGRPC)
|
||||
log.Debugf("\t Enable gRPC Proxy: %v", s.EnableGRPCProxy)
|
||||
log.Debugf("\t Enable websocket RPC: %v", s.EnableWebsocketRPC)
|
||||
log.Debugf("\t Enable deprecated RPC: %v", s.EnableDeprecatedRPC)
|
||||
log.Debugf("\t Enable comms relayer: %v", s.EnableCommsRelayer)
|
||||
log.Debugf("\t Enable event manager: %v", s.EnableEventManager)
|
||||
log.Debugf("\t Event manager sleep delay: %v", s.EventManagerDelay)
|
||||
log.Debugf("\t Enable order manager: %v", s.EnableOrderManager)
|
||||
log.Debugf("\t Enable exchange sync manager: %v", s.EnableExchangeSyncManager)
|
||||
log.Debugf("\t Enable deposit address manager: %v\n", s.EnableDepositAddressManager)
|
||||
log.Debugf("\t Enable ticker syncing: %v", s.EnableTickerSyncing)
|
||||
log.Debugf("\t Enable orderbook syncing: %v", s.EnableOrderbookSyncing)
|
||||
log.Debugf("\t Enable websocket routine: %v\n", s.EnableWebsocketRoutine)
|
||||
log.Debugf("\t Enable NTP client: %v", s.EnableNTPClient)
|
||||
log.Debugf("- FOREX SETTINGS:")
|
||||
log.Debugf("\t Enable currency conveter: %v", s.EnableCurrencyConverter)
|
||||
log.Debugf("\t Enable currency layer: %v", s.EnableCurrencyLayer)
|
||||
log.Debugf("\t Enable fixer: %v", s.EnableFixer)
|
||||
log.Debugf("\t Enable OpenExchangeRates: %v", s.EnableOpenExchangeRates)
|
||||
log.Debugf("- EXCHANGE SETTINGS:")
|
||||
log.Debugf("\t Enable exchange auto pair updates: %v", s.EnableExchangeAutoPairUpdates)
|
||||
log.Debugf("\t Disable all exchange auto pair updates: %v", s.DisableExchangeAutoPairUpdates)
|
||||
log.Debugf("\t Enable exchange websocket support: %v", s.EnableExchangeWebsocketSupport)
|
||||
log.Debugf("\t Enable exchange verbose mode: %v", s.EnableExchangeVerbose)
|
||||
log.Debugf("\t Enable exchange HTTP rate limiter: %v", s.EnableExchangeHTTPRateLimiter)
|
||||
log.Debugf("\t Enable exchange HTTP debugging: %v", s.EnableExchangeHTTPDebugging)
|
||||
log.Debugf("\t Exchange max HTTP request jobs: %v", s.MaxHTTPRequestJobsLimit)
|
||||
log.Debugf("\t Exchange HTTP request timeout retry amount: %v", s.RequestTimeoutRetryAttempts)
|
||||
log.Debugf("\t Exchange HTTP timeout: %v", s.ExchangeHTTPTimeout)
|
||||
log.Debugf("\t Exchange HTTP user agent: %v", s.ExchangeHTTPUserAgent)
|
||||
log.Debugf("\t Exchange HTTP proxy: %v\n", s.ExchangeHTTPProxy)
|
||||
log.Debugf("- COMMON SETTINGS:")
|
||||
log.Debugf("\t Global HTTP timeout: %v", s.GlobalHTTPTimeout)
|
||||
log.Debugf("\t Global HTTP user agent: %v", s.GlobalHTTPUserAgent)
|
||||
log.Debugf("\t Global HTTP proxy: %v", s.ExchangeHTTPProxy)
|
||||
log.Debugln()
|
||||
log.Debugln(log.Global)
|
||||
log.Debugf(log.Global, "ENGINE SETTINGS")
|
||||
log.Debugf(log.Global, "- CORE SETTINGS:")
|
||||
log.Debugf(log.Global, "\t Verbose mode: %v", s.Verbose)
|
||||
log.Debugf(log.Global, "\t Enable dry run mode: %v", s.EnableDryRun)
|
||||
log.Debugf(log.Global, "\t Enable all exchanges: %v", s.EnableAllExchanges)
|
||||
log.Debugf(log.Global, "\t Enable all pairs: %v", s.EnableAllPairs)
|
||||
log.Debugf(log.Global, "\t Enable coinmarketcap analaysis: %v", s.EnableCoinmarketcapAnalysis)
|
||||
log.Debugf(log.Global, "\t Enable portfolio manager: %v", s.EnablePortfolioManager)
|
||||
log.Debugf(log.Global, "\t Enable gPRC: %v", s.EnableGRPC)
|
||||
log.Debugf(log.Global, "\t Enable gRPC Proxy: %v", s.EnableGRPCProxy)
|
||||
log.Debugf(log.Global, "\t Enable websocket RPC: %v", s.EnableWebsocketRPC)
|
||||
log.Debugf(log.Global, "\t Enable deprecated RPC: %v", s.EnableDeprecatedRPC)
|
||||
log.Debugf(log.Global, "\t Enable comms relayer: %v", s.EnableCommsRelayer)
|
||||
log.Debugf(log.Global, "\t Enable event manager: %v", s.EnableEventManager)
|
||||
log.Debugf(log.Global, "\t Event manager sleep delay: %v", s.EventManagerDelay)
|
||||
log.Debugf(log.Global, "\t Enable order manager: %v", s.EnableOrderManager)
|
||||
log.Debugf(log.Global, "\t Enable exchange sync manager: %v", s.EnableExchangeSyncManager)
|
||||
log.Debugf(log.Global, "\t Enable deposit address manager: %v\n", s.EnableDepositAddressManager)
|
||||
log.Debugf(log.Global, "\t Enable ticker syncing: %v", s.EnableTickerSyncing)
|
||||
log.Debugf(log.Global, "\t Enable orderbook syncing: %v", s.EnableOrderbookSyncing)
|
||||
log.Debugf(log.Global, "\t Enable websocket routine: %v\n", s.EnableWebsocketRoutine)
|
||||
log.Debugf(log.Global, "\t Enable NTP client: %v", s.EnableNTPClient)
|
||||
log.Debugf(log.Global, "- FOREX SETTINGS:")
|
||||
log.Debugf(log.Global, "\t Enable currency conveter: %v", s.EnableCurrencyConverter)
|
||||
log.Debugf(log.Global, "\t Enable currency layer: %v", s.EnableCurrencyLayer)
|
||||
log.Debugf(log.Global, "\t Enable fixer: %v", s.EnableFixer)
|
||||
log.Debugf(log.Global, "\t Enable OpenExchangeRates: %v", s.EnableOpenExchangeRates)
|
||||
log.Debugf(log.Global, "- EXCHANGE SETTINGS:")
|
||||
log.Debugf(log.Global, "\t Enable exchange auto pair updates: %v", s.EnableExchangeAutoPairUpdates)
|
||||
log.Debugf(log.Global, "\t Disable all exchange auto pair updates: %v", s.DisableExchangeAutoPairUpdates)
|
||||
log.Debugf(log.Global, "\t Enable exchange websocket support: %v", s.EnableExchangeWebsocketSupport)
|
||||
log.Debugf(log.Global, "\t Enable exchange verbose mode: %v", s.EnableExchangeVerbose)
|
||||
log.Debugf(log.Global, "\t Enable exchange HTTP rate limiter: %v", s.EnableExchangeHTTPRateLimiter)
|
||||
log.Debugf(log.Global, "\t Enable exchange HTTP debugging: %v", s.EnableExchangeHTTPDebugging)
|
||||
log.Debugf(log.Global, "\t Exchange max HTTP request jobs: %v", s.MaxHTTPRequestJobsLimit)
|
||||
log.Debugf(log.Global, "\t Exchange HTTP request timeout retry amount: %v", s.RequestTimeoutRetryAttempts)
|
||||
log.Debugf(log.Global, "\t Exchange HTTP timeout: %v", s.ExchangeHTTPTimeout)
|
||||
log.Debugf(log.Global, "\t Exchange HTTP user agent: %v", s.ExchangeHTTPUserAgent)
|
||||
log.Debugf(log.Global, "\t Exchange HTTP proxy: %v\n", s.ExchangeHTTPProxy)
|
||||
log.Debugf(log.Global, "- COMMON SETTINGS:")
|
||||
log.Debugf(log.Global, "\t Global HTTP timeout: %v", s.GlobalHTTPTimeout)
|
||||
log.Debugf(log.Global, "\t Global HTTP user agent: %v", s.GlobalHTTPUserAgent)
|
||||
log.Debugf(log.Global, "\t Global HTTP proxy: %v", s.ExchangeHTTPProxy)
|
||||
log.Debugln(log.Global)
|
||||
}
|
||||
|
||||
// Start starts the engine
|
||||
func (e *Engine) Start() {
|
||||
if e == nil {
|
||||
log.Fatal("Engine instance is nil")
|
||||
log.Errorln(log.Global, "Engine instance is nil")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Sets up internet connectivity monitor
|
||||
if e.Settings.EnableConnectivityMonitor {
|
||||
if err := e.ConnectionManager.Start(); err != nil {
|
||||
log.Errorf("Connection manager unable to start: %v", err)
|
||||
log.Errorf(log.Global, "Connection manager unable to start: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if e.Settings.EnableNTPClient {
|
||||
if err := e.NTPManager.Start(); err != nil {
|
||||
log.Errorf("NTP manager unable to start: %v", err)
|
||||
log.Errorf(log.Global, "NTP manager unable to start: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
e.Uptime = time.Now()
|
||||
log.Debugf("Bot '%s' started.\n", e.Config.Name)
|
||||
log.Debugf("Using data dir: %s\n", e.Settings.DataDir)
|
||||
log.Debugf(log.Global, "Bot '%s' started.\n", e.Config.Name)
|
||||
log.Debugf(log.Global, "Using data dir: %s\n", e.Settings.DataDir)
|
||||
|
||||
enabledExchanges := e.Config.CountEnabledExchanges()
|
||||
if e.Settings.EnableAllExchanges {
|
||||
enabledExchanges = len(e.Config.Exchanges)
|
||||
}
|
||||
|
||||
log.Debugln()
|
||||
log.Debugln("EXCHANGE COVERAGE")
|
||||
log.Debugf("\t Available Exchanges: %d. Enabled Exchanges: %d.\n",
|
||||
log.Debugln(log.Global, "EXCHANGE COVERAGE")
|
||||
log.Debugf(log.Global, "\t Available Exchanges: %d. Enabled Exchanges: %d.\n",
|
||||
len(e.Config.Exchanges), enabledExchanges)
|
||||
|
||||
if e.Settings.ExchangePurgeCredentials {
|
||||
log.Debugln("Purging exchange API credentials.")
|
||||
log.Debugln(log.Global, "Purging exchange API credentials.")
|
||||
e.Config.PurgeExchangeAPICredentials()
|
||||
}
|
||||
|
||||
log.Debugln("Setting up exchanges..")
|
||||
log.Debugln(log.Global, "Setting up exchanges..")
|
||||
SetupExchanges()
|
||||
if len(e.Exchanges) == 0 {
|
||||
log.Fatalf("No exchanges were able to be loaded. Exiting")
|
||||
log.Errorln(log.Global, "No exchanges were able to be loaded. Exiting")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if e.Settings.EnableCommsRelayer {
|
||||
if err := e.CommsManager.Start(); err != nil {
|
||||
log.Errorf("Communications manager unable to start: %v", err)
|
||||
log.Errorf(log.Global, "Communications manager unable to start: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +326,7 @@ func (e *Engine) Start() {
|
||||
e.Settings.DataDir,
|
||||
e.Settings.Verbose)
|
||||
if err != nil {
|
||||
log.Warn("currency updater system failed to start", err)
|
||||
log.Errorf(log.Global, "currency updater system failed to start %v", err)
|
||||
}
|
||||
|
||||
if e.Settings.EnableGRPC {
|
||||
@@ -347,7 +344,7 @@ func (e *Engine) Start() {
|
||||
|
||||
if e.Settings.EnablePortfolioManager {
|
||||
if err = e.PortfolioManager.Start(); err != nil {
|
||||
log.Errorf("Fund manager unable to start: %v", err)
|
||||
log.Errorf(log.Global, "Fund manager unable to start: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +355,7 @@ func (e *Engine) Start() {
|
||||
|
||||
if e.Settings.EnableOrderManager {
|
||||
if err = e.OrderManager.Start(); err != nil {
|
||||
log.Errorf("Order manager unable to start: %v", err)
|
||||
log.Errorf(log.Global, "Order manager unable to start: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +369,7 @@ func (e *Engine) Start() {
|
||||
|
||||
e.ExchangeCurrencyPairManager, err = NewCurrencyPairSyncer(exchangeSyncCfg)
|
||||
if err != nil {
|
||||
log.Warnf("Unable to initialise exchange currency pair syncer. Err: %s", err)
|
||||
log.Warnf(log.Global, "Unable to initialise exchange currency pair syncer. Err: %s", err)
|
||||
} else {
|
||||
go e.ExchangeCurrencyPairManager.Start()
|
||||
}
|
||||
@@ -388,7 +385,7 @@ func (e *Engine) Start() {
|
||||
|
||||
// Stop correctly shuts down engine saving configuration files
|
||||
func (e *Engine) Stop() {
|
||||
log.Debugln("Engine shutting down..")
|
||||
log.Debugln(log.Global, "Engine shutting down..")
|
||||
|
||||
if len(portfolio.Portfolio.Addresses) != 0 {
|
||||
e.Config.Portfolio = portfolio.Portfolio
|
||||
@@ -396,46 +393,50 @@ func (e *Engine) Stop() {
|
||||
|
||||
if e.OrderManager.Started() {
|
||||
if err := e.OrderManager.Stop(); err != nil {
|
||||
log.Errorf("Order manager unable to stop. Error: %v", err)
|
||||
log.Errorf(log.Global, "Order manager unable to stop. Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if e.NTPManager.Started() {
|
||||
if err := e.NTPManager.Stop(); err != nil {
|
||||
log.Errorf("NTP manager unable to stop. Error: %v", err)
|
||||
log.Errorf(log.Global, "NTP manager unable to stop. Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if e.CommsManager.Started() {
|
||||
if err := e.CommsManager.Stop(); err != nil {
|
||||
log.Errorf("Communication manager unable to stop. Error: %v", err)
|
||||
log.Errorf(log.Global, "Communication manager unable to stop. Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if e.PortfolioManager.Started() {
|
||||
if err := e.PortfolioManager.Stop(); err != nil {
|
||||
log.Errorf("Fund manager unable to stop. Error: %v", err)
|
||||
log.Errorf(log.Global, "Fund manager unable to stop. Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if e.ConnectionManager.Started() {
|
||||
if err := e.ConnectionManager.Stop(); err != nil {
|
||||
log.Errorf("Connection manager unable to stop. Error: %v", err)
|
||||
log.Errorf(log.Global, "Connection manager unable to stop. Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if !e.Settings.EnableDryRun {
|
||||
err := e.Config.SaveConfig(e.Settings.ConfigFile)
|
||||
if err != nil {
|
||||
log.Error("Unable to save config.")
|
||||
log.Errorln(log.Global, "Unable to save config.")
|
||||
} else {
|
||||
log.Debugln("Config file saved successfully.")
|
||||
log.Debugln(log.Global, "Config file saved successfully.")
|
||||
}
|
||||
}
|
||||
// Wait for services to gracefully shutdown
|
||||
e.ServicesWG.Wait()
|
||||
log.Debugln("Exiting.")
|
||||
log.CloseLogFile()
|
||||
log.Debugln(log.Global, "Exiting.")
|
||||
err := log.CloseLogger()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to close logger %v", err)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
@@ -447,7 +448,7 @@ func (e *Engine) handleInterrupt() {
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
sig := <-c
|
||||
log.Debugf("Captured %v, shutdown requested.", sig)
|
||||
log.Debugf(log.Global, "Captured %v, shutdown requested.\n", sig)
|
||||
close(e.Shutdown)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (e *Event) ExecuteAction() bool {
|
||||
if strings.Contains(e.Action, ",") {
|
||||
action := strings.Split(e.Action, ",")
|
||||
if action[0] == ActionSMSNotify {
|
||||
message := fmt.Sprintf("Event triggered: %s", e.String())
|
||||
message := fmt.Sprintf("Event triggered: %s\n", e.String())
|
||||
if action[1] == "ALL" {
|
||||
Bot.CommsManager.PushEvent(base.Event{
|
||||
Type: "event",
|
||||
@@ -135,7 +135,7 @@ func (e *Event) ExecuteAction() bool {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Debugf("Event triggered: %s", e.String())
|
||||
log.Debugf(log.EventMgr, "Event triggered: %s\n", e.String())
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (e *Event) ExecuteAction() bool {
|
||||
// String turns the structure event into a string
|
||||
func (e *Event) String() string {
|
||||
return fmt.Sprintf(
|
||||
"If the %s [%s] %s on %s meets the following %v then %s.", e.Pair.String(),
|
||||
"If the %s [%s] %s on %s meets the following %v then %s.\n", e.Pair.String(),
|
||||
strings.ToUpper(e.Asset.String()), e.Item, e.Exchange, e.Condition, e.Action,
|
||||
)
|
||||
}
|
||||
@@ -152,14 +152,14 @@ func (e *Event) processTicker() bool {
|
||||
t, err := ticker.GetTicker(e.Exchange, e.Pair, e.Asset)
|
||||
if err != nil {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("Events: failed to get ticker. Err: %s", err)
|
||||
log.Debugf(log.EventMgr, "Events: failed to get ticker. Err: %s\n", err)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if t.Last == 0 {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugln("Events: ticker last price is 0")
|
||||
log.Debugln(log.EventMgr, "Events: ticker last price is 0")
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (e *Event) processOrderbook() bool {
|
||||
ob, err := orderbook.Get(e.Exchange, e.Pair, e.Asset)
|
||||
if err != nil {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("Events: Failed to get orderbook. Err: %s", err)
|
||||
log.Debugf(log.EventMgr, "Events: Failed to get orderbook. Err: %s\n", err)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func (e *Event) processOrderbook() bool {
|
||||
result := e.processCondition(subtotal, e.Condition.OrderbookAmount)
|
||||
if result {
|
||||
success = true
|
||||
log.Debugf("Events: Bid Amount: %f Price: %v Subtotal: %v", ob.Bids[x].Amount, ob.Bids[x].Price, subtotal)
|
||||
log.Debugf(log.EventMgr, "Events: Bid Amount: %f Price: %v Subtotal: %v\n", ob.Bids[x].Amount, ob.Bids[x].Price, subtotal)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func (e *Event) processOrderbook() bool {
|
||||
result := e.processCondition(subtotal, e.Condition.OrderbookAmount)
|
||||
if result {
|
||||
success = true
|
||||
log.Debugf("Events: Ask Amount: %f Price: %v Subtotal: %v", ob.Asks[x].Amount, ob.Asks[x].Price, subtotal)
|
||||
log.Debugf(log.EventMgr, "Events: Ask Amount: %f Price: %v Subtotal: %v\n", ob.Asks[x].Amount, ob.Asks[x].Price, subtotal)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ func IsValidEvent(exchange, item string, condition EventConditionParams, action
|
||||
// EventManger is the overarching routine that will iterate through the Events
|
||||
// chain
|
||||
func EventManger() {
|
||||
log.Debugf("EventManager started. SleepDelay: %v", EventSleepDelay.String())
|
||||
log.Debugf(log.EventMgr, "EventManager started. SleepDelay: %v\n", EventSleepDelay.String())
|
||||
|
||||
for {
|
||||
total, executed := GetEventCounter()
|
||||
@@ -289,7 +289,7 @@ func EventManger() {
|
||||
for _, event := range Events {
|
||||
if !event.Executed {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("Events: Processing event %s.", event.String())
|
||||
log.Debugf(log.EventMgr, "Events: Processing event %s.\n", event.String())
|
||||
}
|
||||
success := event.CheckEventCondition()
|
||||
if success {
|
||||
@@ -297,7 +297,7 @@ func EventManger() {
|
||||
"Events: ID: %d triggered on %s successfully [%v]\n", event.ID,
|
||||
event.Exchange, event.String(),
|
||||
)
|
||||
log.Info(msg)
|
||||
log.Infoln(log.EventMgr, msg)
|
||||
Bot.CommsManager.PushEvent(base.Event{Type: "event", Message: msg})
|
||||
event.Executed = true
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func ReloadExchange(name string) error {
|
||||
|
||||
e := GetExchangeByName(name)
|
||||
e.Setup(exchCfg)
|
||||
log.Debugf("%s exchange reloaded successfully.\n", name)
|
||||
log.Debugf(log.ExchangeSys, "%s exchange reloaded successfully.\n", name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -275,13 +275,13 @@ func SetupExchanges() {
|
||||
if CheckExchangeExists(exch.Name) {
|
||||
e := GetExchangeByName(exch.Name)
|
||||
if e == nil {
|
||||
log.Errorf("%s", ErrExchangeNotFound)
|
||||
log.Errorln(log.ExchangeSys, ErrExchangeNotFound)
|
||||
continue
|
||||
}
|
||||
|
||||
err := ReloadExchange(exch.Name)
|
||||
if err != nil {
|
||||
log.Errorf("ReloadExchange %s failed: %s", exch.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "ReloadExchange %s failed: %s\n", exch.Name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -293,15 +293,15 @@ func SetupExchanges() {
|
||||
|
||||
}
|
||||
if !exch.Enabled && !Bot.Settings.EnableAllExchanges {
|
||||
log.Debugf("%s: Exchange support: Disabled", exch.Name)
|
||||
log.Debugf(log.ExchangeSys, "%s: Exchange support: Disabled\n", exch.Name)
|
||||
continue
|
||||
}
|
||||
err := LoadExchange(exch.Name, true, &wg)
|
||||
if err != nil {
|
||||
log.Errorf("LoadExchange %s failed: %s", exch.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "LoadExchange %s failed: %s\n", exch.Name, err)
|
||||
continue
|
||||
}
|
||||
log.Debugf(
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s: Exchange support: Enabled (Authenticated API support: %s - Verbose mode: %s).\n",
|
||||
exch.Name,
|
||||
common.IsEnabled(exch.API.AuthenticatedSupport),
|
||||
|
||||
@@ -119,7 +119,7 @@ func GetExchangeOTPs() (map[string]string, error) {
|
||||
exchName := Bot.Config.Exchanges[x].Name
|
||||
o, err := totp.GenerateCode(otpSecret, time.Now())
|
||||
if err != nil {
|
||||
log.Errorf("Unable to generate OTP code for exchange %s. Err: %s",
|
||||
log.Errorf(log.Global, "Unable to generate OTP code for exchange %s. Err: %s\n",
|
||||
exchName, err)
|
||||
continue
|
||||
}
|
||||
@@ -541,7 +541,7 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("Portfolio: Adding new exchange address: %s, %s, %f, %s\n",
|
||||
log.Debugf(log.PortfolioMgr, "Portfolio: Adding new exchange address: %s, %s, %f, %s\n",
|
||||
exchangeName,
|
||||
currencyName,
|
||||
total,
|
||||
@@ -556,7 +556,7 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
|
||||
} else {
|
||||
if total <= 0 {
|
||||
log.Debugf("Portfolio: Removing %s %s entry.\n",
|
||||
log.Debugf(log.PortfolioMgr, "Portfolio: Removing %s %s entry.\n",
|
||||
exchangeName,
|
||||
currencyName)
|
||||
|
||||
@@ -571,7 +571,7 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
}
|
||||
|
||||
if balance != total {
|
||||
log.Debugf("Portfolio: Updating %s %s entry with balance %f.\n",
|
||||
log.Debugf(log.PortfolioMgr, "Portfolio: Updating %s %s entry with balance %f.\n",
|
||||
exchangeName,
|
||||
currencyName,
|
||||
total)
|
||||
@@ -668,14 +668,14 @@ func GetExchangeCryptocurrencyDepositAddresses() map[string]map[string]string {
|
||||
exchName := Bot.Exchanges[x].GetName()
|
||||
if !Bot.Exchanges[x].GetAuthenticatedAPISupport(exchange.RestAuthentication) {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("GetExchangeCryptocurrencyDepositAddresses: Skippping %s due to disabled authenticated API support.", exchName)
|
||||
log.Debugf(log.ExchangeSys, "GetExchangeCryptocurrencyDepositAddresses: Skippping %s due to disabled authenticated API support.\n", exchName)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
cryptoCurrencies, err := GetCryptocurrenciesByExchange(exchName, true, true, asset.Spot)
|
||||
if err != nil {
|
||||
log.Debugf("%s failed to get cryptocurrency deposit addresses. Err: %s", exchName, err)
|
||||
log.Debugf(log.ExchangeSys, "%s failed to get cryptocurrency deposit addresses. Err: %s\n", exchName, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ func GetExchangeCryptocurrencyDepositAddresses() map[string]map[string]string {
|
||||
cryptocurrency := cryptoCurrencies[y]
|
||||
depositAddr, err := Bot.Exchanges[x].GetDepositAddress(currency.NewCode(cryptocurrency), "")
|
||||
if err != nil {
|
||||
log.Debugf("%s failed to get cryptocurrency deposit addresses. Err: %s", exchName, err)
|
||||
log.Errorf(log.Global, "%s failed to get cryptocurrency deposit addresses. Err: %s\n", exchName, err)
|
||||
continue
|
||||
}
|
||||
cryptoAddr[cryptocurrency] = depositAddr
|
||||
@@ -748,7 +748,7 @@ func GetAllActiveTickers() []EnabledExchangeCurrencies {
|
||||
for z := range currencies {
|
||||
tp, err := exch.FetchTicker(currencies[z], assets[y])
|
||||
if err != nil {
|
||||
log.Debugf("Exchange %s failed to retrieve %s ticker. Err: %s", exchName,
|
||||
log.Errorf(log.ExchangeSys, "Exchange %s failed to retrieve %s ticker. Err: %s\n", exchName,
|
||||
currencies[z].String(),
|
||||
err)
|
||||
continue
|
||||
@@ -768,13 +768,13 @@ func GetAllEnabledExchangeAccountInfo() AllEnabledExchangeAccounts {
|
||||
if individualBot != nil && individualBot.IsEnabled() {
|
||||
if !individualBot.GetAuthenticatedAPISupport(exchange.RestAuthentication) {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("GetAllEnabledExchangeAccountInfo: Skippping %s due to disabled authenticated API support.", individualBot.GetName())
|
||||
log.Debugf(log.ExchangeSys, "GetAllEnabledExchangeAccountInfo: Skippping %s due to disabled authenticated API support.\n", individualBot.GetName())
|
||||
}
|
||||
continue
|
||||
}
|
||||
individualExchange, err := individualBot.GetAccountInfo()
|
||||
if err != nil {
|
||||
log.Debugf("Error encountered retrieving exchange account info for %s. Error %s",
|
||||
log.Errorf(log.ExchangeSys, "Error encountered retrieving exchange account info for %s. Error %s\n",
|
||||
individualBot.GetName(), err)
|
||||
continue
|
||||
}
|
||||
@@ -795,7 +795,7 @@ func checkCerts() error {
|
||||
return genCert(targetDir)
|
||||
}
|
||||
|
||||
log.Debugf("gRPC TLS certs directory already exists, will use them.")
|
||||
log.Debugln(log.Global, "gRPC TLS certs directory already exists, will use them.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -875,6 +875,6 @@ func genCert(targetDir string) error {
|
||||
return fmt.Errorf("failed to write cert.pem file %s", err)
|
||||
}
|
||||
|
||||
log.Debugf("TLS key.pem and cert.pem files written to %s", targetDir)
|
||||
log.Debugf(log.Global, "TLS key.pem and cert.pem files written to %s\n", targetDir)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (o *orderManager) Start() error {
|
||||
return errors.New("order manager already started")
|
||||
}
|
||||
|
||||
log.Debugln("Order manager starting...")
|
||||
log.Debugln(log.OrderBook, "Order manager starting...")
|
||||
|
||||
o.shutdown = make(chan struct{})
|
||||
o.orderStore.Orders = make(map[string][]exchange.OrderDetail)
|
||||
@@ -82,23 +82,23 @@ func (o *orderManager) Stop() error {
|
||||
atomic.CompareAndSwapInt32(&o.started, 1, 0)
|
||||
}()
|
||||
|
||||
log.Debugln("Order manager shutting down...")
|
||||
log.Debugln(log.OrderBook, "Order manager shutting down...")
|
||||
close(o.shutdown)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *orderManager) gracefulShutdown() {
|
||||
if o.cfg.CancelOrdersOnShutdown {
|
||||
log.Debug("Order manager: Cancelling any open orders...")
|
||||
log.Debugln(log.OrderMgr, "Order manager: Cancelling any open orders...")
|
||||
orders := o.orderStore.Get()
|
||||
if orders == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range orders {
|
||||
log.Debugf("Order manager: Cancelling order(s) for exchange %s.", k)
|
||||
log.Debugf(log.OrderMgr, "Order manager: Cancelling order(s) for exchange %s.\n", k)
|
||||
for y := range v {
|
||||
log.Debugf("order manager: Cancelling order ID %v [%v]",
|
||||
log.Debugf(log.OrderMgr, "order manager: Cancelling order ID %v [%v]",
|
||||
v[y].ID, v[y])
|
||||
err := o.Cancel(k, &exchange.OrderCancellation{
|
||||
OrderID: v[y].ID,
|
||||
@@ -106,7 +106,7 @@ func (o *orderManager) gracefulShutdown() {
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("Order manager: Exchange %s unable to cancel order ID=%v. Err: %s",
|
||||
k, v[y].ID, err)
|
||||
log.Debugln(msg)
|
||||
log.Debugln(log.OrderBook, msg)
|
||||
Bot.CommsManager.PushEvent(base.Event{
|
||||
Type: "order",
|
||||
Message: msg,
|
||||
@@ -116,7 +116,7 @@ func (o *orderManager) gracefulShutdown() {
|
||||
|
||||
msg := fmt.Sprintf("Order manager: Exchange %s order ID=%v cancelled.",
|
||||
k, v[y].ID)
|
||||
log.Debugln(msg)
|
||||
log.Debugln(log.OrderBook, msg)
|
||||
Bot.CommsManager.PushEvent(base.Event{
|
||||
Type: "order",
|
||||
Message: msg,
|
||||
@@ -127,11 +127,11 @@ func (o *orderManager) gracefulShutdown() {
|
||||
}
|
||||
|
||||
func (o *orderManager) run() {
|
||||
log.Debugln("Order manager started.")
|
||||
log.Debugln(log.OrderBook, "Order manager started.")
|
||||
tick := time.NewTicker(OrderManagerDelay)
|
||||
Bot.ServicesWG.Add(1)
|
||||
defer func() {
|
||||
log.Debugf("Order manager shutdown.")
|
||||
log.Debugln(log.OrderMgr, "Order manager shutdown.")
|
||||
tick.Stop()
|
||||
Bot.ServicesWG.Done()
|
||||
}()
|
||||
@@ -213,7 +213,7 @@ func (o *orderManager) Submit(exchName string, order *exchange.OrderSubmission)
|
||||
|
||||
id, err := common.GetV4UUID()
|
||||
if err != nil {
|
||||
log.Warnf("Order manager: Unable to generate UUID. Err: %s", err)
|
||||
log.Warnf(log.OrderMgr, "Order manager: Unable to generate UUID. Err: %s\n", err)
|
||||
}
|
||||
|
||||
result, err := exch.SubmitOrder(order)
|
||||
@@ -227,7 +227,7 @@ func (o *orderManager) Submit(exchName string, order *exchange.OrderSubmission)
|
||||
|
||||
msg := fmt.Sprintf("Order manager: Exchange %s submitted order ID=%v [Ours: %v] pair=%v price=%v amount=%v side=%v type=%v.",
|
||||
exchName, result.OrderID, id.String(), order.Pair, order.Price, order.Amount, order.OrderSide, order.OrderType)
|
||||
log.Debugln(msg)
|
||||
log.Debugln(log.OrderMgr, msg)
|
||||
Bot.CommsManager.PushEvent(base.Event{
|
||||
Type: "order",
|
||||
Message: msg,
|
||||
@@ -244,7 +244,7 @@ func (o *orderManager) Submit(exchName string, order *exchange.OrderSubmission)
|
||||
func (o *orderManager) processOrders() {
|
||||
authExchanges := GetAuthAPISupportedExchanges()
|
||||
for x := range authExchanges {
|
||||
log.Debugf("Order manager: Procesing orders for exchange %v.", authExchanges[x])
|
||||
log.Debugf(log.OrderMgr, "Order manager: Procesing orders for exchange %v.\n", authExchanges[x])
|
||||
exch := GetExchangeByName(authExchanges[x])
|
||||
req := exchange.GetOrdersRequest{
|
||||
OrderSide: exchange.AnyOrderSide,
|
||||
@@ -252,7 +252,7 @@ func (o *orderManager) processOrders() {
|
||||
}
|
||||
result, err := exch.GetActiveOrders(&req)
|
||||
if err != nil {
|
||||
log.Debugf("Order manager: Unable to get active orders: %s", err)
|
||||
log.Warnf(log.OrderMgr, "Order manager: Unable to get active orders: %s\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ func (o *orderManager) processOrders() {
|
||||
if result != ErrOrdersAlreadyExists {
|
||||
msg := fmt.Sprintf("Order manager: Exchange %s added order ID=%v pair=%v price=%v amount=%v side=%v type=%v.",
|
||||
order.Exchange, order.ID, order.CurrencyPair, order.Price, order.Amount, order.OrderSide, order.OrderType)
|
||||
log.Debug(msg)
|
||||
log.Debugf(log.OrderMgr, "%v\n", msg)
|
||||
Bot.CommsManager.PushEvent(base.Event{
|
||||
Type: "order",
|
||||
Message: msg,
|
||||
|
||||
@@ -29,7 +29,7 @@ func (p *portfolioManager) Start() error {
|
||||
return errors.New("portfolio manager already started")
|
||||
}
|
||||
|
||||
log.Debugln("Portfolio manager starting...")
|
||||
log.Debugln(log.PortfolioMgr, "Portfolio manager starting...")
|
||||
Bot.Portfolio = &portfolio.Portfolio
|
||||
Bot.Portfolio.Seed(Bot.Config.Portfolio)
|
||||
p.shutdown = make(chan struct{})
|
||||
@@ -41,13 +41,13 @@ func (p *portfolioManager) Stop() error {
|
||||
return errors.New("portfolio manager is already stopped")
|
||||
}
|
||||
|
||||
log.Debugln("Portfolio manager shutting down...")
|
||||
log.Debugln(log.PortfolioMgr, "Portfolio manager shutting down...")
|
||||
close(p.shutdown)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *portfolioManager) run() {
|
||||
log.Debugln("Portfolio manager started.")
|
||||
log.Debugln(log.PortfolioMgr, "Portfolio manager started.")
|
||||
Bot.ServicesWG.Add(1)
|
||||
tick := time.NewTicker(PortfolioSleepDelay)
|
||||
defer func() {
|
||||
@@ -55,7 +55,7 @@ func (p *portfolioManager) run() {
|
||||
atomic.CompareAndSwapInt32(&p.started, 1, 0)
|
||||
tick.Stop()
|
||||
Bot.ServicesWG.Done()
|
||||
log.Debugf("Portfolio manager shutdown.")
|
||||
log.Debugf(log.PortfolioMgr, "Portfolio manager shutdown.")
|
||||
}()
|
||||
|
||||
for {
|
||||
@@ -75,7 +75,7 @@ func (p *portfolioManager) processPortfolio() {
|
||||
for key, value := range data {
|
||||
success := pf.UpdatePortfolio(value, key)
|
||||
if success {
|
||||
log.Debugf(
|
||||
log.Debugf(log.PortfolioMgr,
|
||||
"Portfolio manager: Successfully updated address balance for %s address(es) %s\n",
|
||||
key, value,
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ func RESTLogger(inner http.Handler, name string) http.Handler {
|
||||
start := time.Now()
|
||||
inner.ServeHTTP(w, r)
|
||||
|
||||
log.Debugf(
|
||||
log.Debugf(log.RESTSys,
|
||||
"%s\t%s\t%s\t%s",
|
||||
r.Method,
|
||||
r.RequestURI,
|
||||
@@ -32,20 +32,24 @@ func RESTLogger(inner http.Handler, name string) http.Handler {
|
||||
// StartRESTServer starts a REST server
|
||||
func StartRESTServer() {
|
||||
listenAddr := Bot.Config.RemoteControl.DeprecatedRPC.ListenAddress
|
||||
log.Debugf("Deprecated RPC server support enabled. Listen URL: http://%s:%d\n", common.ExtractHost(listenAddr), common.ExtractPort(listenAddr))
|
||||
log.Debugf(log.RESTSys,
|
||||
"Deprecated RPC server support enabled. Listen URL: http://%s:%d\n",
|
||||
common.ExtractHost(listenAddr), common.ExtractPort(listenAddr))
|
||||
err := http.ListenAndServe(listenAddr, newRouter(true))
|
||||
if err != nil {
|
||||
log.Errorf("Failed to start deprecated RPC server. Err: %s", err)
|
||||
log.Errorf(log.RESTSys, "Failed to start deprecated RPC server. Err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// StartWebsocketServer starts a Websocket server
|
||||
func StartWebsocketServer() {
|
||||
listenAddr := Bot.Config.RemoteControl.WebsocketRPC.ListenAddress
|
||||
log.Debugf("Websocket RPC support enabled. Listen URL: ws://%s:%d/ws\n", common.ExtractHost(listenAddr), common.ExtractPort(listenAddr))
|
||||
log.Debugf(log.RESTSys,
|
||||
"Websocket RPC support enabled. Listen URL: ws://%s:%d/ws\n",
|
||||
common.ExtractHost(listenAddr), common.ExtractPort(listenAddr))
|
||||
err := http.ListenAndServe(listenAddr, newRouter(false))
|
||||
if err != nil {
|
||||
log.Errorf("Failed to start websocket RPC server. Err: %s", err)
|
||||
log.Errorf(log.RESTSys, "Failed to start websocket RPC server. Err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +85,9 @@ func newRouter(isREST bool) *mux.Router {
|
||||
}
|
||||
|
||||
if Bot.Config.Profiler.Enabled {
|
||||
log.Debugf("HTTP Go performance profiler (pprof) endpoint enabled: http://%s:%d/debug", common.ExtractHost(listenAddr),
|
||||
log.Debugf(log.RESTSys,
|
||||
"HTTP Go performance profiler (pprof) endpoint enabled: http://%s:%d/debug\n",
|
||||
common.ExtractHost(listenAddr),
|
||||
common.ExtractPort(listenAddr))
|
||||
router.PathPrefix("/debug").Handler(http.DefaultServeMux)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func RESTfulJSONResponse(w http.ResponseWriter, response interface{}) error {
|
||||
|
||||
// RESTfulError prints the REST method and error
|
||||
func RESTfulError(method string, err error) {
|
||||
log.Errorf("RESTful %s: server failed to send JSON response. Error %s",
|
||||
log.Errorf(log.RESTSys, "RESTful %s: server failed to send JSON response. Error %s\n",
|
||||
method, err)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,8 @@ func GetAllActiveOrderbooks() []EnabledExchangeOrderbooks {
|
||||
for z := range currencies {
|
||||
ob, err := exch.FetchOrderbook(currencies[z], assets[y])
|
||||
if err != nil {
|
||||
log.Errorf("Exchange %s failed to retrieve %s orderbook. Err: %s", exchName,
|
||||
log.Errorf(log.RESTSys,
|
||||
"Exchange %s failed to retrieve %s orderbook. Err: %s\n", exchName,
|
||||
currencies[z].String(),
|
||||
err)
|
||||
continue
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
func printCurrencyFormat(price float64) string {
|
||||
displaySymbol, err := currency.GetSymbolByCurrencyName(Bot.Config.Currency.FiatDisplayCurrency)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get display symbol: %s", err)
|
||||
log.Errorf(log.Global, "Failed to get display symbol: %s\n", err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%.8f", displaySymbol, price)
|
||||
@@ -32,17 +32,17 @@ func printConvertCurrencyFormat(origCurrency currency.Code, origPrice float64) s
|
||||
origCurrency,
|
||||
displayCurrency)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to convert currency: %s", err)
|
||||
log.Errorf(log.Global, "Failed to convert currency: %s\n", err)
|
||||
}
|
||||
|
||||
displaySymbol, err := currency.GetSymbolByCurrencyName(displayCurrency)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get display symbol: %s", err)
|
||||
log.Errorf(log.Global, "Failed to get display symbol: %s\n", err)
|
||||
}
|
||||
|
||||
origSymbol, err := currency.GetSymbolByCurrencyName(origCurrency)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get original currency symbol for %s: %s",
|
||||
log.Errorf(log.Global, "Failed to get original currency symbol for %s: %s\n",
|
||||
origCurrency,
|
||||
err)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func printConvertCurrencyFormat(origCurrency currency.Code, origPrice float64) s
|
||||
|
||||
func printTickerSummary(result *ticker.Price, p currency.Pair, assetType asset.Item, exchangeName string, err error) {
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get %s %s ticker. Error: %s",
|
||||
log.Errorf(log.Ticker, "Failed to get %s %s ticker. Error: %s\n",
|
||||
p.String(),
|
||||
exchangeName,
|
||||
err)
|
||||
@@ -70,7 +70,7 @@ func printTickerSummary(result *ticker.Price, p currency.Pair, assetType asset.I
|
||||
if p.Quote.IsFiatCurrency() &&
|
||||
p.Quote != Bot.Config.Currency.FiatDisplayCurrency {
|
||||
origCurrency := p.Quote.Upper()
|
||||
log.Infof("%s %s %s: TICKER: Last %s Ask %s Bid %s High %s Low %s Volume %.8f",
|
||||
log.Infof(log.Ticker, "%s %s %s: TICKER: Last %s Ask %s Bid %s High %s Low %s Volume %.8f\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -83,7 +83,7 @@ func printTickerSummary(result *ticker.Price, p currency.Pair, assetType asset.I
|
||||
} else {
|
||||
if p.Quote.IsFiatCurrency() &&
|
||||
p.Quote == Bot.Config.Currency.FiatDisplayCurrency {
|
||||
log.Infof("%s %s %s: TICKER: Last %s Ask %s Bid %s High %s Low %s Volume %.8f",
|
||||
log.Infof(log.Ticker, "%s %s %s: TICKER: Last %s Ask %s Bid %s High %s Low %s Volume %.8f\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -94,7 +94,7 @@ func printTickerSummary(result *ticker.Price, p currency.Pair, assetType asset.I
|
||||
printCurrencyFormat(result.Low),
|
||||
result.Volume)
|
||||
} else {
|
||||
log.Infof("%s %s %s: TICKER: Last %.8f Ask %.8f Bid %.8f High %.8f Low %.8f Volume %.8f",
|
||||
log.Infof(log.Ticker, "%s %s %s: TICKER: Last %.8f Ask %.8f Bid %.8f High %.8f Low %.8f Volume %.8f\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -110,7 +110,7 @@ func printTickerSummary(result *ticker.Price, p currency.Pair, assetType asset.I
|
||||
|
||||
func printOrderbookSummary(result *orderbook.Base, p currency.Pair, assetType asset.Item, exchangeName string, err error) {
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get %s %s orderbook of type %s. Error: %s",
|
||||
log.Errorf(log.OrderBook, "Failed to get %s %s orderbook of type %s. Error: %s\n",
|
||||
p,
|
||||
exchangeName,
|
||||
assetType,
|
||||
@@ -124,7 +124,7 @@ func printOrderbookSummary(result *orderbook.Base, p currency.Pair, assetType as
|
||||
if p.Quote.IsFiatCurrency() &&
|
||||
p.Quote != Bot.Config.Currency.FiatDisplayCurrency {
|
||||
origCurrency := p.Quote.Upper()
|
||||
log.Infof("%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %s Asks len: %d Amount: %f %s. Total value: %s",
|
||||
log.Infof(log.OrderBook, "%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %s Asks len: %d Amount: %f %s. Total value: %s\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -140,7 +140,7 @@ func printOrderbookSummary(result *orderbook.Base, p currency.Pair, assetType as
|
||||
} else {
|
||||
if p.Quote.IsFiatCurrency() &&
|
||||
p.Quote == Bot.Config.Currency.FiatDisplayCurrency {
|
||||
log.Infof("%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %s Asks len: %d Amount: %f %s. Total value: %s",
|
||||
log.Infof(log.OrderBook, "%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %s Asks len: %d Amount: %f %s. Total value: %s\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -154,7 +154,7 @@ func printOrderbookSummary(result *orderbook.Base, p currency.Pair, assetType as
|
||||
printCurrencyFormat(asksValue),
|
||||
)
|
||||
} else {
|
||||
log.Infof("%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %f Asks len: %d Amount: %f %s. Total value: %f",
|
||||
log.Infof(log.OrderBook, "%s %s %s: ORDERBOOK: Bids len: %d Amount: %f %s. Total value: %f Asks len: %d Amount: %f %s. Total value: %f\n",
|
||||
exchangeName,
|
||||
FormatCurrency(p).String(),
|
||||
assetType,
|
||||
@@ -180,7 +180,7 @@ func relayWebsocketEvent(result interface{}, event, assetType, exchangeName stri
|
||||
}
|
||||
err := BroadcastWebsocketMessage(evt)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to broadcast websocket event %v. Error: %s",
|
||||
log.Errorf(log.WebsocketMgr, "Failed to broadcast websocket event %v. Error: %s\n",
|
||||
event, err)
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func relayWebsocketEvent(result interface{}, event, assetType, exchangeName stri
|
||||
// TickerUpdaterRoutine fetches and updates the ticker for all enabled
|
||||
// currency pairs and exchanges
|
||||
func TickerUpdaterRoutine() {
|
||||
log.Debugf("Starting ticker updater routine.")
|
||||
log.Debugln(log.Ticker, "Starting ticker updater routine.")
|
||||
var wg sync.WaitGroup
|
||||
for {
|
||||
wg.Add(len(Bot.Exchanges))
|
||||
@@ -233,7 +233,7 @@ func TickerUpdaterRoutine() {
|
||||
}(x, &wg)
|
||||
}
|
||||
wg.Wait()
|
||||
log.Debugln("All enabled currency tickers fetched.")
|
||||
log.Debugln(log.Ticker, "All enabled currency tickers fetched.")
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ func TickerUpdaterRoutine() {
|
||||
// OrderbookUpdaterRoutine fetches and updates the orderbooks for all enabled
|
||||
// currency pairs and exchanges
|
||||
func OrderbookUpdaterRoutine() {
|
||||
log.Debugln("Starting orderbook updater routine.")
|
||||
log.Debugln(log.OrderBook, "Starting orderbook updater routine.")
|
||||
var wg sync.WaitGroup
|
||||
for {
|
||||
wg.Add(len(Bot.Exchanges))
|
||||
@@ -275,7 +275,7 @@ func OrderbookUpdaterRoutine() {
|
||||
}(x, &wg)
|
||||
}
|
||||
wg.Wait()
|
||||
log.Debugln("All enabled currency orderbooks fetched.")
|
||||
log.Debugln(log.OrderBook, "All enabled currency orderbooks fetched.")
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
@@ -283,14 +283,14 @@ func OrderbookUpdaterRoutine() {
|
||||
// WebsocketRoutine Initial routine management system for websocket
|
||||
func WebsocketRoutine() {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugln("Connecting exchange websocket services...")
|
||||
log.Debugln(log.WebsocketMgr, "Connecting exchange websocket services...")
|
||||
}
|
||||
|
||||
for i := range Bot.Exchanges {
|
||||
go func(i int) {
|
||||
if Bot.Exchanges[i].SupportsWebsocket() {
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("Exchange %s websocket support: Yes Enabled: %v", Bot.Exchanges[i].GetName(),
|
||||
log.Debugf(log.WebsocketMgr, "Exchange %s websocket support: Yes Enabled: %v\n", Bot.Exchanges[i].GetName(),
|
||||
common.IsEnabled(Bot.Exchanges[i].IsWebsocketEnabled()))
|
||||
}
|
||||
|
||||
@@ -304,11 +304,11 @@ func WebsocketRoutine() {
|
||||
|
||||
err = ws.Connect()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
log.Errorf(log.WebsocketMgr, "%v\n", err)
|
||||
}
|
||||
}
|
||||
} else if Bot.Settings.Verbose {
|
||||
log.Debugf("Exchange %s websocket support: No", Bot.Exchanges[i].GetName())
|
||||
log.Debugf(log.WebsocketMgr, "Exchange %s websocket support: No\n", Bot.Exchanges[i].GetName())
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
@@ -322,7 +322,7 @@ var wg sync.WaitGroup
|
||||
func Websocketshutdown(ws *exchange.Websocket) error {
|
||||
err := ws.Shutdown() // shutdown routines on the exchange
|
||||
if err != nil {
|
||||
log.Errorf("routines.go error - failed to shutdown %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "routines.go error - failed to shutdown %s\n", err)
|
||||
}
|
||||
|
||||
timer := time.NewTimer(5 * time.Second)
|
||||
@@ -356,12 +356,12 @@ func streamDiversion(ws *exchange.Websocket) {
|
||||
|
||||
case <-ws.Connected:
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("exchange %s websocket feed connected", ws.GetName())
|
||||
log.Debugf(log.WebsocketMgr, "exchange %s websocket feed connected\n", ws.GetName())
|
||||
}
|
||||
|
||||
case <-ws.Disconnected:
|
||||
if Bot.Settings.Verbose {
|
||||
log.Debugf("exchange %s websocket feed disconnected, switching to REST functionality",
|
||||
log.Debugf(log.WebsocketMgr, "exchange %s websocket feed disconnected, switching to REST functionality\n",
|
||||
ws.GetName())
|
||||
}
|
||||
}
|
||||
@@ -387,12 +387,12 @@ func WebsocketDataHandler(ws *exchange.Websocket) {
|
||||
switch d {
|
||||
case exchange.WebsocketNotEnabled:
|
||||
if Bot.Settings.Verbose {
|
||||
log.Warnf("routines.go warning - exchange %s weboscket not enabled",
|
||||
log.Warnf(log.WebsocketMgr, "routines.go warning - exchange %s weboscket not enabled\n",
|
||||
ws.GetName())
|
||||
}
|
||||
|
||||
default:
|
||||
log.Infof(d)
|
||||
log.Info(log.WebsocketMgr, d)
|
||||
}
|
||||
|
||||
case error:
|
||||
@@ -401,7 +401,7 @@ func WebsocketDataHandler(ws *exchange.Websocket) {
|
||||
go ws.WebsocketReset()
|
||||
continue
|
||||
default:
|
||||
log.Errorf("routines.go exchange %s websocket error - %s", ws.GetName(), data)
|
||||
log.Errorf(log.WebsocketMgr, "routines.go exchange %s websocket error - %s", ws.GetName(), data)
|
||||
}
|
||||
|
||||
case exchange.TradeData:
|
||||
@@ -433,7 +433,7 @@ func WebsocketDataHandler(ws *exchange.Websocket) {
|
||||
case exchange.KlineData:
|
||||
// Kline data
|
||||
if Bot.Settings.Verbose {
|
||||
log.Infoln("Websocket Kline Updated: ", d)
|
||||
log.Infof(log.WebsocketMgr, "Websocket Kline Updated: %v\n", d)
|
||||
}
|
||||
case exchange.WebsocketOrderbookUpdate:
|
||||
// Orderbook data
|
||||
@@ -443,10 +443,13 @@ func WebsocketDataHandler(ws *exchange.Websocket) {
|
||||
result.Pair, result.Asset, SyncItemOrderbook, nil)
|
||||
}
|
||||
// TO-DO: printOrderbookSummary
|
||||
//nolint:gocritic log.Infof("Websocket %s %s orderbook updated", ws.GetName(), result.Pair.Pair().String())
|
||||
//nolint:gocritic
|
||||
if Bot.Settings.Verbose {
|
||||
log.Infof(log.WebsocketMgr, "Websocket %s %s orderbook updated\n", ws.GetName(), result.Pair.String())
|
||||
}
|
||||
default:
|
||||
if Bot.Settings.Verbose {
|
||||
log.Warnf("Websocket Unknown type: %s", d)
|
||||
log.Warnf(log.WebsocketMgr, "Websocket Unknown type: %s\n", d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,21 +64,21 @@ func authenticateClient(ctx context.Context) (context.Context, error) {
|
||||
func StartRPCServer() {
|
||||
err := checkCerts()
|
||||
if err != nil {
|
||||
log.Errorf("gRPC checkCerts failed. err: %s", err)
|
||||
log.Errorf(log.GRPCSys, "gRPC checkCerts failed. err: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("gRPC server support enabled. Starting gRPC server on https://%v.", Bot.Config.RemoteControl.GRPC.ListenAddress)
|
||||
log.Debugf(log.GRPCSys, "gRPC server support enabled. Starting gRPC server on https://%v.\n", Bot.Config.RemoteControl.GRPC.ListenAddress)
|
||||
lis, err := net.Listen("tcp", Bot.Config.RemoteControl.GRPC.ListenAddress)
|
||||
if err != nil {
|
||||
log.Errorf("gRPC server failed to bind to port: %s", err)
|
||||
log.Errorf(log.GRPCSys, "gRPC server failed to bind to port: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
targetDir := utils.GetTLSDir(Bot.Settings.DataDir)
|
||||
creds, err := credentials.NewServerTLSFromFile(filepath.Join(targetDir, "cert.pem"), filepath.Join(targetDir, "key.pem"))
|
||||
if err != nil {
|
||||
log.Errorf("gRPC server could not load TLS keys: %s", err)
|
||||
log.Errorf(log.GRPCSys, "gRPC server could not load TLS keys: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ func StartRPCServer() {
|
||||
|
||||
go func() {
|
||||
if err := server.Serve(lis); err != nil {
|
||||
log.Errorf("gRPC server failed to serve: %s", err)
|
||||
log.Errorf(log.GRPCSys, "gRPC server failed to serve: %s\n", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debugf("gRPC server started!")
|
||||
log.Debugln(log.GRPCSys, "gRPC server started!")
|
||||
|
||||
if Bot.Settings.EnableGRPCProxy {
|
||||
StartRPCRESTProxy()
|
||||
@@ -106,7 +106,7 @@ func StartRPCServer() {
|
||||
|
||||
// StartRPCRESTProxy starts a gRPC proxy
|
||||
func StartRPCRESTProxy() {
|
||||
log.Debugf("gRPC proxy server support enabled. Starting gRPC proxy server on http://%v.", Bot.Config.RemoteControl.GRPC.GRPCProxyListenAddress)
|
||||
log.Debugf(log.GRPCSys, "gRPC proxy server support enabled. Starting gRPC proxy server on http://%v.\n", Bot.Config.RemoteControl.GRPC.GRPCProxyListenAddress)
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
@@ -114,7 +114,7 @@ func StartRPCRESTProxy() {
|
||||
targetDir := utils.GetTLSDir(Bot.Settings.DataDir)
|
||||
creds, err := credentials.NewClientTLSFromFile(filepath.Join(targetDir, "cert.pem"), "")
|
||||
if err != nil {
|
||||
log.Errorf("Unabled to start gRPC proxy. Err: %s", err)
|
||||
log.Errorf(log.GRPCSys, "Unabled to start gRPC proxy. Err: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -127,17 +127,17 @@ func StartRPCRESTProxy() {
|
||||
}
|
||||
err = gctrpc.RegisterGoCryptoTraderHandlerFromEndpoint(ctx, mux, Bot.Config.RemoteControl.GRPC.ListenAddress, opts)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to register gRPC proxy. Err: %s", err)
|
||||
log.Errorf(log.GRPCSys, "Failed to register gRPC proxy. Err: %s\n", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := http.ListenAndServe(Bot.Config.RemoteControl.GRPC.GRPCProxyListenAddress, mux); err != nil {
|
||||
log.Errorf("gRPC proxy failed to server: %s", err)
|
||||
log.Errorf(log.GRPCSys, "gRPC proxy failed to server: %s\n", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debugf("gRPC proxy server started!")
|
||||
log.Debugln(log.GRPCSys, "gRPC proxy server started!")
|
||||
select {}
|
||||
|
||||
}
|
||||
@@ -606,7 +606,7 @@ func (s *RPCServer) GetForexRates(ctx context.Context, r *gctrpc.GetForexRatesRe
|
||||
func (s *RPCServer) GetOrders(ctx context.Context, r *gctrpc.GetOrdersRequest) (*gctrpc.GetOrdersResponse, error) {
|
||||
exch := GetExchangeByName(r.Exchange)
|
||||
if exch == nil {
|
||||
log.Debugln(exch)
|
||||
log.Debugln(log.GRPCSys, exch)
|
||||
return nil, errors.New("exchange is not loaded/doesn't exist")
|
||||
}
|
||||
|
||||
@@ -827,3 +827,31 @@ func (s *RPCServer) WithdrawCryptocurrencyFunds(ctx context.Context, r *gctrpc.W
|
||||
func (s *RPCServer) WithdrawFiatFunds(ctx context.Context, r *gctrpc.WithdrawCurrencyRequest) (*gctrpc.WithdrawResponse, error) {
|
||||
return &gctrpc.WithdrawResponse{}, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
func (s *RPCServer) GetLoggerDetails(ctx context.Context, r *gctrpc.GetLoggerDetailsRequest) (*gctrpc.GetLoggerDetailsResponse, error) {
|
||||
levels, err := log.Level(r.Logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &gctrpc.GetLoggerDetailsResponse{
|
||||
Info: levels.Info,
|
||||
Debug: levels.Debug,
|
||||
Warn: levels.Warn,
|
||||
Error: levels.Error,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *RPCServer) SetLoggerDetails(ctx context.Context, r *gctrpc.SetLoggerDetailsRequest) (*gctrpc.GetLoggerDetailsResponse, error) {
|
||||
levels, err := log.SetLevel(r.Logger, r.Level)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &gctrpc.GetLoggerDetailsResponse{
|
||||
Info: levels.Info,
|
||||
Debug: levels.Debug,
|
||||
Warn: levels.Warn,
|
||||
Error: levels.Error,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ func NewCurrencyPairSyncer(c CurrencyPairSyncerConfig) (*ExchangeCurrencyPairSyn
|
||||
|
||||
s.tickerBatchLastRequested = make(map[string]time.Time)
|
||||
|
||||
log.Debugf("Exchange currency pair syncer config:")
|
||||
log.Debugf("SyncContinuously: %v", s.Cfg.SyncContinuously)
|
||||
log.Debugf("SyncTicker: %v", s.Cfg.SyncTicker)
|
||||
log.Debugf("SyncOrderbook: %v", s.Cfg.SyncOrderbook)
|
||||
log.Debugf("SyncTrades: %v", s.Cfg.SyncTrades)
|
||||
log.Debugf("NumWorkers: %v", s.Cfg.NumWorkers)
|
||||
log.Debugln(log.SyncMgr, "Exchange currency pair syncer config:")
|
||||
log.Debugf(log.SyncMgr, "SyncContinuously: %v\n", s.Cfg.SyncContinuously)
|
||||
log.Debugf(log.SyncMgr, "SyncTicker: %v\n", s.Cfg.SyncTicker)
|
||||
log.Debugf(log.SyncMgr, "SyncOrderbook: %v\n", s.Cfg.SyncOrderbook)
|
||||
log.Debugf(log.SyncMgr, "SyncTrades: %v\n", s.Cfg.SyncTrades)
|
||||
log.Debugf(log.SyncMgr, "NumWorkers: %v\n", s.Cfg.NumWorkers)
|
||||
|
||||
return &s, nil
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (e *ExchangeCurrencyPairSyncer) add(c *CurrencyPairSyncAgent) {
|
||||
defer e.mux.Unlock()
|
||||
|
||||
if e.Cfg.SyncTicker {
|
||||
log.Debugf("%s: Added ticker sync item %v: using websocket: %v using REST: %v", c.Exchange, c.Pair.String(),
|
||||
log.Debugf(log.SyncMgr, "%s: Added ticker sync item %v: using websocket: %v using REST: %v\n", c.Exchange, c.Pair.String(),
|
||||
c.Ticker.IsUsingWebsocket, c.Ticker.IsUsingREST)
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 {
|
||||
e.initSyncWG.Add(1)
|
||||
@@ -101,7 +101,7 @@ func (e *ExchangeCurrencyPairSyncer) add(c *CurrencyPairSyncAgent) {
|
||||
}
|
||||
|
||||
if e.Cfg.SyncOrderbook {
|
||||
log.Debugf("%s: Added orderbook sync item %v: using websocket: %v using REST: %v", c.Exchange, c.Pair.String(),
|
||||
log.Debugf(log.SyncMgr, "%s: Added orderbook sync item %v: using websocket: %v using REST: %v\n", c.Exchange, c.Pair.String(),
|
||||
c.Orderbook.IsUsingWebsocket, c.Orderbook.IsUsingREST)
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 {
|
||||
e.initSyncWG.Add(1)
|
||||
@@ -110,7 +110,7 @@ func (e *ExchangeCurrencyPairSyncer) add(c *CurrencyPairSyncAgent) {
|
||||
}
|
||||
|
||||
if e.Cfg.SyncTrades {
|
||||
log.Debugf("%s: Added trade sync item %v: using websocket: %v using REST: %v", c.Exchange, c.Pair.String(),
|
||||
log.Debugf(log.SyncMgr, "%s: Added trade sync item %v: using websocket: %v using REST: %v\n", c.Exchange, c.Pair.String(),
|
||||
c.Trade.IsUsingWebsocket, c.Trade.IsUsingREST)
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 {
|
||||
e.initSyncWG.Add(1)
|
||||
@@ -197,7 +197,7 @@ func (e *ExchangeCurrencyPairSyncer) update(exchangeName string, p currency.Pair
|
||||
return
|
||||
}
|
||||
default:
|
||||
log.Warnf("ExchangeCurrencyPairSyncer: unknown sync item %v", syncType)
|
||||
log.Warnf(log.SyncMgr, "ExchangeCurrencyPairSyncer: unknown sync item %v\n", syncType)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ func (e *ExchangeCurrencyPairSyncer) update(exchangeName string, p currency.Pair
|
||||
e.CurrencyPairs[x].Ticker.HaveData = true
|
||||
e.CurrencyPairs[x].Ticker.IsProcessing = false
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 && !origHadData {
|
||||
log.Debugf("%s ticker sync complete %v [%d/%d].", exchangeName, p, removedCounter, createdCounter)
|
||||
log.Debugf(log.SyncMgr, "%s ticker sync complete %v [%d/%d].\n", exchangeName, p, removedCounter, createdCounter)
|
||||
removedCounter++
|
||||
e.initSyncWG.Done()
|
||||
}
|
||||
@@ -232,7 +232,7 @@ func (e *ExchangeCurrencyPairSyncer) update(exchangeName string, p currency.Pair
|
||||
e.CurrencyPairs[x].Orderbook.HaveData = true
|
||||
e.CurrencyPairs[x].Orderbook.IsProcessing = false
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 && !origHadData {
|
||||
log.Debugf("%s orderbook sync complete %v [%d/%d].", exchangeName, p, removedCounter, createdCounter)
|
||||
log.Debugf(log.SyncMgr, "%s orderbook sync complete %v [%d/%d].\n", exchangeName, p, removedCounter, createdCounter)
|
||||
removedCounter++
|
||||
e.initSyncWG.Done()
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (e *ExchangeCurrencyPairSyncer) update(exchangeName string, p currency.Pair
|
||||
e.CurrencyPairs[x].Trade.HaveData = true
|
||||
e.CurrencyPairs[x].Trade.IsProcessing = false
|
||||
if atomic.LoadInt32(&e.initSyncCompleted) != 1 && !origHadData {
|
||||
log.Debugf("%s trade sync complete %v [%d/%d].", exchangeName, p, removedCounter, createdCounter)
|
||||
log.Debugf(log.SyncMgr, "%s trade sync complete %v [%d/%d].\n", exchangeName, p, removedCounter, createdCounter)
|
||||
removedCounter++
|
||||
e.initSyncWG.Done()
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func (e *ExchangeCurrencyPairSyncer) update(exchangeName string, p currency.Pair
|
||||
|
||||
func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
cleanup := func() {
|
||||
log.Debugf("Exchange CurrencyPairSyncer worker shutting down.")
|
||||
log.Debugln(log.SyncMgr, "Exchange CurrencyPairSyncer worker shutting down.")
|
||||
}
|
||||
defer cleanup()
|
||||
|
||||
@@ -277,7 +277,7 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
if Bot.Exchanges[x].SupportsWebsocket() && Bot.Exchanges[x].IsWebsocketEnabled() {
|
||||
ws, err := Bot.Exchanges[x].GetWebsocket()
|
||||
if err != nil {
|
||||
log.Debugf("%s unable to get websocket pointer. Err: %s", exchangeName, err)
|
||||
log.Errorf(log.SyncMgr, "%s unable to get websocket pointer. Err: %s\n", exchangeName, err)
|
||||
usingREST = true
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
|
||||
c, err := e.get(exchangeName, p, assetTypes[y])
|
||||
if err != nil {
|
||||
log.Errorf("failed to get item. Err: %s", err)
|
||||
log.Errorf(log.SyncMgr, "failed to get item. Err: %s\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemTicker, true)
|
||||
c.Ticker.IsUsingWebsocket = false
|
||||
c.Ticker.IsUsingREST = true
|
||||
log.Warnf("%s %s: No ticker update after 10 seconds, switching from websocket to rest",
|
||||
log.Warnf(log.SyncMgr, "%s %s: No ticker update after 10 seconds, switching from websocket to rest\n",
|
||||
c.Exchange, c.Pair.String())
|
||||
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemTicker, false)
|
||||
}
|
||||
@@ -367,14 +367,14 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
if batchLastDone.IsZero() || time.Since(batchLastDone) > defaultSyncerTimeout {
|
||||
e.mux.Lock()
|
||||
if e.Cfg.Verbose {
|
||||
log.Debugf("%s Init'ing REST ticker batching", exchangeName)
|
||||
log.Debugf(log.SyncMgr, "%s Init'ing REST ticker batching\n", exchangeName)
|
||||
}
|
||||
result, err = Bot.Exchanges[x].UpdateTicker(c.Pair, c.AssetType)
|
||||
e.tickerBatchLastRequested[exchangeName] = time.Now()
|
||||
e.mux.Unlock()
|
||||
} else {
|
||||
if e.Cfg.Verbose {
|
||||
log.Debugf("%s Using recent batching cache", exchangeName)
|
||||
log.Debugf(log.OrderMgr, "%s Using recent batching cache\n", exchangeName)
|
||||
}
|
||||
result, err = Bot.Exchanges[x].FetchTicker(c.Pair, c.AssetType)
|
||||
}
|
||||
@@ -407,7 +407,7 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemOrderbook, true)
|
||||
c.Orderbook.IsUsingWebsocket = false
|
||||
c.Orderbook.IsUsingREST = true
|
||||
log.Warnf("%s %s: No orderbook update after 15 seconds, switching from websocket to rest",
|
||||
log.Warnf(log.SyncMgr, "%s %s: No orderbook update after 15 seconds, switching from websocket to rest\n",
|
||||
c.Exchange, c.Pair.String())
|
||||
e.setProcessing(c.Exchange, c.Pair, c.AssetType, SyncItemOrderbook, false)
|
||||
}
|
||||
@@ -445,7 +445,7 @@ func (e *ExchangeCurrencyPairSyncer) worker() {
|
||||
|
||||
// Start starts an exchange currency pair syncer
|
||||
func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
log.Debugf("Exchange CurrencyPairSyncer started.")
|
||||
log.Debugln(log.SyncMgr, "Exchange CurrencyPairSyncer started.")
|
||||
|
||||
for x := range Bot.Exchanges {
|
||||
if !Bot.Exchanges[x].IsEnabled() {
|
||||
@@ -458,7 +458,7 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
supportsREST := Bot.Exchanges[x].SupportsREST()
|
||||
|
||||
if !supportsREST && !supportsWebsocket {
|
||||
log.Warnf("Loaded exchange %s does not support REST or Websocket.", exchangeName)
|
||||
log.Warnf(log.SyncMgr, "Loaded exchange %s does not support REST or Websocket.\n", exchangeName)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
if supportsWebsocket {
|
||||
ws, err := Bot.Exchanges[x].GetWebsocket()
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to get websocket. Err: %s", exchangeName, err)
|
||||
log.Errorf(log.SyncMgr, "%s failed to get websocket. Err: %s\n", exchangeName, err)
|
||||
usingREST = true
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
|
||||
err = ws.Connect()
|
||||
if err != nil {
|
||||
log.Errorf("%s websocket failed to connect. Err: %s", exchangeName, err)
|
||||
log.Errorf(log.SyncMgr, "%s websocket failed to connect. Err: %s\n", exchangeName, err)
|
||||
usingREST = true
|
||||
} else {
|
||||
usingWebsocket = true
|
||||
@@ -529,21 +529,21 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
}
|
||||
|
||||
if atomic.CompareAndSwapInt32(&e.initSyncStarted, 0, 1) {
|
||||
log.Debugln("Exchange CurrencyPairSyncer initial sync started.")
|
||||
log.Debugln(log.SyncMgr, "Exchange CurrencyPairSyncer initial sync started.")
|
||||
e.initSyncStartTime = time.Now()
|
||||
log.Debugln(createdCounter)
|
||||
log.Debugln(removedCounter)
|
||||
log.Debugln(log.SyncMgr, createdCounter)
|
||||
log.Debugln(log.SyncMgr, removedCounter)
|
||||
}
|
||||
|
||||
go func() {
|
||||
e.initSyncWG.Wait()
|
||||
if atomic.CompareAndSwapInt32(&e.initSyncCompleted, 0, 1) {
|
||||
log.Debugf("Exchange CurrencyPairSyncer initial sync is complete.")
|
||||
log.Debugf(log.SyncMgr, "Exchange CurrencyPairSyncer initial sync is complete.\n")
|
||||
completedTime := time.Now()
|
||||
log.Debugf("Exchange CurrencyPairSyncer initiial sync took %v [%v sync items].", completedTime.Sub(e.initSyncStartTime), createdCounter)
|
||||
log.Debugf(log.SyncMgr, "Exchange CurrencyPairSyncer initiial sync took %v [%v sync items].\n", completedTime.Sub(e.initSyncStartTime), createdCounter)
|
||||
|
||||
if !e.Cfg.SyncContinuously {
|
||||
log.Debugf("Exchange CurrencyPairSyncer stopping.")
|
||||
log.Debugln(log.SyncMgr, "Exchange CurrencyPairSyncer stopping.")
|
||||
e.Stop()
|
||||
Bot.Stop()
|
||||
return
|
||||
@@ -564,6 +564,6 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
|
||||
func (e *ExchangeCurrencyPairSyncer) Stop() {
|
||||
stopped := atomic.CompareAndSwapInt32(&e.shutdown, 0, 1)
|
||||
if stopped {
|
||||
log.Debugf("Exchange CurrencyPairSyncer stopped.")
|
||||
log.Debugln(log.SyncMgr, "Exchange CurrencyPairSyncer stopped.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
)
|
||||
|
||||
func TestNewCurrencyPairSyncer(t *testing.T) {
|
||||
@@ -27,7 +26,7 @@ func TestNewCurrencyPairSyncer(t *testing.T) {
|
||||
SetupExchanges()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("failed to start exchange syncer")
|
||||
t.Log("failed to start exchange syncer")
|
||||
}
|
||||
|
||||
Bot.ExchangeCurrencyPairManager, err = NewCurrencyPairSyncer(CurrencyPairSyncerConfig{
|
||||
|
||||
@@ -42,7 +42,7 @@ func (n *ntpManager) Start() (err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debugln("NTP manager starting...")
|
||||
log.Debugln(log.TimeMgr, "NTP manager starting...")
|
||||
if Bot.Config.NTPClient.Level == 0 {
|
||||
// Initial NTP check (prompts user on how we should proceed)
|
||||
n.inititalCheck = true
|
||||
@@ -55,7 +55,7 @@ func (n *ntpManager) Start() (err error) {
|
||||
case nil:
|
||||
break
|
||||
case errNTPDisabled:
|
||||
log.Debugf("NTP manager: User disabled NTP prompts. Exiting.")
|
||||
log.Debugln(log.TimeMgr, "NTP manager: User disabled NTP prompts. Exiting.")
|
||||
disable = true
|
||||
err = nil
|
||||
return
|
||||
@@ -68,7 +68,7 @@ func (n *ntpManager) Start() (err error) {
|
||||
}
|
||||
n.shutdown = make(chan struct{})
|
||||
go n.run()
|
||||
log.Debugln("NTP manager started.")
|
||||
log.Debugln(log.TimeMgr, "NTP manager started.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (n *ntpManager) Stop() error {
|
||||
}
|
||||
|
||||
close(n.shutdown)
|
||||
log.Debugln("NTP manager shutting down...")
|
||||
log.Debugln(log.TimeMgr, "NTP manager shutting down...")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (n *ntpManager) run() {
|
||||
t.Stop()
|
||||
atomic.CompareAndSwapInt32(&n.stopped, 1, 0)
|
||||
atomic.CompareAndSwapInt32(&n.started, 1, 0)
|
||||
log.Debugln("NTP manager shutdown.")
|
||||
log.Debugln(log.TimeMgr, "NTP manager shutdown.")
|
||||
}()
|
||||
|
||||
for {
|
||||
@@ -123,14 +123,14 @@ func (n *ntpManager) processTime() error {
|
||||
configNTPTime := *Bot.Config.NTPClient.AllowedDifference
|
||||
configNTPNegativeTime := (*Bot.Config.NTPClient.AllowedNegativeDifference - (*Bot.Config.NTPClient.AllowedNegativeDifference * 2))
|
||||
if NTPcurrentTimeDifference > configNTPTime || NTPcurrentTimeDifference < configNTPNegativeTime {
|
||||
log.Warnf("NTP manager: Time out of sync (NTP): %v | (time.Now()): %v | (Difference): %v | (Allowed): +%v / %v", NTPTime, currentTime, NTPcurrentTimeDifference, configNTPTime, configNTPNegativeTime)
|
||||
log.Warnf(log.TimeMgr, "NTP manager: Time out of sync (NTP): %v | (time.Now()): %v | (Difference): %v | (Allowed): +%v / %v\n", NTPTime, currentTime, NTPcurrentTimeDifference, configNTPTime, configNTPNegativeTime)
|
||||
if n.inititalCheck {
|
||||
n.inititalCheck = false
|
||||
disable, err := Bot.Config.DisableNTPCheck(os.Stdin)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to disable NTP check: %s", err)
|
||||
}
|
||||
log.Info(disable)
|
||||
log.Infoln(log.TimeMgr, disable)
|
||||
if Bot.Config.NTPClient.Level == -1 {
|
||||
return errNTPDisabled
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (h *WebsocketHub) run() {
|
||||
h.Clients[client] = true
|
||||
case client := <-h.Unregister:
|
||||
if _, ok := h.Clients[client]; ok {
|
||||
log.Debugln("websocket: disconnected client")
|
||||
log.Debugln(log.WebsocketMgr, "websocket: disconnected client")
|
||||
delete(h.Clients, client)
|
||||
close(client.Send)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (h *WebsocketHub) run() {
|
||||
select {
|
||||
case client.Send <- message:
|
||||
default:
|
||||
log.Debugln("websocket: disconnected client")
|
||||
log.Debugln(log.WebsocketMgr, "websocket: disconnected client")
|
||||
close(client.Send)
|
||||
delete(h.Clients, client)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func (h *WebsocketHub) run() {
|
||||
func (c *WebsocketClient) SendWebsocketMessage(evt interface{}) error {
|
||||
data, err := common.JSONEncode(evt)
|
||||
if err != nil {
|
||||
log.Errorf("websocket: failed to send message: %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: failed to send message: %s\n", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (c *WebsocketClient) read() {
|
||||
msgType, message, err := c.Conn.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
log.Errorf("websocket: client disconnected, err: %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: client disconnected, err: %s\n", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -108,39 +108,39 @@ func (c *WebsocketClient) read() {
|
||||
var evt WebsocketEvent
|
||||
err := common.JSONDecode(message, &evt)
|
||||
if err != nil {
|
||||
log.Errorf("websocket: failed to decode JSON sent from client %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: failed to decode JSON sent from client %s\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if evt.Event == "" {
|
||||
log.Warnf("websocket: client sent a blank event, disconnecting")
|
||||
log.Warnln(log.WebsocketMgr, "websocket: client sent a blank event, disconnecting")
|
||||
continue
|
||||
}
|
||||
|
||||
dataJSON, err := common.JSONEncode(evt.Data)
|
||||
if err != nil {
|
||||
log.Errorf("websocket: client sent data we couldn't JSON decode")
|
||||
log.Errorln(log.WebsocketMgr, "websocket: client sent data we couldn't JSON decode")
|
||||
break
|
||||
}
|
||||
|
||||
req := strings.ToLower(evt.Event)
|
||||
log.Debugf("websocket: request received: %s", req)
|
||||
log.Debugf(log.WebsocketMgr, "websocket: request received: %s\n", req)
|
||||
|
||||
result, ok := wsHandlers[req]
|
||||
if !ok {
|
||||
log.Debugln("websocket: unsupported event")
|
||||
log.Debugln(log.WebsocketMgr, "websocket: unsupported event")
|
||||
continue
|
||||
}
|
||||
|
||||
if result.authRequired && !c.Authenticated {
|
||||
log.Warnf("Websocket: request %s failed due to unauthenticated request on an authenticated API", evt.Event)
|
||||
log.Warnf(log.WebsocketMgr, "Websocket: request %s failed due to unauthenticated request on an authenticated API\n", evt.Event)
|
||||
c.SendWebsocketMessage(WebsocketEventResponse{Event: evt.Event, Error: "unauthorised request on authenticated API"})
|
||||
continue
|
||||
}
|
||||
|
||||
err = result.handler(c, dataJSON)
|
||||
if err != nil {
|
||||
log.Errorf("websocket: request %s failed. Error %s", evt.Event, err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: request %s failed. Error %s\n", evt.Event, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -156,13 +156,13 @@ func (c *WebsocketClient) write() {
|
||||
case message, ok := <-c.Send:
|
||||
if !ok {
|
||||
c.Conn.WriteMessage(websocket.CloseMessage, []byte{})
|
||||
log.Debugln("websocket: hub closed the channel")
|
||||
log.Debugln(log.WebsocketMgr, "websocket: hub closed the channel")
|
||||
return
|
||||
}
|
||||
|
||||
w, err := c.Conn.NextWriter(websocket.TextMessage)
|
||||
if err != nil {
|
||||
log.Errorf("websocket: failed to create new io.writeCloser: %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: failed to create new io.writeCloser: %s\n", err)
|
||||
return
|
||||
}
|
||||
w.Write(message)
|
||||
@@ -174,7 +174,7 @@ func (c *WebsocketClient) write() {
|
||||
}
|
||||
|
||||
if err := w.Close(); err != nil {
|
||||
log.Errorf("websocket: failed to close io.WriteCloser: %s", err)
|
||||
log.Errorf(log.WebsocketMgr, "websocket: failed to close io.WriteCloser: %s\n", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,8 @@ func WebsocketClientHandler(w http.ResponseWriter, r *http.Request) {
|
||||
numClients := len(wsHub.Clients)
|
||||
|
||||
if numClients >= connectionLimit {
|
||||
log.Warnf("websocket: client rejected due to websocket client limit reached. Number of clients %d. Limit %d.",
|
||||
log.Warnf(log.WebsocketMgr,
|
||||
"websocket: client rejected due to websocket client limit reached. Number of clients %d. Limit %d.\n",
|
||||
numClients, connectionLimit)
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
@@ -236,13 +237,14 @@ func WebsocketClientHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.WebsocketMgr, err)
|
||||
return
|
||||
}
|
||||
|
||||
client := &WebsocketClient{Hub: wsHub, Conn: conn, Send: make(chan []byte, 1024)}
|
||||
client.Hub.Register <- client
|
||||
log.Debugf("websocket: client connected. Connected clients: %d. Limit %d.",
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"websocket: client connected. Connected clients: %d. Limit %d.\n",
|
||||
numClients+1, connectionLimit)
|
||||
|
||||
go client.read()
|
||||
@@ -266,7 +268,8 @@ func wsAuth(client *WebsocketClient, data interface{}) error {
|
||||
if auth.Username == Bot.Config.RemoteControl.Username && auth.Password == hashPW {
|
||||
client.Authenticated = true
|
||||
wsResp.Data = WebsocketResponseSuccess
|
||||
log.Debugf("websocket: client authenticated successfully")
|
||||
log.Debugln(log.WebsocketMgr,
|
||||
"websocket: client authenticated successfully")
|
||||
return client.SendWebsocketMessage(wsResp)
|
||||
}
|
||||
|
||||
@@ -274,13 +277,15 @@ func wsAuth(client *WebsocketClient, data interface{}) error {
|
||||
client.authFailures++
|
||||
client.SendWebsocketMessage(wsResp)
|
||||
if client.authFailures >= Bot.Config.RemoteControl.WebsocketRPC.MaxAuthFailures {
|
||||
log.Debugf("websocket: disconnecting client, maximum auth failures threshold reached (failures: %d limit: %d)",
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"websocket: disconnecting client, maximum auth failures threshold reached (failures: %d limit: %d)\n",
|
||||
client.authFailures, Bot.Config.RemoteControl.WebsocketRPC.MaxAuthFailures)
|
||||
wsHub.Unregister <- client
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("websocket: client sent wrong username/password (failures: %d limit: %d)",
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"websocket: client sent wrong username/password (failures: %d limit: %d)\n",
|
||||
client.authFailures, Bot.Config.RemoteControl.WebsocketRPC.MaxAuthFailures)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,25 +20,25 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
a.WebsocketConn, _, err = Dialer.Dial(a.API.Endpoints.WebsocketURL, http.Header{})
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s Unable to connect to Websocket. Error: %s\n", a.Name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if a.Verbose {
|
||||
log.Debugf("%s Connected to Websocket.\n", a.Name)
|
||||
log.Debugf(log.ExchangeSys, "%s Connected to Websocket.\n", a.Name)
|
||||
}
|
||||
|
||||
err = a.WebsocketConn.WriteMessage(websocket.TextMessage, []byte(`{"messageType": "logon"}`))
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
return
|
||||
}
|
||||
|
||||
for a.Enabled {
|
||||
msgType, resp, err := a.WebsocketConn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
msgType := MsgType{}
|
||||
err := common.JSONDecode(resp, &msgType)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ func (a *Alphapoint) WebsocketClient() {
|
||||
ticker := WebsocketTicker{}
|
||||
err = common.JSONDecode(resp, &ticker)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
a.WebsocketConn.Close()
|
||||
log.Debugf("%s Websocket client disconnected.", a.Name)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket client disconnected.", a.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func (a *ANX) GetOrderList(isActiveOrdersOnly bool) ([]OrderResponse, error) {
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return nil, errors.New(response.ResultCode)
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (a *ANX) OrderInfo(orderID string) (OrderResponse, error) {
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return OrderResponse{}, errors.New(response.ResultCode)
|
||||
}
|
||||
return response.Order, nil
|
||||
@@ -263,7 +263,7 @@ func (a *ANX) Send(currency, address, otp, amount string) (string, error) {
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return "", errors.New(response.ResultCode)
|
||||
}
|
||||
return response.TransactionID, nil
|
||||
@@ -289,7 +289,7 @@ func (a *ANX) CreateNewSubAccount(currency, name string) (string, error) {
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return "", errors.New(response.ResultCode)
|
||||
}
|
||||
return response.SubAccount, nil
|
||||
@@ -323,7 +323,7 @@ func (a *ANX) GetDepositAddressByCurrency(currency, name string, newAddr bool) (
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return "", errors.New(response.ResultCode)
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
|
||||
}
|
||||
|
||||
if a.Verbose {
|
||||
log.Debugf("Request JSON: %s\n", PayloadJSON)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s\n", PayloadJSON)
|
||||
}
|
||||
|
||||
hmac := crypto.GetHMAC(crypto.HashSHA512, []byte(path+string("\x00")+string(PayloadJSON)), []byte(a.API.Credentials.Secret))
|
||||
@@ -430,7 +430,7 @@ func (a *ANX) GetAccountInformation() (AccountInformation, error) {
|
||||
}
|
||||
|
||||
if response.ResultCode != "OK" {
|
||||
log.Errorf("Response code is not OK: %s\n", response.ResultCode)
|
||||
log.Errorf(log.ExchangeSys, "Response code is not OK: %s\n", response.ResultCode)
|
||||
return response, errors.New(response.ResultCode)
|
||||
}
|
||||
return response, nil
|
||||
@@ -453,7 +453,7 @@ func (a *ANX) CheckAPIWithdrawPermission() (bool, error) {
|
||||
}
|
||||
|
||||
if !apiAllowsWithdraw {
|
||||
log.Warn("API key is missing withdrawal permissions")
|
||||
log.Warn(log.ExchangeSys, "API key is missing withdrawal permissions")
|
||||
}
|
||||
|
||||
return apiAllowsWithdraw, nil
|
||||
|
||||
@@ -130,12 +130,13 @@ func (a *ANX) Run() {
|
||||
if !common.StringDataContains(a.GetEnabledPairs(asset.Spot).Strings(), "_") ||
|
||||
!common.StringDataContains(a.GetAvailablePairs(asset.Spot).Strings(), "_") {
|
||||
enabledPairs := currency.NewPairsFromStrings([]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.Warn("WARNING: Enabled pairs for ANX reset due to config upgrade, please enable the ones you would like again.")
|
||||
log.Warn(log.ExchangeSys,
|
||||
"Enabled pairs for ANX reset due to config upgrade, please enable the ones you would like again.")
|
||||
|
||||
forceUpdate = true
|
||||
err := a.UpdatePairs(enabledPairs, asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update currencies.\n", a.GetName())
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update currencies.\n", a.GetName())
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -146,7 +147,7 @@ func (a *ANX) Run() {
|
||||
|
||||
err := a.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", a.GetName(), err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", a.GetName(), err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -499,7 +499,7 @@ func (b *Binance) SendAuthHTTPRequest(method, path string, params url.Values, re
|
||||
headers["X-MBX-APIKEY"] = b.API.Credentials.Key
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("sent path: %s", path)
|
||||
log.Debugf(log.ExchangeSys, "sent path: %s", path)
|
||||
}
|
||||
|
||||
path = common.EncodeURLValues(path, params)
|
||||
|
||||
@@ -131,7 +131,8 @@ func (b *Binance) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the Binance wrapper
|
||||
func (b *Binance) Run() {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.Websocket.GetWebsocketURL())
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.Websocket.GetWebsocketURL())
|
||||
b.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -139,12 +140,13 @@ func (b *Binance) Run() {
|
||||
if !common.StringDataContains(b.GetEnabledPairs(asset.Spot).Strings(), "-") ||
|
||||
!common.StringDataContains(b.GetAvailablePairs(asset.Spot).Strings(), "-") {
|
||||
enabledPairs := currency.NewPairsFromStrings([]string{"BTC-USDT"})
|
||||
log.Warn("WARNING: Available pairs for Binance reset due to config upgrade, please enable the ones you would like again")
|
||||
log.Warn(log.ExchangeSys,
|
||||
"Available pairs for Binance reset due to config upgrade, please enable the ones you would like again")
|
||||
forceUpdate = true
|
||||
|
||||
err := b.UpdatePairs(enabledPairs, asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update currencies. Err: %s\n", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update currencies. Err: %s\n", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +156,7 @@ func (b *Binance) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -951,7 +951,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("Request JSON: %s\n", PayloadJSON)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s\n", PayloadJSON)
|
||||
}
|
||||
|
||||
PayloadBase64 := crypto.Base64Encode(PayloadJSON)
|
||||
|
||||
@@ -73,7 +73,7 @@ func (b *Bitfinex) wsSend(data interface{}) error {
|
||||
return err
|
||||
}
|
||||
if b.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", b.Name, data)
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", b.Name, data)
|
||||
}
|
||||
return b.WebsocketConn.WriteMessage(websocket.TextMessage, json)
|
||||
}
|
||||
@@ -119,7 +119,7 @@ func (b *Bitfinex) WsAddSubscriptionChannel(chanID int, channel, pair string) {
|
||||
b.WebsocketSubdChannels[chanID] = chanInfo
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Subscribed to Channel: %s Pair: %s ChannelID: %d\n",
|
||||
log.Debugf(log.ExchangeSys, "%s Subscribed to Channel: %s Pair: %s ChannelID: %d\n",
|
||||
b.GetName(),
|
||||
channel,
|
||||
pair,
|
||||
@@ -163,13 +163,13 @@ func (b *Bitfinex) WsConnect() error {
|
||||
|
||||
err = b.WsSendAuth()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", b.Name, err)
|
||||
}
|
||||
|
||||
b.GenerateDefaultSubscriptions()
|
||||
if hs.Event == "info" {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Connected to Websocket.\n", b.GetName())
|
||||
log.Debugf(log.ExchangeSys, "%s Connected to Websocket.\n", b.GetName())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ func (b *Bitfinex) WsDataHandler() {
|
||||
eventData := result.(map[string]interface{})
|
||||
event := eventData["event"]
|
||||
if b.Verbose {
|
||||
log.Debugf("%v Received message. Type '%v' Message: %v", b.Name, event, eventData)
|
||||
log.Debugf(log.ExchangeSys, "%v Received message. Type '%v' Message: %v", b.Name, event, eventData)
|
||||
}
|
||||
switch event {
|
||||
case "subscribed":
|
||||
|
||||
@@ -131,7 +131,8 @@ func (b *Bitfinex) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the Bitfinex wrapper
|
||||
func (b *Bitfinex) Run() {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
|
||||
b.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -141,7 +142,8 @@ func (b *Bitfinex) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys,
|
||||
"%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +464,7 @@ func (b *Bitfinex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest)
|
||||
orderSide := exchange.OrderSide(strings.ToUpper(resp[i].Side))
|
||||
timestamp, err := strconv.ParseInt(resp[i].Timestamp, 10, 64)
|
||||
if err != nil {
|
||||
log.Warnf("Unable to convert timestamp '%v', leaving blank", resp[i].Timestamp)
|
||||
log.Warnf(log.ExchangeSys, "Unable to convert timestamp '%v', leaving blank", resp[i].Timestamp)
|
||||
}
|
||||
orderDate := time.Unix(timestamp, 0)
|
||||
|
||||
@@ -521,7 +523,7 @@ func (b *Bitfinex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest)
|
||||
orderSide := exchange.OrderSide(strings.ToUpper(resp[i].Side))
|
||||
timestamp, err := strconv.ParseInt(resp[i].Timestamp, 10, 64)
|
||||
if err != nil {
|
||||
log.Warnf("Unable to convert timestamp '%v', leaving blank", resp[i].Timestamp)
|
||||
log.Warnf(log.ExchangeSys, "Unable to convert timestamp '%v', leaving blank", resp[i].Timestamp)
|
||||
}
|
||||
orderDate := time.Unix(timestamp, 0)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestGetAddressInfoCA(t *testing.T) {
|
||||
t.Error("test failed - Bitflyer - GetAddressInfoCA() error:", err)
|
||||
}
|
||||
if v.UnconfirmedBalance == 0 || v.ConfirmedBalance == 0 {
|
||||
log.Warn("Donation wallet is empty :( - please consider donating")
|
||||
log.Warn(log.ExchangeSys, "Donation wallet is empty :( - please consider donating")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ func (b *Bitflyer) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ func (b *Bithumb) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ func (b *Bitmex) WsConnector() error {
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("Successfully connected to Bitmex %s at time: %s Limit: %d",
|
||||
log.Debugf(log.ExchangeSys, "Successfully connected to Bitmex %s at time: %s Limit: %d",
|
||||
welcomeResp.Info,
|
||||
welcomeResp.Timestamp,
|
||||
welcomeResp.Limit.Remaining)
|
||||
@@ -112,7 +112,7 @@ func (b *Bitmex) WsConnector() error {
|
||||
|
||||
err = b.websocketSendAuth()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", b.Name, err)
|
||||
}
|
||||
b.GenerateAuthenticatedSubscriptions()
|
||||
return nil
|
||||
@@ -195,13 +195,13 @@ func (b *Bitmex) wsHandleIncomingData() {
|
||||
b.Websocket.DataHandler <- decodedResp
|
||||
if len(quickCapture) == 3 {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s websocket: Successfully subscribed to %s",
|
||||
log.Debugf(log.ExchangeSys, "%s websocket: Successfully subscribed to %s",
|
||||
b.Name, decodedResp.Subscribe)
|
||||
}
|
||||
} else {
|
||||
b.Websocket.SetCanUseAuthenticatedEndpoints(true)
|
||||
if b.Verbose {
|
||||
log.Debugf("%s websocket: Successfully authenticated websocket connection",
|
||||
log.Debugf(log.ExchangeSys, "%s websocket: Successfully authenticated websocket connection",
|
||||
b.Name)
|
||||
}
|
||||
}
|
||||
@@ -561,7 +561,7 @@ func (b *Bitmex) wsSend(data interface{}) error {
|
||||
b.wsRequestMtx.Lock()
|
||||
defer b.wsRequestMtx.Unlock()
|
||||
if b.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", b.Name, data)
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", b.Name, data)
|
||||
}
|
||||
return b.WebsocketConn.WriteJSON(data)
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func (b *Bitmex) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the Bitmex wrapper
|
||||
func (b *Bitmex) Run() {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.API.Endpoints.WebsocketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()), b.API.Endpoints.WebsocketURL)
|
||||
b.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ func (b *Bitmex) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (b *Bitmex) UpdateTradablePairs(forceUpdate bool) error {
|
||||
|
||||
err = b.UpdatePairs(currency.NewPairsFromStrings(assetPairs), b.CurrencyPairs.AssetTypes[x], false, false)
|
||||
if err != nil {
|
||||
log.Warnf("%s failed to update available pairs. Err: %v", b.Name, err)
|
||||
log.Warnf(log.ExchangeSys, "%s failed to update available pairs. Err: %v", b.Name, err)
|
||||
}
|
||||
assetPairs = nil
|
||||
}
|
||||
|
||||
@@ -192,12 +192,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Bids = append(orderbook.Bids, OrderbookBase{price, amount})
|
||||
@@ -206,12 +206,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Asks = append(orderbook.Asks, OrderbookBase{price, amount})
|
||||
@@ -598,7 +598,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("Sending POST request to " + path)
|
||||
log.Debugf(log.ExchangeSys, "Sending POST request to "+path)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
|
||||
@@ -46,7 +46,7 @@ func (b *Bitstamp) WsConnect() error {
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Connected to Websocket.\n", b.GetName())
|
||||
log.Debugf(log.ExchangeSys, "%s Connected to Websocket.\n", b.GetName())
|
||||
}
|
||||
|
||||
err = b.seedOrderBook()
|
||||
@@ -69,7 +69,7 @@ func (b *Bitstamp) WsReadData() (exchange.WebsocketResponse, error) {
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("%s websocket raw response: %s", b.GetName(), resp)
|
||||
log.Debugf(log.ExchangeSys, "%s websocket raw response: %s", b.GetName(), resp)
|
||||
}
|
||||
|
||||
b.Websocket.TrafficAlert <- struct{}{}
|
||||
@@ -106,7 +106,7 @@ func (b *Bitstamp) WsHandleData() {
|
||||
switch wsResponse.Event {
|
||||
case "bts:request_reconnect":
|
||||
if b.Verbose {
|
||||
log.Debugf("%v - Websocket reconnection request received", b.GetName())
|
||||
log.Debugf(log.ExchangeSys, "%v - Websocket reconnection request received", b.GetName())
|
||||
}
|
||||
go b.Websocket.WebsocketReset()
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ func (b *Bitstamp) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the Bitstamp wrapper
|
||||
func (b *Bitstamp) Run() {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s.", b.GetName(), common.IsEnabled(b.Websocket.IsEnabled()))
|
||||
b.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (b *Bitstamp) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ func (b *Bitstamp) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest)
|
||||
case order.XRP > 0:
|
||||
baseCurrency = currency.XRP
|
||||
default:
|
||||
log.Warnf("no base currency found for OrderID '%v'", order.OrderID)
|
||||
log.Warnf(log.ExchangeSys, "no base currency found for OrderID '%v'", order.OrderID)
|
||||
}
|
||||
|
||||
switch {
|
||||
@@ -498,7 +498,7 @@ func (b *Bitstamp) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest)
|
||||
case order.EUR > 0:
|
||||
quoteCurrency = currency.EUR
|
||||
default:
|
||||
log.Warnf("no quote currency found for orderID '%v'", order.OrderID)
|
||||
log.Warnf(log.ExchangeSys, "no quote currency found for orderID '%v'", order.OrderID)
|
||||
}
|
||||
|
||||
var currPair currency.Pair
|
||||
|
||||
@@ -119,11 +119,11 @@ func (b *Bittrex) Run() {
|
||||
!common.StringDataContains(b.GetAvailablePairs(asset.Spot).Strings(), "-") {
|
||||
forceUpdate = true
|
||||
enabledPairs := []string{"USDT-BTC"}
|
||||
log.Warn("WARNING: Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
|
||||
log.Warn(log.ExchangeSys, "Available pairs for Bittrex reset due to config upgrade, please enable the ones you would like again")
|
||||
|
||||
err := b.UpdatePairs(currency.NewPairsFromStrings(enabledPairs), asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update currencies. Err: %s\n", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update currencies. Err: %s\n", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func (b *Bittrex) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ func (b *Bittrex) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) (
|
||||
for i := range resp.Result {
|
||||
orderDate, err := time.Parse(time.RFC3339, resp.Result[i].Opened)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
b.Name, "GetActiveOrders", resp.Result[i].OrderUUID, resp.Result[i].Opened)
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ func (b *Bittrex) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) (
|
||||
for i := range resp.Result {
|
||||
orderDate, err := time.Parse(time.RFC3339, resp.Result[i].TimeStamp)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
b.Name, "GetActiveOrders", resp.Result[i].OrderUUID, resp.Result[i].Opened)
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data, result
|
||||
[]byte(req), []byte(b.API.Credentials.Secret))
|
||||
|
||||
if b.Verbose {
|
||||
log.Debugf("Sending %s request to URL %s with params %s\n",
|
||||
log.Debugf(log.ExchangeSys, "Sending %s request to URL %s with params %s\n",
|
||||
reqType,
|
||||
b.API.Endpoints.URL+path,
|
||||
req)
|
||||
|
||||
@@ -118,12 +118,12 @@ func (b *BTCMarkets) Run() {
|
||||
if !common.StringDataContains(b.GetEnabledPairs(asset.Spot).Strings(), "-") ||
|
||||
!common.StringDataContains(b.GetAvailablePairs(asset.Spot).Strings(), "-") {
|
||||
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.Warnln(log.ExchangeSys, "Available pairs for BTC Markets reset due to config upgrade, please enable the pairs you would like again.")
|
||||
forceUpdate = true
|
||||
|
||||
err := b.UpdatePairs(currency.NewPairsFromStrings(enabledPairs), asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update currencies. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update currencies. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func (b *BTCMarkets) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ func (b *BTSE) SendAuthenticatedHTTPRequest(method, endpoint string, req map[str
|
||||
|
||||
p := fmt.Sprintf("%s/%s", b.API.Endpoints.URL, endpoint)
|
||||
if b.Verbose {
|
||||
log.Debugf("Sending %s request to URL %s with params %s\n", method, p, string(payload))
|
||||
log.Debugf(log.ExchangeSys, "Sending %s request to URL %s with params %s\n", method, p, string(payload))
|
||||
}
|
||||
return b.SendPayload(method, p, headers, strings.NewReader(string(payload)),
|
||||
&result, true, false, b.Verbose, b.HTTPDebugging)
|
||||
|
||||
@@ -93,7 +93,7 @@ func (b *BTSE) WsHandleData() {
|
||||
|
||||
if strings.Contains(string(resp.Raw), "Welcome to BTSE") {
|
||||
if b.Verbose {
|
||||
log.Debugf("%s websocket client successfully connected to %s",
|
||||
log.Debugf(log.ExchangeSys, "%s websocket client successfully connected to %s",
|
||||
b.Name, b.Websocket.GetWebsocketURL())
|
||||
}
|
||||
continue
|
||||
@@ -252,7 +252,7 @@ func (b *BTSE) wsSend(data interface{}) error {
|
||||
b.wsRequestMtx.Lock()
|
||||
defer b.wsRequestMtx.Unlock()
|
||||
if b.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", b.Name, data)
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", b.Name, data)
|
||||
}
|
||||
json, err := common.JSONEncode(data)
|
||||
if err != nil {
|
||||
|
||||
@@ -135,7 +135,7 @@ func (b *BTSE) Run() {
|
||||
|
||||
err := b.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", b.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ func (b *BTSE) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]e
|
||||
|
||||
fills, err := b.GetFills(order.ID, "", "", "", "")
|
||||
if err != nil {
|
||||
log.Errorf("unable to get order fills for orderID %s", order.ID)
|
||||
log.Errorf(log.ExchangeSys, "unable to get order fills for orderID %s", order.ID)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -731,7 +731,7 @@ func (c *CoinbasePro) SendAuthenticatedHTTPRequest(method, path string, params m
|
||||
}
|
||||
|
||||
if c.Verbose {
|
||||
log.Debugf("Request JSON: %s\n", payload)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s\n", payload)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ func (c *CoinbasePro) wsSend(data interface{}) error {
|
||||
c.wsRequestMtx.Lock()
|
||||
defer c.wsRequestMtx.Unlock()
|
||||
if c.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", c.Name, data)
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", c.Name, data)
|
||||
}
|
||||
json, err := common.JSONEncode(data)
|
||||
if err != nil {
|
||||
|
||||
@@ -130,7 +130,7 @@ func (c *CoinbasePro) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the coinbasepro wrapper
|
||||
func (c *CoinbasePro) Run() {
|
||||
if c.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinbaseproWebsocketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinbaseproWebsocketURL)
|
||||
c.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ func (c *CoinbasePro) Run() {
|
||||
|
||||
err := c.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", c.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", c.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ func (c *CoinbasePro) GetActiveOrders(getOrdersRequest *exchange.GetOrdersReques
|
||||
orderType := exchange.OrderType(strings.ToUpper(respOrders[i].Type))
|
||||
orderDate, err := time.Parse(time.RFC3339, respOrders[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
c.Name, "GetActiveOrders", respOrders[i].ID, respOrders[i].CreatedAt)
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ func (c *CoinbasePro) GetOrderHistory(getOrdersRequest *exchange.GetOrdersReques
|
||||
orderType := exchange.OrderType(strings.ToUpper(respOrders[i].Type))
|
||||
orderDate, err := time.Parse(time.RFC3339, respOrders[i].CreatedAt)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
c.Name, "GetActiveOrders", respOrders[i].ID, respOrders[i].CreatedAt)
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{
|
||||
}
|
||||
|
||||
if c.Verbose {
|
||||
log.Debugf("Request JSON: %s", payload)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s", payload)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
|
||||
@@ -459,7 +459,7 @@ func (c *COINUT) wsSend(data interface{}) error {
|
||||
return err
|
||||
}
|
||||
if c.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", c.Name, string(json))
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", c.Name, string(json))
|
||||
}
|
||||
// Basic rate limiter
|
||||
time.Sleep(coinutWebsocketRateLimit)
|
||||
|
||||
@@ -128,7 +128,7 @@ func (c *COINUT) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the COINUT wrapper
|
||||
func (c *COINUT) Run() {
|
||||
if c.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinutWebsocketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", c.GetName(), common.IsEnabled(c.Websocket.IsEnabled()), coinutWebsocketURL)
|
||||
c.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func (c *COINUT) Run() {
|
||||
|
||||
err := c.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", c.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", c.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ func (e *Base) SetAPIKeys(apiKey, apiSecret, clientID string) {
|
||||
if err != nil {
|
||||
e.API.AuthenticatedSupport = false
|
||||
e.API.AuthenticatedWebsocketSupport = false
|
||||
log.Warnf(warningBase64DecryptSecretKeyFailed, e.Name)
|
||||
log.Warnf(log.ExchangeSys, warningBase64DecryptSecretKeyFailed, e.Name)
|
||||
}
|
||||
e.API.Credentials.Secret = string(result)
|
||||
} else {
|
||||
@@ -482,7 +482,8 @@ func (e *Base) ValidateAPICredentials() bool {
|
||||
if e.API.CredentialsValidator.RequiresKey {
|
||||
if e.API.Credentials.Key == "" ||
|
||||
e.API.Credentials.Key == config.DefaultAPIKey {
|
||||
log.Warnf("exchange %s requires API key but default/empty one set",
|
||||
log.Warnf(log.ExchangeSys,
|
||||
"exchange %s requires API key but default/empty one set",
|
||||
e.Name)
|
||||
return false
|
||||
}
|
||||
@@ -491,7 +492,8 @@ func (e *Base) ValidateAPICredentials() bool {
|
||||
if e.API.CredentialsValidator.RequiresSecret {
|
||||
if e.API.Credentials.Secret == "" ||
|
||||
e.API.Credentials.Secret == config.DefaultAPISecret {
|
||||
log.Warnf("exchange %s requires API secret but default/empty one set",
|
||||
log.Warnf(log.ExchangeSys,
|
||||
"exchange %s requires API secret but default/empty one set",
|
||||
e.Name)
|
||||
return false
|
||||
}
|
||||
@@ -500,7 +502,8 @@ func (e *Base) ValidateAPICredentials() bool {
|
||||
if e.API.CredentialsValidator.RequiresPEM {
|
||||
if e.API.Credentials.PEMKey == "" ||
|
||||
strings.Contains(e.API.Credentials.PEMKey, "JUSTADUMMY") {
|
||||
log.Warnf("exchange %s requires API PEM key but default/empty one set",
|
||||
log.Warnf(log.ExchangeSys,
|
||||
"exchange %s requires API PEM key but default/empty one set",
|
||||
e.Name)
|
||||
return false
|
||||
}
|
||||
@@ -509,7 +512,8 @@ func (e *Base) ValidateAPICredentials() bool {
|
||||
if e.API.CredentialsValidator.RequiresClientID {
|
||||
if e.API.Credentials.ClientID == "" ||
|
||||
e.API.Credentials.ClientID == config.DefaultAPIClientID {
|
||||
log.Warnf("exchange %s requires API ClientID but default/empty one set",
|
||||
log.Warnf(log.ExchangeSys,
|
||||
"exchange %s requires API ClientID but default/empty one set",
|
||||
e.Name)
|
||||
return false
|
||||
}
|
||||
@@ -518,7 +522,8 @@ func (e *Base) ValidateAPICredentials() bool {
|
||||
if e.API.CredentialsValidator.RequiresBase64DecodeSecret && !e.LoadedByConfig {
|
||||
_, err := crypto.Base64Decode(e.API.Credentials.Secret)
|
||||
if err != nil {
|
||||
log.Warnf("exchange %s API secret base64 decode failed: %s",
|
||||
log.Warnf(log.ExchangeSys,
|
||||
"exchange %s API secret base64 decode failed: %s",
|
||||
e.Name, err)
|
||||
return false
|
||||
}
|
||||
@@ -575,15 +580,18 @@ func (e *Base) UpdatePairs(exchangeProducts currency.Pairs, assetType asset.Item
|
||||
|
||||
if force || len(newPairs) > 0 || len(removedPairs) > 0 {
|
||||
if force {
|
||||
log.Debugf("%s forced update of %s [%v] pairs.", e.Name, updateType,
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s forced update of %s [%v] pairs.", e.Name, updateType,
|
||||
strings.ToUpper(assetType.String()))
|
||||
} else {
|
||||
if len(newPairs) > 0 {
|
||||
log.Debugf("%s Updating pairs [%v] - New: %s.\n", e.Name,
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s Updating pairs [%v] - New: %s.\n", e.Name,
|
||||
strings.ToUpper(assetType.String()), newPairs)
|
||||
}
|
||||
if len(removedPairs) > 0 {
|
||||
log.Debugf("%s Updating pairs [%v] - Removed: %s.\n", e.Name,
|
||||
log.Debugf(log.ExchangeSys,
|
||||
"%s Updating pairs [%v] - Removed: %s.\n", e.Name,
|
||||
strings.ToUpper(assetType.String()), removedPairs)
|
||||
}
|
||||
}
|
||||
@@ -725,7 +733,7 @@ func (e *Base) IsAssetTypeSupported(asset asset.Item) bool {
|
||||
// PrintEnabledPairs prints the exchanges enabled asset pairs
|
||||
func (e *Base) PrintEnabledPairs() {
|
||||
for k, v := range e.CurrencyPairs.Pairs {
|
||||
log.Infof("%s Asset type %v:\n\t Enabled pairs: %v",
|
||||
log.Infof(log.ExchangeSys, "%s Asset type %v:\n\t Enabled pairs: %v",
|
||||
e.Name, strings.ToUpper(k.String()), v.Enabled)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va
|
||||
[]byte(e.API.Credentials.Secret))
|
||||
|
||||
if e.Verbose {
|
||||
log.Debugf("Sending %s request to %s with params %s\n",
|
||||
log.Debugf(log.ExchangeSys, "Sending %s request to %s with params %s\n",
|
||||
method,
|
||||
endpoint,
|
||||
payload)
|
||||
|
||||
@@ -122,7 +122,7 @@ func (e *EXMO) Run() {
|
||||
|
||||
err := e.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", e.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", e.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (g *Gateio) WsConnect() error {
|
||||
|
||||
err = g.wsServerSignIn()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", g.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", g.Name, err)
|
||||
}
|
||||
g.GenerateAuthenticatedSubscriptions()
|
||||
g.GenerateDefaultSubscriptions()
|
||||
@@ -456,7 +456,7 @@ func (g *Gateio) wsSend(data interface{}) error {
|
||||
g.wsRequestMtx.Lock()
|
||||
defer g.wsRequestMtx.Unlock()
|
||||
if g.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", g.Name, data)
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", g.Name, data)
|
||||
}
|
||||
// Basic rate limiter
|
||||
time.Sleep(gateioWebsocketRateLimit)
|
||||
|
||||
@@ -142,7 +142,7 @@ func (g *Gateio) Run() {
|
||||
|
||||
err := g.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", g.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", g.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st
|
||||
}
|
||||
|
||||
if g.Verbose {
|
||||
log.Debugf("Request JSON: %s", PayloadJSON)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s", PayloadJSON)
|
||||
}
|
||||
|
||||
PayloadBase64 := crypto.Base64Encode(PayloadJSON)
|
||||
|
||||
@@ -48,7 +48,7 @@ func (g *Gemini) WsConnect() error {
|
||||
go g.WsHandleData()
|
||||
err := g.WsSecureSubscribe(&dialer, geminiWsOrderEvents)
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", g.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", g.Name, err)
|
||||
}
|
||||
return g.WsSubscribe(&dialer)
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ func (g *Gemini) Run() {
|
||||
|
||||
err := g.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", g.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", g.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (h *HitBTC) WsConnect() error {
|
||||
go h.WsHandleData()
|
||||
err = h.wsLogin()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", h.Name, err)
|
||||
}
|
||||
|
||||
h.GenerateDefaultSubscriptions()
|
||||
@@ -391,7 +391,7 @@ func (h *HitBTC) wsSend(data interface{}) error {
|
||||
return err
|
||||
}
|
||||
if h.Verbose {
|
||||
log.Debugf("%v sending message to websocket %v", h.Name, string(json))
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %v", h.Name, string(json))
|
||||
}
|
||||
return h.WebsocketConn.WriteMessage(websocket.TextMessage, json)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (h *HitBTC) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the HitBTC wrapper
|
||||
func (h *HitBTC) Run() {
|
||||
if h.Verbose {
|
||||
log.Debugf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), hitbtcWebsocketAddress)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), hitbtcWebsocketAddress)
|
||||
h.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -135,12 +135,12 @@ func (h *HitBTC) Run() {
|
||||
if !common.StringDataContains(h.GetEnabledPairs(asset.Spot).Strings(), "-") ||
|
||||
!common.StringDataContains(h.GetAvailablePairs(asset.Spot).Strings(), "-") {
|
||||
enabledPairs := []string{"BTC-USD"}
|
||||
log.Warn("WARNING: Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")
|
||||
log.Warn(log.ExchangeSys, "Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")
|
||||
forceUpdate = true
|
||||
|
||||
err := h.UpdatePairs(currency.NewPairsFromStrings(enabledPairs), asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update enabled currencies.\n", h.GetName())
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update enabled currencies.\n", h.GetName())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (h *HitBTC) Run() {
|
||||
|
||||
err := h.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ func (h *HUOBI) WsConnect() error {
|
||||
}
|
||||
err = h.wsAuthenticatedDial(&dialer)
|
||||
if err != nil {
|
||||
log.Errorf("%v - authenticated dial failed: %v", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authenticated dial failed: %v\n", h.Name, err)
|
||||
}
|
||||
err = h.wsLogin()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", h.Name, err)
|
||||
}
|
||||
|
||||
go h.WsHandleData()
|
||||
@@ -156,7 +156,7 @@ func (h *HUOBI) WsHandleData() {
|
||||
return
|
||||
case resp := <-comms:
|
||||
if h.Verbose {
|
||||
log.Debugf("%v: %v: %v", h.Name, resp.URL, string(resp.Raw))
|
||||
log.Debugf(log.ExchangeSys, "%v: %v: %v", h.Name, resp.URL, string(resp.Raw))
|
||||
}
|
||||
switch resp.URL {
|
||||
case wsMarketURL:
|
||||
@@ -189,14 +189,14 @@ func (h *HUOBI) wsHandleAuthenticatedData(resp WsMessage) {
|
||||
if init.Ping != 0 {
|
||||
err = h.WebsocketConn.WriteJSON(`{"pong":1337}`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if init.Op == "sub" {
|
||||
if h.Verbose {
|
||||
log.Debugf("%v: %v: Successfully subscribed to %v", h.Name, resp.URL, init.Topic)
|
||||
log.Debugf(log.ExchangeSys, "%v: %v: Successfully subscribed to %v", h.Name, resp.URL, init.Topic)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -277,7 +277,7 @@ func (h *HUOBI) wsHandleMarketData(resp WsMessage) {
|
||||
if init.Ping != 0 {
|
||||
err = h.WebsocketConn.WriteJSON(`{"pong":1337}`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -420,7 +420,7 @@ func (h *HUOBI) wsSend(data []byte) error {
|
||||
h.wsRequestMtx.Lock()
|
||||
defer h.wsRequestMtx.Unlock()
|
||||
if h.Verbose {
|
||||
log.Debugf("%v sending message to websocket %s", h.Name, string(data))
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %s", h.Name, string(data))
|
||||
}
|
||||
return h.WebsocketConn.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
@@ -456,7 +456,7 @@ func (h *HUOBI) wsAuthenticatedSend(request interface{}) error {
|
||||
return err
|
||||
}
|
||||
if h.Verbose {
|
||||
log.Debugf("%v sending Authenticated message to websocket %s", h.Name, string(encodedRequest))
|
||||
log.Debugf(log.ExchangeSys, "%v sending Authenticated message to websocket %s", h.Name, string(encodedRequest))
|
||||
}
|
||||
return h.AuthenticatedWebsocketConn.WriteMessage(websocket.TextMessage, encodedRequest)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func (h *HUOBI) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the HUOBI wrapper
|
||||
func (h *HUOBI) Run() {
|
||||
if h.Verbose {
|
||||
log.Debugf("%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), wsMarketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s (url: %s).\n", h.GetName(), common.IsEnabled(h.Websocket.IsEnabled()), wsMarketURL)
|
||||
h.PrintEnabledPairs()
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ func (h *HUOBI) Run() {
|
||||
cfg := config.GetConfig()
|
||||
exchCfg, err := cfg.GetExchangeConfig(h.Name)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to get exchange config. %s\n", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to get exchange config. %s\n", h.Name, err)
|
||||
return
|
||||
}
|
||||
exchCfg.BaseCurrencies = currency.Currencies{currency.USD}
|
||||
@@ -162,11 +162,11 @@ func (h *HUOBI) Run() {
|
||||
Delimiter: "-",
|
||||
},
|
||||
}
|
||||
log.Warn("WARNING: Available and enabled pairs for Huobi reset due to config upgrade, please enable the ones you would like again")
|
||||
log.Warn(log.ExchangeSys, "Available and enabled pairs for Huobi reset due to config upgrade, please enable the ones you would like again")
|
||||
|
||||
err := h.UpdatePairs(enabledPairs, asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s Failed to update enabled currencies.\n", h.GetName())
|
||||
log.Errorf(log.ExchangeSys, "%s Failed to update enabled currencies.\n", h.GetName())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ func (h *HUOBI) Run() {
|
||||
|
||||
err := h.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/common/crypto"
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -330,7 +331,7 @@ func (h *HUOBIHADAX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error)
|
||||
bytesParams, _ := json.Marshal(vals)
|
||||
postBodyParams := string(bytesParams)
|
||||
if h.Verbose {
|
||||
fmt.Println("Post params:", postBodyParams)
|
||||
log.Debugf(log.ExchangeSys, "Post params: %v", postBodyParams)
|
||||
}
|
||||
|
||||
var result response
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package huobihadax
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -276,7 +275,7 @@ func TestSpotNewOrder(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Huobi SpotNewOrder: %s", err)
|
||||
} else {
|
||||
fmt.Println(newOrderID)
|
||||
t.Log(newOrderID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ func (h *HUOBIHADAX) WsConnect() error {
|
||||
}
|
||||
err = h.wsAuthenticatedDial(&dialer)
|
||||
if err != nil {
|
||||
log.Errorf("%v - authenticated dial failed: %v", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authenticated dial failed: %v\n", h.Name, err)
|
||||
}
|
||||
err = h.wsLogin()
|
||||
if err != nil {
|
||||
log.Errorf("%v - authentication failed: %v", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v - authentication failed: %v\n", h.Name, err)
|
||||
}
|
||||
|
||||
go h.WsHandleData()
|
||||
@@ -156,7 +156,7 @@ func (h *HUOBIHADAX) WsHandleData() {
|
||||
return
|
||||
case resp := <-comms:
|
||||
if h.Verbose {
|
||||
log.Debugf("%v: %v: %v", h.Name, resp.URL, string(resp.Raw))
|
||||
log.Debugf(log.ExchangeSys, "%v: %v: %v", h.Name, resp.URL, string(resp.Raw))
|
||||
}
|
||||
switch resp.URL {
|
||||
case HuobiHadaxSocketIOAddress:
|
||||
@@ -189,14 +189,14 @@ func (h *HUOBIHADAX) wsHandleAuthenticatedData(resp WsMessage) {
|
||||
if init.Ping != 0 {
|
||||
err = h.WebsocketConn.WriteJSON(`{"pong":1337}`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if init.Op == "sub" {
|
||||
if h.Verbose {
|
||||
log.Debugf("%v: %v: Successfully subscribed to %v", h.Name, resp.URL, init.Topic)
|
||||
log.Debugf(log.ExchangeSys, "%v: %v: Successfully subscribed to %v", h.Name, resp.URL, init.Topic)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -277,7 +277,7 @@ func (h *HUOBIHADAX) wsHandleMarketData(resp WsMessage) {
|
||||
if init.Ping != 0 {
|
||||
err = h.WebsocketConn.WriteJSON(`{"pong":1337}`)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -420,7 +420,7 @@ func (h *HUOBIHADAX) wsSend(data []byte) error {
|
||||
h.wsRequestMtx.Lock()
|
||||
defer h.wsRequestMtx.Unlock()
|
||||
if h.Verbose {
|
||||
log.Debugf("%v sending message to websocket %s", h.Name, string(data))
|
||||
log.Debugf(log.ExchangeSys, "%v sending message to websocket %s", h.Name, string(data))
|
||||
}
|
||||
return h.WebsocketConn.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
@@ -456,7 +456,7 @@ func (h *HUOBIHADAX) wsAuthenticatedSend(request interface{}) error {
|
||||
return err
|
||||
}
|
||||
if h.Verbose {
|
||||
log.Debugf("%v sending Authenticated message to websocket %s", h.Name, string(encodedRequest))
|
||||
log.Debugf(log.ExchangeSys, "%v sending Authenticated message to websocket %s", h.Name, string(encodedRequest))
|
||||
}
|
||||
return h.AuthenticatedWebsocketConn.WriteMessage(websocket.TextMessage, encodedRequest)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (h *HUOBIHADAX) Run() {
|
||||
|
||||
err := h.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", h.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method, path string, params map[str
|
||||
}
|
||||
|
||||
if i.Verbose {
|
||||
log.Debugf("Request JSON: %s\n", PayloadJSON)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s\n", PayloadJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ func (i *ItBit) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequest) ([]
|
||||
side := exchange.OrderSide(strings.ToUpper(allOrders[j].Side))
|
||||
orderDate, err := time.Parse(time.RFC3339, allOrders[j].CreatedTime)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
i.Name, "GetActiveOrders", allOrders[j].ID, allOrders[j].CreatedTime)
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ func (i *ItBit) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest) ([]
|
||||
side := exchange.OrderSide(strings.ToUpper(allOrders[j].Side))
|
||||
orderDate, err := time.Parse(time.RFC3339, allOrders[j].CreatedTime)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
i.Name, "GetActiveOrders", allOrders[j].ID, allOrders[j].CreatedTime)
|
||||
}
|
||||
|
||||
|
||||
@@ -835,7 +835,7 @@ func GetError(apiErrors []string) error {
|
||||
for _, e := range apiErrors {
|
||||
switch e[0] {
|
||||
case 'W':
|
||||
log.Warnf("%s API warning: %v\n", exchangeName, e[1:])
|
||||
log.Warnf(log.ExchangeSys, "%s API warning: %v\n", exchangeName, e[1:])
|
||||
default:
|
||||
return fmt.Errorf("%s API error: %v", exchangeName, e[1:])
|
||||
}
|
||||
@@ -865,7 +865,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values,
|
||||
append([]byte(path), shasum...), []byte(k.API.Credentials.Secret)))
|
||||
|
||||
if k.Verbose {
|
||||
log.Debugf("Sending POST request to %s, path: %s, params: %s",
|
||||
log.Debugf(log.ExchangeSys, "Sending POST request to %s, path: %s, params: %s",
|
||||
k.API.Endpoints.URL,
|
||||
path,
|
||||
encoded)
|
||||
|
||||
@@ -72,7 +72,7 @@ func (k *Kraken) writeToWebsocket(message []byte) error {
|
||||
k.wsRequestMtx.Lock()
|
||||
defer k.wsRequestMtx.Unlock()
|
||||
if k.Verbose {
|
||||
log.Debugf("Sending message to WS: %v",
|
||||
log.Debugf(log.ExchangeSys, "Sending message to WS: %v",
|
||||
string(message))
|
||||
}
|
||||
// Really basic WS rate limit
|
||||
@@ -98,7 +98,7 @@ func (k *Kraken) WsConnect() error {
|
||||
|
||||
var err error
|
||||
if k.Verbose {
|
||||
log.Debugf("Attempting to connect to %v",
|
||||
log.Debugf(log.ExchangeSys, "Attempting to connect to %v",
|
||||
k.Websocket.GetWebsocketURL())
|
||||
}
|
||||
k.WebsocketConn, _, err = dialer.Dial(k.Websocket.GetWebsocketURL(),
|
||||
@@ -109,7 +109,7 @@ func (k *Kraken) WsConnect() error {
|
||||
err)
|
||||
}
|
||||
if k.Verbose {
|
||||
log.Debugf("Successful connection to %v",
|
||||
log.Debugf(log.ExchangeSys, "Successful connection to %v",
|
||||
k.Websocket.GetWebsocketURL())
|
||||
}
|
||||
go k.WsHandleData()
|
||||
@@ -142,7 +142,7 @@ func (k *Kraken) WsReadData() (exchange.WebsocketResponse, error) {
|
||||
}
|
||||
}
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket message received: %v",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket message received: %v",
|
||||
k.Name,
|
||||
string(standardMessage))
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func (k *Kraken) wsPingHandler() {
|
||||
case <-ticker.C:
|
||||
pingEvent := fmt.Sprintf("{\"event\":\"%v\"}", krakenWsPing)
|
||||
if k.Verbose {
|
||||
log.Debugf("%v sending ping",
|
||||
log.Debugf(log.ExchangeSys, "%v sending ping",
|
||||
k.GetName())
|
||||
}
|
||||
err := k.writeToWebsocket([]byte(pingEvent))
|
||||
@@ -221,36 +221,36 @@ func (k *Kraken) WsHandleDataResponse(response WebsocketDataResponse) {
|
||||
switch channelData.Subscription {
|
||||
case krakenWsTicker:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket ticker data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket ticker data received",
|
||||
k.GetName())
|
||||
}
|
||||
k.wsProcessTickers(&channelData, response[1])
|
||||
case krakenWsOHLC:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket OHLC data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket OHLC data received",
|
||||
k.GetName())
|
||||
}
|
||||
k.wsProcessCandles(&channelData, response[1])
|
||||
case krakenWsOrderbook:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket Orderbook data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket Orderbook data received",
|
||||
k.GetName())
|
||||
}
|
||||
k.wsProcessOrderBook(&channelData, response[1])
|
||||
case krakenWsSpread:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket Spread data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket Spread data received",
|
||||
k.GetName())
|
||||
}
|
||||
k.wsProcessSpread(&channelData, response[1])
|
||||
case krakenWsTrade:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket Trade data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket Trade data received",
|
||||
k.GetName())
|
||||
}
|
||||
k.wsProcessTrades(&channelData, response[1])
|
||||
default:
|
||||
log.Errorf("%v Unidentified websocket data received: %v",
|
||||
log.Errorf(log.ExchangeSys, "%v Unidentified websocket data received: %v",
|
||||
k.GetName(), response)
|
||||
}
|
||||
}
|
||||
@@ -260,17 +260,17 @@ func (k *Kraken) WsHandleEventResponse(response *WebsocketEventResponse) {
|
||||
switch response.Event {
|
||||
case krakenWsHeartbeat:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket heartbeat data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket heartbeat data received",
|
||||
k.GetName())
|
||||
}
|
||||
case krakenWsPong:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket pong data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket pong data received",
|
||||
k.GetName())
|
||||
}
|
||||
case krakenWsSystemStatus:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket status data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket status data received",
|
||||
k.GetName())
|
||||
}
|
||||
if response.Status != "online" {
|
||||
@@ -278,12 +278,12 @@ func (k *Kraken) WsHandleEventResponse(response *WebsocketEventResponse) {
|
||||
k.GetName(), response.Status)
|
||||
}
|
||||
if response.WebsocketStatusResponse.Version != krakenWSSupportedVersion {
|
||||
log.Warnf("%v New version of Websocket API released. Was %v Now %v",
|
||||
log.Warnf(log.ExchangeSys, "%v New version of Websocket API released. Was %v Now %v",
|
||||
k.GetName(), krakenWSSupportedVersion, response.WebsocketStatusResponse.Version)
|
||||
}
|
||||
case krakenWsSubscriptionStatus:
|
||||
if k.Verbose {
|
||||
log.Debugf("%v Websocket subscription status data received",
|
||||
log.Debugf(log.ExchangeSys, "%v Websocket subscription status data received",
|
||||
k.GetName())
|
||||
}
|
||||
if response.Status != "subscribed" {
|
||||
@@ -296,7 +296,7 @@ func (k *Kraken) WsHandleEventResponse(response *WebsocketEventResponse) {
|
||||
}
|
||||
addNewSubscriptionChannelData(response)
|
||||
default:
|
||||
log.Errorf("%v Unidentified websocket data received: %v", k.GetName(), response)
|
||||
log.Errorf(log.ExchangeSys, "%v Unidentified websocket data received: %v", k.GetName(), response)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ func (k *Kraken) wsProcessSpread(channelData *WebsocketChannelData, data interfa
|
||||
sec, dec := math.Modf(timeData)
|
||||
spreadTimestamp := time.Unix(int64(sec), int64(dec*(1e9)))
|
||||
if k.Verbose {
|
||||
log.Debugf("Spread data for '%v' received. Best bid: '%v' Best ask: '%v' Time: '%v'",
|
||||
log.Debugf(log.ExchangeSys, "Spread data for '%v' received. Best bid: '%v' Best ask: '%v' Time: '%v'",
|
||||
channelData.Pair,
|
||||
bestBid,
|
||||
bestAsk,
|
||||
@@ -550,7 +550,7 @@ func (k *Kraken) wsProcessOrderBookBuffer(channelData *WebsocketChannelData, obD
|
||||
}
|
||||
orderbookBuffer[channelData.ChannelID] = append(orderbookBuffer[channelData.ChannelID], ob)
|
||||
if k.Verbose {
|
||||
log.Debugf("Adding orderbook to buffer for channel %v. Lastupdated: %v. %v / %v",
|
||||
log.Debugf(log.ExchangeSys, "Adding orderbook to buffer for channel %v. Lastupdated: %v. %v / %v",
|
||||
channelData.ChannelID,
|
||||
ob.LastUpdated,
|
||||
len(orderbookBuffer[channelData.ChannelID]),
|
||||
@@ -561,12 +561,12 @@ func (k *Kraken) wsProcessOrderBookBuffer(channelData *WebsocketChannelData, obD
|
||||
// wsProcessOrderBookUpdate updates an orderbook entry for a given currency pair
|
||||
func (k *Kraken) wsProcessOrderBookUpdate(channelData *WebsocketChannelData) error {
|
||||
if k.Verbose {
|
||||
log.Debugf("Current orderbook 'LastUpdated': %v",
|
||||
log.Debugf(log.ExchangeSys, "Current orderbook 'LastUpdated': %v",
|
||||
krakenOrderBooks[channelData.ChannelID].LastUpdated)
|
||||
}
|
||||
lowestLastUpdated := orderbookBuffer[channelData.ChannelID][0].LastUpdated
|
||||
if k.Verbose {
|
||||
log.Debugf("Sorting orderbook. Earliest 'LastUpdated' entry: %v",
|
||||
log.Debugf(log.ExchangeSys, "Sorting orderbook. Earliest 'LastUpdated' entry: %v",
|
||||
lowestLastUpdated)
|
||||
}
|
||||
sort.Slice(orderbookBuffer[channelData.ChannelID], func(i, j int) bool {
|
||||
@@ -575,7 +575,7 @@ func (k *Kraken) wsProcessOrderBookUpdate(channelData *WebsocketChannelData) err
|
||||
|
||||
lowestLastUpdated = orderbookBuffer[channelData.ChannelID][0].LastUpdated
|
||||
if k.Verbose {
|
||||
log.Debugf("Sorted orderbook. Earliest 'LastUpdated' entry: %v",
|
||||
log.Debugf(log.ExchangeSys, "Sorted orderbook. Earliest 'LastUpdated' entry: %v",
|
||||
lowestLastUpdated)
|
||||
}
|
||||
// The earliest update has to be after the previously stored orderbook
|
||||
@@ -590,7 +590,7 @@ func (k *Kraken) wsProcessOrderBookUpdate(channelData *WebsocketChannelData) err
|
||||
k.updateChannelOrderbookEntries(channelData)
|
||||
highestLastUpdate := orderbookBuffer[channelData.ChannelID][len(orderbookBuffer[channelData.ChannelID])-1].LastUpdated
|
||||
if k.Verbose {
|
||||
log.Debugf("Saving orderbook. Lastupdated: %v",
|
||||
log.Debugf(log.ExchangeSys, "Saving orderbook. Lastupdated: %v",
|
||||
highestLastUpdate)
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ func (k *Kraken) updateChannelOrderbookAsks(i, j int, channelData *WebsocketChan
|
||||
askFound := k.updateChannelOrderbookAsk(i, j, channelData)
|
||||
if !askFound {
|
||||
if k.Verbose {
|
||||
log.Debugf("Adding Ask for channel %v. Price %v. Amount %v",
|
||||
log.Debugf(log.ExchangeSys, "Adding Ask for channel %v. Price %v. Amount %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Asks[j].Price,
|
||||
orderbookBuffer[channelData.ChannelID][i].Asks[j].Amount)
|
||||
@@ -646,7 +646,7 @@ func (k *Kraken) updateChannelOrderbookAsk(i, j int, channelData *WebsocketChann
|
||||
if orderbookBuffer[channelData.ChannelID][i].Asks[j].Amount == 0 {
|
||||
// Remove existing entry
|
||||
if k.Verbose {
|
||||
log.Debugf("Removing Ask for channel %v. Price %v. Old amount %v. Buffer %v",
|
||||
log.Debugf(log.ExchangeSys, "Removing Ask for channel %v. Price %v. Old amount %v. Buffer %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Asks[j].Price,
|
||||
krakenOrderBooks[channelData.ChannelID].Asks[l].Amount, i)
|
||||
@@ -657,7 +657,7 @@ func (k *Kraken) updateChannelOrderbookAsk(i, j int, channelData *WebsocketChann
|
||||
l--
|
||||
} else if krakenOrderBooks[channelData.ChannelID].Asks[l].Amount != orderbookBuffer[channelData.ChannelID][i].Asks[j].Amount {
|
||||
if k.Verbose {
|
||||
log.Debugf("Updating Ask for channel %v. Price %v. Old amount %v, New Amount %v",
|
||||
log.Debugf(log.ExchangeSys, "Updating Ask for channel %v. Price %v. Old amount %v, New Amount %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Asks[j].Price,
|
||||
krakenOrderBooks[channelData.ChannelID].Asks[l].Amount,
|
||||
@@ -675,7 +675,7 @@ func (k *Kraken) updateChannelOrderbookBids(i, j int, channelData *WebsocketChan
|
||||
bidFound := k.updateChannelOrderbookBid(i, j, channelData)
|
||||
if !bidFound {
|
||||
if k.Verbose {
|
||||
log.Debugf("Adding Bid for channel %v. Price %v. Amount %v",
|
||||
log.Debugf(log.ExchangeSys, "Adding Bid for channel %v. Price %v. Amount %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Bids[j].Price,
|
||||
orderbookBuffer[channelData.ChannelID][i].Bids[j].Amount)
|
||||
@@ -694,7 +694,7 @@ func (k *Kraken) updateChannelOrderbookBid(i, j int, channelData *WebsocketChann
|
||||
if orderbookBuffer[channelData.ChannelID][i].Bids[j].Amount == 0 {
|
||||
// Remove existing entry
|
||||
if k.Verbose {
|
||||
log.Debugf("Removing Bid for channel %v. Price %v. Old amount %v. Buffer %v",
|
||||
log.Debugf(log.ExchangeSys, "Removing Bid for channel %v. Price %v. Old amount %v. Buffer %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Bids[j].Price,
|
||||
krakenOrderBooks[channelData.ChannelID].Bids[l].Amount, i)
|
||||
@@ -705,7 +705,7 @@ func (k *Kraken) updateChannelOrderbookBid(i, j int, channelData *WebsocketChann
|
||||
l--
|
||||
} else if krakenOrderBooks[channelData.ChannelID].Bids[l].Amount != orderbookBuffer[channelData.ChannelID][i].Bids[j].Amount {
|
||||
if k.Verbose {
|
||||
log.Debugf("Updating Bid for channel %v. Price %v. Old amount %v, New Amount %v",
|
||||
log.Debugf(log.ExchangeSys, "Updating Bid for channel %v. Price %v. Old amount %v, New Amount %v",
|
||||
channelData.ChannelID,
|
||||
orderbookBuffer[channelData.ChannelID][i].Bids[j].Price,
|
||||
krakenOrderBooks[channelData.ChannelID].Bids[l].Amount,
|
||||
@@ -777,7 +777,7 @@ func (k *Kraken) Subscribe(channelToSubscribe exchange.WebsocketChannelSubscript
|
||||
json, err := common.JSONEncode(resp)
|
||||
if err != nil {
|
||||
if k.Verbose {
|
||||
log.Debugf("%v subscribe error: %v", k.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v subscribe error: %v", k.Name, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -796,7 +796,7 @@ func (k *Kraken) Unsubscribe(channelToSubscribe exchange.WebsocketChannelSubscri
|
||||
json, err := common.JSONEncode(resp)
|
||||
if err != nil {
|
||||
if k.Verbose {
|
||||
log.Debugf("%v unsubscribe error: %v", k.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%v unsubscribe error: %v", k.Name, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ func (k *Kraken) Run() {
|
||||
if !common.StringDataContains(k.GetEnabledPairs(asset.Spot).Strings(), "-") ||
|
||||
!common.StringDataContains(k.GetAvailablePairs(asset.Spot).Strings(), "-") {
|
||||
enabledPairs := currency.NewPairsFromStrings([]string{"XBT-USD"})
|
||||
log.Warn("WARNING: Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
|
||||
log.Warn(log.ExchangeSys, "Available pairs for Kraken reset due to config upgrade, please enable the ones you would like again")
|
||||
forceUpdate = true
|
||||
|
||||
err := k.UpdatePairs(enabledPairs, asset.Spot, true, true)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update currencies. Err: %s\n", k.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update currencies. Err: %s\n", k.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func (k *Kraken) Run() {
|
||||
|
||||
err := k.UpdateTradablePairs(forceUpdate)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", k.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", k.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,12 +93,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Bids = append(orderbook.Bids, OrderbookStructure{price, amount})
|
||||
@@ -107,12 +107,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Asks = append(orderbook.Asks, OrderbookStructure{price, amount})
|
||||
@@ -265,7 +265,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int
|
||||
hmac := crypto.GetHMAC(crypto.HashSHA1, []byte(req), []byte(l.API.Credentials.Secret))
|
||||
|
||||
if l.Verbose {
|
||||
log.Debugf("Sending POST request to %s calling method %s with params %s\n", l.API.Endpoints.URL, method, req)
|
||||
log.Debugf(log.ExchangeSys, "Sending POST request to %s calling method %s with params %s\n", l.API.Endpoints.URL, method, req)
|
||||
}
|
||||
|
||||
postData := make(map[string]interface{})
|
||||
|
||||
@@ -120,7 +120,7 @@ func (l *LakeBTC) Run() {
|
||||
|
||||
err := l.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", l.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", l.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -635,12 +635,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Bids = append(orderbook.Bids, Price{price, amount})
|
||||
@@ -649,12 +649,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.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
amount, err := strconv.ParseFloat(x[1], 64)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error(log.ExchangeSys, err)
|
||||
continue
|
||||
}
|
||||
orderbook.Asks = append(orderbook.Asks, Price{price, amount})
|
||||
@@ -688,7 +688,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
if l.Verbose {
|
||||
log.Debugf("Sending POST request to `%s`, path: `%s`, params: `%s`.", l.API.Endpoints.URL, path, encoded)
|
||||
log.Debugf(log.ExchangeSys, "Sending POST request to `%s`, path: `%s`, params: `%s`.", l.API.Endpoints.URL, path, encoded)
|
||||
}
|
||||
|
||||
if method == http.MethodGet && len(encoded) > 0 {
|
||||
|
||||
@@ -121,7 +121,7 @@ func (l *LocalBitcoins) Run() {
|
||||
|
||||
err := l.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", l.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", l.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ func (l *LocalBitcoins) GetActiveOrders(getOrdersRequest *exchange.GetOrdersRequ
|
||||
for i := range resp {
|
||||
orderDate, err := time.Parse(time.RFC3339, resp[i].Data.CreatedAt)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
l.Name,
|
||||
"GetActiveOrders",
|
||||
resp[i].Data.Advertisement.ID,
|
||||
@@ -481,7 +481,7 @@ func (l *LocalBitcoins) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequ
|
||||
for i := range allTrades {
|
||||
orderDate, err := time.Parse(time.RFC3339, allTrades[i].Data.CreatedAt)
|
||||
if err != nil {
|
||||
log.Warnf("Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
log.Warnf(log.ExchangeSys, "Exchange %v Func %v Order %v Could not parse date to unix with value of %v",
|
||||
l.Name,
|
||||
"GetActiveOrders",
|
||||
allTrades[i].Data.Advertisement.ID,
|
||||
|
||||
@@ -113,7 +113,7 @@ func (o *OKCoin) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the OKEX wrapper
|
||||
func (o *OKCoin) Run() {
|
||||
if o.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.WebsocketURL)
|
||||
}
|
||||
|
||||
if !o.GetEnabledFeatures().AutoPairUpdates {
|
||||
@@ -122,7 +122,7 @@ func (o *OKCoin) Run() {
|
||||
|
||||
err := o.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", o.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", o.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func (o *OKEX) Start(wg *sync.WaitGroup) {
|
||||
// Run implements the OKEX wrapper
|
||||
func (o *OKEX) Run() {
|
||||
if o.Verbose {
|
||||
log.Debugf("%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.API.Endpoints.WebsocketURL)
|
||||
log.Debugf(log.ExchangeSys, "%s Websocket: %s. (url: %s).\n", o.GetName(), common.IsEnabled(o.Websocket.IsEnabled()), o.API.Endpoints.WebsocketURL)
|
||||
}
|
||||
|
||||
if !o.GetEnabledFeatures().AutoPairUpdates {
|
||||
@@ -122,7 +122,7 @@ func (o *OKEX) Run() {
|
||||
|
||||
err := o.UpdateTradablePairs(false)
|
||||
if err != nil {
|
||||
log.Errorf("%s failed to update tradable pairs. Err: %s", o.Name, err)
|
||||
log.Errorf(log.ExchangeSys, "%s failed to update tradable pairs. Err: %s", o.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -495,7 +495,7 @@ func (o *OKGroup) GetMarginTransactionDetails(request GetSpotTransactionDetailsR
|
||||
func FormatParameters(request interface{}) (parameters string) {
|
||||
v, err := query.Values(request)
|
||||
if err != nil {
|
||||
log.Errorf("Could not parse %v to URL values. Check that the type has url fields", reflect.TypeOf(request).Name())
|
||||
log.Errorf(log.ExchangeSys, "Could not parse %v to URL values. Check that the type has url fields", reflect.TypeOf(request).Name())
|
||||
return
|
||||
}
|
||||
urlEncodedValues := v.Encode()
|
||||
@@ -546,13 +546,13 @@ func (o *OKGroup) SendHTTPRequest(httpMethod, requestType, requestPath string, d
|
||||
}
|
||||
|
||||
if o.Verbose {
|
||||
log.Debugf("Request JSON: %s\n", payload)
|
||||
log.Debugf(log.ExchangeSys, "Request JSON: %s\n", payload)
|
||||
}
|
||||
}
|
||||
|
||||
path := o.API.Endpoints.URL + requestType + o.APIVersion + requestPath
|
||||
if o.Verbose {
|
||||
log.Debugf("Sending %v request to %s \n", requestType, path)
|
||||
log.Debugf(log.ExchangeSys, "Sending %v request to %s \n", requestType, path)
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user