Skip to main content

Crate qs_core

Crate qs_core 

Source
Expand description

quant-system-core package (qs_core library) - Core trade engine for the quant-system workspace.

This crate provides the synchronous, side-effect-free trading domain used by deterministic replay and trading applications. It contains the trade engine, strict raw signals, management-policy resolution, position sizing, and currency-conversion logic, but performs no configuration IO, networking, storage, state lookup, or broker calls.

§Key types

TypePurpose
TradeEngineMain entry point - processes actions and price updates
PositionAtomic unit of market exposure with data and rules
RuleComposable management rule such as stoploss, trailing, or take profit
ActionConcrete engine input vocabulary
EffectObservable engine output for the caller
SignalTimestamped action for replay or backtesting

§Design principle

Effects out, logic pure. The engine never performs IO. It takes inputs (Action, PriceQuote) and returns Vec<Effect>. The caller decides how to handle effects for replay, accounting, or other application behavior.

Re-exports§

pub use alert_register::PriceAlertRegister;
pub use currency::ConversionError;
pub use currency::ConversionLeg;
pub use currency::ConversionLegAudit;
pub use currency::ConversionPriceSide;
pub use currency::ConversionQuoteBook;
pub use currency::ConversionResult;
pub use currency::ConversionRoute;
pub use currency::FxPair;
pub use currency::FxPairDirection;
pub use currency::QuoteValidationError;
pub use currency::RunCurrencyPlan;
pub use currency::RunCurrencyPlanError;
pub use currency::resolve_conversion_route;
pub use currency::resolve_fx_pair;
pub use engine::FutureApplyError;
pub use engine::FutureApplyResult;
pub use engine::TradeEngine;
pub use error::CoreError;
pub use error::Result;
pub use execution::ExecutionError;
pub use execution::ExecutionPricer;
pub use execution::ExecutionResult;
pub use position::Position;
pub use profile::ManagementProfile;
pub use profile::PositionRef;
pub use profile::PositionResolver;
pub use profile::ProfileApplicationError;
pub use profile::ProfileValidationError;
pub use profile::RawSignal;
pub use profile::ResolvedEntry;
pub use profile::RuleConfigDef;
pub use profile::StoplossMode;
pub use profile::TargetResolution;
pub use profile::TargetSelection;
pub use profile::allocate_target_steps;
pub use profile::allocate_target_units;
pub use profile::resolve_signal;
pub use profile::resolve_unprofiled_entry;
pub use profile::validate_profile;
pub use rules::Rule;
pub use sizing::InstrumentSizingError;
pub use sizing::LotCapStatus;
pub use sizing::SizingError;
pub use sizing::SizingPolicy;
pub use sizing::SizingResult;
pub use sizing::compute_instrument_native_loss_per_lot;
pub use sizing::compute_instrument_size;
pub use sizing::compute_instrument_size_for_spec;
pub use sizing::compute_instrument_size_for_spec_with_prices;
pub use sizing::compute_size;
pub use types::Action;
pub use types::CloseReason;
pub use types::Effect;
pub use types::EffectiveStop;
pub use types::ExecutionConvention;
pub use types::ExecutionFill;
pub use types::ExecutionModel;
pub use types::Fill;
pub use types::FillModel;
pub use types::FillPurpose;
pub use types::FixedPrice;
pub use types::FutureEffect;
pub use types::FutureFill;
pub use types::GroupId;
pub use types::Lots;
pub use types::OrderType;
pub use types::PositionId;
pub use types::PositionRecord;
pub use types::PositionStatus;
pub use types::PreparedPendingFill;
pub use types::PriceQuote;
pub use types::RuleConfig;
pub use types::Side;
pub use types::Signal;
pub use types::SlippageModel;
pub use types::StopOrigin;
pub use types::TargetSpec;
pub use types::TradeId;
pub use validation::RawSignalValidationError;
pub use validation::validate_raw_signal;
pub use validation::validate_raw_signals;

Modules§

alert_register
Price alert register — BTreeMap-indexed rule evaluation for O(log N + K) per tick.
currency
Deterministic account-currency conversion from historical FX ticks.
engine
Trade engine — the main entry point for processing actions and price updates.
error
execution
Pure, deterministic execution pricing.
position
Position — the atomic unit of market exposure.
position_manager
Position manager — collection of positions with lookup helpers.
profile
Management profiles — decouple entry signals from trade management.
rules
Composable position management rules.
sizing
In-place account position sizing for backtests.
types
Core type definitions shared across the trade engine.
validation
Shared raw-signal validation.