mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 15:10:49 +00:00
Engine QA (#367)
* Improved error message when no config is set on startup * Change inccorect error wording * bump Bitfinex websocket orderbook return length to max * temporary fix of incorrect orderbook updates, limit to bid and ask len of 100, will be extended later if needed * Fixed issue in binance websocket that appended 0 volume bid/ask items * Fix panic when unmarshalling an empty pair from config * Add get pair asset method for exchange base Fix Bitmex orderbook stream Unbuffer Bitmex orderbook stream * force syncer to update ticker instead of fetch, which allows a stream * Fix websocket last price for coinbasepro * fix websocket ticker for coinut * Fix websocket orderbook stream Huobi * increase orderbook depth REST for Huobi * Fix websocket support and ensure data integrity * Fix time parsing issue after error checks * check error, only process enabled currency pairs, signal websocket data processing * expanded websocket functionality for okgroup * Add logic to not process zero length slice for orderbooks * fix websocket ticker only updating enabled and individual book updates * ZB fixes to order submission/retrieval/cancellation w/ general fixes * Quiet unnecessary warning * updated config entry values for REST and websocket (initial hack until I come up with a better solution for asset types) * Ch GetName function to field access modifyer & rm useless code * Add in error I missed * Nits addressed * some more fixes * Turned kraken default websocket to true and some small changes * fixes linter issues * Ensured okgroup books and sent update through to datahandler. Zb update as well. * Add test case to get asset type from pair * Add test for pairs unmarshal * Add testing and addressed nits * FIX linter issue * Addressed Gees nits * Thanks glorious spotter * more nitorinos * Addres even more nits * Add stringerino 4000 * Fix for panic cause by sort slice out of range, also nits addressed * fix linter issues * Changed from function to field access * Changed from function to field access * fix for orderbook update panic, removes quick fix - caused by sync item fetching through same protocol * Add new test and update random generator * pass in invalid string to future ob fetching, due to futures contract expire and a http 400 error is returned
This commit is contained in:
committed by
Adrian Gallagher
parent
e2c349424f
commit
22ff33cd54
@@ -206,8 +206,17 @@ func (b *Bitmex) wsHandleIncomingData() {
|
||||
}
|
||||
|
||||
p := currency.NewPairFromString(orderbooks.Data[0].Symbol)
|
||||
// TODO: update this to support multiple asset types
|
||||
err = b.processOrderbook(orderbooks.Data, orderbooks.Action, p, "CONTRACT")
|
||||
var a asset.Item
|
||||
a, err = b.GetPairAssetType(p)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
}
|
||||
|
||||
err = b.processOrderbook(orderbooks.Data,
|
||||
orderbooks.Action,
|
||||
p,
|
||||
a)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
@@ -345,12 +354,14 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
|
||||
asks = append(asks, orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
})
|
||||
continue
|
||||
}
|
||||
bids = append(bids, orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -379,24 +390,23 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
|
||||
for i := range data {
|
||||
if strings.EqualFold(data[i].Side, "Sell") {
|
||||
asks = append(asks, orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
})
|
||||
continue
|
||||
}
|
||||
bids = append(bids, orderbook.Item{
|
||||
Price: data[i].Price,
|
||||
Amount: float64(data[i].Size),
|
||||
ID: data[i].ID,
|
||||
})
|
||||
}
|
||||
|
||||
err := b.Websocket.Orderbook.Update(&wsorderbook.WebsocketOrderbookUpdate{
|
||||
Bids: bids,
|
||||
Asks: asks,
|
||||
CurrencyPair: currencyPair,
|
||||
UpdateTime: time.Now(),
|
||||
AssetType: assetType,
|
||||
Action: action,
|
||||
Bids: bids,
|
||||
Asks: asks,
|
||||
Pair: currencyPair,
|
||||
Asset: assetType,
|
||||
Action: action,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -413,7 +423,16 @@ func (b *Bitmex) processOrderbook(data []OrderBookL2, action string, currencyPai
|
||||
|
||||
// GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()
|
||||
func (b *Bitmex) GenerateDefaultSubscriptions() {
|
||||
contracts := b.GetEnabledPairs(asset.PerpetualContract)
|
||||
assets := b.GetAssetTypes()
|
||||
var allPairs currency.Pairs
|
||||
|
||||
for x := range assets {
|
||||
contracts := b.GetEnabledPairs(assets[x])
|
||||
for y := range contracts {
|
||||
allPairs = allPairs.Add(contracts[y])
|
||||
}
|
||||
}
|
||||
|
||||
channels := []string{bitmexWSOrderbookL2, bitmexWSTrade}
|
||||
subscriptions := []wshandler.WebsocketChannelSubscription{
|
||||
{
|
||||
@@ -422,10 +441,10 @@ func (b *Bitmex) GenerateDefaultSubscriptions() {
|
||||
}
|
||||
|
||||
for i := range channels {
|
||||
for j := range contracts {
|
||||
for j := range allPairs {
|
||||
subscriptions = append(subscriptions, wshandler.WebsocketChannelSubscription{
|
||||
Channel: fmt.Sprintf("%v:%v", channels[i], contracts[j].String()),
|
||||
Currency: contracts[j],
|
||||
Channel: fmt.Sprintf("%v:%v", channels[i], allPairs[j].String()),
|
||||
Currency: allPairs[j],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ func (b *Bitmex) Setup(exch *config.ExchangeConfig) error {
|
||||
|
||||
b.Websocket.Orderbook.Setup(
|
||||
exch.WebsocketOrderbookBufferLimit,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user