Skip to main content

Module commands

Module commands 

Source
Expand description

Strategy commands sent to the engine.

Commands are the write-side API for strategies. A strategy never calls an exchange directly; it emits commands through StrategyContext, and the engine turns those commands into exchange writes and later execution events.

§Example

use bot_core::{
    Command, Environment, ExchangeId, ExchangeInstance, InstrumentId, OrderSide, PlaceOrder,
    Price, Qty,
};
use rust_decimal::Decimal;

let exchange = ExchangeInstance::new(ExchangeId::new("hyperliquid"), Environment::Testnet);
let order = PlaceOrder::limit(
    exchange,
    InstrumentId::new("BTC-PERP"),
    OrderSide::Buy,
    Price::new(Decimal::new(65_000, 0)),
    Qty::new(Decimal::new(1, 3)),
);

let command = Command::PlaceOrder(order);
assert_eq!(command.instrument().unwrap().as_str(), "BTC-PERP");

Structs§

CancelAll
Cancel all orders (optionally for a specific instrument)
CancelOrder
Cancel an existing order
PlaceOrder
Place a new order
StopStrategy
Stop strategy command - requests the engine to stop a strategy

Enums§

Command
Commands that strategies can emit.