Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bybit: Fix WS ticker processing #1538

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
288 changes: 169 additions & 119 deletions exchanges/bybit/bybit_test.go

Large diffs are not rendered by default.

87 changes: 10 additions & 77 deletions exchanges/bybit/bybit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ type TickerData struct {
List []TickerItem `json:"list"`
}

// TickerItem represents a ticker item detail.
// TickerItem represents a ticker item detail
type TickerItem struct {
Symbol string `json:"symbol"`
TickDirection string `json:"tickDirection"`
LastPrice types.Number `json:"lastPrice"`
IndexPrice types.Number `json:"indexPrice"`
MarkPrice types.Number `json:"markPrice"`
Expand All @@ -193,6 +194,7 @@ type TickerItem struct {
Bid1Iv types.Number `json:"bid1Iv"`
Ask1Iv types.Number `json:"ask1Iv"`
MarkIv types.Number `json:"markIv"`
MarkPriceIv types.Number `json:"markPriceIv"`
UnderlyingPrice types.Number `json:"underlyingPrice"`
TotalVolume types.Number `json:"totalVolume"`
TotalTurnover types.Number `json:"totalTurnover"`
Expand All @@ -201,6 +203,13 @@ type TickerItem struct {
Vega types.Number `json:"vega"`
Theta types.Number `json:"theta"`
Change24Hour types.Number `json:"change24h"`
UsdIndexPrice types.Number `json:"usdIndexPrice"`
BidPrice types.Number `json:"bidPrice"`
BidSize types.Number `json:"bidSize"`
BidIv types.Number `json:"bidIv"`
AskPrice types.Number `json:"askPrice"`
AskSize types.Number `json:"askSize"`
AskIv types.Number `json:"askIv"`
}

// FundingRateHistory represents a funding rate history for a category.
Expand Down Expand Up @@ -1786,72 +1795,6 @@ type WebsocketPublicTrades []struct {
BlockTrade bool `json:"BT"`
}

// WsLinearTicker represents a linear ticker information.
type WsLinearTicker struct {
Symbol string `json:"symbol"`
TickDirection string `json:"tickDirection"`
Price24HPcnt types.Number `json:"price24hPcnt"`
LastPrice types.Number `json:"lastPrice"`
PrevPrice24H types.Number `json:"prevPrice24h"`
HighPrice24H types.Number `json:"highPrice24h"`
LowPrice24H types.Number `json:"lowPrice24h"`
PrevPrice1H types.Number `json:"prevPrice1h"`
MarkPrice types.Number `json:"markPrice"`
IndexPrice types.Number `json:"indexPrice"`
OpenInterest types.Number `json:"openInterest"`
OpenInterestValue types.Number `json:"openInterestValue"`
Turnover24H types.Number `json:"turnover24h"`
Volume24H types.Number `json:"volume24h"`
NextFundingTime convert.ExchangeTime `json:"nextFundingTime"`
FundingRate types.Number `json:"fundingRate"`
Bid1Price types.Number `json:"bid1Price"`
Bid1Size types.Number `json:"bid1Size"`
Ask1Price types.Number `json:"ask1Price"`
Ask1Size types.Number `json:"ask1Size"`
}

// WsOptionTicker represents options public ticker data.
type WsOptionTicker struct {
Symbol string `json:"symbol"`
BidPrice types.Number `json:"bidPrice"`
BidSize types.Number `json:"bidSize"`
BidIv types.Number `json:"bidIv"`
AskPrice types.Number `json:"askPrice"`
AskSize types.Number `json:"askSize"`
AskIv types.Number `json:"askIv"`
LastPrice types.Number `json:"lastPrice"`
HighPrice24H types.Number `json:"highPrice24h"`
LowPrice24H types.Number `json:"lowPrice24h"`
MarkPrice types.Number `json:"markPrice"`
IndexPrice types.Number `json:"indexPrice"`
MarkPriceIv types.Number `json:"markPriceIv"`
UnderlyingPrice types.Number `json:"underlyingPrice"`
OpenInterest types.Number `json:"openInterest"`
Turnover24H types.Number `json:"turnover24h"`
Volume24H types.Number `json:"volume24h"`
TotalVolume types.Number `json:"totalVolume"`
TotalTurnover types.Number `json:"totalTurnover"`
Delta types.Number `json:"delta"`
Gamma types.Number `json:"gamma"`
Vega types.Number `json:"vega"`
Theta types.Number `json:"theta"`
PredictedDeliveryPrice types.Number `json:"predictedDeliveryPrice"`
Change24H types.Number `json:"change24h"`
}

// WsSpotTicker represents a spot public ticker information.
type WsSpotTicker struct {
Symbol string `json:"symbol"`
LastPrice types.Number `json:"lastPrice"`
HighPrice24H types.Number `json:"highPrice24h"`
LowPrice24H types.Number `json:"lowPrice24h"`
PrevPrice24H types.Number `json:"prevPrice24h"`
Volume24H types.Number `json:"volume24h"`
Turnover24H types.Number `json:"turnover24h"`
Price24HPcnt types.Number `json:"price24hPcnt"`
UsdIndexPrice types.Number `json:"usdIndexPrice"`
}

// WsKlines represents a list of Kline data.
type WsKlines []struct {
Confirm bool `json:"confirm"`
Expand Down Expand Up @@ -1889,16 +1832,6 @@ type LTKlines []struct {
Timestamp convert.ExchangeTime `json:"timestamp"`
}

// LTTicker represents a leverage token ticker.
type LTTicker struct {
Symbol string `json:"symbol"`
LastPrice types.Number `json:"lastPrice"`
HighPrice24H types.Number `json:"highPrice24h"`
LowPrice24H types.Number `json:"lowPrice24h"`
PrevPrice24H types.Number `json:"prevPrice24h"`
Price24HPercentage types.Number `json:"price24hPcnt"`
}

// LTNav represents leveraged token nav stream.
type LTNav struct {
Symbol string `json:"symbol"`
Expand Down