66import logging
77from collections .abc import Generator
88from collections .abc import Iterator
9+ from collections .abc import Mapping
910from io import BytesIO
1011from os import PathLike
1112from pathlib import Path
1819 Final ,
1920 Literal ,
2021 Protocol ,
22+ TextIO ,
2123 overload ,
2224)
2325
@@ -108,20 +110,16 @@ class DataSource(abc.ABC):
108110 Abstract base class for backing DBNStore instances with data.
109111 """
110112
111- def __init__ (self , source : object ) -> None :
112- ...
113+ def __init__ (self , source : object ) -> None : ...
113114
114115 @property
115- def name (self ) -> str :
116- ...
116+ def name (self ) -> str : ...
117117
118118 @property
119- def nbytes (self ) -> int :
120- ...
119+ def nbytes (self ) -> int : ...
121120
122121 @property
123- def reader (self ) -> IO [bytes ]:
124- ...
122+ def reader (self ) -> IO [bytes ]: ...
125123
126124
127125class FileDataSource (DataSource ):
@@ -675,6 +673,27 @@ def from_bytes(cls, data: BytesIO | bytes | IO[bytes]) -> DBNStore:
675673 """
676674 return cls (MemoryDataSource (data ))
677675
676+ def insert_symbology_json (
677+ self ,
678+ json_data : str | Mapping [str , Any ] | TextIO ,
679+ clear_existing : bool = True ,
680+ ) -> None :
681+ """
682+ Insert the given JSON data obtained from the `symbology.resolve`
683+ endpoint or a `symbology.json` file.
684+
685+ Parameters
686+ ----------
687+ json_data : str | Mapping[str, Any] | TextIO
688+ The JSON data to insert.
689+ clear_existing : bool, default True
690+ If existing symbology data should be cleared from the internal mappings.
691+
692+ """
693+ if clear_existing :
694+ self ._instrument_map .clear ()
695+ self ._instrument_map .insert_json (json_data )
696+
678697 def replay (self , callback : Callable [[Any ], None ]) -> None :
679698 """
680699 Replay data by passing records sequentially to the given callback.
@@ -834,8 +853,7 @@ def to_df(
834853 schema : Schema | str | None = ...,
835854 tz : pytz .BaseTzInfo | str = ...,
836855 count : None = ...,
837- ) -> pd .DataFrame :
838- ...
856+ ) -> pd .DataFrame : ...
839857
840858 @overload
841859 def to_df (
@@ -846,16 +864,17 @@ def to_df(
846864 schema : Schema | str | None = ...,
847865 tz : pytz .BaseTzInfo | str = ...,
848866 count : int = ...,
849- ) -> DataFrameIterator :
850- ...
867+ ) -> DataFrameIterator : ...
851868
852869 def to_df (
853870 self ,
854871 price_type : Literal ["fixed" , "float" , "decimal" ] = "float" ,
855872 pretty_ts : bool = True ,
856873 map_symbols : bool = True ,
857874 schema : Schema | str | None = None ,
858- tz : pytz .BaseTzInfo | str | Default [pytz .BaseTzInfo ] = Default [pytz .BaseTzInfo ](pytz .UTC ),
875+ tz : pytz .BaseTzInfo | str | Default [pytz .BaseTzInfo ] = Default [pytz .BaseTzInfo ](
876+ pytz .UTC ,
877+ ),
859878 count : int | None = None ,
860879 ) -> pd .DataFrame | DataFrameIterator :
861880 """
@@ -903,7 +922,9 @@ def to_df(
903922 if isinstance (tz , Default ):
904923 tz = tz .value # consume default
905924 elif not pretty_ts :
906- raise ValueError ("A timezone was specified when `pretty_ts` is `False`. Did you mean to set `pretty_ts=True`?" )
925+ raise ValueError (
926+ "A timezone was specified when `pretty_ts` is `False`. Did you mean to set `pretty_ts=True`?" ,
927+ )
907928
908929 if not isinstance (tz , pytz .BaseTzInfo ):
909930 tz = pytz .timezone (tz )
@@ -1096,16 +1117,14 @@ def to_ndarray( # type: ignore [misc]
10961117 self ,
10971118 schema : Schema | str | None = ...,
10981119 count : None = ...,
1099- ) -> np .ndarray [Any , Any ]:
1100- ...
1120+ ) -> np .ndarray [Any , Any ]: ...
11011121
11021122 @overload
11031123 def to_ndarray (
11041124 self ,
11051125 schema : Schema | str | None = ...,
11061126 count : int = ...,
1107- ) -> NDArrayIterator :
1108- ...
1127+ ) -> NDArrayIterator : ...
11091128
11101129 def to_ndarray (
11111130 self ,
@@ -1242,12 +1261,10 @@ def _schema_struct_map(self) -> dict[Schema, type[DBNRecord]]:
12421261
12431262class NDArrayIterator (Protocol ):
12441263 @abc .abstractmethod
1245- def __iter__ (self ) -> NDArrayIterator :
1246- ...
1264+ def __iter__ (self ) -> NDArrayIterator : ...
12471265
12481266 @abc .abstractmethod
1249- def __next__ (self ) -> np .ndarray [Any , Any ]:
1250- ...
1267+ def __next__ (self ) -> np .ndarray [Any , Any ]: ...
12511268
12521269
12531270class NDArrayStreamIterator (NDArrayIterator ):
0 commit comments