Repository navigation
Expand file tree
/
Copy pathbinance_deposit_withdrawal_example.rs
More file actions
78 lines (67 loc) · 2.37 KB
/
Copy pathbinance_deposit_withdrawal_example.rs
File metadata and controls
78 lines (67 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Binance Deposit/Withdrawal Example
//!
//! Note: Deposit and withdrawal methods are not yet migrated to the new modular structure.
//! This is a placeholder example.
//!
//! # Running the Example
//!
//! ```bash
//! cargo run --example binance_deposit_withdrawal_example
//! ```
use ccxt_core::ExchangeConfig;
use ccxt_exchanges::binance::Binance;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("=================================");
println!("Binance Deposit/Withdrawal Example");
println!("=================================\n");
let config = ExchangeConfig {
api_key: std::env::var("BINANCE_API_KEY")
.ok()
.map(ccxt_core::SecretString::new),
secret: std::env::var("BINANCE_API_SECRET")
.ok()
.map(ccxt_core::SecretString::new),
..Default::default()
};
let _binance = Binance::new(config)?;
// Note: Deposit and withdrawal methods are not yet migrated to the new modular structure:
// - fetch_deposits
// - fetch_withdrawals
// - withdraw
println!(
"Note: Deposit and withdrawal methods are not yet migrated to the new modular structure."
);
println!(" See rest_old.rs for the original implementations.\n");
println!("Code examples (not executable until methods are migrated):");
println!(
r#"
// Fetch deposits (using i64 timestamps)
let deposits = binance.fetch_deposits(
Some("BTC"), // Currency filter
None, // Since timestamp (Option<i64> - milliseconds since Unix epoch)
Some(100), // Limit
None, // Optional parameters
).await?;
// Fetch withdrawals (using i64 timestamps)
let withdrawals = binance.fetch_withdrawals(
Some("USDT"), // Currency filter
None, // Since timestamp (Option<i64> - milliseconds since Unix epoch)
Some(100), // Limit
None, // Optional parameters
).await?;
// Withdraw
let result = binance.withdraw(
"USDT", // Currency
100.0, // Amount
"0x1234...", // Address
None, // Tag (for some currencies)
None, // Optional parameters
).await?;
"#
);
println!("\n=================================");
println!("Example completed!");
println!("=================================");
Ok(())
}