Add management fee callbacks
This commit is contained in:
@@ -17,6 +17,13 @@ use crate::universe::{DynamicMarketCapBandSelector, SelectionContext, UniverseSe
|
||||
|
||||
pub trait Strategy {
|
||||
fn name(&self) -> &str;
|
||||
fn management_fee(
|
||||
&mut self,
|
||||
_ctx: &StrategyContext<'_>,
|
||||
_rate: f64,
|
||||
) -> Result<Option<f64>, BacktestError> {
|
||||
Ok(None)
|
||||
}
|
||||
fn on_process_event(
|
||||
&mut self,
|
||||
_ctx: &StrategyContext<'_>,
|
||||
@@ -115,6 +122,8 @@ pub struct PortfolioRuntimeView {
|
||||
pub trading_pnl: f64,
|
||||
pub position_pnl: f64,
|
||||
pub cash_liabilities: f64,
|
||||
pub management_fee_rate: f64,
|
||||
pub management_fees: f64,
|
||||
}
|
||||
|
||||
pub struct StrategyContext<'a> {
|
||||
@@ -368,6 +377,8 @@ impl StrategyContext<'_> {
|
||||
trading_pnl: self.portfolio.trading_pnl(),
|
||||
position_pnl: self.portfolio.position_pnl(),
|
||||
cash_liabilities: self.portfolio.cash_liabilities(),
|
||||
management_fee_rate: self.portfolio.management_fee_rate(),
|
||||
management_fees: self.portfolio.management_fees(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,6 +830,10 @@ pub enum OrderIntent {
|
||||
amount: f64,
|
||||
reason: String,
|
||||
},
|
||||
SetManagementFeeRate {
|
||||
rate: f64,
|
||||
reason: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user