Skip to content

Commit

Permalink
ccxt#208 nova wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Sep 17, 2017
1 parent 58fdd36 commit cee457e
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 1 deletion.
223 changes: 223 additions & 0 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -14944,6 +14944,228 @@ var mixcoins = {
},
}

//-----------------------------------------------------------------------------

var nova = {

'id': 'nova',
'name': 'Novaexchange',
'countries': 'US',
'rateLimit': 2000,
'version': 'v2',
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/30518571-78ca0bca-9b8a-11e7-8840-64b83a4a94b2.jpg',
'api': 'https://novaexchange.com/remote',
'www': 'https://novaexchange.com',
'doc': 'https://novaexchange.com/remote/faq',
},
'api': {
'public': {
'get': [
'markets/',
'markets/{basecurrency}',
'market/info/{pair}/',
'market/orderhistory/{pair}/',
'market/openorders/{pair}/buy/',
'market/openorders/{pair}/sell/',
'market/openorders/{pair}/both/',
'market/openorders/{pair}/{ordertype}/',
],
},
'private': {
'post': [
'getbalances/',
'getbalance/{currency}/',
'getdeposits/',
'getwithdrawals/',
'getnewdepositaddress/{currency}/',
'getdepositaddress/{currency}/',
'myopenorders/',
'myopenorders_market/{pair}/',
'cancelorder/{orderid}/',
'withdraw/{currency}/',
'trade/{pair}/',
'tradehistory/',
'getdeposithistory/',
'getwithdrawalhistory/',
'walletstatus/',
'walletstatus/{currency}/',
],
},
},

async fetchMarkets () {
let response = await this.publicGetMarkets ();
let markets = response['markets'];
let result = [];
for (let i = 0; i < markets.length; i++) {
let market = markets[i];
// let base = market['currency'];
// let quote = market['basecurrency'];
let id = market['marketname'];
let [ base, quote ] = id.split ('_');
let symbol = base + '/' + quote;
result.push ({
'id': id,
'symbol': symbol,
'base': base,
'quote': quote,
'info': market,
});
}
return result;
},

async fetchOrderBook (symbol, params = {}) {
let orderbook = await this.publicGetMarketOpenordersPairBoth (this.extend ({
'pair': this.marketId (symbol),
}, params));
return this.parseOrderBook (orderbook, undefined, 'buyorders', 'sellorders', 'price', 'amount');
},

async fetchTicker (symbol) {
let response = await this.publicGetMarketInfoPair ({
'pair': this.marketId (symbol),
});
let ticker = response['markets'][0];
let timestamp = this.milliseconds ();
let bid = undefined;
let ask = undefined;
if ('bid' in ticker)
if (ticker['bid'])
bid = parseFloat (ticker['bid']);
if ('ask' in ticker)
if (ticker['ask'])
ask = parseFloat (ticker['ask']);
return {
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'high': parseFloat (ticker['high24h']),
'low': parseFloat (ticker['low24h']),
'bid': bid,
'ask': ask,
'vwap': parseFloat (ticker['vwap24h']),
'open': parseFloat (ticker['openToday']),
'close': undefined,
'first': undefined,
'last': parseFloat (ticker['last_price']),
'change': undefined,
'percentage': undefined,
'average': undefined,
'baseVolume': undefined,
'quoteVolume': parseFloat (ticker['volume24h']),
'info': ticker,
};
},

parseTrade (trade, market) {
let timestamp = this.parse8601 (trade['timestamp']);
let id = trade['matchNumber'].toString ();
return {
'info': trade,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'symbol': market['symbol'],
'id': id,
'order': id,
'type': undefined,
'side': undefined,
'price': parseFloat (trade['price']),
'amount': parseFloat (trade['amount']),
};
},

async fetchTrades (symbol, params = {}) {
let market = this.market (symbol);
let response = await this.publicGetMarketsSymbolTrades (this.extend ({
'symbol': market['id'],
}, params));
return this.parseTrades (response['recentTrades'], market);
},

