Skip to content

Commit

Permalink
VER: Release 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen authored Apr 6, 2023
2 parents eb9d6e9 + e5548e4 commit 43d6ef6
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 47 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.4.2 - 2023-04-06
- Fixed support for `ErrorMsg`, `SystemMsg`, and `SymbolMappingMsg` in Python

## 0.4.1 - 2023-04-05
- Added enums `MatchAlgorithm`, `UserDefinedInstrument`
- Added constants `UNDEF_PRICE` and `UNDEF_ORDER_SIZE`
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dbn-c"
authors = ["Databento <support@databento.com>"]
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "C bindings for working with Databento Binary Encoding (DBN)"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "databento-dbn"
authors = ["Databento <support@databento.com>"]
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "Python library written in Rust for working with Databento Binary Encoding (DBN)"
license = "Apache-2.0"
Expand Down
44 changes: 15 additions & 29 deletions python/databento_dbn.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
"""Type stubs for databento_dbn"""
from typing import Any, BinaryIO, Dict, Optional, Sequence, Union

DBNRecord = Union[
"Metadata",
"MBOMsg",
"TradeMsg",
"MBP1Msg",
"MBP10Msg",
"OhlcvMsg",
"InstrumentDefMsg",
"ImbalanceMsg",
"ErrorMsg",
"SymbolMappingMsg",
"SystemMsg",
]
from typing import Any, BinaryIO, Dict, Optional, Sequence, SupportsBytes

class Metadata:
"""
Expand Down Expand Up @@ -215,7 +201,7 @@ class RecordHeader:
"""

class _Record:
class Record(SupportsBytes):
"""
Base class for DBN records.
"""
Expand Down Expand Up @@ -347,7 +333,7 @@ class _MBOBase:
"""

class MBOMsg(_Record, _MBOBase):
class MBOMsg(Record, _MBOBase):
"""
A market-by-order (MBO) tick message.
"""
Expand Down Expand Up @@ -515,13 +501,13 @@ class _MBPBase:
"""

class TradeMsg(_Record, _MBPBase):
class TradeMsg(Record, _MBPBase):
"""
Market by price implementation with a book depth of 0. Equivalent to
MBP-0. The record of the `Trades` schema.
"""

class MBP1Msg(_Record, _MBPBase):
class MBP1Msg(Record, _MBPBase):
"""
Market by price implementation with a known book depth of 1.
"""
Expand All @@ -541,7 +527,7 @@ class MBP1Msg(_Record, _MBPBase):
"""

class MBP10Msg(_Record, _MBPBase):
class MBP10Msg(Record, _MBPBase):
"""
Market by price implementation with a known book depth of 10.
"""
Expand All @@ -561,7 +547,7 @@ class MBP10Msg(_Record, _MBPBase):
"""

class OhlcvMsg(_Record):
class OHLCVMsg(Record):
"""
Open, high, low, close, and volume message.
"""
Expand Down Expand Up @@ -617,7 +603,7 @@ class OhlcvMsg(_Record):
"""

class InstrumentDefMsg(_Record):
class InstrumentDefMsg(Record):
"""
Definition of an instrument.
"""
Expand Down Expand Up @@ -1246,7 +1232,7 @@ class InstrumentDefMsg(_Record):
"""

class ImbalanceMsg(_Record):
class ImbalanceMsg(Record):
"""
An auction imbalance message.
"""
Expand Down Expand Up @@ -1454,7 +1440,7 @@ class ImbalanceMsg(_Record):
"""

class ErrorMsg(_Record):
class ErrorMsg(Record):
"""
An error message from the Databento Live Subscription Gateway (LSG).
"""
Expand All @@ -1470,7 +1456,7 @@ class ErrorMsg(_Record):
"""

