macro_rules! nautilus_execution_algorithm {
($ty:ty) => { ... };
($ty:ty, $field:ident) => { ... };
($ty:ty, { $($extra:item)* }) => { ... };
($ty:ty, $field:ident, { $($extra:item)* }) => { ... };
}Expand description
Implements DataActorNative, ExecutionAlgorithmNative, and ExecutionAlgorithm for an
execution algorithm type.
The struct must contain a field of type
ExecutionAlgorithmCore. By default the macro
expects the field to be named core; pass a second argument to use a different name.
A brace-delimited block adds on_order and any extra methods to the generated
impl ExecutionAlgorithm. Native runtime core access is generated through
ExecutionAlgorithmNative; normal execution algorithm logic should use
ExecutionAlgorithm facade methods.
§Examples
ⓘ
use nautilus_trading::{algorithm::ExecutionAlgorithmCore, nautilus_execution_algorithm};
pub struct MyExecutionAlgorithm {
core: ExecutionAlgorithmCore,
// ...
}
nautilus_execution_algorithm!(MyExecutionAlgorithm, {
fn on_order(&mut self, order: OrderAny) -> anyhow::Result<()> {
// custom handling
Ok(())
}
});With a custom field name and hooks:
ⓘ
pub struct MyExecutionAlgorithm {
algorithm_core: ExecutionAlgorithmCore,
// ...
}
nautilus_execution_algorithm!(MyExecutionAlgorithm, algorithm_core, {
fn on_order(&mut self, order: OrderAny) -> anyhow::Result<()> {
// custom handling
Ok(())
}
});