async fetchBalance (params = {}) {
let response = await this.privateGetBalances ();
let balances = response['balances'];
let result = { 'info': response };
for (let b = 0; b < balances.length; b++) {
let balance = balances[b];
let currency = balance['currency'];
let account = {
'free': parseFloat (balance['availableBalance']),
'used': 0.0,
'total': parseFloat (balance['totalBalance']),
};
account['used'] = account['total'] - account['free'];
result[currency] = account;
}
return result;
},

fetchWallets () {
return this.privateGetWallets ();
},

nonce () {
return this.milliseconds ();
},

async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
if (type == 'market')
throw new ExchangeError (this.id + ' allows limit orders only');
amount = amount.toString ();
price = price.toString ();
let market = this.market (symbol);
let order = {
'side': side,
'type': type,
'currency': market['base'],
'amount': amount,
'display': amount,
'price': price,
'instrument': market['id'],
};
let response = await this.privatePostTradeAdd (this.extend (order, params));
return {
'info': response,
'id': response['id'],
};
},

async cancelOrder (id, params = {}) {
return this.privateDeleteWalletsWalletIdOrdersId (this.extend ({
'id': id,
}, params));
},

async request (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
let url = this.urls['api'] + '/' + this.version + '/';
if (api == 'private')
url += api + '/';
url += this.implodeParams (path, params);
let query = this.omit (params, this.extractParams (path));
if (api == 'public') {
if (Object.keys (query).length)
url += '?' + this.urlencode (query);
} else {
let nonce = this.nonce ().toString ();
url += '?' + this.urlencode ({ 'nonce': nonce });
let signature = this.hmac (this.encode (url), this.encode (this.secret), 'sha512', 'base64');
body = this.urlencode (this.extend ({
'apikey': this.apiKey,
'signature': signature,
}, query));
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
};
}
let response = this.fetch (url, method, headers, body);
if ('status' in response)
if (response['status'] != 'success')
throw new ExchangeError (this.id + ' ' + this.json (response));
return response;
},
}

//-----------------------------------------------------------------------------
// OKCoin
// China
Expand Down Expand Up @@ -18237,6 +18459,7 @@ var exchanges = {
'luno': luno,
'mercado': mercado,
'mixcoins': mixcoins,
'nova': nova,
'okcoincny': okcoincny,
'okcoinusd': okcoinusd,
'okex': okex,
Expand Down
1 change: 1 addition & 0 deletions keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"liqui": { "apiKey": "3CCPNOH2-7W0SYD8F-UNEVV304-NDU3MVJE-Z43H2I05", "secret": "9c6aad97f1e0b97b58fc3a69ac88b57483215f9b4037c668151d946871e177f4" },
"livecoin": { "apiKey": "W5z7bvQM2pEShvGmqq1bXZkb1MR32GKw", "secret": "n8FrknvqwsRnTpGeNAbC51waYdE4xxSB" },
"luno": { "apiKey": "nrpzg7rkd8pnf", "secret": "Ps0DXw0TpTzdJ2Yek8V5TzFDfTWzyU5vfLdCiBP6vsI" },
"nova": { "apiKey": "nrpzg7rkd8pnf", "secret": "Ps0DXw0TpTzdJ2Yek8V5TzFDfTWzyU5vfLdCiBP6vsI", "timeout": 30000 },
"okcoinusd": { "apiKey": "da83cf1b-6fdc-495a-af55-f809bec64e2b", "secret": "614D2E6D3428C2C5E54C81139A500BE0" },
"okex": { "apiKey": "da83cf1b-6fdc-495a-af55-f809bec64e2b", "secret": "614D2E6D3428C2C5E54C81139A500BE0" },
"poloniex": { "apiKey": "LWMI8IK7-A9213MUB-W02YZL9K-KSP9AY1M", "secret": "a4bbe32d3612d254689e930a9aca78c576f661f36c50e95012900b2109e19ebe8941f2827e09b7900fe6578a7edc431b9855930e2c535d3433ed056be3a3cab2" },
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ let tryAllProxies = async function (exchange, proxies) {
let maxRetries = proxies.length

// a special case for ccex
if (exchange.id == 'ccex')
if ((exchange.id == 'ccex') || (exchange.id == 'nova'))
currentProxy = 1

for (let numRetries = 0; numRetries < maxRetries; numRetries++) {
Expand Down

0 comments on commit cee457e

Please sign in to comment.