Automate local JoinQuant smoke prep
This commit is contained in:
@@ -25,6 +25,7 @@ from plugins.joinquant.schema import (
|
||||
JOINQUANT_TARGET_COLUMNS,
|
||||
RECONCILE_COLUMNS,
|
||||
)
|
||||
from plugins.joinquant.smoke import build_fixed_share_positions
|
||||
from plugins.joinquant.symbols import from_joinquant_symbol, to_joinquant_symbol
|
||||
from plugins.joinquant.wrapper_strategy import write_wrapper_strategy
|
||||
|
||||
@@ -505,3 +506,27 @@ 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
|
||||
|
||||
|
||||
def test_build_fixed_share_positions_excludes_final_executionless_date():
|
||||
data = pd.DataFrame({
|
||||
"symbol_id": ["sh600000", "sh600000", "sh600000"],
|
||||
"date": pd.to_datetime(["2024-01-09", "2024-01-10", "2024-01-11"]),
|
||||
"close": [10.0, 10.5, 11.0],
|
||||
})
|
||||
|
||||
positions = build_fixed_share_positions(
|
||||
data,
|
||||
trade_symbol="sh600000",
|
||||
portfolio_name="run1",
|
||||
shares=1000,
|
||||
booksize=1_000_000.0,
|
||||
)
|
||||
|
||||
assert list(positions.columns) == POSITION_COLUMNS
|
||||
assert positions["date"].dt.strftime("%Y-%m-%d").tolist() == [
|
||||
"2024-01-09",
|
||||
"2024-01-10",
|
||||
]
|
||||
assert positions["position_shares"].tolist() == [1000, 1000]
|
||||
assert positions["target_value"].tolist() == [10_000.0, 10_500.0]
|
||||
|
||||
Reference in New Issue
Block a user