Save all data available from the ws stream.
This commit is contained in:
@@ -1,25 +1,41 @@
|
||||
package main
|
||||
|
||||
// Tick represents a single raw trade event from the Bybit WebSocket.
|
||||
// Tick represents a single trade event persisted into hot storage.
|
||||
type Tick struct {
|
||||
Timestamp int64 // Epoch millisecond timestamp
|
||||
Price float64 // Transacted trade price
|
||||
Volume float64 // Trade quantity
|
||||
Side string // "Buy" or "Sell"
|
||||
// Exchange identifiers
|
||||
TradeID string
|
||||
Seq int64
|
||||
|
||||
// Timing
|
||||
TradeTS int64 // Bybit trade timestamp (T)
|
||||
MessageTS int64
|
||||
RecvTS int64 // Local receive timestamp
|
||||
|
||||
// Trade data
|
||||
Symbol string
|
||||
Side string
|
||||
Price float64
|
||||
Volume float64
|
||||
|
||||
// Exchange metadata
|
||||
TickDir string // L
|
||||
BlockTrade bool // BT
|
||||
RPI bool // RPI
|
||||
}
|
||||
|
||||
// FeatureBucket holds aggregated 5-second feature data ready for insertion into features.db.
|
||||
|
||||
// FeatureBucket holds aggregated 5-second feature data.
|
||||
type FeatureBucket struct {
|
||||
Timestamp int64 // Epoch millisecond (start of 5s bucket)
|
||||
LogReturn float64 // ln(Price_end / Price_start)
|
||||
RealizedVol float64 // Volatility of ticks inside the bucket
|
||||
OFI float64 // Net volume (Buy volume - Sell volume)
|
||||
VolumeSum float64 // Total volume exchanged
|
||||
ClosePrice float64 // Final transaction price in the bucket
|
||||
VWAP float64 // Volume-Weighted Average Price in the bucket
|
||||
Timestamp int64
|
||||
LogReturn float64
|
||||
RealizedVol float64
|
||||
OFI float64
|
||||
VolumeSum float64
|
||||
ClosePrice float64
|
||||
VWAP float64
|
||||
}
|
||||
|
||||
// BybitWSMessage represents the top-level WebSocket message from Bybit V5 publicTrade.
|
||||
// Top-level websocket message.
|
||||
type BybitWSMessage struct {
|
||||
Topic string `json:"topic"`
|
||||
Type string `json:"type"`
|
||||
@@ -27,13 +43,22 @@ type BybitWSMessage struct {
|
||||
Data []BybitTradeRaw `json:"data"`
|
||||
}
|
||||
|
||||
// BybitTradeRaw represents a single trade object within the Bybit WebSocket data array.
|
||||
// Price and Volume arrive as strings from the API and need conversion.
|
||||
// Raw trade from Bybit publicTrade stream.
|
||||
type BybitTradeRaw struct {
|
||||
T int64 `json:"T"` // Timestamp (ms) that the order is filled
|
||||
S string `json:"s"` // Symbol name
|
||||
SD string `json:"S"` // Side of taker: "Buy" or "Sell"
|
||||
V string `json:"v"` // Trade size (string)
|
||||
P string `json:"p"` // Trade price (string)
|
||||
I string `json:"i"` // Trade ID
|
||||
T int64 `json:"T"`
|
||||
|
||||
S string `json:"s"`
|
||||
SD string `json:"S"`
|
||||
|
||||
V string `json:"v"`
|
||||
P string `json:"p"`
|
||||
|
||||
L string `json:"L"`
|
||||
|
||||
I string `json:"i"`
|
||||
|
||||
BT bool `json:"BT"`
|
||||
RPI bool `json:"RPI"`
|
||||
|
||||
Seq int64 `json:"seq"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user