pub struct StrategyEngine {
pub strategies: Vec<Box<dyn Strategy>>,
}Fields§
§strategies: Vec<Box<dyn Strategy>>Implementations§
Source§impl StrategyEngine
impl StrategyEngine
Sourcepub fn add_strategy(&mut self, strategy: Box<dyn Strategy>)
pub fn add_strategy(&mut self, strategy: Box<dyn Strategy>)
添加策略
Sourcepub fn backtest(&self, prices: Vec<f64>) -> Vec<f64>
pub fn backtest(&self, prices: Vec<f64>) -> Vec<f64>
回测所有策略
Examples found in repository?
examples/solana_trader.rs (line 18)
17 pub fn determine_strategy(&mut self, prices: Vec<f64>) {
18 let results = self.engine.backtest(prices.clone());
19 let best_strategy_index = results
20 .iter()
21 .enumerate()
22 .max_by(|(_, a), (_, b)| a.partial_cmp(b).unwrap())
23 .unwrap()
24 .0;
25
26 self.current_strategy = Some(best_strategy_index);
27 println!("Best Strategy: {}", best_strategy_index + 1);
28 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for StrategyEngine
impl !RefUnwindSafe for StrategyEngine
impl !Send for StrategyEngine
impl !Sync for StrategyEngine
impl Unpin for StrategyEngine
impl !UnwindSafe for StrategyEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more