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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
use indexmap::map::IndexMap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use super::{
AssetPairInfo, EndpointInfo, Input, InputList, InputListItem, IntoInputList, KAssetPair,
KrakenInput, MethodType, MutateInput, Output, UpdateInput,
};
pub struct KIAssetPairs {
params: IndexMap<String, String>,
}
impl KIAssetPairs {
pub fn build() -> Self {
KIAssetPairs {
params: IndexMap::new(),
}
}
pub fn clear_pair_list(self) -> Self {
self.update_input("pair", String::from(""))
}
pub fn with_asset_pair(self, pair: KAssetPair) -> Self {
self.with_item(pair)
}
pub fn with_asset_pair_list<T>(self, pairs: T) -> Self
where
T: IntoIterator<Item = KAssetPair>,
{
self.with_item_list(pairs)
}
pub fn info(self, info: AssetPairInfo) -> Self {
self.update_input("info", info.to_string())
}
}
impl Input for KIAssetPairs {
fn finish(self) -> KrakenInput {
KrakenInput {
info: EndpointInfo {
methodtype: MethodType::Public,
endpoint: String::from("AssetPairs"),
},
params: Some(self.params),
}
}
fn finish_clone(self) -> (KrakenInput, Self) {
(
KrakenInput {
info: EndpointInfo {
methodtype: MethodType::Public,
endpoint: String::from("AssetPairs"),
},
params: Some(self.params.clone()),
},
self,
)
}
}
impl MutateInput for KIAssetPairs {
fn list_mut(&mut self) -> &mut IndexMap<String, String> {
&mut self.params
}
}
impl UpdateInput for KIAssetPairs {}
impl IntoInputList for KIAssetPairs {
fn list_name(&self) -> String {
String::from("pair")
}
}
impl InputListItem for KIAssetPairs {
type ListItem = KAssetPair;
}
impl InputList for KIAssetPairs {}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOAssetPair {
pub aclass_base: String,
pub aclass_quote: String,
pub altname: String,
pub base: String,
pub fee_volume_currency: String,
pub fees: Vec<(u64, f64)>,
pub fees_maker: Option<Vec<(u64, f64)>>,
pub leverage_buy: Vec<u32>,
pub leverage_sell: Vec<u32>,
pub lot: String,
pub lot_decimals: u32,
pub lot_multiplier: u32,
pub margin_call: u32,
pub margin_stop: u32,
pub ordermin: Option<String>,
pub pair_decimals: u32,
pub quote: String,
pub wsname: Option<String>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KOAssetPairInfo {
#[serde(flatten)]
pub pair: HashMap<KAssetPair, KOAssetPair>,
}
impl Output for KOAssetPairInfo {}