Documentation
¶
Index ¶
- Constants
- Variables
- func DatasetToHostname(dataset string) string
- func DbnScannerDecode[R Record, RP RecordPtr[R]](s *DbnScanner) (*R, error)
- func Fixed9ToFloat64(fixed int64) float64
- func JsonScannerDecode[R Record, RP RecordPtr[R]](s *JsonScanner) (*R, error)
- func MakeCompressedReader(filename string, useZstd bool) (io.Reader, io.Closer, error)
- func MakeCompressedWriter(filename string, useZstd bool) (io.Writer, func(), error)
- func ReadJsonToSlice[R Record, RP RecordPtr[R]](reader io.Reader) ([]R, error)
- func TimeToYMD(t time.Time) uint32
- func TimestampToSecNanos(dbnTimestamp uint64) (int64, int64)
- func TimestampToTime(dbnTimestamp uint64) time.Time
- func TrimNullBytes(b []byte) string
- func YMDToTime(yyyymmdd int, loc *time.Location) time.Time
- type Action
- type BidAskPair
- type CbboMsg
- type Compression
- type ConsolidatedBidAskPair
- type DbnScanner
- func (s *DbnScanner) DecodeSymbolMappingMsg() (*SymbolMappingMsg, error)
- func (s *DbnScanner) Error() error
- func (s *DbnScanner) GetLastHeader() (RHeader, error)
- func (s *DbnScanner) GetLastRecord() []byte
- func (s *DbnScanner) GetLastSize() int
- func (s *DbnScanner) Metadata() (*Metadata, error)
- func (s *DbnScanner) Next() bool
- func (s *DbnScanner) Visit(visitor Visitor) error
- type Encoding
- type ErrorMsg
- type ImbalanceMsg
- type InstrumentClass
- type InstrumentDefMsg
- type JsonScanner
- type MappingInterval
- type MatchAlgorithm
- type MboMsg
- type Mbp0Msg
- type Mbp1Msg
- type Mbp10Msg
- type Metadata
- type MetadataHeaderV1
- type MetadataHeaderV2
- type MetadataPrefix
- type NullVisitor
- func (v *NullVisitor) OnCbbo(record *CbboMsg) error
- func (v *NullVisitor) OnErrorMsg(record *ErrorMsg) error
- func (v *NullVisitor) OnImbalance(record *ImbalanceMsg) error
- func (v *NullVisitor) OnInstrumentDefMsg(record *InstrumentDefMsg) error
- func (v *NullVisitor) OnMbo(record *MboMsg) error
- func (v *NullVisitor) OnMbp0(record *Mbp0Msg) error
- func (v *NullVisitor) OnMbp1(record *Mbp1Msg) error
- func (v *NullVisitor) OnMbp10(record *Mbp10Msg) error
- func (v *NullVisitor) OnOhlcv(record *OhlcvMsg) error
- func (v *NullVisitor) OnStatMsg(record *StatMsg) error
- func (v *NullVisitor) OnStatusMsg(record *StatusMsg) error
- func (v *NullVisitor) OnStreamEnd() error
- func (v *NullVisitor) OnSymbolMappingMsg(record *SymbolMappingMsg) error
- func (v *NullVisitor) OnSystemMsg(record *SystemMsg) error
- func (v *NullVisitor) OnTcbbo(record *TcbboMsg) error
- type OhlcvMsg
- type PitSymbolMap
- type RHeader
- type RType
- type Record
- type RecordPtr
- type SType
- type Schema
- type SecurityUpdateAction
- type Side
- type StatMsg
- type StatType
- type StatUpdateAction
- type StatusAction
- type StatusMsg
- type StatusReason
- type SymbolMapping
- type SymbolMappingMsg
- type SystemMsg
- type TcbboMsg
- type TradeMsg
- type TradingEvent
- type TriState
- type TsSymbolMap
- func (tsm *TsSymbolMap) FillFromMetadata(metadata *Metadata) error
- func (tsm *TsSymbolMap) Get(dt time.Time, instrID uint32) string
- func (tsm *TsSymbolMap) Insert(instrID uint32, startDate uint32, endDate uint32, ticker string) error
- func (tsm *TsSymbolMap) IsEmpty() bool
- func (tsm *TsSymbolMap) Len() int
- type UserDefinedInstrument
- type VersionUpgradePolicy
- type Visitor
Constants ¶
const ( /// Indicates it's the last message in the packet from the venue for a given /// `instrument_id`. RFlag_LAST uint8 = 1 << 7 /// Indicates a top-of-book message, not an individual order. RFlag_TOB uint8 = 1 << 6 /// Indicates the message was sourced from a replay, such as a snapshot server. RFlag_SNAPSHOT uint8 = 1 << 5 /// Indicates an aggregated price level message, not an individual order. RFlag_MBP uint8 = 1 << 4 /// Indicates the `ts_recv` value is inaccurate due to clock issues or packet /// reordering. RFlag_BAD_TS_RECV uint8 = 1 << 3 /// Indicates an unrecoverable gap was detected in the channel. RFlag_MAYBE_BAD_BOOK uint8 = 1 << 2 )
/ Constants for the bit flag record fields.
const ( HeaderVersion1 = 1 HeaderVersion2 = 2 MetadataV1_SymbolCstrLen = 22 MetadataV1_ReservedLen = 47 MetadataV2_SymbolCstrLen = 71 MetadataV2_ReservedLen = 53 Metadata_DatasetCstrLen = 16 Metadata_PrefixSize = 8 MetadataHeaderV1_Size = 100 // Size of the fixed-size portion of Metadata v1, without Prefix MetadataHeaderV2_Size = 100 // Size of the fixed-size portion of Metadata v2, without Prefix MetadataHeaderV1_SizeFuzz = 12 // Difference between actual layout size and Golang struct MetadataHeaderV2_SizeFuzz = 12 // Difference between actual layout size and Golang struct )
const BidAskPair_Size = 32
const CbboMsg_Size = RHeader_Size + 32 + ConsolidatedBidAskPair_Size
const ConsolidatedBidAskPair_Size = 32
const DEFAULT_DECODE_BUFFER_SIZE = 16 * 1024
Default buffer size for decoding
const DEFAULT_SCRATCH_BUFFER_SIZE = 512 // bigger than largest record size
const ErrorMsg_ErrSize = 302
const ErrorMsg_Size = RHeader_Size + ErrorMsg_ErrSize + 2
const FIXED_PRICE_SCALE float64 = 1000000000.0
/ The denominator of fixed prices in DBN.
const ImbalanceMsg_Size = RHeader_Size + 96
const InstrumentDefMsg_AssetCstrLen = 7
const InstrumentDefMsg_MinSize = RHeader_Size + 370
const InstrumentDefMsg_Size = 360
const MboMsg_Size = RHeader_Size + 40
const Mbp0Msg_Size = RHeader_Size + 32
const Mbp10Msg_Size = RHeader_Size + 32 + 10*BidAskPair_Size
const Mbp1Msg_Size = RHeader_Size + 64
const OhlcvMsg_Size = RHeader_Size + 40
const RHeader_Size = 16
const StatMsg_Size = RHeader_Size + 48
const StatusMsg_Size = RHeader_Size + 24 // TODO check size, add test
const SymbolMappingMsg_MinSize = RHeader_Size + 16
Minimum size of SymbolMappingMsg, the size with 0-length c-strings We add 2*SymbolCstrLength to it to get actual size.
const SystemMsg_MsgSize = 303
const SystemMsg_Size = RHeader_Size + SystemMsg_MsgSize + 1
const TcbboMsg_Size = RHeader_Size + 64
const TradeMsg_Size = RHeader_Size + 32
Variables ¶
var ( ErrInvalidDBNVersion = fmt.Errorf("invalid DBN version") ErrInvalidDBNFile = fmt.Errorf("invalid DBN file") ErrHeaderTooShort = fmt.Errorf("header shorter than expected") ErrHeaderTooLong = fmt.Errorf("header longer than expected") ErrUnexpectedCStrLength = fmt.Errorf("unexpected cstr length") ErrNoRecord = fmt.Errorf("no record scanned") ErrMalformedRecord = fmt.Errorf("malformed record") ErrUnknownRType = fmt.Errorf("unknown rtype") ErrDateOutsideQueryRange = fmt.Errorf("date outside the query range") ErrWrongStypesForMapping = fmt.Errorf("wrong stypes for mapping") ErrNoMetadata = fmt.Errorf("no metadata") )
Functions ¶
func DatasetToHostname ¶
DatasetToHostname returns the dataset string into the hostname formnat. This is the dataset in lowercase with . replaced with -.
func DbnScannerDecode ¶
func DbnScannerDecode[R Record, RP RecordPtr[R]](s *DbnScanner) (*R, error)
Parses the Scanner's current record as a `Record`. This a plain function because receiver functions cannot be generic.
func Fixed9ToFloat64 ¶
func JsonScannerDecode ¶
func JsonScannerDecode[R Record, RP RecordPtr[R]](s *JsonScanner) (*R, error)
Parses the Scanner's current record as a `Record`. This a plain function (not a method) because methods cannot be generic.
func MakeCompressedReader ¶
Returns a io.Reader for the given filename, or os.Stdout if filename is "-". Also returns a closing function to defer. If the filename ends in ".zst" or ".zstd", or if useZstd is true, the reader will zstd-decompress the input.
func MakeCompressedWriter ¶
Returns an io.Writer for the given filename, or os.Stdout if filename is "-". Also returns a closing function to defer and any error. If the filename ends in ".zst" or ".zstd", or if useZstd is true, the writer will zstd-compress the output.
func ReadJsonToSlice ¶
ReadJsonToSlice reads the entire stream from a JSONL stream of DBN records. It will scan for type R (for example Mbp0) and decode it into a slice of R. Returns the slice and any error. Example:
fileReader, err := os.Open(dbnFilename) records, err := dbn.ReadJsonToSlice[dbn.Mbp0Msg](fileReader)
func TimeToYMD ¶
TimeToYMD returns the YYYYMMDD for the time.Time in that Time's location. A zero time returns a 0 value. From https://github.com/neomantra/ymdflag/blob/main/ymdflag.go#L49
func TimestampToSecNanos ¶
TimestampToSecNanos converts a DBN timestamp to seconds and nanoseconds.
func TimestampToTime ¶
TimestampToTime converts a DBN timestamp to time.Time
func TrimNullBytes ¶
TrimNullBytes removes trailing nulls from a byte slice and returns a string.
func YMDToTime ¶
YMDtoTime returns the Time corresponding to the YYYYMMDD in the specified location, without validating the argument.` A value of 0 returns a Zero Time, independent of location. A nil location implies local time. https://github.com/neomantra/ymdflag/blob/main/ymdflag.go#L34
Types ¶
type Action ¶
type Action uint8
Action
const ( // An existing order was modified. Action_Modify Action = 'M' // A trade executed. Action_Trade Action = 'T' // An existing order was filled. Action_Fill Action = 'F' // An order was cancelled. Action_Cancel Action = 'C' // A new order was added. Action_Add Action = 'A' // Reset the book; clear all orders for an instrument. Action_Clear Action = 'R' )
type BidAskPair ¶
type BidAskPair struct {
BidPx int64 `json:"bid_px" csv:"bid_px"` // The bid price.
AskPx int64 `json:"ask_px" csv:"ask_px"` // The ask price.
BidSz uint32 `json:"bid_sz" csv:"bid_sz"` // The bid size.
AskSz uint32 `json:"ask_sz" csv:"ask_sz"` // The ask size.
BidCt uint32 `json:"bid_ct" csv:"bid_ct"` // The bid order count.
AskCt uint32 `json:"ask_ct" csv:"ask_ct"` // The ask order count.
}
func (*BidAskPair) Fill_Raw ¶
func (p *BidAskPair) Fill_Raw(b []byte) error
type CbboMsg ¶
type CbboMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Price int64 `json:"price" csv:"price"` // The order price expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Action byte `json:"action" csv:"action"` // The event action. Can be **A**dd, **C**ancel, **M**odify, clea**R**, or **T**rade.
Side byte `json:"side" csv:"side"` // The side that initiates the event. Can be **A**sk for a sell order (or sell aggressor in a trade), **B**id for a buy order (or buy aggressor in a trade), or **N**one where no side is specified by the original source.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating event end, message characteristics, and data quality. See [`enums::flags`](crate::enums::flags) for possible values.
Reserved byte `json:"_reserved,omitempty" csv:"_reserved"` // Reserved for future usage.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
Level ConsolidatedBidAskPair `json:"levels" csv:"levels"` // The top of the order book.
}
type Compression ¶
type Compression uint8
Compression is the compression format or none if uncompressed.
const ( /// Uncompressed. Compress_None Compression = 0 /// Zstandard compressed. Compress_ZStd Compression = 1 )
func CompressionFromString ¶
func CompressionFromString(str string) (Compression, error)
CompressionFromString converts a string to a Compression. Returns an error if the string is unknown.
func (Compression) MarshalJSON ¶
func (c Compression) MarshalJSON() ([]byte, error)
func (*Compression) Set ¶
func (c *Compression) Set(value string) error
Set implements the flag.Value interface.
func (Compression) String ¶
func (c Compression) String() string
Returns the string representation of the Compression ('zstd' or 'none'), or empty string if unknown.
func (*Compression) Type ¶
func (*Compression) Type() string
Type implements pflag.Value.Type. Returns "dbn.Compression".
func (*Compression) UnmarshalJSON ¶
func (c *Compression) UnmarshalJSON(data []byte) error
type ConsolidatedBidAskPair ¶
type ConsolidatedBidAskPair struct {
BidPx int64 `json:"bid_px" csv:"bid_px"` // The bid price.
AskPx int64 `json:"ask_px" csv:"ask_px"` // The ask price.
BidSz uint32 `json:"bid_sz" csv:"bid_sz"` // The bid size.
AskSz uint32 `json:"ask_sz" csv:"ask_sz"` // The ask size.
BidPb uint16 `json:"bid_pb" csv:"bid_pb"` // The bid publisher ID assigned by Databento, which denotes the dataset and venue.
Reserved1 uint16 `json:"_reserved1" csv:"_reserved1"` // Reserved for later usage
AskPb uint16 `json:"ask_pb" csv:"ask_pb"` // The ask publisher ID assigned by Databento, which denotes the dataset and venue.
Reserved2 uint16 `json:"_reserved2" csv:"_reserved2"` // Reserved for later usage
}
A price level consolidated from multiple venues.
func (*ConsolidatedBidAskPair) Fill_Json ¶
func (p *ConsolidatedBidAskPair) Fill_Json(val *fastjson.Value) error
func (*ConsolidatedBidAskPair) Fill_Raw ¶
func (p *ConsolidatedBidAskPair) Fill_Raw(b []byte) error
type DbnScanner ¶
type DbnScanner struct {
// contains filtered or unexported fields
}
DbnScanner scans a raw DBN stream
func NewDbnScanner ¶
func NewDbnScanner(sourceReader io.Reader) *DbnScanner
NewDbnScanner creates a new dbn.DbnScanner
func (*DbnScanner) DecodeSymbolMappingMsg ¶
func (s *DbnScanner) DecodeSymbolMappingMsg() (*SymbolMappingMsg, error)
DecodeSymbolMappingMsg parses the Scanner's current record as a `SymbolMappingMsg`. This is outside the DbnScannerDecode function because SymbolMappingMsg.Fill_Raw is two-argum,ent, depending on the DbnScanner's metadata's SymbolCstrLen.
func (*DbnScanner) Error ¶
func (s *DbnScanner) Error() error
Error returns the last error from Next(). May be io.EOF.
func (*DbnScanner) GetLastHeader ¶
func (s *DbnScanner) GetLastHeader() (RHeader, error)
GetLastHeader returns the RHeader of the last record read, or an error
func (*DbnScanner) GetLastRecord ¶
func (s *DbnScanner) GetLastRecord() []byte
GetLastRecord returns the raw bytes of the last record read
func (*DbnScanner) GetLastSize ¶
func (s *DbnScanner) GetLastSize() int
GetLastSize returns the size of the last record read
func (*DbnScanner) Metadata ¶
func (s *DbnScanner) Metadata() (*Metadata, error)
Metadata returns the metadata for the stream, or nil if none. May try to read the metadata, which may result in an error.
func (*DbnScanner) Next ¶
func (s *DbnScanner) Next() bool
Next parses the next record from the stream
func (*DbnScanner) Visit ¶
func (s *DbnScanner) Visit(visitor Visitor) error
Parses the current Record and passes it to the Visitor.
type Encoding ¶
type Encoding uint8
/ Encoding A data encoding format.
func EncodingFromString ¶
EncodingFromString converts a string to an Encoding. Returns an error if the string is unknown.
func (Encoding) MarshalJSON ¶
func (Encoding) String ¶
Returns the string representation of the Encoding, or empty string if unknown.
func (*Encoding) UnmarshalJSON ¶
type ErrorMsg ¶
type ErrorMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The common header.
Error [ErrorMsg_ErrSize]byte `json:"err" csv:"err"` // The error message.
Code uint8 `json:"code" csv:"code"` // The error code. Currently unused.
IsLast uint8 `json:"is_last" csv:"is_last"` // Sometimes multiple errors are sent together. This field will be non-zero for the last error.
}
type ImbalanceMsg ¶
type ImbalanceMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as the number of nanoseconds since the UNIX epoch.
RefPrice int64 `json:"ref_price" csv:"ref_price"` // The price at which the imbalance shares are calculated, where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
AuctionTime uint64 `json:"auction_time" csv:"auction_time"` // Reserved for future use.
ContBookClrPrice int64 `json:"cont_book_clr_price" csv:"contBook_clr_price"` // The hypothetical auction-clearing price for both cross and continuous orders.
AuctInterestClrPrice int64 `json:"auct_interest_clr_price" csv:"auctInterest_clr_price"` // The hypothetical auction-clearing price for cross orders only.
SsrFillingPrice int64 `json:"ssr_filling_price" csv:"ssr_filling_price"` // Reserved for future use.
IndMatchPrice int64 `json:"ind_match_price" csv:"ind_match_price"` // Reserved for future use.
UpperCollar int64 `json:"upper_collar" csv:"upper_collar"` // Reserved for future use.
LowerCollar int64 `json:"lower_collar" csv:"lower_collar"` // Reserved for future use.
PairedQty uint32 `json:"paired_qty" csv:"paired_qty"` // The quantity of shares that are eligible to be matched at `ref_price`.
TotalImbalanceQty uint32 `json:"total_imbalance_qty" csv:"total_imbalance_qty"` // The quantity of shares that are not paired at `ref_price`.
MarketImbalanceQty uint32 `json:"market_imbalance_qty" csv:"market_ombalance_qty"` // Reserved for future use.
UnpairedQty int32 `json:"unpaired_qty" csv:"unpaired_qty"` // Reserved for future use.
AuctionType uint8 `json:"auction_type" csv:"auction_type"` // Venue-specific character code indicating the auction type.
Side uint8 `json:"side" csv:"side"` // The market side of the `total_imbalance_qty`. Can be **A**sk, **B**id, or **N**one.
AuctionStatus uint8 `json:"auction_status" csv:"auction_status"` // Reserved for future use.
FreezeStatus uint8 `json:"freeze_status" csv:"freeze_status"` // Reserved for future use.
NumExtensions uint8 `json:"num_extensions" csv:"num_extensions"` // Reserved for future use.
UnpairedSide uint8 `json:"unpaired_side" csv:"unpaired_side"` // Reserved for future use.
SignificantImbalance uint8 `json:"significant_imbalance" csv:"significant_imbalance"` // Venue-specific character code. For Nasdaq, contains the raw Price Variation Indicator.
Reserved uint8 `json:"reserved" csv:"reserved"` // Filler for alignment.
}
Databento Normalized Imbalance Message {"ts_recv":"1711027500000942123","hd":{"ts_event":"1711027500000776211","rtype":20,"publisher_id":2,"instrument_id":17598},"ref_price":"0","auction_time":"0","cont_book_clr_price":"0","auct_interest_clr_price":"0","ssr_filling_price":"0","ind_match_price":"0","upper_collar":"0","lower_collar":"0","paired_qty":0,"total_imbalance_qty":0,"market_imbalance_qty":0,"unpaired_qty":0,"auction_type":"O","side":"N","auction_status":0,"freeze_status":0,"num_extensions":0,"unpaired_side":"N","significant_imbalance":"~"}
func (*ImbalanceMsg) Fill_Json ¶
func (r *ImbalanceMsg) Fill_Json(val *fastjson.Value, header *RHeader) error
func (*ImbalanceMsg) Fill_Raw ¶
func (r *ImbalanceMsg) Fill_Raw(b []byte) error
func (*ImbalanceMsg) RSize ¶
func (*ImbalanceMsg) RSize() uint16
func (*ImbalanceMsg) RType ¶
func (*ImbalanceMsg) RType() RType
type InstrumentClass ¶
type InstrumentClass uint8
InstrumentClass
const ( // A bond. InstrumentClass_Bond InstrumentClass = 'B' // A call option. InstrumentClass_Call InstrumentClass = 'C' // A future. InstrumentClass_Future InstrumentClass = 'F' // A stock. InstrumentClass_Stock InstrumentClass = 'K' // A spread composed of multiple instrument classes InstrumentClass_MixedSpread InstrumentClass = 'M' // A put option InstrumentClass_Put InstrumentClass = 'P' // A spread composed of futures. InstrumentClass_FutureSpread InstrumentClass = 'S' // A spread composed of options. InstrumentClass_OptionSpread InstrumentClass = 'T' // A foreign exchange spot. InstrumentClass_FxSpot InstrumentClass = 'X' )
func (InstrumentClass) IsFuture ¶
func (i InstrumentClass) IsFuture() bool
func (InstrumentClass) IsOption ¶
func (i InstrumentClass) IsOption() bool
func (InstrumentClass) IsSpread ¶
func (i InstrumentClass) IsSpread() bool
type InstrumentDefMsg ¶
type InstrumentDefMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The common header.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as the number of nanoseconds since the UNIX epoch.
MinPriceIncrement int64 `json:"min_price_increment" csv:"min_price_increment"` // Fixed price The minimum constant tick for the instrument in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
DisplayFactor int64 `json:"display_factor" csv:"display_factor"` // The multiplier to convert the venue’s display price to the conventional price, in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Expiration uint64 `json:"expiration" csv:"expiration"` // The last eligible trade time expressed as a number of nanoseconds since the UNIX epoch. Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities.
Activation uint64 `json:"activation" csv:"activation"` // The time of instrument activation expressed as a number of nanoseconds since the UNIX epoch. Will be [`crate::UNDEF_TIMESTAMP`] when null, such as for equities.
HighLimitPrice int64 `json:"high_limit_price" csv:"high_limit_price"` // The allowable high limit price for the trading day in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
LowLimitPrice int64 `json:"low_limit_price" csv:"low_limit_price"` // The allowable low limit price for the trading day in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
MaxPriceVariation int64 `json:"max_price_variation" csv:"max_price_variation"` // The differential value for price banding in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
TradingReferencePrice int64 `json:"trading_reference_price" csv:"trading_reference_price"` // The trading reference price for the instrument in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
UnitOfMeasureQty int64 `json:"unit_of_measure_qty" csv:"unit_of_measure_qty"` // The contract size for each instrument, in combination with `unit_of_measure`, in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
MinPriceIncrementAmount int64 `json:"min_price_increment_amount" csv:"min_price_increment_amount"` // The value currently under development by the venue. Converted to units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
PriceRatio int64 `json:"price_ratio" csv:"price_ratio"` // The value used for price calculation in spread and leg pricing in units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
StrikePrice int64 `json:"strike_price" csv:"strike_price"` // The strike price of the option. Converted to units of 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
InstAttribValue int32 `json:"inst_attrib_value" csv:"inst_attrib_value"` // A bitmap of instrument eligibility attributes.
UnderlyingID uint32 `json:"underlying_id" csv:"underlying_id"` // The `instrument_id` of the first underlying instrument.
RawInstrumentID uint64 `json:"raw_instrument_id" csv:"raw_instrument_id"` // The instrument ID assigned by the publisher. May be the same as `instrument_id`.
LegPrice int64 `json:"leg_price" csv:"leg_price"` // The tied price (if any) of the leg.
LegDelta int64 `json:"leg_delta" csv:"leg_delta"` // The associated delta (if any) of the leg.
MarketDepthImplied int32 `json:"market_depth_implied" csv:"market_depth_implied"` // The implied book depth on the price level data feed.
MarketDepth int32 `json:"market_depth" csv:"market_depth"` // The (outright) book depth on the price level data feed.
MarketSegmentID uint32 `json:"market_segment_id" csv:"market_segment_id"` // The market segment of the instrument.
MaxTradeVol uint32 `json:"max_trade_vol" csv:"max_trade_vol"` // The maximum trading volume for the instrument.
MinLotSize int32 `json:"min_lot_size" csv:"min_lot_size"` // The minimum order entry quantity for the instrument.
MinLotSizeBlock int32 `json:"min_lot_size_block" csv:"min_lot_size_block"` // The minimum quantity required for a block trade of the instrument.
MinLotSizeRoundLot int32 `json:"min_lot_size_round_lot" csv:"min_lot_size_round_lot"` // The minimum quantity required for a round lot of the instrument. Multiples of this quantity are also round lots.
MinTradeVol uint32 `json:"min_trade_vol" csv:"min_trade_vol"` // The minimum trading volume for the instrument.
ContractMultiplier int32 `json:"contract_multiplier" csv:"contract_multiplier"` // The number of deliverables per instrument, i.e. peak days.
DecayQuantity int32 `json:"decay_quantity" csv:"decay_quantity"` // The quantity that a contract will decay daily, after `decay_start_date` has been reached.
OriginalContractSize int32 `json:"original_contract_size" csv:"original_contract_size"` // The fixed contract value assigned to each instrument.
LegInstrumentID uint32 `json:"leg_instrument_id" csv:"leg_instrument_id"` // The numeric ID assigned to the leg instrument.
LegRatioPriceNumerator int32 `json:"leg_ratio_price_numerator" csv:"leg_ratio_price_numerator"` // The numerator of the price ratio of the leg within the spread.
LegRatioPriceDenominator int32 `json:"leg_ratio_price_denominator" csv:"leg_ratio_price_denominator"` // The denominator of the price ratio of the leg within the spread.
LegRatioQtyNumerator int32 `json:"leg_ratio_qty_numerator" csv:"leg_ratio_qty_numerator"` // The numerator of the quantity ratio of the leg within the spread.
LegRatioQtyDenominator int32 `json:"leg_ratio_qty_denominator" csv:"leg_ratio_qty_denominator"` // The denominator of the quantity ratio of the leg within the spread.
LegUnderlyingID uint32 `json:"leg_underlying_id" csv:"leg_underlying_id"` // The numeric ID of the leg instrument's underlying instrument.
ApplID int16 `json:"appl_id" csv:"appl_id"` // The channel ID assigned at the venue.
MaturityYear uint16 `json:"maturity_year" csv:"maturity_year"` // The calendar year reflected in the instrument symbol.
DecayStartDate uint16 `json:"decay_start_date" csv:"decay_start_date"` // The date at which a contract will begin to decay.
ChannelID uint16 `json:"channel_id" csv:"channel_id"` // The channel ID assigned by Databento as an incrementing integer starting at zero.
LegCount uint16 `json:"leg_count" csv:"leg_count"` // The number of legs in the strategy or spread. Will be 0 for outrights.
LegIndex uint16 `json:"leg_index" csv:"leg_index"` // The 0-based index of the leg.
TradingReferenceDate uint16 `json:"trading_reference_date" csv:"trading_reference_date"` // The trading reference date for the instrument.
Currency [4]byte `json:"currency" csv:"currency"` // The currency used for price fields.
SettlCurrency [4]byte `json:"settl_currency" csv:"settl_currency"` // The currency used for settlement, if different from `currency`.
Secsubtype [6]byte `json:"secsubtype" csv:"secsubtype"` // The strategy type of the spread.
RawSymbol [MetadataV2_SymbolCstrLen]byte `json:"raw_symbol" csv:"raw_symbol"` // The instrument raw symbol assigned by the publisher.
Group [21]byte `json:"group" csv:"group"` // The security group code of the instrument.
Exchange [5]byte `json:"exchange" csv:"exchange"` // The exchange used to identify the instrument.
Asset [InstrumentDefMsg_AssetCstrLen]byte `json:"asset" csv:"asset"` // The underlying asset code (product code) of the instrument.
Cfi [7]byte `json:"cfi" csv:"cfi"` // The ISO standard instrument categorization code.
SecurityType [7]byte `json:"security_type" csv:"security_type"` // The type of the instrument, e.g. FUT for future or future spread.
UnitOfMeasure [31]byte `json:"unit_of_measure" csv:"unit_of_measure"` // The unit of measure for the instrument’s original contract size, e.g. USD or LBS.
Underlying [21]byte `json:"underlying" csv:"underlying"` // The symbol of the first underlying instrument.
StrikePriceCurrency [4]byte `json:"strike_price_currency" csv:"strike_price_currency"` // The currency of [`strike_price`](Self::strike_price).
LegRawSymbol [MetadataV2_SymbolCstrLen]byte `json:"leg_raw_symbol" csv:"leg_raw_symbol"` // The leg instrument's raw symbol assigned by the publisher.
InstrumentClass byte `json:"instrument_class" csv:"instrument_class"` // The classification of the instrument.
MatchAlgorithm byte `json:"match_algorithm" csv:"match_algorithm"` // The matching algorithm used for the instrument, typically **F**IFO.
MdSecurityTradingStatus uint8 `json:"md_security_trading_status" csv:"md_security_trading_status"` // The market data security trading status.
MainFraction uint8 `json:"main_fraction" csv:"main_fraction"` // The price denominator of the main fraction.
PriceDisplayFormat uint8 `json:"price_display_format" csv:"price_display_format"` // The number of digits to the right of the tick mark, to display fractional prices.
SettlPrice_type uint8 `json:"settl_price_type" csv:"settl_price_type"` // The settlement price type.
SubFraction uint8 `json:"sub_fraction" csv:"sub_fraction"` // The price denominator of the sub fraction.
UnderlyingProduct uint8 `json:"underlying_product" csv:"underlying_product"` // The product complex of the instrument.
SecurityUpdateAction byte `json:"security_update_action" csv:"security_update_action"` // Indicates if the instrument definition has been added, modified, or deleted.
MaturityMonth uint8 `json:"maturity_month" csv:"maturity_month"` // The calendar month reflected in the instrument symbol.
MaturityDay uint8 `json:"maturity_day" csv:"maturity_day"` // The calendar day reflected in the instrument symbol, or 0.
MaturityWeek uint8 `json:"maturity_week" csv:"maturity_week"` // The calendar week reflected in the instrument symbol, or 0.
UserDefinedInstrument byte `json:"user_defined_instrument" csv:"user_defined_instrument"` // Indicates if the instrument is user defined: Yes or No.
ContractMultiplierUnit int8 `json:"contract_multiplier_unit" csv:"contract_multiplier_unit"` // The type of `contract_multiplier`. Either `1` for hours, or `2` for days.
FlowScheduleType int8 `json:"flow_schedule_type" csv:"flow_schedule_type"` // The schedule for delivering electricity.
TickRule uint8 `json:"tick_rule" csv:"tick_rule"` // The tick rule of the spread.
LegInstrumentClass byte `json:"leg_instrument_class" csv:"leg_instrument_class"` // The classification of the leg instrument.
LegSide byte `json:"leg_side" csv:"leg_side"` // The side taken for the leg when purchasing the spread.
Reserved [17]byte `json:"_reserved,omitempty" csv:"_reserved"` // Reserved for future usage.
}
InstrumentDefMsg is an instrument definition message conforming to Databento's latest format. This is not a strict byte-layout because RawSymbol has dynamic length that depends on metadata's SymbolCstrLen.
func (*InstrumentDefMsg) Fill_Json ¶
func (r *InstrumentDefMsg) Fill_Json(val *fastjson.Value, header *RHeader) error
func (*InstrumentDefMsg) Fill_Raw ¶
func (r *InstrumentDefMsg) Fill_Raw(b []byte) error
func (*InstrumentDefMsg) Fill_RawWithLen ¶
func (r *InstrumentDefMsg) Fill_RawWithLen(b []byte, symbolLen uint16) error
func (*InstrumentDefMsg) RSize ¶
func (*InstrumentDefMsg) RSize() uint16
func (*InstrumentDefMsg) RType ¶
func (*InstrumentDefMsg) RType() RType
type JsonScanner ¶
type JsonScanner struct {
// contains filtered or unexported fields
}
JsonScanner scans a series of DBN JSON values. Delimited by whitespace (generally newlines)
func NewJsonScanner ¶
func NewJsonScanner(r io.Reader) *JsonScanner
NewJsonScanner creates a new dbn.JsonScanner from a byte array
func (*JsonScanner) Error ¶
func (s *JsonScanner) Error() error
Error returns the last error from Next().
func (*JsonScanner) GetLastRecord ¶
func (s *JsonScanner) GetLastRecord() []byte
GetLastRecord returns the raw JSON bytes of the last record read. This data may be overwritten by the next call to Next().
func (*JsonScanner) GetLastSize ¶
func (s *JsonScanner) GetLastSize() int
GetLastSize returns the size of the last record read.
func (*JsonScanner) Next ¶
func (s *JsonScanner) Next() bool
Next parses the next JSON value from the data. Returns true on success. Returns false either on error or on the end of data. Call Error() in order to determine the cause of the returned false. Acces the raw data with GetLastRecord, JsonScannerDecocde, or Visit.
func (*JsonScanner) Visit ¶
func (s *JsonScanner) Visit(visitor Visitor) error
Parses the current Record and passes it to the Visitor.
type MappingInterval ¶
type MappingInterval struct {
StartDate uint32 // The UTC start date of interval (inclusive), as YYYYMMDD
EndDate uint32 // The UTC end date of interval (exclusive), as YYYYMMDD.
Symbol string // The resolved symbol for this interval.
}
The resolved symbol for a date range.
type MatchAlgorithm ¶
type MatchAlgorithm uint8
MatchAlgorithm
const ( // First-in-first-out matching. MatchAlgorithm_Fifo MatchAlgorithm = 'F' // A configurable match algorithm. MatchAlgorithm_Configurable MatchAlgorithm = 'K' // Trade quantity is allocated to resting orders based on a pro-rata percentage: // resting order quantity divided by total quantity. MatchAlgorithm_ProRata MatchAlgorithm = 'C' // Like [`Self::Fifo`] but with LMM allocations prior to FIFO allocations. MatchAlgorithm_FifoLmm MatchAlgorithm = 'T' // Like [`Self::ProRata`] but includes a configurable allocation to the first order that improves the market. MatchAlgorithm_ThresholdProRata MatchAlgorithm = 'O' // Like [`Self::FifoLmm`] but includes a configurable allocation to the first order that improves the market. MatchAlgorithm_FifoTopLmm MatchAlgorithm = 'S' // Like [`Self::ThresholdProRata`] but includes a special priority to LMMs. MatchAlgorithm_ThresholdProRataLmm MatchAlgorithm = 'Q' // Special variant used only for Eurodollar futures on CME. See // [CME documentation](https://www.cmegroup.com/confluence/display/EPICSANDBOX/Supported+Matching+Algorithms#SupportedMatchingAlgorithms-Pro-RataAllocationforEurodollarFutures). MatchAlgorithm_EurodollarFutures MatchAlgorithm = 'Y' )
type MboMsg ¶
type MboMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
OrderID uint64 `json:"order_id" csv:"order_id"` // The order ID assigned at the venue.
Price int64 `json:"price" csv:"price"` // The order price expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating event end, message characteristics, and data quality. See [`enums::flags`](crate::enums::flags) for possible values.
ChannelID uint8 `json:"channel_id" csv:"channel_id"` // A channel ID within the venue.
Action byte `json:"action" csv:"action"` // The event action. Can be **A**dd, **C**ancel, **M**odify, clea**R**, **T**rade, or **F**ill.
Side byte `json:"side" csv:"side"` // The side that initiates the event. Can be **A**sk for a sell order (or sell aggressor in a trade), **B**id for a buy order (or buy aggressor in a trade), or **N**one where no side is specified by the original source.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
}
Databento Normalized market-by-order (MBO) message. The record of the [`Mbo`](crate::enums::Schema::Mbo) schema.
type Mbp0Msg ¶
type Mbp0Msg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Price int64 `json:"price" csv:"price"` // The order price where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Action uint8 `json:"action" csv:"action"` // The event action. Always Trade in the trades schema. See Action.
Side uint8 `json:"side" csv:"side"` // The side that initiates the event. Can be Ask for a sell aggressor, Bid for a buy aggressor, or None where no side is specified by the original trade.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating packet end, message characteristics, and data quality. See Flags.
Depth uint8 `json:"depth" csv:"depth"` // The book level where the update event occurred.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as the number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The matching-engine-sending timestamp expressed as the number of nanoseconds before ts_recv.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
}
Databento Normalized Mbp0 message (Market-by-price depth0) {"ts_recv":"1704186000404085841","hd":{"ts_event":"1704186000403918695","rtype":0,"publisher_id":2,"instrument_id":15144},"action":"T","side":"B","depth":0,"price":"476370000000","size":40,"flags":130,"ts_in_delta":167146,"sequence":277449,"symbol":"SPY"}
type Mbp1Msg ¶
type Mbp1Msg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Price int64 `json:"price" csv:"price"` // The order price expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Action byte `json:"action" csv:"action"` // The event action. Can be **A**dd, **C**ancel, **M**odify, clea**R**, or **T**rade.
Side byte `json:"side" csv:"side"` // The side that initiates the event. Can be **A**sk for a sell order (or sell aggressor in a trade), **B**id for a buy order (or buy aggressor in a trade), or **N**one where no side is specified by the original source.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating event end, message characteristics, and data quality. See [`enums::flags`](crate::enums::flags) for possible values.
Depth uint8 `json:"depth" csv:"depth"` // The depth of actual book change.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
Level BidAskPair `json:"levels" csv:"levels"` // The top of the order book.
}
Databento Normalized market-by-price (MBP) implementation with a known book depth of 1. The record of the [`Mbp1`](crate::enums::Schema::Mbp1) schema.
type Mbp10Msg ¶
type Mbp10Msg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Price int64 `json:"price" csv:"price"` // The order price expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Action byte `json:"action" csv:"action"` // The event action. Can be **A**dd, **C**ancel, **M**odify, clea**R**, or **T**rade.
Side byte `json:"side" csv:"side"` // The side that initiates the event. Can be **A**sk for a sell order (or sell aggressor in a trade), **B**id for a buy order (or buy aggressor in a trade), or **N**one where no side is specified by the original source.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating event end, message characteristics, and data quality. See [`enums::flags`](crate::enums::flags) for possible values.
Depth uint8 `json:"depth" csv:"depth"` // The depth of actual book change.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
Levels [10]BidAskPair `json:"levels" csv:"levels"` // The top 10 levels of the order book.
}
Databento Normalized market-by-price implementation with a known book depth of 10. The record of the [`Mbp10`](crate::enums::Schema::Mbp10) schema.
type Metadata ¶
type Metadata struct {
VersionNum uint8
Schema Schema // The data record schema. u16::MAX indicates a potential mix of schemas and record types, which will always be the case for live data.
Start uint64 // The start time of query range in UNIX epoch nanoseconds.
End uint64 // The end time of query range in UNIX epoch nanoseconds. u64::MAX indicates no end time was provided.
Limit uint64 // The maximum number of records to return. 0 indicates no limit.
StypeIn SType // The symbology type of input symbols. u8::MAX indicates a potential mix of types, such as with live data.
StypeOut SType // The symbology type of output symbols.
TsOut uint8 // Whether each record has an appended gateway send timestamp.
SymbolCstrLen uint16 // The number of bytes in fixed-length string symbols, including a null terminator byte. Version 2 only, symbol strings are always 22 in version 1.
Dataset string
SchemaDefinition []byte // Self-describing schema to be implemented in the future.
Symbols []string
Partial []string
NotFound []string
Mappings []SymbolMapping
}
Normalized Metadata about the data contained in a DBN file or stream. DBN requires the Metadata to be included at the start of the encoded data.
func ReadDBNToSlice ¶
ReadDBNToSlice reads the entire raw DBN stream from an io.Reader. It will scan for type R (for example Mbp0) and decode it into a slice of R. Returns the slice, the stream's metadata, and any error. Example:
fileReader, err := os.Open(dbnFilename) records, metadata, err := dbn.ReadDBNToSlice[dbn.Mbp0Msg](fileReader)
func ReadMetadata ¶
ReadMetadata reads the Metadata from a DBN stream over an io.Reader.
func (*Metadata) IsInverseMapping ¶
IsInverseMapping returns true if the map goes from InstrumentId to some other type. Returns an error if neither of the STypes are InstrumentId.
type MetadataHeaderV1 ¶
type MetadataHeaderV1 struct {
DatasetRaw [Metadata_DatasetCstrLen]byte // The dataset code (string identifier).
Schema Schema // The data record schema. u16::MAX indicates a potential mix of schemas and record types, which will always be the case for live data.
Start uint64 // The start time of query range in UNIX epoch nanoseconds.
End uint64 // The end time of query range in UNIX epoch nanoseconds. u64::MAX indicates no end time was provided.
Limit uint64 // The maximum number of records to return. 0 indicates no limit.
ReservedX [8]byte // Reserved padding
StypeIn SType // The symbology type of input symbols. u8::MAX indicates a potential mix of types, such as with live data.
StypeOut SType // The symbology type of output symbols.
TsOut uint8 // Whether each record has an appended gateway send timestamp.
Reserved [MetadataV1_ReservedLen]byte // Reserved padding, after is dynamically sized section
}
Raw DBN Metadata Header V1. Every DBN file begins with this header, followed by variable length fields. See Metadata for the full nomralized decoded structure.
func (*MetadataHeaderV1) FillFixed_Raw ¶
func (m1 *MetadataHeaderV1) FillFixed_Raw(b []byte) error
type MetadataHeaderV2 ¶
type MetadataHeaderV2 struct {
DatasetRaw [Metadata_DatasetCstrLen]byte // The dataset code (string identifier).
Schema Schema // The data record schema. u16::MAX indicates a potential mix of schemas and record types, which will always be the case for live data.
Start uint64 // The start time of query range in UNIX epoch nanoseconds.
End uint64 // The end time of query range in UNIX epoch nanoseconds. u64::MAX indicates no end time was provided.
Limit uint64 // The maximum number of records to return. 0 indicates no limit.
StypeIn SType // The symbology type of input symbols. u8::MAX indicates a potential mix of types, such as with live data.
StypeOut SType // The symbology type of output symbols.
TsOut uint8 // Whether each record has an appended gateway send timestamp.
SymbolCstrLen uint16 // The number of bytes in fixed-length string symbols, including a null terminator byte. Version 2 only, symbol strings are always 22 in version 1.
Reserved [MetadataV2_ReservedLen]byte // Reserved padding, after is dynamically sized section
}
Raw DBN Metadata Header V2. Every DBN file begins with this header, followed by variable length fields. See Metadata for the full nomralized decoded structure.
func (*MetadataHeaderV2) FillFixed_Raw ¶
func (m2 *MetadataHeaderV2) FillFixed_Raw(b []byte) error
type MetadataPrefix ¶
type MetadataPrefix struct {
VersionRaw [4]byte // "DBN" followed by the version of DBN the file is encoded in as a u8.
Length uint32 // The length of the remaining metadata header, i.e. excluding MetadataPrefix
}
The start of every Metadata header, independent of version
type NullVisitor ¶
type NullVisitor struct {
}
NullVisitor is an implementation of all the dbn.Visitor interface. It is useful for copy/pasting to ones own implementation.
func (*NullVisitor) OnCbbo ¶
func (v *NullVisitor) OnCbbo(record *CbboMsg) error
func (*NullVisitor) OnErrorMsg ¶
func (v *NullVisitor) OnErrorMsg(record *ErrorMsg) error
func (*NullVisitor) OnImbalance ¶
func (v *NullVisitor) OnImbalance(record *ImbalanceMsg) error
func (*NullVisitor) OnInstrumentDefMsg ¶
func (v *NullVisitor) OnInstrumentDefMsg(record *InstrumentDefMsg) error
func (*NullVisitor) OnMbo ¶
func (v *NullVisitor) OnMbo(record *MboMsg) error
func (*NullVisitor) OnMbp0 ¶
func (v *NullVisitor) OnMbp0(record *Mbp0Msg) error
func (*NullVisitor) OnMbp1 ¶
func (v *NullVisitor) OnMbp1(record *Mbp1Msg) error
func (*NullVisitor) OnMbp10 ¶
func (v *NullVisitor) OnMbp10(record *Mbp10Msg) error
func (*NullVisitor) OnOhlcv ¶
func (v *NullVisitor) OnOhlcv(record *OhlcvMsg) error
func (*NullVisitor) OnStatMsg ¶
func (v *NullVisitor) OnStatMsg(record *StatMsg) error
func (*NullVisitor) OnStatusMsg ¶
func (v *NullVisitor) OnStatusMsg(record *StatusMsg) error
func (*NullVisitor) OnStreamEnd ¶
func (v *NullVisitor) OnStreamEnd() error
func (*NullVisitor) OnSymbolMappingMsg ¶
func (v *NullVisitor) OnSymbolMappingMsg(record *SymbolMappingMsg) error
func (*NullVisitor) OnSystemMsg ¶
func (v *NullVisitor) OnSystemMsg(record *SystemMsg) error
func (*NullVisitor) OnTcbbo ¶
func (v *NullVisitor) OnTcbbo(record *TcbboMsg) error
type OhlcvMsg ¶
type OhlcvMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Open int64 `json:"open" csv:"open"` // The open price for the bar.
High int64 `json:"high" csv:"high"` // The high price for the bar.
Low int64 `json:"low" csv:"low"` // The low price for the bar.
Close int64 `json:"close" csv:"close"` // The close price for the bar.
Volume uint64 `json:"volume" csv:"volume"` // The total volume traded during the aggregation period.
}
Databento Normalized Ohlcv Message (OHLC candlestick, bar) {"hd":{"ts_event":"1702987922000000000","rtype":32,"publisher_id":40,"instrument_id":15144},"open":"472600000000","high":"472600000000","low":"472600000000","close":"472600000000","volume":"300"}
type PitSymbolMap ¶
type PitSymbolMap struct {
// contains filtered or unexported fields
}
PitSymbolMap is a point-in-time symbol map. Useful for working with live symbology or a historical request over a single day or other situations where the symbol mappings are known not to change. TOOD: handle nuance of int<>string and string<>string mappings based on SType
func NewPitSymbolMap ¶
func NewPitSymbolMap() *PitSymbolMap
func (*PitSymbolMap) FillFromMetadata ¶
func (p *PitSymbolMap) FillFromMetadata(metadata *Metadata, timestamp uint64) error
Fills the PitSymbolMap with mappings from `metadata` for `date`, clearing any original contents Returns an error if any.
func (*PitSymbolMap) Get ¶
func (p *PitSymbolMap) Get(instrumentID uint32) string
Returns the string mapping of the instrument ID, or empty string if not found.
func (*PitSymbolMap) IsEmpty ¶
func (p *PitSymbolMap) IsEmpty() bool
IsEmpty returns `true` if there are no mappings.
func (*PitSymbolMap) Len ¶
func (p *PitSymbolMap) Len() int
Returns the number of symbol mappings in the map.
func (*PitSymbolMap) OnSymbolMappingMsg ¶
func (p *PitSymbolMap) OnSymbolMappingMsg(symbolMapping *SymbolMappingMsg) error
OnSymbolMappingMsg handles updating the mappings (if required) for a SymbolMappingMsg record.
type RHeader ¶
type RHeader struct {
Length uint8 `json:"len,omitempty"` // The length of the record in 32-bit words.
RType RType `json:"rtype" csv:"rtype"` // Sentinel values for different DBN record types.
PublisherID uint16 `json:"publisher_id" csv:"publisher_id"` // The publisher ID assigned by Databento, which denotes the dataset and venue.
InstrumentID uint32 `json:"instrument_id" csv:"instrument_id"` // The numeric instrument ID.
TsEvent uint64 `json:"ts_event" csv:"ts_event"` // The matching-engine-received timestamp expressed as the number of nanoseconds since the UNIX epoch.
}
Databento Normalized Record Header {"ts_event":"1704186000403918695","rtype":0,"publisher_id":2,"instrument_id":15144}
type RType ¶
type RType uint8
const ( // Sentinel values for different DBN record types. // comments from: https://github.com/databento/dbn/blob/main/rust/dbn/src/enums.rs RType_Mbp0 RType = 0x00 // Denotes a market-by-price record with a book depth of 0 (used for the Trades schema) RType_Mbp1 RType = 0x01 // Denotes a market-by-price record with a book depth of 1 (also used for the Tbbo schema) RType_Mbp10 RType = 0x0A // Denotes a market-by-price record with a book depth of 10. RType_OhlcvDeprecated RType = 0x11 // Deprecated in 0.4.0. Denotes an open, high, low, close, and volume record at an unspecified cadence. RType_Ohlcv1S RType = 0x20 // Denotes an open, high, low, close, and volume record at a 1-second cadence. RType_Ohlcv1M RType = 0x21 // Denotes an open, high, low, close, and volume record at a 1-minute cadence. RType_Ohlcv1H RType = 0x22 // Denotes an open, high, low, close, and volume record at an hourly cadence. RType_Ohlcv1D RType = 0x23 // Denotes an open, high, low, close, and volume record at a daily cadence based on the UTC date. RType_OhlcvEod RType = 0x24 // Denotes an open, high, low, close, and volume record at a daily cadence based on the end of the trading session. RType_Status RType = 0x12 // Denotes an exchange status record. RType_InstrumentDef RType = 0x13 // Denotes an instrument definition record. RType_Imbalance RType = 0x14 // Denotes an order imbalance record. RType_Error RType = 0x15 // Denotes an error from gateway. RType_SymbolMapping RType = 0x16 // Denotes a symbol mapping record. RType_System RType = 0x17 // Denotes a non-error message from the gateway. Also used for heartbeats. RType_Statistics RType = 0x18 // Denotes a statistics record from the publisher (not calculated by Databento). RType_Mbo RType = 0xA0 // Denotes a market by order record. RType_Cbbo RType = 0xB1 // Denotes a consolidated best bid and offer record. RType_Cbbo1S RType = 0xC0 // Denotes a consolidated best bid and offer record subsampled on a one-second interval. RType_Cbbo1M RType = 0xC1 // Denotes a consolidated best bid and offer record subsampled on a one-minute interval. RType_Tcbbo RType = 0xC2 // Denotes a consolidated best bid and offer trade record containing the consolidated BBO before the trade. RType_Bbo1S RType = 0xC3 // Denotes a best bid and offer record subsampled on a one-second interval. RType_Bbo1M RType = 0xC4 // Denotes a best bid and offer record subsampled on a one-minute interval. RType_Unknown RType = 0xFF // Golang-only: Unknown or invalid record type )
func (RType) IsCompatibleWith ¶
type SType ¶
type SType uint8
SType Symbology type
const ( /// Symbology using a unique numeric ID. SType_InstrumentId SType = 0 /// Symbology using the original symbols provided by the publisher. SType_RawSymbol SType = 1 /// Deprecated: A set of Databento-specific symbologies for referring to groups of symbols. SType_Smart SType = 2 /// A Databento-specific symbology where one symbol may point to different /// instruments at different points of time, e.g. to always refer to the front month /// future. SType_Continuous SType = 3 /// A Databento-specific symbology for referring to a group of symbols by one /// "parent" symbol, e.g. ES.FUT to refer to all ES futures. SType_Parent SType = 4 /// Symbology for US equities using NASDAQ Integrated suffix conventions. SType_NasdaqSymbol SType = 5 /// Symbology for US equities using CMS suffix conventions. SType_CmsSymbol SType = 6 /// Symbology using International Security Identification Numbers (ISIN) - ISO 6166. SType_Isin SType = 7 /// Symbology using US domestic Committee on Uniform Securities Identification Procedure (CUSIP) codes. SType_UsCode SType = 8 /// Symbology using Bloomberg composite global IDs. SType_BbgCompId SType = 9 /// Symbology using Bloomberg composite tickers. SType_BbgCompTicker SType = 10 /// Symbology using Bloomberg FIGI exchange level IDs. SType_Figi SType = 11 /// Symbology using Bloomberg exchange level tickers. SType_FigiTicker SType = 12 )
func STypeFromString ¶
STypeFromString converts a string to an SType. Returns an error if the string is unknown. Possible string values: instrument_id, id, instr, raw_symbol, raw, smart, continuous, parent, nasdaq, cms
func (SType) MarshalJSON ¶
func (*SType) UnmarshalJSON ¶
type Schema ¶
type Schema uint16
const ( /// The data record schema. u16::MAX indicates a potential mix of schemas and record types, which will always be the case for live data. Schema_Mixed Schema = 0xFFFF /// Market by order. Schema_Mbo Schema = 0 /// Market by price with a book depth of 1. Schema_Mbp1 Schema = 1 /// Market by price with a book depth of 10. Schema_Mbp10 Schema = 2 /// All trade events with the best bid and offer (BBO) immediately **before** the effect of the trade. Schema_Tbbo Schema = 3 /// All trade events. Schema_Trades Schema = 4 /// Open, high, low, close, and volume at a one-second interval. Schema_Ohlcv1S Schema = 5 /// Open, high, low, close, and volume at a one-minute interval. Schema_Ohlcv1M Schema = 6 /// Open, high, low, close, and volume at an hourly interval. Schema_Ohlcv1H Schema = 7 /// Open, high, low, close, and volume at a daily interval based on the UTC date. Schema_Ohlcv1D Schema = 8 /// Instrument definitions. Schema_Definition Schema = 9 /// Additional data disseminated by publishers. Schema_Statistics Schema = 10 /// Trading status events. Schema_Status Schema = 11 /// Auction imbalance events. Schema_Imbalance Schema = 12 /// Open, high, low, close, and volume at a daily cadence based on the end of the trading session. Schema_OhlcvEod Schema = 13 /// Consolidated best bid and offer. Schema_Cbbo Schema = 14 /// Consolidated best bid and offer subsampled at one-second intervals, in addition to trades. Schema_Cbbo1S Schema = 15 /// Consolidated best bid and offer subsampled at one-minute intervals, in addition to trades. Schema_Cbbo1M Schema = 16 /// All trade events with the consolidated best bid and offer (CBBO) immediately **before** the effect of the trade.6 Schema_Tcbbo Schema = 17 /// Best bid and offer subsampled at one-second intervals, in addition to trades. Schema_Bbo1S Schema = 18 /// Best bid and offer subsampled at one-minute intervals, in addition to trades. Schema_Bbo1M Schema = 19 )
func SchemaFromString ¶
SchemaFromString converts a string to a Schema. Returns an error if the string is unknown.
func (Schema) MarshalJSON ¶
func (*Schema) UnmarshalJSON ¶
type SecurityUpdateAction ¶
type SecurityUpdateAction uint8
/ The type of [`InstrumentDefMsg`](crate::record::InstrumentDefMsg) update.
const ( /// A new instrument definition. Add SecurityUpdateAction = 'A' /// A modified instrument definition of an existing one. Modify SecurityUpdateAction = 'M' /// Removal of an instrument definition. Delete SecurityUpdateAction = 'D' // Deprecated: Still present in legacy files." Invalid SecurityUpdateAction = '~' )
type StatMsg ¶
type StatMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The common header.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as the number of nanoseconds since the UNIX epoch.
TsRef uint64 `json:"ts_ref" csv:"ts_ref"` // The reference timestamp of the statistic value expressed as the number of nanoseconds since the UNIX epoch. Will be [`crate::UNDEF_TIMESTAMP`] when unused.
Price int64 `json:"price" csv:"price"` // The value for price statistics expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001. Will be [`crate::UNDEF_PRICE`] when unused.
Quantity int32 `json:"quantity" csv:"quantity"` // The value for non-price statistics. Will be [`crate::UNDEF_STAT_QUANTITY`] when unused.
Sequence uint32 `json:"sequence" csv:"sequence"` // The message sequence number assigned at the venue.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
StatType uint16 `json:"stat_type" csv:"stat_type"` // The type of statistic value contained in the message. Refer to the [`StatType`](crate::enums::StatType) for variants.
ChannelID uint16 `json:"channel_id" csv:"channel_id"` // A channel ID within the venue.
UpdateAction uint8 `json:"update_action" csv:"update_action"` // Indicates if the statistic is newly added (1) or deleted (2). (Deleted is only used with some stat types)
StatFlags uint8 `json:"stat_flags" csv:"stat_flags"` // Additional flags associate with certain stat types.
Reserved [6]uint8 // Filler for alignment
}
StatMsg is a statistics message. A catchall for various data disseminated by publishers. The [`stat_type`](Self::stat_type) indicates the statistic contained in the message.
type StatType ¶
type StatType uint8
/ The type of statistic contained in a [`StatMsg`](crate::record::StatMsg).
const ( /// The price of the first trade of an instrument. `price` will be set. StatType_OpeningPrice StatType = 1 /// The probable price of the first trade of an instrument published during pre- /// open. Both `price` and `quantity` will be set. StatType_IndicativeOpeningPrice StatType = 2 /// The settlement price of an instrument. `price` will be set and `flags` indicate /// whether the price is final or preliminary and actual or theoretical. `ts_ref` /// will indicate the trading date of the settlement price. StatType_SettlementPrice StatType = 3 /// The lowest trade price of an instrument during the trading session. `price` will /// be set. StatType_TradingSessionLowPrice StatType = 4 /// The highest trade price of an instrument during the trading session. `price` will /// be set. StatType_TradingSessionHighPrice StatType = 5 /// The number of contracts cleared for an instrument on the previous trading date. /// `quantity` will be set. `ts_ref` will indicate the trading date of the volume. StatType_ClearedVolume StatType = 6 /// The lowest offer price for an instrument during the trading session. `price` /// will be set. StatType_LowestOffer StatType = 7 /// The highest bid price for an instrument during the trading session. `price` /// will be set. StatType_HighestBid StatType = 8 /// The current number of outstanding contracts of an instrument. `quantity` will /// be set. `ts_ref` will indicate the trading date for which the open interest was /// calculated. StatType_OpenInterest StatType = 9 /// The volume-weighted average price (VWAP) for a fixing period. `price` will be /// set. StatType_FixingPrice StatType = 10 /// The last trade price during a trading session. `price` will be set. StatType_ClosePrice StatType = 11 /// The change in price from the close price of the previous trading session to the /// most recent trading session. `price` will be set. StatType_NetChange StatType = 12 /// The volume-weighted average price (VWAP) during the trading session. /// `price` will be set to the VWAP while `quantity` will be the traded /// volume. StatType_Vwap StatType = 13 )
type StatUpdateAction ¶
type StatUpdateAction uint8
/ The type of [`StatMsg`](crate::record::StatMsg) update.
const ( /// A new statistic. StatUpdateAction_New StatUpdateAction = 1 /// A removal of a statistic. StatUpdateAction_Delete StatUpdateAction = 2 )
type StatusAction ¶
type StatusAction uint8
/ The primary enum for the type of [`StatusMsg`](crate::record::StatusMsg) update.
const ( /// No change. StatusAction_None StatusAction = 0 /// The instrument is in a pre-open period. StatusAction_PreOpen StatusAction = 1 /// The instrument is in a pre-cross period. StatusAction_PreCross StatusAction = 2 /// The instrument is quoting but not trading. StatusAction_Quoting StatusAction = 3 /// The instrument is in a cross/auction. StatusAction_Cross StatusAction = 4 /// The instrument is being opened through a trading rotation. StatusAction_Rotation StatusAction = 5 /// A new price indication is available for the instrument. StatusAction_NewPriceIndication StatusAction = 6 /// The instrument is trading. StatusAction_Trading StatusAction = 7 /// Trading in the instrument has been halted. StatusAction_Halt StatusAction = 8 /// Trading in the instrument has been paused. StatusAction_Pause StatusAction = 9 /// Trading in the instrument has been suspended. StatusAction_Suspend StatusAction = 10 /// The instrument is in a pre-close period. StatusAction_PreClose StatusAction = 11 /// Trading in the instrument has closed. StatusAction_Close StatusAction = 12 /// The instrument is in a post-close period. StatusAction_PostClose StatusAction = 13 /// A change in short-selling restrictions. StatusAction_SsrChange StatusAction = 14 /// The instrument is not available for trading, either trading has closed or been /// halted. StatusAction_NotAvailableForTrading StatusAction = 15 )
const ( /// No reason is given. StatusReason_None StatusAction = 0 /// The change in status occurred as scheduled. StatusReason_Scheduled StatusAction = 1 /// The instrument stopped due to a market surveillance intervention. StatusReason_SurveillanceIntervention StatusAction = 2 /// The status changed due to activity in the market. StatusReason_MarketEvent StatusAction = 3 /// The derivative instrument began trading. StatusReason_InstrumentActivation StatusAction = 4 /// The derivative instrument expired. StatusReason_InstrumentExpiration StatusAction = 5 /// Recovery in progress. StatusReason_RecoveryInProcess StatusAction = 6 /// The status change was caused by a regulatory action. StatusReason_Regulatory StatusAction = 10 /// The status change was caused by an administrative action. StatusReason_Administrative StatusAction = 11 /// The status change was caused by the issuer not being compliance with regulatory /// requirements. StatusReason_NonCompliance StatusAction = 12 /// Trading halted because the issuer's filings are not current. StatusReason_FilingsNotCurrent StatusAction = 13 /// Trading halted due to an SEC trading suspension. StatusReason_SecTradingSuspension StatusAction = 14 /// The status changed because a new issue is available. StatusReason_NewIssue StatusAction = 15 /// The status changed because an issue is available. StatusReason_IssueAvailable StatusAction = 16 /// The status changed because the issue was reviewed. StatusReason_IssuesReviewed StatusAction = 17 /// The status changed because the filing requirements were satisfied. StatusReason_FilingReqsSatisfied StatusAction = 18 /// Relevant news is pending. StatusReason_NewsPending StatusAction = 30 /// Relevant news was released. StatusReason_NewsReleased StatusAction = 31 /// The news has been fully disseminated and times are available for the resumption /// in quoting and trading. StatusReason_NewsAndResumptionTimes StatusAction = 32 /// The relevants news was not forthcoming. StatusReason_NewsNotForthcoming StatusAction = 33 /// Halted for order imbalance. StatusReason_OrderImbalance StatusAction = 40 /// The instrument hit limit up or limit down. StatusReason_LuldPause StatusAction = 50 /// An operational issue occurred with the venue. StatusReason_Operational StatusAction = 60 /// The status changed until the exchange receives additional information. StatusReason_AdditionalInformationRequested StatusAction = 70 /// Trading halted due to merger becoming effective. StatusReason_MergerEffective StatusAction = 80 /// Trading is halted in an ETF due to conditions with the component securities. StatusReason_Etf StatusAction = 90 /// Trading is halted for a corporate action. StatusReason_CorporateAction StatusAction = 100 /// Trading is halted because the instrument is a new offering. StatusReason_NewSecurityOffering StatusAction = 110 /// Halted due to the market-wide circuit breaker level 1. StatusReason_MarketWideHaltLevel1 StatusAction = 120 /// Halted due to the market-wide circuit breaker level 2. StatusReason_MarketWideHaltLevel2 StatusAction = 121 /// Halted due to the market-wide circuit breaker level 3. StatusReason_MarketWideHaltLevel3 StatusAction = 122 /// Halted due to the carryover of a market-wide circuit breaker from the previous /// trading day. StatusReason_MarketWideHaltCarryover StatusAction = 123 /// Resumption due to the end of the a market-wide circuit breaker halt. StatusReason_MarketWideHaltResumption StatusAction = 124 /// Halted because quotation is not available. StatusReason_QuotationNotAvailable StatusAction = 130 )
type StatusMsg ¶
type StatusMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
Action uint16 `json:"action" csv:"action"` // The type of status change.
Reason uint16 `json:"reason" csv:"reason"` // Additional details about the cause of the status change.
TradingEvent uint16 `json:"trading_event" csv:"trading_event"` // Further information about the status change and its effect on trading.
IsTrading uint8 `json:"is_trading" csv:"is_trading"` // The state of trading in the instrument.
IsQuoting uint8 `json:"is_quoting" csv:"is_quoting"` // The state of quoting in the instrument.
IsShortSellRestricted uint8 `json:"is_short_sell_restricted" csv:"is_short_sell_restricted"` // The state of short sell restrictions for the instrument.
Reserved [7]uint8 // Filler for alignment.
}
Databento normalized Trading Status Update message.
type StatusReason ¶
type StatusReason uint8
/ The secondary enum for a [`StatusMsg`](crate::record::StatusMsg) update, explains / the cause of a halt or other change in `action`.
type SymbolMapping ¶
type SymbolMapping struct {
RawSymbol string // The symbol assigned by publisher.
Intervals []MappingInterval // The mappings of `native` for different date ranges.
}
A raw symbol and its symbol mappings for different time ranges within the query range.
type SymbolMappingMsg ¶
type SymbolMappingMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The common header.
StypeIn SType `json:"stype_in" csv:"stype_in"` // The input symbology type of `stype_in_symbol`.
StypeInSymbol string `json:"stype_in_symbol" csv:"stype_in_symbol"` // The input symbol.
StypeOut SType `json:"stype_out" csv:"stype_out"` // The output symbology type of `stype_out_symbol`.
StypeOutSymbol string `json:"stype_out_symbol" csv:"stype_out_symbol"` // The output symbol.
StartTs uint64 `json:"start_ts" csv:"start_ts"` // The start of the mapping interval expressed as the number of nanoseconds since the UNIX epoch.
EndTs uint64 `json:"end_ts" csv:"end_ts"` // The end of the mapping interval expressed as the number of nanoseconds since the UNIX epoch.
}
Databento Symbol Mapping Message This is not a strict byte-layout because StypeInSymbol and StypeOutSymbol have dynamic lengths that depend on metadata's SymbolCstrLen.
func (*SymbolMappingMsg) Fill_Json ¶
func (r *SymbolMappingMsg) Fill_Json(val *fastjson.Value, header *RHeader) error
func (*SymbolMappingMsg) Fill_Raw ¶
func (r *SymbolMappingMsg) Fill_Raw(b []byte, cstrLength uint16) error
func (*SymbolMappingMsg) RSize ¶
func (*SymbolMappingMsg) RSize(cstrLength uint16) uint16
func (*SymbolMappingMsg) RType ¶
func (*SymbolMappingMsg) RType() RType
type SystemMsg ¶
type SystemMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The common header.
Message [SystemMsg_MsgSize]byte `json:"msg" csv:"msg"` // The message from the Databento Live Subscription Gateway (LSG).
Code uint8 `json:"code" csv:"code"` // The type of system message. Currently unused.
}
type TcbboMsg ¶
type TcbboMsg struct {
Header RHeader `json:"hd" csv:"hd"` // The record header.
Price int64 `json:"price" csv:"price"` // The order price expressed as a signed integer where every 1 unit corresponds to 1e-9, i.e. 1/1,000,000,000 or 0.000000001.
Size uint32 `json:"size" csv:"size"` // The order quantity.
Action byte `json:"action" csv:"action"` // The event action. Can be **A**dd, **C**ancel, **M**odify, clea**R**, or **T**rade.
Side byte `json:"side" csv:"side"` // The side that initiates the event. Can be **A**sk for a sell order (or sell aggressor in a trade), **B**id for a buy order (or buy aggressor in a trade), or **N**one where no side is specified by the original source.
Flags uint8 `json:"flags" csv:"flags"` // A bit field indicating event end, message characteristics, and data quality. See [`enums::flags`](crate::enums::flags) for possible values.
Reserved1 byte `json:"_reserved1,omitempty" csv:"_reserved1"` // Reserved for future usage.
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"` // The capture-server-received timestamp expressed as number of nanoseconds since the UNIX epoch.
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"` // The delta of `ts_recv - ts_exchange_send`, max 2 seconds.
Reserved2 [4]byte `json:"_reserved2,omitempty" csv:"_reserved2"` // Reserved for future usage.
Level ConsolidatedBidAskPair `json:"levels" csv:"levels"` // The top of the order book.
}
type TradeMsg ¶
type TradeMsg struct {
Header RHeader `json:"hd" csv:"hd"`
Price int64 `json:"price" csv:"price"`
Size uint32 `json:"size" csv:"size"`
Action byte `json:"action" csv:"action"`
Side byte `json:"side" csv:"side"`
Flags uint8 `json:"flags" csv:"flags"`
Depth uint8 `json:"depth" csv:"depth"`
TsRecv uint64 `json:"ts_recv" csv:"ts_recv"`
TsInDelta int32 `json:"ts_in_delta" csv:"ts_in_delta"`
Sequence uint32 `json:"sequence" csv:"sequence"`
}
type TradingEvent ¶
type TradingEvent uint8
/ Further information about a status update.
const ( /// No additional information given. TradingEvent_None TradingEvent = 0 /// Order entry and modification are not allowed. TradingEvent_NoCancel TradingEvent = 1 /// A change of trading session occurred. Daily statistics are reset. TradingEvent_ChangeTradingSession TradingEvent = 2 /// Implied matching is available. TradingEvent_ImpliedMatchingOn TradingEvent = 3 /// Implied matching is not available. TradingEvent_ImpliedMatchingOff TradingEvent = 4 )
const ( /// The value is not applicable or not known. TriState_NotAvailable TradingEvent = '~' /// False TriState_No TradingEvent = 'N' /// True TriState_Yes TradingEvent = 'Y' )
type TriState ¶
type TriState uint8
/ An enum for representing unknown, true, or false values. Equivalent to / `Option<bool>` but with a human-readable repr.
type TsSymbolMap ¶
type TsSymbolMap struct {
// contains filtered or unexported fields
}
TsSymbolMap is a timeseries symbol map. Generally useful for working with historical data and is commonly built from a Metadata object.
func NewTsSymbolMap ¶
func NewTsSymbolMap() *TsSymbolMap
func (*TsSymbolMap) FillFromMetadata ¶
func (tsm *TsSymbolMap) FillFromMetadata(metadata *Metadata) error
FillFromMetadata fills the TsSymbolMap with mappings from `metadata`.
func (*TsSymbolMap) Get ¶
func (tsm *TsSymbolMap) Get(dt time.Time, instrID uint32) string
Get returns the symbol mapping for the given date and instrument ID. Returns empty string if no mapping exists.
func (*TsSymbolMap) Insert ¶
func (tsm *TsSymbolMap) Insert(instrID uint32, startDate uint32, endDate uint32, ticker string) error
Insert adds mappings for a date range. dates are YYYYMMDD ints
func (*TsSymbolMap) IsEmpty ¶
func (tsm *TsSymbolMap) IsEmpty() bool
IsEmpty returns true if there are no mappings.
func (*TsSymbolMap) Len ¶
func (tsm *TsSymbolMap) Len() int
Len returns the number of symbol mappings in the map.
type UserDefinedInstrument ¶
type UserDefinedInstrument uint8
UserDefinedInstrument
const ( /// The instrument is not user-defined. UserDefinedInstrument_No UserDefinedInstrument = 'N' /// The instrument is user-defined. UserDefinedInstrument_Yes UserDefinedInstrument = 'Y' )
type VersionUpgradePolicy ¶
type VersionUpgradePolicy uint8
/ How to handle decoding DBN data from a prior version.
const ( /// Decode data from previous versions as-is. VersionUpgradePolicy_AsIs VersionUpgradePolicy = 0 /// Decode data from previous versions converting it to the latest version. This /// breaks zero-copy decoding for structs that need updating, but makes usage /// simpler. VersionUpgradePolicy_Upgrade VersionUpgradePolicy = 1 )
type Visitor ¶
type Visitor interface {
OnMbp0(record *Mbp0Msg) error
OnMbp1(record *Mbp1Msg) error
OnMbp10(record *Mbp10Msg) error
OnMbo(record *MboMsg) error
OnOhlcv(record *OhlcvMsg) error
OnCbbo(record *CbboMsg) error
OnTcbbo(record *TcbboMsg) error
OnImbalance(record *ImbalanceMsg) error
OnStatMsg(record *StatMsg) error
OnStatusMsg(record *StatusMsg) error
OnInstrumentDefMsg(record *InstrumentDefMsg) error
OnErrorMsg(record *ErrorMsg) error
OnSystemMsg(record *SystemMsg) error
OnSymbolMappingMsg(record *SymbolMappingMsg) error
OnStreamEnd() error
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
dbn-go-file
command
|
|
|
dbn-go-hist
command
|
|
|
dbn-go-live
command
|
|
|
dbn-go-mcp
command
|
|
|
dbn-go-tui
command
|
|
|
internal
|
|