trading-maid 1.0.2

A high-fidelity crypto futures backtesting and live trading framework with matching, margin, leverage and liquidation simulation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::context::Context;

#[async_trait::async_trait(?Send)]
pub trait Strategy {
    async fn next(&mut self, cx: &Context) -> anyhow::Result<()>;
}

#[async_trait::async_trait(?Send)]
impl<T> Strategy for T
where
    T: AsyncFn(&Context) -> anyhow::Result<()>,
{
    async fn next(&mut self, cx: &Context) -> anyhow::Result<()> {
        self(cx).await
    }
}