隔离次日执行价与信号日资金预算
This commit is contained in:
@@ -1329,6 +1329,19 @@ impl PlatformExprStrategy {
|
|||||||
self.marked_total_value_for_portfolio(ctx, ctx.portfolio, date)
|
self.marked_total_value_for_portfolio(ctx, ctx.portfolio, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn signal_visible_total_value(
|
||||||
|
&self,
|
||||||
|
ctx: &StrategyContext<'_>,
|
||||||
|
date: NaiveDate,
|
||||||
|
defer_execution: bool,
|
||||||
|
) -> f64 {
|
||||||
|
if defer_execution {
|
||||||
|
ctx.portfolio.total_value()
|
||||||
|
} else {
|
||||||
|
self.marked_total_value(ctx, date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn round_lot_quantity(
|
fn round_lot_quantity(
|
||||||
&self,
|
&self,
|
||||||
quantity: u32,
|
quantity: u32,
|
||||||
@@ -8494,7 +8507,8 @@ impl Strategy for PlatformExprStrategy {
|
|||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
let marked_total_value = self.marked_total_value(ctx, projection_date);
|
let marked_total_value =
|
||||||
|
self.signal_visible_total_value(ctx, projection_date, defer_execution_risk);
|
||||||
let mut aiquant_total_value = if marked_total_value.is_finite() && marked_total_value > 0.0
|
let mut aiquant_total_value = if marked_total_value.is_finite() && marked_total_value > 0.0
|
||||||
{
|
{
|
||||||
marked_total_value
|
marked_total_value
|
||||||
@@ -12131,6 +12145,8 @@ mod tests {
|
|||||||
let marked = strategy.marked_total_value(&ctx, date);
|
let marked = strategy.marked_total_value(&ctx, date);
|
||||||
|
|
||||||
assert!((marked - 1_250.0).abs() < 1e-6, "{marked}");
|
assert!((marked - 1_250.0).abs() < 1e-6, "{marked}");
|
||||||
|
let deferred_total = strategy.signal_visible_total_value(&ctx, date, true);
|
||||||
|
assert!((deferred_total - 1_100.0).abs() < 1e-6, "{deferred_total}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user