File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " zaif-api"
3- version = " 0.2 .0"
3+ version = " 0.3 .0"
44authors = [" yajamon <yajamon.tatsuki@gmail.com>" ]
55
66license = " MIT"
Original file line number Diff line number Diff line change @@ -20,17 +20,31 @@ use zaif_api::public_api::*;
2020use zaif_api :: trade_api :: * ;
2121
2222fn main () {
23- let api = public_api :: DepthBuilder :: new (). currency_pair (" btc_jpy" ). finalize ();
24- println! (" {}" , api . exec (). unwrap ());
23+ let api = CurrenciesBuilder :: new (). name (" btc" . to_string ()). finalize ();
24+ for currency in api . exec (). unwrap () {
25+ println! (" name: {} is_token: {}" , currency . name, currency . is_token);
26+ }
2527
2628 let access_key = AccessKey :: new (" YOUR_API_KEY" , " YOUR_API_SECRET" );
2729
28- let api = TradeBuilder :: new (access_key . clone ())
29- . currency_pair (" zaif_jpy" )
30+ let api = TradeBuilder :: new ()
31+ . access_key (access_key . clone ())
32+ . currency_pair (" zaif_jpy" . to_string ())
3033 . action (TradeAction :: Bid )
3134 . price (1.0 )
3235 . amount (0.1 )
3336 . finalize ();
34- println! (" {}" , api . exec (). unwrap ());
37+ let _ = api . exec (). and_then (| res | {
38+ println! (
39+ " received: {}, remains: {}, order_id: {}" ,
40+ res . received,
41+ res . remains,
42+ res . order_id
43+ );
44+ if res . order_id == 0 {
45+ panic! (" Complete trade." );
46+ }
47+ Ok (res . order_id)
48+ });
3549}
3650```
You can’t perform that action at this time.
0 commit comments