-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathpublic_endpoints.rs
82 lines (72 loc) · 2.46 KB
/
public_endpoints.rs
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
79
80
81
82
extern crate bitfinex;
use bitfinex::api::*;
use bitfinex::pairs::*;
use bitfinex::currency::*;
use bitfinex::precision::*;
fn main() {
let api = Bitfinex::new(None, None);
// TICKER
let trading_pair = api.ticker.trading_pair(ETHUSD);
match trading_pair {
Ok(answer) => println!("bid: {:?} ask: {:?}", answer.bid, answer.ask),
Err(e) => println!("Error: {}", e),
}
let funding_currency = api.ticker.funding_currency(USD);
match funding_currency {
Ok(answer) => println!("bid: {:?} ask: {:?}", answer.bid, answer.ask),
Err(e) => println!("Error: {}", e),
}
// TRADES
let trading_pairs = api.trades.trading_pair(ETHUSD);
match trading_pairs {
Ok(trades) => {
for trade in &trades {
println!("Trading => amount: {:?} price: {:?}", trade.amount, trade.price);
}
},
Err(e) => println!("Error: {}", e),
}
let funding_currency = api.trades.funding_currency(USD);
match funding_currency {
Ok(trades) => {
for trade in &trades {
println!("Funding => amount: {:?} price: {:?}", trade.amount, trade.price);
}
},
Err(e) => println!("Error: {}", e),
}
// BOOK
let trading_pairs = api.book.trading_pair(ETHUSD, P0);
match trading_pairs {
Ok(books) => {
for book in &books {
println!("Trading => price: {:?} amount: {:?}", book.price, book.amount);
}
},
Err(e) => println!("Error: {}", e),
}
let funding_currency = api.book.funding_currency(USD, P0);
match funding_currency {
Ok(books) => {
for book in &books {
println!("Funding => rate: {:?} amount: {:?}", book.rate, book.amount);
}
},
Err(e) => println!("Error: {}", e),
}
// CANDLES
let last = api.candles.last(ETHUSD, "1m");
match last {
Ok(answer) => println!("Candle Last => High: {:?} low: {:?}", answer.high, answer.low),
Err(e) => println!("Error: {}", e),
}
let history = api.candles.history(ETHUSD, "12h", &CandleHistoryParams::new());
match history {
Ok(candles) => {
for candle in &candles {
println!("Candle History => High: {:?} Low: {:?}", candle.high, candle.low);
}
},
Err(e) => println!("Error: {}", e),
}
}