mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
poloniex: websocket update (#659)
* poloniex: websocket update with debug output and currency tracking system * linter: fix issues * nits: Addr * poloniex: govet fix * nits: addr * Bittrex: Fix fee test
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/stats"
|
||||
@@ -323,6 +324,11 @@ func (bot *Engine) WebsocketDataHandler(exchName string, data interface{}) error
|
||||
}
|
||||
printOrderbookSummary(d, "websocket", bot, nil)
|
||||
case *order.Detail:
|
||||
if bot.Settings.Verbose {
|
||||
printOrderSummary(d)
|
||||
}
|
||||
// TODO: Dont check if exists this creates two locks, on conflict update
|
||||
// else insert.
|
||||
if !bot.OrderManager.orderStore.exists(d) {
|
||||
err := bot.OrderManager.orderStore.Add(d)
|
||||
if err != nil {
|
||||
@@ -335,9 +341,11 @@ func (bot *Engine) WebsocketDataHandler(exchName string, data interface{}) error
|
||||
}
|
||||
od.UpdateOrderFromDetail(d)
|
||||
}
|
||||
case *order.Cancel:
|
||||
return bot.OrderManager.Cancel(d)
|
||||
case *order.Modify:
|
||||
if bot.Settings.Verbose {
|
||||
printOrderChangeSummary(d)
|
||||
}
|
||||
// TODO: On conflict update or insert if not found
|
||||
od, err := bot.OrderManager.orderStore.GetByExchangeAndID(d.Exchange, d.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -347,6 +355,10 @@ func (bot *Engine) WebsocketDataHandler(exchName string, data interface{}) error
|
||||
return errors.New(d.Error())
|
||||
case stream.UnhandledMessageWarning:
|
||||
log.Warn(log.WebsocketMgr, d.Message)
|
||||
case account.Change:
|
||||
if bot.Settings.Verbose {
|
||||
printAccountHoldingsChangeSummary(d)
|
||||
}
|
||||
default:
|
||||
if bot.Settings.Verbose {
|
||||
log.Warnf(log.WebsocketMgr,
|
||||
@@ -357,3 +369,59 @@ func (bot *Engine) WebsocketDataHandler(exchName string, data interface{}) error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// printOrderChangeSummary this function will be deprecated when a order manager
|
||||
// update is done.
|
||||
func printOrderChangeSummary(m *order.Modify) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"Order Change: %s %s %s %s %s %s OrderID:%s ClientOrderID:%s Price:%f Amount:%f Executed Amount:%f Remaining Amount:%f",
|
||||
m.Exchange,
|
||||
m.AssetType,
|
||||
m.Pair,
|
||||
m.Status,
|
||||
m.Type,
|
||||
m.Side,
|
||||
m.ID,
|
||||
m.ClientOrderID,
|
||||
m.Price,
|
||||
m.Amount,
|
||||
m.ExecutedAmount,
|
||||
m.RemainingAmount)
|
||||
}
|
||||
|
||||
// printOrderSummary this function will be deprecated when a order manager
|
||||
// update is done.
|
||||
func printOrderSummary(m *order.Detail) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"New Order: %s %s %s %s %s %s OrderID:%s ClientOrderID:%s Price:%f Amount:%f Executed Amount:%f Remaining Amount:%f",
|
||||
m.Exchange,
|
||||
m.AssetType,
|
||||
m.Pair,
|
||||
m.Status,
|
||||
m.Type,
|
||||
m.Side,
|
||||
m.ID,
|
||||
m.ClientOrderID,
|
||||
m.Price,
|
||||
m.Amount,
|
||||
m.ExecutedAmount,
|
||||
m.RemainingAmount)
|
||||
}
|
||||
|
||||
// printAccountHoldingsChangeSummary this function will be deprecated when a
|
||||
// account holdings update is done.
|
||||
func printAccountHoldingsChangeSummary(m account.Change) {
|
||||
log.Debugf(log.WebsocketMgr,
|
||||
"Account Holdings Balance Changed: %s %s %s has changed balance by %f for account: %s",
|
||||
m.Exchange,
|
||||
m.Asset,
|
||||
m.Currency,
|
||||
m.Amount,
|
||||
m.Account)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user