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:
Enginewith plug and playStrategyandRiskManagercomponents.- Centralised cache friendly
EngineStatemanagement with O(1) constant lookups using indexed data structures. Strategyinterfaces for customising Engine behavior (AlgoStrategy, ClosePositionsStrategy, OnDisconnectStrategy, etc.).RiskManagerinterface 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
Re-exports§
pub use crate::engine::state::position::SplitRoundingPolicy;
Modules§
- backtest
- Backtesting utilities.
- engine
- Algorithmic trading
Engine, and entry points for processing inputEvents. - 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
Engineactions on disconnect / trading disabled. - system
- Utilities for initialising and interacting with a full trading system.
Structs§
- Invalid
Split Ratio - Re-export of the corporate-action public API so callers can build and handle
EngineEvent::CorporateActionwithout a directrustrade_instrumentdependency — mirroring theSplitRoundingPolicyre-export above.CorporateActionKindis the event’s market-factkind,SplitRatio/InvalidSplitRatioare its validated ratio and construction error,SplitAdjustmentKindis the OCC option classification, andsplit_effective_instantresolves an effective date to the engine’s stamping instant. Error from constructing aSplitRatiofrom a non-positiveDecimal. - Sequence
- Monotonically increasing event sequence. Used to track
Engineevent processing sequence. - Split
Ratio - Re-export of the corporate-action public API so callers can build and handle
EngineEvent::CorporateActionwithout a directrustrade_instrumentdependency — mirroring theSplitRoundingPolicyre-export above.CorporateActionKindis the event’s market-factkind,SplitRatio/InvalidSplitRatioare its validated ratio and construction error,SplitAdjustmentKindis the OCC option classification, andsplit_effective_instantresolves an effective date to the engine’s stamping instant. A validated stock-split ratio: strictly positive (> 0). - Timed
- A timed value.
Enums§
- Corporate
Action Kind - Re-export of the corporate-action public API so callers can build and handle
EngineEvent::CorporateActionwithout a directrustrade_instrumentdependency — mirroring theSplitRoundingPolicyre-export above.CorporateActionKindis the event’s market-factkind,SplitRatio/InvalidSplitRatioare its validated ratio and construction error,SplitAdjustmentKindis the OCC option classification, andsplit_effective_instantresolves 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. - Engine
Event - Default
Engineevent that encompasses market events, account/execution events, andEnginecommands. - Split
Adjustment Kind - Re-export of the corporate-action public API so callers can build and handle
EngineEvent::CorporateActionwithout a directrustrade_instrumentdependency — mirroring theSplitRoundingPolicyre-export above.CorporateActionKindis the event’s market-factkind,SplitRatio/InvalidSplitRatioare its validated ratio and construction error,SplitAdjustmentKindis the OCC option classification, andsplit_effective_instantresolves 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 byCorporateActionKind::split_kind.
Functions§
- split_
effective_ instant - Re-export of the corporate-action public API so callers can build and handle
EngineEvent::CorporateActionwithout a directrustrade_instrumentdependency — mirroring theSplitRoundingPolicyre-export above.CorporateActionKindis the event’s market-factkind,SplitRatio/InvalidSplitRatioare its validated ratio and construction error,SplitAdjustmentKindis the OCC option classification, andsplit_effective_instantresolves an effective date to the engine’s stamping instant. Resolve a stock split’s effective date (a calendarNaiveDatemarket fact) to the exactDateTime<Utc>instant at which the adjustment takes effect: midnight (00:00) UTC on that date.