| Crates.io | nt-core |
| lib.rs | nt-core |
| version | 1.0.0 |
| created_at | 2025-11-13 16:11:49.707923+00 |
| updated_at | 2025-11-13 16:11:49.707923+00 |
| description | Core types, traits, and utilities for Neural Trader - A high-performance algorithmic trading platform |
| homepage | |
| repository | https://github.com/ruvnet/neural-trader |
| max_upload_size | |
| id | 1931447 |
| size | 135,952 |
Core types, traits, and abstractions for the NeuralTrader algorithmic trading system.
The nt-core crate provides the foundational building blocks used across all NeuralTrader components, including order types, position management, market data structures, account abstractions, and essential trading primitives.
serderust_decimaltokio for high-performance concurrent operationsdashmap and parking_lotvalidator derive macrosthiserror and anyhowAdd nt-core to your Cargo.toml:
[dependencies]
nt-core = "0.1"
use nt_core::{
types::{Order, OrderType, Side, Position, MarketData, Account},
traits::{OrderManager, PositionManager},
config::TradingConfig,
};
use rust_decimal::Decimal;
use chrono::Utc;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a market order
let order = Order {
id: uuid::Uuid::new_v4(),
symbol: "AAPL".to_string(),
side: Side::Buy,
order_type: OrderType::Market,
quantity: Decimal::from(100),
price: None,
status: OrderStatus::Pending,
created_at: Utc::now(),
updated_at: Utc::now(),
};
// Create a position
let position = Position {
symbol: "AAPL".to_string(),
quantity: Decimal::from(100),
entry_price: Decimal::new(15000, 2), // $150.00
current_price: Decimal::new(15200, 2), // $152.00
unrealized_pnl: Decimal::from(200),
realized_pnl: Decimal::ZERO,
opened_at: Utc::now(),
};
// Load configuration
let config = TradingConfig::from_file("config.toml")?;
println!("Position P&L: ${}", position.unrealized_pnl);
Ok(())
}
The crate is organized into several key modules:
nt-core/
├── types.rs # Core data types (Order, Position, MarketData, Account)
├── traits.rs # Trait definitions (OrderManager, PositionManager, DataProvider)
├── config.rs # Configuration management
├── error.rs # Error types and conversions
└── lib.rs # Module exports and prelude
| Crate | Purpose |
|---|---|
tokio |
Async runtime |
serde |
Serialization/deserialization |
rust_decimal |
Decimal arithmetic for financial calculations |
chrono |
Date and time handling |
uuid |
Unique identifiers |
thiserror |
Error type derivation |
validator |
Input validation |
dashmap |
Concurrent hash map |
parking_lot |
Efficient synchronization primitives |
Run the test suite:
cargo test -p nt-core
Run with property-based testing:
cargo test -p nt-core --features proptest
Run benchmarks:
cargo bench -p nt-core
Contributions are welcome! Please ensure:
cargo test -p nt-corecargo fmt -p nt-corecargo clippy -p nt-core -- -D warningscargo doc -p nt-core --no-depsLicensed under either of:
at your option.