class SymbolMappingMsg(_Record):
class SymbolMappingMsg(Record):
"""
A symbol mapping message which maps a symbol of one `SType` to another.
"""
Expand Down Expand Up @@ -1518,7 +1504,7 @@ class SymbolMappingMsg(_Record):
"""

class SystemMsg(_Record):
class SystemMsg(Record):
"""
A non-error message from the Databento Live Subscription Gateway (LSG). Also used
for heartbeating.
Expand Down Expand Up @@ -1552,13 +1538,13 @@ class DbnDecoder:
"""
def decode(
self,
) -> Sequence[DBNRecord]:
) -> Sequence[Record]:
"""
Decode the buffered data into DBN records.
Returns
-------
Sequence[DBNRecord]
Sequence[Record]
Raises
------
Expand Down Expand Up @@ -1693,7 +1679,7 @@ def write_dbn_file(
start: int,
stype_in: int,
stype_out: int,
records: Sequence[DBNRecord],
records: Sequence[Record],
end: Optional[int] = None,
) -> None:
"""
Expand Down
5 changes: 4 additions & 1 deletion python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dbn::{
python::to_val_err,
record::{
BidAskPair, ErrorMsg, ImbalanceMsg, InstrumentDefMsg, MboMsg, Mbp10Msg, Mbp1Msg, OhlcvMsg,
RecordHeader, SymbolMappingMsg, SystemMsg, TradeMsg,
RecordHeader, StatusMsg, SymbolMappingMsg, SystemMsg, TradeMsg,
},
};

Expand All @@ -36,6 +36,7 @@ fn databento_dbn(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
checked_add_class::<Mbp10Msg>(m)?;
checked_add_class::<OhlcvMsg>(m)?;
checked_add_class::<ImbalanceMsg>(m)?;
checked_add_class::<StatusMsg>(m)?;
checked_add_class::<InstrumentDefMsg>(m)?;
checked_add_class::<ErrorMsg>(m)?;
checked_add_class::<SymbolMappingMsg>(m)?;
Expand Down Expand Up @@ -102,6 +103,7 @@ impl DbnDecoder {
| rtype::OHLCV_1D => {
recs.push(rec.get::<OhlcvMsg>().unwrap().clone().into_py(py))
}
rtype::STATUS => recs.push(rec.get::<StatusMsg>().unwrap().clone().into_py(py)),
rtype::IMBALANCE => {
recs.push(rec.get::<ImbalanceMsg>().unwrap().clone().into_py(py))
}
Expand All @@ -112,6 +114,7 @@ impl DbnDecoder {
rtype::SYMBOL_MAPPING => {
recs.push(rec.get::<SymbolMappingMsg>().unwrap().clone().into_py(py))
}
rtype::SYSTEM => recs.push(rec.get::<SystemMsg>().unwrap().clone().into_py(py)),
rtype::MBO => recs.push(rec.get::<MboMsg>().unwrap().clone().into_py(py)),
rtype => {
return Err(to_val_err(format!("Invalid rtype {rtype} found in record")))
Expand Down
4 changes: 2 additions & 2 deletions rust/dbn-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dbn-cli"
authors = ["Databento <support@databento.com>"]
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "Command-line utility for converting Databento Binary Encoding (DBN) files to text-based formats"
default-run = "dbn"
Expand All @@ -17,7 +17,7 @@ path = "src/main.rs"

[dependencies]
# Databento common DBN library
dbn = { path = "../dbn", version = "=0.4.1" }
dbn = { path = "../dbn", version = "=0.4.2" }

# Error handling
anyhow = "1.0.68"
Expand Down
2 changes: 1 addition & 1 deletion rust/dbn-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dbn-macros"
authors = ["Databento <support@databento.com>"]
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "Proc macros for dbn crate"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions rust/dbn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dbn"
authors = ["Databento <support@databento.com>"]
version = "0.4.1"
version = "0.4.2"
edition = "2021"
description = "Library for working with Databento Binary Encoding (DBN)"
license = "Apache-2.0"
Expand All @@ -18,7 +18,7 @@ python = ["pyo3"]
trivial_copy = []

[dependencies]
dbn-macros = { version = "=0.4.1", path = "../dbn-macros" }
dbn-macros = { version = "=0.4.2", path = "../dbn-macros" }

# error handling
anyhow = "1.0"
Expand Down
8 changes: 5 additions & 3 deletions rust/dbn/src/encode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use crate::{
decode::DecodeDbn,
enums::{Compression, Encoding, Schema},
record::{
HasRType, ImbalanceMsg, InstrumentDefMsg, MboMsg, Mbp10Msg, Mbp1Msg, OhlcvMsg, TbboMsg,
TradeMsg, WithTsOut,
HasRType, ImbalanceMsg, InstrumentDefMsg, MboMsg, Mbp10Msg, Mbp1Msg, OhlcvMsg, StatusMsg,
TbboMsg, TradeMsg, WithTsOut,
},
Metadata,
};
Expand Down Expand Up @@ -97,7 +97,9 @@ pub trait EncodeDbn {
(Schema::Imbalance, false) => {
self.encode_stream(decoder.decode_stream::<ImbalanceMsg>()?)
}
(Schema::Statistics | Schema::Status, _) => Err(anyhow!("Not implemented")),
(Schema::Status, true) => self.encode_stream(decoder.decode_stream::<StatusMsg>()?),
(Schema::Status, false) => self.encode_stream(decoder.decode_stream::<StatusMsg>()?),
(Schema::Statistics, _) => Err(anyhow!("Not implemented")),
}
}
}
Expand Down
Loading

0 comments on commit 43d6ef6

Please sign in to comment.