Skip to main content

Crate rustrade

Crate rustrade 

Source
Expand description

§Barter

Barter core is a Rust framework for building high-performance live-trading, paper-trading and back-testing systems.

  • Fast: Written in native Rust. Minimal allocations. Data-oriented state management system with direct index lookups.
  • Robust: Strongly typed. Thread safe. Extensive test coverage.
  • Customisable: Plug and play Strategy and RiskManager components that facilitates most trading strategies (MarketMaking, StatArb, HFT, etc.).
  • Scalable: Multithreaded architecture with modular design. Leverages Tokio for I/O. Memory efficient data structures.

§Overview

Barter core is a Rust framework for building professional grade live-trading, paper-trading and back-testing systems. The central Engine facilitates executing on many exchanges simultaneously, and offers the flexibility to run most types of trading strategies. It allows turning algorithmic order generation on/off and can action Commands issued from external processes (eg/ CloseAllPositions, OpenOrders, CancelOrders, etc.)

At a high-level, it provides a few major components:

  • Engine with plug and play Strategy and RiskManager components.
  • Centralised cache friendly EngineState management with O(1) constant lookups using indexed data structures.
  • Strategy interfaces for customising Engine behavior (AlgoStrategy, ClosePositionsStrategy, OnDisconnectStrategy, etc.).
  • RiskManager interface for defining custom risk logic which checking generated algorithmic orders.
  • Event-driven system that allows for Commands to be issued from external processes (eg/ CloseAllPositions, OpenOrders, CancelOrders, etc.), as well as turning algorithmic trading on/off.
  • Comprehensive statistics package that provides a summary of key performance metrics (PnL, Sharpe, Sortino, Drawdown, etc.).

§Getting Started Via Engine Examples

See Engine Examples

Re-exports§

pub use crate::engine::state::position::SplitRoundingPolicy;

Modules§

backtest
Backtesting utilities.
engine
Algorithmic trading Engine, and entry points for processing input Events.
error
Defines all possible errors in Barter core.
execution
Components for initialising multi-exchange execution, routing ExecutionRequests and other execution logic.
logging
Provides default Barter core Tracing logging initialisers.
risk
RiskManager interface for reviewing and optionally filtering algorithmic cancel and open order requests.
shutdown
Traits and types related to component shutdowns.
statistic
Statistical algorithms for analysing datasets, financial metrics and financial summaries.
strategy
Strategy interfaces for generating algorithmic orders, closing positions, and performing Engine actions on disconnect / trading disabled.
system
Utilities for initialising and interacting with a full trading system.

Structs§

InvalidSplitRatio
Re-export of the corporate-action public API so callers can build and handle EngineEvent::CorporateAction without a direct rustrade_instrument dependency — mirroring the SplitRoundingPolicy re-export above. CorporateActionKind is the event’s market-fact kind, SplitRatio/InvalidSplitRatio are its validated ratio and construction error, SplitAdjustmentKind is the OCC option classification, and split_effective_instant resolves an effective date to the engine’s stamping instant. Error from constructing a SplitRatio from a non-positive Decimal.
Sequence
Monotonically increasing event sequence. Used to track Engine event processing sequence.
SplitRatio
Re-export of the corporate-action public API so callers can build and handle EngineEvent::CorporateAction without a direct rustrade_instrument dependency — mirroring the SplitRoundingPolicy re-export above. CorporateActionKind is the event’s market-fact kind, SplitRatio/InvalidSplitRatio are its validated ratio and construction error, SplitAdjustmentKind is the OCC option classification, and split_effective_instant resolves an effective date to the engine’s stamping instant. A validated stock-split ratio: strictly positive (> 0).
Timed
A timed value.

Enums§

CorporateActionKind
Re-export of the corporate-action public API so callers can build and handle EngineEvent::CorporateAction without a direct rustrade_instrument dependency — mirroring the SplitRoundingPolicy re-export above. CorporateActionKind is the event’s market-fact kind, SplitRatio/InvalidSplitRatio are its validated ratio and construction error, SplitAdjustmentKind is the OCC option classification, and split_effective_instant resolves an effective date to the engine’s stamping instant. A corporate-action market fact — what happened to an instrument, independent of any account, broker, or rounding policy.
EngineEvent
Default Engine event that encompasses market events, account/execution events, and Engine commands.
SplitAdjustmentKind
Re-export of the corporate-action public API so callers can build and handle EngineEvent::CorporateAction without a direct rustrade_instrument dependency — mirroring the SplitRoundingPolicy re-export above. CorporateActionKind is the event’s market-fact kind, SplitRatio/InvalidSplitRatio are its validated ratio and construction error, SplitAdjustmentKind is the OCC option classification, and split_effective_instant resolves an effective date to the engine’s stamping instant. How the OCC adjusts listed options on an underlying that undergoes a stock split (OCC By-Laws Article VI, §11) — the classification returned by CorporateActionKind::split_kind.

Functions§

split_effective_instant
Re-export of the corporate-action public API so callers can build and handle EngineEvent::CorporateAction without a direct rustrade_instrument dependency — mirroring the SplitRoundingPolicy re-export above. CorporateActionKind is the event’s market-fact kind, SplitRatio/InvalidSplitRatio are its validated ratio and construction error, SplitAdjustmentKind is the OCC option classification, and split_effective_instant resolves an effective date to the engine’s stamping instant. Resolve a stock split’s effective date (a calendar NaiveDate market fact) to the exact DateTime<Utc> instant at which the adjustment takes effect: midnight (00:00) UTC on that date.