|
48 | 48 | Metadata, |
49 | 49 | ] |
50 | 50 |
|
| 51 | +INT64_NULL = 9223372036854775807 |
| 52 | +NAN = float("NaN") |
| 53 | + |
51 | 54 |
|
52 | 55 | logger = logging.getLogger(__name__) |
53 | 56 |
|
@@ -420,11 +423,11 @@ def _apply_pretty_px(self, df: pd.DataFrame) -> pd.DataFrame: |
420 | 423 | or column.startswith("bid_px") # MBP |
421 | 424 | or column.startswith("ask_px") # MBP |
422 | 425 | ): |
423 | | - df[column] = df[column] * 1e-9 |
| 426 | + df[column] = df[column].replace(INT64_NULL, NAN) * 1e-9 |
424 | 427 |
|
425 | 428 | if self.schema == Schema.DEFINITION: |
426 | 429 | for column in DEFINITION_PRICE_COLUMNS: |
427 | | - df[column] = df[column] * 1e-9 |
| 430 | + df[column] = df[column].replace(INT64_NULL, NAN) * 1e-9 |
428 | 431 |
|
429 | 432 | return df |
430 | 433 |
|
@@ -882,7 +885,8 @@ def to_csv( |
882 | 885 | `int` to `pd.Timestamp` tz-aware (UTC). |
883 | 886 | pretty_px : bool, default True |
884 | 887 | If all price columns should be converted from `int` to `float` at |
885 | | - the correct scale (using the fixed precision scalar 1e-9). |
| 888 | + the correct scale (using the fixed precision scalar 1e-9). Null |
| 889 | + prices are replaced with an empty string. |
886 | 890 | map_symbols : bool, default True |
887 | 891 | If symbology mappings from the metadata should be used to create |
888 | 892 | a 'symbol' column, mapping the instrument ID to its native symbol for |
@@ -925,7 +929,8 @@ def to_df( |
925 | 929 | `int` to `pd.Timestamp` tz-aware (UTC). |
926 | 930 | pretty_px : bool, default True |
927 | 931 | If all price columns should be converted from `int` to `float` at |
928 | | - the correct scale (using the fixed precision scalar 1e-9). |
| 932 | + the correct scale (using the fixed precision scalar 1e-9). Null |
| 933 | + prices are replaced with NaN. |
929 | 934 | map_symbols : bool, default True |
930 | 935 | If symbology mappings from the metadata should be used to create |
931 | 936 | a 'symbol' column, mapping the instrument ID to its native symbol for |
|
0 commit comments