Skip to content

Commit 7247acb

Browse files
committed
Update dependencies and pre-commit
1 parent 9bd0835 commit 7247acb

8 files changed

+109
-95
lines changed

Diff for: .pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
# General checks
44
##############################################################################
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.5.0
6+
rev: v4.6.0
77
hooks:
88
- id: fix-encoding-pragma
99
args: [--remove]
@@ -24,7 +24,7 @@ repos:
2424
- id: check-yaml
2525

2626
- repo: https://github.com/codespell-project/codespell
27-
rev: v2.2.6
27+
rev: v2.3.0
2828
hooks:
2929
- id: codespell
3030
description: Checks for common misspellings.
@@ -41,20 +41,20 @@ repos:
4141
types: [python]
4242

4343
- repo: https://github.com/psf/black
44-
rev: 24.2.0
44+
rev: 24.4.2
4545
hooks:
4646
- id: black
4747
types_or: [python, pyi]
4848
entry: "black"
4949

5050
- repo: https://github.com/charliermarsh/ruff-pre-commit
51-
rev: v0.3.0
51+
rev: v0.4.7
5252
hooks:
5353
- id: ruff
5454
args: ["--fix"]
5555

5656
- repo: https://github.com/pre-commit/mirrors-mypy
57-
rev: v1.8.0
57+
rev: v1.10.0
5858
hooks:
5959
- id: mypy
6060
args: [--no-strict-optional, --ignore-missing-imports, --warn-no-return, --explicit-package-bases]

Diff for: bench_data/check_invariant.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import sys
2+
23
import pandas as pd
34

45

56
def check_file(file_name):
6-
"""Check if the 'start_ts' column is in ascending order and 'end_ts' for a row groups comes before 'start_ts' of the next row group."""
7+
"""
8+
Check if the 'start_ts' column is in ascending order and 'end_ts' for a row
9+
groups comes before 'start_ts' of the next row group.
10+
11+
"""
712
df = pd.read_csv(file_name)
813

914
# Check if 'start_ts' is in ascending order

Diff for: bench_data/extract_groups.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import sys
2+
13
import pandas as pd
24
import pyarrow as pa
35
import pyarrow.parquet as pq
4-
import sys
6+
57

68
# Define schema for quote ticks
79
quote_tick_schema = pa.schema(
@@ -12,15 +14,15 @@
1214
("ask_size", pa.uint64()),
1315
("ts_event", pa.uint64()),
1416
("ts_init", pa.uint64()),
15-
]
17+
],
1618
)
1719

1820
quote_tick_schema = quote_tick_schema.with_metadata(
1921
{
2022
"instrument_id": "EUR/USD.SIM",
2123
"price_precision": "0",
2224
"size_precision": "0",
23-
}
25+
},
2426
)
2527

2628
trade_tick_schema = pa.schema(
@@ -31,15 +33,15 @@
3133
("trade_id", pa.string()),
3234
("ts_event", pa.uint64()),
3335
("ts_init", pa.uint64()),
34-
]
36+
],
3537
)
3638

3739
trade_tick_schema = trade_tick_schema.with_metadata(
3840
{
3941
"instrument_id": "EUR/USD.SIM",
4042
"price_precision": "0",
4143
"size_precision": "0",
42-
}
44+
},
4345
)
4446

4547

@@ -64,7 +66,9 @@ def write_parquet_with_row_group(input_file, output_file, rows_per_row_group):
6466

6567
if __name__ == "__main__":
6668
if len(sys.argv) < 4:
67-
print("Usage: python extract_ts_init.py <parquet_file> <num_rows_per_row_group>")
69+
print(
70+
"Usage: python extract_ts_init.py <parquet_file> <num_rows_per_row_group>",
71+
)
6872
sys.exit(1)
6973

7074
# Get command-line inputs

Diff for: bench_data/extract_ts_init.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import pyarrow.parquet as pq
21
import csv
32
import sys
43

4+
import pyarrow.parquet as pq
5+
56

67
def extract_ts_init_values(parquet_file, csv_file):
78
"""Write the first and last 'ts_init' values of each row group to a CSV file."""
@@ -11,7 +12,9 @@ def extract_ts_init_values(parquet_file, csv_file):
1112
# Open the CSV file for writing
1213
with open(csv_file, "w", newline="") as csvfile:
1314
writer = csv.writer(csvfile)
14-
writer.writerow(["index", "start_ts", "end_ts", "group_size"]) # Write the header
15+
writer.writerow(
16+
["index", "start_ts", "end_ts", "group_size"],
17+
) # Write the header
1518

1619
# Iterate over each row group in the Parquet file
1720
for i in range(parquet_file.num_row_groups):

Diff for: bench_data/gen_data_stats.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import sys
2-
import os
31
import csv
2+
import os
3+
import sys
4+
45
import pyarrow.parquet as pq
56

67

@@ -9,7 +10,7 @@ def record_data_stats(folder_path, csv_file):
910
with open(csv_file, "w", newline="") as csvfile:
1011
writer = csv.writer(csvfile)
1112
writer.writerow(
12-
["file_name", "file_size_kb", "total_rows", "max_row_group_size"]
13+
["file_name", "file_size_kb", "total_rows", "max_row_group_size"],
1314
) # Write the header
1415

1516
# Walk the folder
@@ -34,7 +35,9 @@ def record_data_stats(folder_path, csv_file):
3435
max_row_group_size = max(max_row_group_size, num_rows)
3536

3637
# Write the statistics to the CSV file
37-
writer.writerow([file_path, file_size_kb, total_rows, max_row_group_size])
38+
writer.writerow(
39+
[file_path, file_size_kb, total_rows, max_row_group_size],
40+
)
3841

3942

4043
if __name__ == "__main__":

Diff for: nautilus_data/hist_data_to_catalog.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from os import PathLike
1717
from pathlib import Path
18-
import requests
1918

19+
import requests
2020
from nautilus_trader.persistence.catalog import ParquetDataCatalog
2121
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
2222
from nautilus_trader.test_kit.providers import CSVTickDataLoader
@@ -36,7 +36,11 @@ def load_fx_hist_data(
3636
instrument = TestInstrumentProvider.default_fx_ccy(currency)
3737
wrangler = QuoteTickDataWrangler(instrument)
3838

39-
df = CSVTickDataLoader.load(filename, index_col=0, datetime_format="%Y%m%d %H%M%S%f")
39+
df = CSVTickDataLoader.load(
40+
filename,
41+
index_col=0,
42+
datetime_format="%Y%m%d %H%M%S%f",
43+
)
4044
df.columns = ["bid_price", "ask_price", "size"]
4145
print(df)
4246

0 commit comments

Comments
 (0)