mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 07:26:48 +00:00
Bugfixes: Bitfinex websocket, ZB market response and portfolio (#397)
* bug fix for websocket orderbook processing * Fix more panics * fix linter issue * kick panic can down the road * temp fix for issue with a 404 returned error as chainz.cryptoid dropped eth support * Address nits and fixed orderbook updating * Fix trade data, rm'd event time from struct * fix time conversion for huobi * Actually process kline data and fix time stamps * btse time conversion fix and RM log, as it seems that the gain is reflecting transaction side. Drop ticker fetching support because there does not seem to be support on docs. And added trade fetching support. * revert huobi println * Adressed suggestion * rm unnecessary assignment * rm unnecessary check and assign * fix conversion mishap * fix currency conversion bug * update websocket logging * RM websocket type which stops conversion and copy * fix linter issue, add in unknown side type
This commit is contained in:
committed by
Adrian Gallagher
parent
467d8d91a2
commit
98a277a4c3
@@ -60,6 +60,7 @@ type Websocket struct {
|
||||
features *protocol.Features
|
||||
}
|
||||
|
||||
// WebsocketSetup defines variables for setting up a websocket connection
|
||||
type WebsocketSetup struct {
|
||||
Enabled bool
|
||||
Verbose bool
|
||||
@@ -103,28 +104,21 @@ type TradeData struct {
|
||||
AssetType asset.Item
|
||||
Exchange string
|
||||
EventType string
|
||||
EventTime int64
|
||||
Price float64
|
||||
Amount float64
|
||||
Side string
|
||||
}
|
||||
|
||||
// TickerData defines ticker feed
|
||||
type TickerData struct {
|
||||
Exchange string
|
||||
Open float64
|
||||
Close float64
|
||||
Volume float64
|
||||
QuoteVolume float64
|
||||
High float64
|
||||
Low float64
|
||||
Bid float64
|
||||
Ask float64
|
||||
Last float64
|
||||
PriceATH float64
|
||||
Timestamp time.Time
|
||||
AssetType asset.Item
|
||||
Pair currency.Pair
|
||||
// FundingData defines funding data
|
||||
type FundingData struct {
|
||||
Timestamp time.Time
|
||||
CurrencyPair currency.Pair
|
||||
AssetType asset.Item
|
||||
Exchange string
|
||||
Amount float64
|
||||
Rate float64
|
||||
Period int64
|
||||
Side string
|
||||
}
|
||||
|
||||
// KlineData defines kline feed
|
||||
|
||||
@@ -196,6 +196,29 @@ func (w *WebsocketOrderbookLocal) updateByIDAndAction(o *orderbook.Base, u *Webs
|
||||
sort.Slice(o.Asks, func(i, j int) bool {
|
||||
return o.Asks[i].Price < o.Asks[j].Price
|
||||
})
|
||||
|
||||
case "update/insert":
|
||||
updateBids:
|
||||
for x := range u.Bids {
|
||||
for y := range o.Bids {
|
||||
if o.Bids[y].ID == u.Bids[x].ID {
|
||||
o.Bids[y].Amount = u.Bids[x].Amount
|
||||
continue updateBids
|
||||
}
|
||||
}
|
||||
o.Bids = append(o.Bids, u.Bids[x])
|
||||
}
|
||||
|
||||
updateAsks:
|
||||
for x := range u.Asks {
|
||||
for y := range o.Asks {
|
||||
if o.Asks[y].ID == u.Asks[x].ID {
|
||||
o.Asks[y].Amount = u.Asks[x].Amount
|
||||
continue updateAsks
|
||||
}
|
||||
}
|
||||
o.Asks = append(o.Asks, u.Asks[x])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user