stock-bot/apps/stock/engine/tests/integration_test.rs
2025-07-04 11:24:27 -04:00

52 lines
No EOL
1.4 KiB
Rust

// Simple integration test that verifies basic functionality
use engine::{Order, OrderType, Side, TimeInForce, TradingMode};
use chrono::Utc;
#[test]
fn test_trading_mode_creation() {
let backtest_mode = TradingMode::Backtest {
start_time: Utc::now(),
end_time: Utc::now(),
speed_multiplier: 1.0,
};
match backtest_mode {
TradingMode::Backtest { speed_multiplier, .. } => {
assert_eq!(speed_multiplier, 1.0);
}
_ => panic!("Expected backtest mode"),
}
let paper_mode = TradingMode::Paper {
starting_capital: 100_000.0,
};
match paper_mode {
TradingMode::Paper { starting_capital } => {
assert_eq!(starting_capital, 100_000.0);
}
_ => panic!("Expected paper mode"),
}
}
#[test]
fn test_order_with_limit_price() {
let order = Order {
id: "limit-order-1".to_string(),
symbol: "AAPL".to_string(),
side: Side::Buy,
quantity: 100.0,
order_type: OrderType::Limit { price: 150.0 },
time_in_force: TimeInForce::GTC,
};
assert_eq!(order.symbol, "AAPL");
assert_eq!(order.side, Side::Buy);
assert_eq!(order.quantity, 100.0);
match order.order_type {
OrderType::Limit { price } => assert_eq!(price, 150.0),
_ => panic!("Expected limit order"),
}
}