Repository navigation
Expand file tree
/
Copy pathbinance_margin_borrow_example.rs
More file actions
76 lines (65 loc) · 2.08 KB
/
Copy pathbinance_margin_borrow_example.rs
File metadata and controls
76 lines (65 loc) · 2.08 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
//! Binance Margin Borrow Example
//!
//! Note: Margin borrow methods are not yet migrated to the new modular structure.
//! This is a placeholder example.
//!
//! # Running the Example
//!
//! ```bash
//! cargo run --example binance_margin_borrow_example
//! ```
use ccxt_core::ExchangeConfig;
use ccxt_exchanges::binance::Binance;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("=================================");
println!("Binance Margin Borrow 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: Margin borrow methods are not yet migrated to the new modular structure:
// - borrow_margin
// - repay_margin
// - fetch_borrow_interest
println!("Note: Margin borrow 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#"
// Borrow margin
let result = binance.borrow_margin(
"BTC", // Asset
0.1, // Amount
"BTC/USDT", // Symbol
None, // Optional parameters
).await?;
// Repay margin
let result = binance.repay_margin(
"BTC", // Asset
0.1, // Amount
"BTC/USDT", // Symbol
None, // Optional parameters
).await?;
// Fetch borrow interest
let interests = binance.fetch_borrow_interest(
Some("BTC"), // Asset filter
None, // Symbol filter
None, // Since timestamp
Some(10), // Limit
None, // Optional parameters
).await?;
"#
);
println!("\n=================================");
println!("Example completed!");
println!("=================================");
Ok(())
}