-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbleutrade.js
166 lines (158 loc) · 6.02 KB
/
bleutrade.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
'use strict';
// ---------------------------------------------------------------------------
const bittrex = require ('./bittrex.js');
const { AuthenticationError, InvalidOrder, InsufficientFunds, DDoSProtection } = require ('./base/errors');
// ---------------------------------------------------------------------------
module.exports = class bleutrade extends bittrex {
describe () {
return this.deepExtend (super.describe (), {
'id': 'bleutrade',
'name': 'Bleutrade',
'countries': 'BR', // Brazil
'rateLimit': 1000,
'version': 'v2',
'has': {
'CORS': true,
'fetchTickers': true,
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/30303000-b602dbe6-976d-11e7-956d-36c5049c01e7.jpg',
'api': {
'public': 'https://bleutrade.com/api',
'account': 'https://bleutrade.com/api',
'market': 'https://bleutrade.com/api',
},
'www': 'https://bleutrade.com',
'doc': 'https://bleutrade.com/help/API',
'fees': 'https://bleutrade.com/help/fees_and_deadlines',
},
'fees': {
'funding': {
'withdraw': {
'ADC': 0.1,
'BTA': 0.1,
'BITB': 0.1,
'BTC': 0.001,
'BCC': 0.001,
'BTCD': 0.001,
'BTG': 0.001,
'BLK': 0.1,
'CDN': 0.1,
'CLAM': 0.01,
'DASH': 0.001,
'DCR': 0.05,
'DGC': 0.1,
'DP': 0.1,
'DPC': 0.1,
'DOGE': 10.0,
'EFL': 0.1,
'ETH': 0.01,
'EXP': 0.1,
'FJC': 0.1,
'BSTY': 0.001,
'GB': 0.1,
'NLG': 0.1,
'HTML': 1.0,
'LTC': 0.001,
'MONA': 0.01,
'MOON': 1.0,
'NMC': 0.015,
'NEOS': 0.1,
'NVC': 0.05,
'OK': 0.1,
'PPC': 0.1,
'POT': 0.1,
'XPM': 0.001,
'QTUM': 0.1,
'RDD': 0.1,
'SLR': 0.1,
'START': 0.1,
'SLG': 0.1,
'TROLL': 0.1,
'UNO': 0.01,
'VRC': 0.1,
'VTC': 0.1,
'XVP': 0.1,
'WDC': 0.001,
'ZET': 0.1,
},
},
},
});
}
async fetchMarkets () {
let markets = await this.publicGetMarkets ();
let result = [];
for (let p = 0; p < markets['result'].length; p++) {
let market = markets['result'][p];
let id = market['MarketName'];
let base = market['MarketCurrency'];
let quote = market['BaseCurrency'];
base = this.commonCurrencyCode (base);
quote = this.commonCurrencyCode (quote);
let symbol = base + '/' + quote;
let precision = {
'amount': 8,
'price': 8,
};
let active = market['IsActive'];
result.push ({
'id': id,
'symbol': symbol,
'base': base,
'quote': quote,
'active': active,
'info': market,
'lot': Math.pow (10, -precision['amount']),
'precision': precision,
'limits': {
'amount': {
'min': market['MinTradeSize'],
'max': undefined,
},
'price': {
'min': undefined,
'max': undefined,
},
'cost': {
'min': 0,
'max': undefined,
},
},
});
}
return result;
}
getOrderIdField () {
return 'orderid';
}
async fetchOrderBook (symbol, limit = undefined, params = {}) {
await this.loadMarkets ();
let request = {
'market': this.marketId (symbol),
'type': 'ALL',
};
if (typeof limit !== 'undefined')
request['depth'] = limit; // 50
let response = await this.publicGetOrderbook (this.extend (request, params));
let orderbook = response['result'];
return this.parseOrderBook (orderbook, undefined, 'buy', 'sell', 'Rate', 'Quantity');
}
throwExceptionOnError (response) {
if ('message' in response) {
if (response['message'] === 'Insufficient funds!')
throw new InsufficientFunds (this.id + ' ' + this.json (response));
if (response['message'] === 'MIN_TRADE_REQUIREMENT_NOT_MET')
throw new InvalidOrder (this.id + ' ' + this.json (response));
if (response['message'] === 'APIKEY_INVALID') {
if (this.hasAlreadyAuthenticatedSuccessfully) {
throw new DDoSProtection (this.id + ' ' + this.json (response));
} else {
throw new AuthenticationError (this.id + ' ' + this.json (response));
}
}
if (response['message'] === 'DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT')
throw new InvalidOrder (this.id + ' order cost should be over 50k satoshi ' + this.json (response));
}
}
};