39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
package main
|
|
|
|
// Tick represents a single raw trade event from the Bybit WebSocket.
|
|
type Tick struct {
|
|
Timestamp int64 // Epoch millisecond timestamp
|
|
Price float64 // Transacted trade price
|
|
Volume float64 // Trade quantity
|
|
Side string // "Buy" or "Sell"
|
|
}
|
|
|
|
// FeatureBucket holds aggregated 5-second feature data ready for insertion into features.db.
|
|
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
|
|
}
|
|
|
|
// BybitWSMessage represents the top-level WebSocket message from Bybit V5 publicTrade.
|
|
type BybitWSMessage struct {
|
|
Topic string `json:"topic"`
|
|
Type string `json:"type"`
|
|
TS int64 `json:"ts"`
|
|
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.
|
|
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
|
|
}
|