Expand description
§rshioaji - Rust Wrapper for Taiwan Shioaji API
A high-performance trading library with native event callbacks for Taiwan Shioaji API.
§Features
- 🚀 High Performance: Built with Rust for excellent performance and memory safety
- 📡 Native Event Callbacks: Full Rust trait-based event callback system
- 🌐 Multi-platform: Supports macOS ARM64 and Linux x86_64
- ⚡ Async Support: Built on tokio for async operations
- 🛡️ Type Safety: Complete Rust type definitions with compile-time checks
§Version 0.4.9 - Market Data Structure Complete Compatibility
This version achieves complete compatibility with Python shioaji market data structures:
- TickSTKv1 - 24 fields, complete compatibility with Python definition
- TickFOPv1 - 19 fields, complete compatibility with Python definition
- BidAskSTKv1 - 11 fields, complete compatibility with Python definition
- BidAskFOPv1 - 16 fields, complete compatibility with Python definition
- QuoteSTKv1 - 35 fields, complete compatibility with Python definition
§Quick Start
use rshioaji::{Shioaji, Exchange, TickSTKv1};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Shioaji::new(true, HashMap::new())?;
client.init().await?;
// Register stock tick callback
client.on_tick_stk_v1(|exchange: Exchange, tick: TickSTKv1| {
println!("Received tick for {}: {}", tick.code, tick.close);
}, false).await?;
// Register system event callback
client.on_event(|resp_code, event_code, info, event| {
println!("System event: {} {} - {} {}", resp_code, event_code, info, event);
}).await?;
Ok(())
}Re-exports§
pub use callbacks::BidAskCallback;pub use callbacks::EventHandlers;pub use callbacks::OrderCallback;pub use callbacks::QuoteCallback;pub use callbacks::SystemCallback;pub use callbacks::TickCallback;pub use client::Shioaji;pub use config::Config;pub use error::Error;pub use error::Result;pub use platform::Platform;pub use utils::check_contract_cache;pub use utils::clear_outdated_contract_cache;pub use utils::get_contract_folder;pub use utils::init_logging;pub use utils::raise_resp_error;pub use utils::set_error_tracking;pub use utils::status_error_wrapper;pub use utils::timeout_exception;pub use utils::EnvironmentConfig;pub use types::accounts::*;pub use types::constants::*;pub use types::contracts::*;pub use types::market_data::*;pub use types::orders::*;pub use types::positions::*;
Modules§
Macros§
- impl_
callbacks - Convenience macro for implementing multiple callback traits on a single struct