Crates.io | rtpx |
lib.rs | rtpx |
version | 1.0.2 |
source | src |
created_at | 2024-12-02 18:27:41.090359 |
updated_at | 2024-12-09 21:28:49.093363 |
description | Safe Rust bindings for CTP (Comprehensive Transaction Platform) and its variations for Chinese financial markets |
homepage | https://github.com/glacierx/RTP |
repository | https://github.com/glacierx/RTP |
max_upload_size | |
id | 1469098 |
size | 23,010,173 |
Rust binding for CTP and it's variations
rtp
provides safe and ergonomic Rust bindings for the CTP (Comprehensive Transaction Platform) trading system, widely used in Chinese financial markets. This project aims to bring Rust's safety and performance guarantees to the CTP ecosystem while maintaining compatibility with various CTP-compatible implementations.
sdk | version | original URL |
---|---|---|
CTP | 6.7.7_210240607 | http://www.sfit.com.cn/DocumentDown/api_3/5_2_2/v6.7.7_traderapi_20240607.zip |
ATP | 6.3.15 | N/A |
use rust_ctp::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new CTP client
let mut client = CtpTradingClient::new()
.front_addr("tcp://180.168.146.187:10130")
.broker_id("9999")
.build()?;
// Connect and login
client.connect().await?;
client.login("YOUR_USERNAME", "YOUR_PASSWORD").await?;
// Subscribe to market data
client.subscribe(&["rb2410"]).await?;
// Handle market data
while let Some(data) = client.next_tick().await {
println!("Received tick: {:?}", data);
}
Ok(())
}
Add this to your Cargo.toml
:
[dependencies]
rtp = "0.1.0"
# Clone the repository
git clone https://github.com/glacierx/rtp
cd rtp
# Build the project
cargo build --release
# Run tests
cargo test
For detailed documentation and examples, visit docs.rs/rtp.
The documentation includes:
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
This software is provided "as is", without warranty of any kind. Trading in financial markets carries significant risk. Make sure to test thoroughly in a simulated environment before using in production.
Licensed under either of
at your option.
Note: This is an unofficial Rust binding. CTP is a trademark of Shanghai Futures Exchange.