Align JoinQuant targets to execution dates
This commit is contained in:
@@ -269,6 +269,32 @@ def test_export_targets_target_value_mode_from_position_columns(tmp_path):
|
||||
assert target.loc[0, "target_shares"] == 250
|
||||
|
||||
|
||||
def test_export_targets_can_shift_to_next_execution_session(tmp_path):
|
||||
positions_path = tmp_path / "positions.pq"
|
||||
_positions(date="2024-01-09").to_parquet(positions_path, index=False)
|
||||
calendar_path = tmp_path / "daily.pq"
|
||||
pd.DataFrame({
|
||||
"date": pd.to_datetime(["2024-01-09", "2024-01-10", "2024-01-11"]),
|
||||
"symbol_id": ["sh600000", "sh600000", "sh600000"],
|
||||
}).to_parquet(calendar_path, index=False)
|
||||
|
||||
snapshots = export_targets(
|
||||
positions_path,
|
||||
portfolio_name="run1",
|
||||
out_dir=tmp_path / "targets_shifted",
|
||||
mode="target_shares",
|
||||
start_date="2024-01-10",
|
||||
end_date="2024-01-10",
|
||||
execution_calendar_path=calendar_path,
|
||||
)
|
||||
|
||||
assert len(snapshots) == 1
|
||||
assert snapshots[0]["date"] == "2024-01-10"
|
||||
assert (tmp_path / "targets_shifted" / "run1" / "20240110.csv").exists()
|
||||
target = pd.read_csv(tmp_path / "targets_shifted" / "run1" / "20240110.csv")
|
||||
assert target.loc[0, "date"] == "2024-01-10"
|
||||
|
||||
|
||||
def test_ingest_permissive_csv_column_mapping_and_output_schemas(tmp_path):
|
||||
fills_csv = tmp_path / "jq_fills.csv"
|
||||
positions_csv = tmp_path / "jq_positions.csv"
|
||||
@@ -479,4 +505,3 @@ def test_wrapper_strategy_generation_smoke(tmp_path):
|
||||
assert 'PORTFOLIO_NAME = "run2"' in text
|
||||
assert 'TARGET_MODE = "target_value"' in text
|
||||
assert "order_target_value" in text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user