Skip to content

Commit

Permalink
engine: Ticker REST/Websocket improvements (thrasher-corp#345)
Browse files Browse the repository at this point in the history
* Adds extra properties to Websocket ticker. Adds new properties to binance and bitfinex, but doesn't test anything yet. Changes names and properties of ticker package to make more streamlined

* Adds support for coinbasepro, coinut, gateio, gitbtc, huobi, hadax, kraken, okex, okcoin. Adds quoteVolume

* Adds poloniex and ZB ticker datas

* Updates ANX, Binance, Bitfinex, Bistamp, Bittrex, BTCMarkets, BTSE, CoinbasePRo, Coinut, Exmo tickers. It looks like a whole bunch of stuff is wrong in how tickers are done though :/

* Updates tickers everywhere. Will revert batch ones

* Re-Preseves ticker batching

* Minor fixes to ticks and removal of comment

* Logging errors instead of returning mid loop. Adds bitfinex batch ticker processing. Fixes unrelated okgroup wallet bug

* Removes bad code I wrote preventing function from running if feature not enabled

* Fixes issue with bitmex and rebase issues

* Fixes bitmex iterator error, splits hitbtc ticker requests

* Fixes okgroup currency pair formatting. Updates okgroup to use ticker batching. Fixes okgroup ticker issues due to assetTypes. Fixes okgroup ws pinging. Fixes Kraken's currency pairs formatting. Reverts ANXs auto parsing back to strings because ANX json makes me cry. Minor property improvements for coinut, coinbasepro, btse, exmo. Protects wshandler manageSubscriptions() from running and returning an error when feature not supported

* Updates config example to reflect the underscore dash situation

* Fixes a config delimiter oopsie. Simplifies ANX wrapper ticker parsing. Fixes bittrex date parsing. Simplifies okcoin switch to if.

* Fixes super fun issue where kraken has updated their currency pair format and must add new delimiter support. Fixes super fun issue where okex has updated their currency pair format and must add new delimiter support. Fixes super fun issue where okcoin has updated their currency pair format and must add new delimiter support.

* Updates config example for kraken

* Adds lbank batch ticker support. Adds details to errors

* Updates FetchTradablePairs to use the config delimiter to prevent issues if the delimiter ever changes

* Fixes nil reference bug. Uses NAme not GetNAme

* Fixes hardcoded delimiter in Binance.  Expands bitfinex websocket ticker fields. Updates Bitstamp rate limits. Expands BTSE ticker data fields. Fixes typo in coibasepro. Expands Coinut ticker data. Renames currency to curr as it conflicts with package name. Expands GateIO websocket ticker data. Fixes ticker data implementation for huobi and huobi hadax. Reverts ticker map to string instead of assetType. Fixes real stupid bug I introduced which preveted subscriptions from running :glitch_crab: Adds Price ATH to ws ticker type. Adds quotevolume to yobit ticker. Uses delimiter in ZB rather than hardcoded field.

* Fixes bug in syncer where if the websocket is already connected, then UsingWebsocket is not set

* Updates broken tests

* Simplifies poloniex frozen check

* Updates configtest.json with new delimiters

* Renames shorthand properties of structs. Fixes delimiter referencing

* Fixes some bugs and nits around variable declaration, currency pairs and config upscaling

* Adds config upgrade path for okcoin and okex. Reverts configtest.json.

* Fixes okex futures currency formatting by no longer using global currency format. updates Run code to adapt. Removes BTSE value

* Adds ":" as a delimiter for when a delimiter only shows up SOMETIMES

* Adds support for optional delimiter
  • Loading branch information
gloriousCode authored and thrasher- committed Sep 2, 2019
1 parent 833a866 commit 74d5bca
Show file tree
Hide file tree
Showing 86 changed files with 1,575 additions and 1,042 deletions.
20 changes: 10 additions & 10 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -1211,18 +1211,18 @@
"apiUrlSecondary": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"proxyAddress": "",
"websocketUrl": "NON_DEFAULT_HTTP_LINK_TO_WEBSOCKET_EXCHANGE_API",
"availablePairs": "BTC_USD,LTC_USD,ETH_USD,ETC_USD,TUSD_USD,USDT_USD,ZEC_USD,ADA_USD,XLM_USD,ZRX_USD,XRP_USD,BAT_USD,PAX_USD,GUSD_USD,USDC_USD,BCH_USD,BSV_USD,TRX_USD,GRIN_USD,DCR_USD,EOS_USD,BTC_TUSD,BTC_USDT,BTC_PAX,BTC_GUSD,BTC_USDC",
"enabledPairs": "BTC_USD",
"availablePairs": "BTC-USD,LTC-USD,ETH-USD,ETC-USD,TUSD-USD,USDT-USD,ZEC-USD,ADA-USD,XLM-USD,ZRX-USD,XRP-USD,BAT-USD,PAX-USD,GUSD-USD,USDC-USD,BCH-USD,BSV-USD,TRX-USD,GRIN-USD,DCR-USD,EOS-USD,BTC-TUSD,BTC-USDT,BTC-PAX,BTC-GUSD,BTC-USDC",
"enabledPairs": "BTC-USD",
"baseCurrencies": "USD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": true,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"
"delimiter": "-"
},
"requestCurrencyPairFormat": {
"uppercase": false,
"delimiter": "_"
"uppercase": true,
"delimiter": "-"
},
"bankAccounts": [
{
Expand Down Expand Up @@ -1256,18 +1256,18 @@
"apiUrlSecondary": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"proxyAddress": "",
"websocketUrl": "NON_DEFAULT_HTTP_LINK_TO_WEBSOCKET_EXCHANGE_API",
"availablePairs": "DASH_BTC,CTXC_BTC,ZIL_BTC,YOU_BTC,LBA_BTC,LSK_BTC,CAI_BTC,AE_BTC,SC_BTC,KAN_BTC,WIN_BTC,DCR_BTC,WAVES_BTC,ORS_BTC,NXT_BTC,ARDR_BTC,XAS_BTC,CVT_BTC,EGT_BTC,ZCO_BTC,LET_BTC,HPB_BTC,ADA_BTC,HYC_BTC,VITE_BTC,ABL_BTC,PAX_BTC,TUSD_BTC,USDC_BTC,GUSD_BTC,BCH_BTC,BSV_BTC,BTT_BTC,ATOM_BTC,BLOC_BTC,XRP_BTC,LRC_BTC,NULS_BTC,MCO_BTC,ELF_BTC,ZEC_BTC,CMT_BTC,ITC_BTC,SBTC_BTC,EDO_BTC,BCX_BTC,NEO_BTC,GAS_BTC,HC_BTC,QTUM_BTC,IOTA_BTC,XUC_BTC,EOS_BTC,SNT_BTC,OMG_BTC,LTC_BTC,ETH_BTC,ETC_BTC,BCD_BTC,BTG_BTC,ACT_BTC,PAY_BTC,BTM_BTC,DGD_BTC,GNT_BTC,LINK_BTC,WTC_BTC,ZRX_BTC,BNT_BTC,CVC_BTC,MANA_BTC,KNC_BTC,GNX_BTC,ICX_BTC,XEM_BTC,ARK_BTC,YOYO_BTC,FUN_BTC,ACE_BTC,TRX_BTC,DG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D-USDT,XUC-USDT,CMT-USDT,ITC-USDT,PRA-USDT,EDO-USDT,ETH-USDT,LTC-USDT,ETC-USDT,EOS-USDT,OMG-USDT,ACT-USDT,BTM-USDT,STORJ-USDT,PAY-USDT,DGD-USDT,GNT-USDT,SNT-USDT,LINK-USDT,WTC-USDT,ZRX-USDT,BNT-USDT,CVC-USDT,MANA-USDT,KNC-USDT,ICX-USDT,XEM-USDT,ARK-USDT,YOYO-USDT,AST-USDT,TRX-USDT,MDA-USDT,DGB-USDT,PPT-USDT,SWFTC-USDT,XMR-USDT,XLM-USDT,KCASH-USDT,MDT-USDT,NAS-USDT,RNT-USDT,UGC-USDT,DPY-USDT,SSC-USDT,AAC-USDT,FAIR-USDT,UBTC-USDT,SHOW-USDT,VIB-USDT,MOT-USDT,UTK-USDT,TOPC-USDT,QUN-USDT,INT-USDT,IPC-USDT,IOST-USDT,INS-USDT,YEE-USDT,MOF-USDT,TCT-USDT,STC-USDT,THETA-USDT,PST-USDT,MKR-USDT,LIGHT-USDT,TRUE-USDT,OF-USDT,SOC-USDT,ZEN-USDT,HMC-USDT,ZIP-USDT,NANO-USDT,CIC-USDT,GTO-USDT,CHAT-USDT,INSUR-USDT,R-USDT,BEC-USDT,MITH-USDT,ABT-USDT,BKX-USDT,RFR-USDT,TRIO-USDT,DADI-USDT,ONT-USDT,OKB-USDT,NEO-OKB,LTC-OKB,ETC-OKB,XRP-OKB,ZEC-OKB,QTUM-OKB,IOTA-OKB,EOS-OKB",
"enabledPairs": "EOS-USDT",
"baseCurrencies": "USD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": true,
"configCurrencyPairFormat": {
"uppercase": true,
"delimiter": "_"
"delimiter": "-"
},
"requestCurrencyPairFormat": {
"uppercase": false,
"delimiter": "_"
"uppercase": true,
"delimiter": "-"
},
"bankAccounts": [
{
Expand Down
2 changes: 1 addition & 1 deletion currency/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewPairFromIndex(currencyPair, index string) (Pair, error) {
// NewPairFromString converts currency string into a new CurrencyPair
// with or without delimeter
func NewPairFromString(currencyPair string) Pair {
delimiters := []string{"_", "-", "/"}
delimiters := []string{"_", "-", "/", ":"}
var delimiter string
for _, x := range delimiters {
if strings.Contains(currencyPair, x) {
Expand Down
19 changes: 14 additions & 5 deletions engine/routines.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,18 +428,27 @@ func WebsocketDataHandler(ws *wshandler.Websocket) {
// }

tickerNew := ticker.Price{
Last: d.Last,
High: d.High,
Low: d.Low,
Bid: d.Bid,
Ask: d.Ask,
Volume: d.Volume,
QuoteVolume: d.QuoteVolume,
PriceATH: d.PriceATH,
Open: d.Open,
Close: d.Close,
Pair: d.Pair,
LastUpdated: d.Timestamp,
Last: d.ClosePrice,
High: d.HighPrice,
Low: d.LowPrice,
Volume: d.Quantity,
}
if Bot.Settings.EnableExchangeSyncManager && Bot.ExchangeCurrencyPairManager != nil {
Bot.ExchangeCurrencyPairManager.update(ws.GetName(),
d.Pair, d.AssetType, SyncItemTicker, nil)
}
ticker.ProcessTicker(ws.GetName(), &tickerNew, d.AssetType)
err := ticker.ProcessTicker(ws.GetName(), &tickerNew, d.AssetType)
if err != nil {
log.Errorf(log.WebsocketMgr, "routines.go exchange %s websocket error - %s", ws.GetName(), err)
}
printTickerSummary(&tickerNew, tickerNew.Pair, d.AssetType, ws.GetName(), nil)
case wshandler.KlineData:
// Kline data
Expand Down
2 changes: 2 additions & 0 deletions engine/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ func (e *ExchangeCurrencyPairSyncer) Start() {
} else {
usingWebsocket = true
}
} else {
usingWebsocket = true
}
} else if supportsREST {
usingREST = true
Expand Down
20 changes: 10 additions & 10 deletions exchanges/anx/anx_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ type TickerComponent struct {
type Ticker struct {
Result string `json:"result"`
Data struct {
High TickerComponent `json:"high"`
Low TickerComponent `json:"low"`
Avg TickerComponent `json:"avg"`
Vwap TickerComponent `json:"vwap"`
Vol TickerComponent `json:"vol"`
Last TickerComponent `json:"last"`
Buy TickerComponent `json:"buy"`
Sell TickerComponent `json:"sell"`
Now string `json:"now"`
UpdateTime string `json:"dataUpdateTime"`
High TickerComponent `json:"high"`
Low TickerComponent `json:"low"`
Average TickerComponent `json:"avg"`
VolumeWeightedAveragePrice TickerComponent `json:"vwap"`
Volume TickerComponent `json:"vol"`
Last TickerComponent `json:"last"`
Buy TickerComponent `json:"buy"`
Sell TickerComponent `json:"sell"`
Now int64 `json:"now,string"`
UpdateTime int64 `json:"dataUpdateTime,string"`
} `json:"data"`
}

Expand Down
75 changes: 18 additions & 57 deletions exchanges/anx/anx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package anx

import (
"fmt"
"strconv"
"strings"
"sync"
"time"

"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/convert"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
Expand Down Expand Up @@ -173,7 +173,7 @@ func (a *ANX) FetchTradablePairs(asset asset.Item) ([]string, error) {

var currencies []string
for x := range result.CurrencyPairs {
currencies = append(currencies, result.CurrencyPairs[x].TradedCcy+"_"+result.CurrencyPairs[x].SettlementCcy)
currencies = append(currencies, fmt.Sprintf("%v%v%v", result.CurrencyPairs[x].TradedCcy, a.GetPairFormat(asset, false).Delimiter, result.CurrencyPairs[x].SettlementCcy))
}

return currencies, nil
Expand All @@ -186,61 +186,22 @@ func (a *ANX) UpdateTicker(p currency.Pair, assetType asset.Item) (ticker.Price,
if err != nil {
return tickerPrice, err
}

tickerPrice.Pair = p

if tick.Data.Sell.Value != "" {
tickerPrice.Ask, err = strconv.ParseFloat(tick.Data.Sell.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.Ask = 0
}

if tick.Data.Buy.Value != "" {
tickerPrice.Bid, err = strconv.ParseFloat(tick.Data.Buy.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.Bid = 0
}

if tick.Data.Low.Value != "" {
tickerPrice.Low, err = strconv.ParseFloat(tick.Data.Low.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.Low = 0
}

if tick.Data.Last.Value != "" {
tickerPrice.Last, err = strconv.ParseFloat(tick.Data.Last.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.Last = 0
}

if tick.Data.Vol.Value != "" {
tickerPrice.Volume, err = strconv.ParseFloat(tick.Data.Vol.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.Volume = 0
}

if tick.Data.High.Value != "" {
tickerPrice.High, err = strconv.ParseFloat(tick.Data.High.Value, 64)
if err != nil {
return tickerPrice, err
}
} else {
tickerPrice.High = 0
last, _ := convert.FloatFromString(tick.Data.Last.Value)
high, _ := convert.FloatFromString(tick.Data.High.Value)
low, _ := convert.FloatFromString(tick.Data.Low.Value)
bid, _ := convert.FloatFromString(tick.Data.Buy.Value)
ask, _ := convert.FloatFromString(tick.Data.Sell.Value)
volume, _ := convert.FloatFromString(tick.Data.Volume.Value)

tickerPrice = ticker.Price{
Last: last,
High: high,
Low: low,
Bid: bid,
Ask: ask,
Volume: volume,
Pair: p,
LastUpdated: time.Unix(0, tick.Data.UpdateTime),
}

err = ticker.ProcessTicker(a.GetName(), &tickerPrice, assetType)
Expand Down
84 changes: 42 additions & 42 deletions exchanges/binance/binance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,29 @@ type KlineStream struct {

// TickerStream holds the ticker stream data
type TickerStream struct {
EventType string `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
PriceChange string `json:"p"`
PriceChangePercent string `json:"P"`
WeightedAvgPrice string `json:"w"`
PrevDayClose string `json:"x"`
CurrDayClose string `json:"c"`
CloseTradeQuantity string `json:"Q"`
BestBidPrice string `json:"b"`
BestBidQuantity string `json:"B"`
BestAskPrice string `json:"a"`
BestAskQuantity string `json:"A"`
OpenPrice string `json:"o"`
HighPrice string `json:"h"`
LowPrice string `json:"l"`
TotalTradedVolume string `json:"v"`
TotalTradedQuoteVolume string `json:"q"`
OpenTime int64 `json:"O"`
CloseTime int64 `json:"C"`
FirstTradeID int64 `json:"F"`
LastTradeID int64 `json:"L"`
NumberOfTrades int64 `json:"n"`
EventType string `json:"e"`
EventTime int64 `json:"E"`
Symbol currency.Pair `json:"s"`
PriceChange float64 `json:"p,string"`
PriceChangePercent float64 `json:"P,string"`
WeightedAvgPrice float64 `json:"w,string"`
ClosePrice float64 `json:"x,string"`
LastPrice float64 `json:"c,string"`
LastPriceQuantity float64 `json:"Q,string"`
BestBidPrice float64 `json:"b,string"`
BestBidQuantity float64 `json:"B,string"`
BestAskPrice float64 `json:"a,string"`
BestAskQuantity float64 `json:"A,string"`
OpenPrice float64 `json:"o,string"`
HighPrice float64 `json:"h,string"`
LowPrice float64 `json:"l,string"`
TotalTradedVolume float64 `json:"v,string"`
TotalTradedQuoteVolume float64 `json:"q,string"`
OpenTime int64 `json:"O"`
CloseTime int64 `json:"C"`
FirstTradeID int64 `json:"F"`
LastTradeID int64 `json:"L"`
NumberOfTrades int64 `json:"n"`
}

// HistoricalTrade holds recent trade data
Expand Down Expand Up @@ -239,25 +239,25 @@ type AveragePrice struct {

// PriceChangeStats contains statistics for the last 24 hours trade
type PriceChangeStats struct {
Symbol string `json:"symbol"`
PriceChange float64 `json:"priceChange,string"`
PriceChangePercent float64 `json:"priceChangePercent,string"`
WeightedAvgPrice float64 `json:"weightedAvgPrice,string"`
PrevClosePrice float64 `json:"prevClosePrice,string"`
LastPrice float64 `json:"lastPrice,string"`
LastQty float64 `json:"lastQty,string"`
BidPrice float64 `json:"bidPrice,string"`
AskPrice float64 `json:"askPrice,string"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"fristId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
Symbol currency.Pair `json:"symbol"`
PriceChange float64 `json:"priceChange,string"`
PriceChangePercent float64 `json:"priceChangePercent,string"`
WeightedAvgPrice float64 `json:"weightedAvgPrice,string"`
PrevClosePrice float64 `json:"prevClosePrice,string"`
LastPrice float64 `json:"lastPrice,string"`
LastQty float64 `json:"lastQty,string"`
BidPrice float64 `json:"bidPrice,string"`
AskPrice float64 `json:"askPrice,string"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"fristId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}

// SymbolPrice holds basic symbol price
Expand Down
Loading

0 comments on commit 74d5bca

Please sign in to comment.