Closed kazz187 closed 6 months ago
📝 I'm a little busy, so it will take me a while to review
The omission of these columns in recent updates
It does not seem to be specifically mentioned in the documentation below. https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
I will run the following to check.
$ git branch --show-current
fix-v5-ws-public-ticker
package main
import (
"context"
"log"
"github.com/hirokisan/bybit/v2"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
wsClient := bybit.NewWebsocketClient()
svc, err := wsClient.V5().Public(bybit.CategoryV5Linear)
if err != nil {
return err
}
if _, err := svc.SubscribeTicker(
bybit.V5WebsocketPublicTickerParamKey{
Symbol: bybit.SymbolV5("ADAUSDT"),
},
func(response bybit.V5WebsocketPublicTickerResponse) error {
log.Printf("%+v\n", response.Data.LinearInverse)
return nil
},
); err != nil {
return err
}
if err := svc.Start(context.Background(), func(isWebsocketClosed bool, err error) {
if isWebsocketClosed {
log.Println("closed: ", err)
}
}); err != nil {
return err
}
return nil
}
Here are the results.
2024/03/27 08:45:42 &{Symbol:ADAUSDT TickDirection:MinusTick Price24hPercent:0.014945 LastPrice:0.6655 PrevPrice24h: HighPrice24h: LowPrice24h: PrevPrice1h: MarkPrice: IndexPrice: OpenInterest: OpenInterestValue: Turnover24h:96135777.2116 Volume24h:144049355.0000 NextFundingTime: FundingRate: Bid1Price:0.6654 Bid1Size:700 Ask1Price:0.6655 Ask1Size:320 DeliveryTime: BasisRate: DeliveryFeeRate: PredictedDeliveryPrice:}
2024/03/27 08:45:42 &{Symbol:ADAUSDT TickDirection:ZeroMinusTick Price24hPercent: LastPrice: PrevPrice24h: HighPrice24h: LowPrice24h: PrevPrice1h: MarkPrice: IndexPrice: OpenInterest: OpenInterestValue: Turnover24h: Volume24h: NextFundingTime: FundingRate: Bid1Price:0.6653 Bid1Size:16875 Ask1Price:0.6654 Ask1Size:8006 DeliveryTime: BasisRate: DeliveryFeeRate: PredictedDeliveryPrice:}
2024/03/27 08:45:43 &{Symbol:ADAUSDT TickDirection: Price24hPercent: LastPrice: PrevPrice24h: HighPrice24h: LowPrice24h: PrevPrice1h: MarkPrice: IndexPrice: OpenInterest: OpenInterestValue: Turnover24h: Volume24h: NextFundingTime: FundingRate: Bid1Price:0.6653 Bid1Size:14617 Ask1Price:0.6654 Ask1Size:9159 DeliveryTime: BasisRate: DeliveryFeeRate: PredictedDeliveryPrice:}
2024/03/27 08:45:43 &{Symbol:ADAUSDT TickDirection: Price24hPercent: LastPrice: PrevPrice24h: HighPrice24h: LowPrice24h: PrevPrice1h: MarkPrice: IndexPrice: OpenInterest: OpenInterestValue: Turnover24h: Volume24h: NextFundingTime: FundingRate: Bid1Price: Bid1Size: Ask1Price:0.6654 Ask1Size:11876 DeliveryTime: BasisRate: DeliveryFeeRate: PredictedDeliveryPrice:}
So I thought the change seemed reasonable 👍
Description
This pull request addresses the need for adjustments due to changes in the structure of data updates from bybit's WebSocket service. Previously, certain columns such as
Bid1Price
andGamma
were included in updates, serving as indicators for categorizing data as linear, inverse, option, or spot. The omission of these columns in recent updates necessitated a new approach to ensure continued accurate categorization and processing.Key Changes
V5WebsocketPublicService
andV5WebsocketPublicTickerData
structures.UnmarshalJSON
function for data updates has been updated to utilize the newly introduced category field, enabling the appropriate structuring of data based on the update category.