Add rqalpha-style scheduler time rules
This commit is contained in:
@@ -1232,8 +1232,12 @@ where
|
||||
let mut desired_targets = BTreeMap::new();
|
||||
let mut diagnostics = Vec::new();
|
||||
for (symbol, weight) in target_weights {
|
||||
let price =
|
||||
self.rebalance_valuation_price_with_overrides(date, symbol, data, valuation_prices)?;
|
||||
let price = self.rebalance_valuation_price_with_overrides(
|
||||
date,
|
||||
symbol,
|
||||
data,
|
||||
valuation_prices,
|
||||
)?;
|
||||
let raw_qty = ((equity * weight) / price).floor() as u32;
|
||||
desired_targets.insert(
|
||||
symbol.clone(),
|
||||
@@ -1486,7 +1490,10 @@ where
|
||||
symbols.extend(target_quantities.keys().cloned());
|
||||
|
||||
for symbol in &symbols {
|
||||
let current_qty = portfolio.position(symbol).map(|pos| pos.quantity).unwrap_or(0);
|
||||
let current_qty = portfolio
|
||||
.position(symbol)
|
||||
.map(|pos| pos.quantity)
|
||||
.unwrap_or(0);
|
||||
let target_qty = target_quantities.get(symbol).copied().unwrap_or(0);
|
||||
if current_qty <= target_qty {
|
||||
continue;
|
||||
@@ -1529,7 +1536,10 @@ where
|
||||
}
|
||||
|
||||
for symbol in &symbols {
|
||||
let current_qty = portfolio.position(symbol).map(|pos| pos.quantity).unwrap_or(0);
|
||||
let current_qty = portfolio
|
||||
.position(symbol)
|
||||
.map(|pos| pos.quantity)
|
||||
.unwrap_or(0);
|
||||
let target_qty = target_quantities.get(symbol).copied().unwrap_or(0);
|
||||
if target_qty <= current_qty {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user