Skip to content

Commit 3e00a28

Browse files
feat: aligned elements properly
1 parent a851c17 commit 3e00a28

File tree

7 files changed

+161
-947
lines changed

7 files changed

+161
-947
lines changed

examples/csv_validation_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import pandas as pd
9+
910
from quant_research_starter.data import validate_input_csv, validate_price_csv
1011

1112

@@ -23,7 +24,7 @@ def example_validate_price_file():
2324

2425
# Check results
2526
if result["valid"]:
26-
print(f"✓ File is valid!")
27+
print("✓ File is valid!")
2728
print(f" Rows: {result['row_count']}")
2829
print(f" Columns: {result['column_count']}")
2930
else:
@@ -55,7 +56,7 @@ def example_validate_with_required_columns():
5556
if is_valid:
5657
print(f"✓ All required symbols present: {', '.join(required_symbols)}")
5758
else:
58-
print(f"✗ Validation failed:")
59+
print("✗ Validation failed:")
5960
for err in errors:
6061
print(f" {err}")
6162

@@ -76,7 +77,7 @@ def load_and_validate_prices(file_path: str):
7677
if not result["valid"]:
7778
# Handle errors
7879
error_messages = [err["message"] for err in result["errors"]]
79-
raise ValueError(f"Invalid price file:\n" + "\n".join(error_messages))
80+
raise ValueError("Invalid price file:\n" + "\n".join(error_messages))
8081

8182
# If valid, proceed with loading
8283
prices = pd.read_csv(file_path, index_col=0, parse_dates=True)
@@ -102,7 +103,7 @@ def example_detailed_error_info():
102103

103104
result = validate_input_csv("invalid_file.csv", csv_type="price")
104105

105-
print(f"Validation Summary:")
106+
print("Validation Summary:")
106107
print(f" Valid: {result['valid']}")
107108
print(f" Errors: {len(result['errors'])}")
108109
print(f" Warnings: {len(result['warnings'])}")

notebooks/01-getting-started.ipynb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"\n",
4646
"# Show which Python the kernel is using (debugging)\n",
4747
"import sys as _sys\n",
48+
"\n",
4849
"print(\"Kernel Python:\", _sys.executable)\n"
4950
]
5051
},
@@ -56,14 +57,17 @@
5657
"outputs": [],
5758
"source": [
5859
"# Setup: imports\n",
59-
"import os\n",
60-
"import json\n",
61-
"import pandas as pd\n",
6260
"import matplotlib.pyplot as plt\n",
61+
"import pandas as pd\n",
6362
"\n",
64-
"from quant_research_starter.data import SampleDataLoader, SyntheticDataGenerator\n",
65-
"from quant_research_starter.factors import MomentumFactor, ValueFactor, SizeFactor, VolatilityFactor\n",
6663
"from quant_research_starter.backtest import VectorizedBacktest\n",
64+
"from quant_research_starter.data import SampleDataLoader\n",
65+
"from quant_research_starter.factors import (\n",
66+
" MomentumFactor,\n",
67+
" SizeFactor,\n",
68+
" ValueFactor,\n",
69+
" VolatilityFactor,\n",
70+
")\n",
6771
"from quant_research_starter.metrics import RiskMetrics\n",
6872
"\n"
6973
]
@@ -384,7 +388,7 @@
384388
"# Backtest\n",
385389
"common = prices.index.intersection(signals.index)\n",
386390
"px = prices.loc[common]\n",
387-
"sg = pd.DataFrame({c: signals['composite'] for c in px.columns}, index=signals.index).loc[common]\n",
391+
"sg = pd.DataFrame(dict.fromkeys(px.columns, signals['composite']), index=signals.index).loc[common]\n",
388392
"\n",
389393
"bt = VectorizedBacktest(px, sg, initial_capital=100000)\n",
390394
"results = bt.run(weight_scheme=\"rank\")\n",

output/backtest_plot.png

28.9 KB
Loading

0 commit comments

Comments
 (0)