-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkuna.js
181 lines (169 loc) · 8.5 KB
/
kuna.js
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
'use strict';
// ---------------------------------------------------------------------------
const acx = require ('./acx.js');
const { ExchangeError } = require ('./base/errors');
// ---------------------------------------------------------------------------
module.exports = class kuna extends acx {
describe () {
return this.deepExtend (super.describe (), {
'id': 'kuna',
'name': 'Kuna',
'countries': 'UA',
'rateLimit': 1000,
'version': 'v2',
'has': {
'CORS': false,
'fetchTickers': false,
'fetchOHLCV': false,
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/31697638-912824fa-b3c1-11e7-8c36-cf9606eb94ac.jpg',
'api': 'https://kuna.io',
'www': 'https://kuna.io',
'doc': 'https://kuna.io/documents/api',
'fees': 'https://kuna.io/documents/api',
},
'api': {
'public': {
'get': [
'tickers/{market}',
'order_book',
'order_book/{market}',
'trades',
'trades/{market}',
'timestamp',
],
},
'private': {
'get': [
'members/me',
'orders',
'trades/my',
],
'post': [
'orders',
'order/delete',
],
},
},
'markets': {
'BTC/UAH': { 'id': 'btcuah', 'symbol': 'BTC/UAH', 'base': 'BTC', 'quote': 'UAH', 'precision': { 'amount': 6, 'price': 0 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 1, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'ETH/UAH': { 'id': 'ethuah', 'symbol': 'ETH/UAH', 'base': 'ETH', 'quote': 'UAH', 'precision': { 'amount': 6, 'price': 0 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 1, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'GBG/UAH': { 'id': 'gbguah', 'symbol': 'GBG/UAH', 'base': 'GBG', 'quote': 'UAH', 'precision': { 'amount': 3, 'price': 2 }, 'lot': 0.001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 0.01, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}}, // Golos Gold (GBG != GOLOS)
'KUN/BTC': { 'id': 'kunbtc', 'symbol': 'KUN/BTC', 'base': 'KUN', 'quote': 'BTC', 'precision': { 'amount': 6, 'price': 6 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 0.000001, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'BCH/BTC': { 'id': 'bchbtc', 'symbol': 'BCH/BTC', 'base': 'BCH', 'quote': 'BTC', 'precision': { 'amount': 6, 'price': 6 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 0.000001, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'BCH/UAH': { 'id': 'bchuah', 'symbol': 'BCH/UAH', 'base': 'BCH', 'quote': 'UAH', 'precision': { 'amount': 6, 'price': 0 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 1, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'WAVES/UAH': { 'id': 'wavesuah', 'symbol': 'WAVES/UAH', 'base': 'WAVES', 'quote': 'UAH', 'precision': { 'amount': 6, 'price': 0 }, 'lot': 0.000001, 'limits': { 'amount': { 'min': 0.000001, 'max': undefined }, 'price': { 'min': 1, 'max': undefined }, 'cost': { 'min': 0.000001, 'max': undefined }}},
'ARN/BTC': { 'id': 'arnbtc', 'symbol': 'ARN/BTC', 'base': 'ARN', 'quote': 'BTC' },
'B2B/BTC': { 'id': 'b2bbtc', 'symbol': 'B2B/BTC', 'base': 'B2B', 'quote': 'BTC' },
'EVR/BTC': { 'id': 'evrbtc', 'symbol': 'EVR/BTC', 'base': 'EVR', 'quote': 'BTC' },
'GOL/GBG': { 'id': 'golgbg', 'symbol': 'GOL/GBG', 'base': 'GOL', 'quote': 'GBG' },
'R/BTC': { 'id': 'rbtc', 'symbol': 'R/BTC', 'base': 'R', 'quote': 'BTC' },
'RMC/BTC': { 'id': 'rmcbtc', 'symbol': 'RMC/BTC', 'base': 'RMC', 'quote': 'BTC' },
},
'fees': {
'trading': {
'taker': 0.25 / 100,
'maker': 0.25 / 100,
},
'funding': {
'withdraw': {
'UAH': '1%',
'BTC': 0.001,
'BCH': 0.001,
'ETH': 0.01,
'WAVES': 0.01,
'GOL': 0.0,
'GBG': 0.0,
// 'RMC': 0.001 BTC
// 'ARN': 0.01 ETH
// 'R': 0.01 ETH
// 'EVR': 0.01 ETH
},
'deposit': {
// 'UAH': (amount) => amount * 0.001 + 5
},
},
},
});
}
async fetchOrderBook (symbol, limit = undefined, params = {}) {
let market = this.market (symbol);
let orderBook = await this.publicGetOrderBook (this.extend ({
'market': market['id'],
}, params));
return this.parseOrderBook (orderBook, undefined, 'bids', 'asks', 'price', 'remaining_volume');
}
async fetchL3OrderBook (symbol, limit = undefined, params = {}) {
return this.fetchOrderBook (symbol, limit, params);
}
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
if (!symbol)
throw new ExchangeError (this.id + ' fetchOpenOrders requires a symbol argument');
let market = this.market (symbol);
let orders = await this.privateGetOrders (this.extend ({
'market': market['id'],
}, params));
// todo emulation of fetchClosedOrders, fetchOrders, fetchOrder
// with order cache + fetchOpenOrders
// as in BTC-e, Liqui, Yobit, DSX, Tidex, WEX
return this.parseOrders (orders, market, since, limit);
}
parseTrade (trade, market = undefined) {
let timestamp = this.parse8601 (trade['created_at']);
let symbol = undefined;
if (market)
symbol = market['symbol'];
return {
'id': trade['id'].toString (),
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'symbol': symbol,
'type': undefined,
'side': undefined,
'price': parseFloat (trade['price']),
'amount': parseFloat (trade['volume']),
'info': trade,
};
}
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
let market = this.market (symbol);
let response = await this.publicGetTrades (this.extend ({
'market': market['id'],
}, params));
return this.parseTrades (response, market, since, limit);
}
parseMyTrade (trade, market) {
let timestamp = this.parse8601 (trade['created_at']);
let symbol = undefined;
if (market)
symbol = market['symbol'];
return {
'id': trade['id'],
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'price': trade['price'],
'amount': trade['volume'],
'cost': trade['funds'],
'symbol': symbol,
'side': trade['side'],
'order': trade['order_id'],
};
}
parseMyTrades (trades, market = undefined) {
let parsedTrades = [];
for (let i = 0; i < trades.length; i++) {
let trade = trades[i];
let parsedTrade = this.parseMyTrade (trade, market);
parsedTrades.push (parsedTrade);
}
return parsedTrades;
}
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
if (!symbol)
throw new ExchangeError (this.id + ' fetchOpenOrders requires a symbol argument');
let market = this.market (symbol);
let response = await this.privateGetTradesMy ({ 'market': market['id'] });
return this.parseMyTrades (response, market);
}
};