Skip to content

Commit

Permalink
multiple edits to ccxt#473
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 8, 2017
2 parents dcbfeb9 + df98fa4 commit ab4ae3c
Show file tree
Hide file tree
Showing 9 changed files with 629 additions and 560 deletions.
8 changes: 4 additions & 4 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ You can call the unified ``fetchTrades`` / ``fetch_trades`` method to get the li

::

async fetchTrades (symbol, params = {})
async fetchTrades (symbol, since = undefined, limit = undefined, params = {})

For example, if you want to print recent trades for all symbols one by one sequentially (mind the rateLimit!) you would do it like so:

Expand Down Expand Up @@ -1455,21 +1455,21 @@ All Orders

.. code:: javascript
exchange.fetchOrders (symbol = undefined, params = {})
exchange.fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {})
Open Orders
^^^^^^^^^^^

.. code:: javascript
exchange.fetchOpenOrders (symbol = undefined, params = {})
exchange.fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {})
Closed Orders
^^^^^^^^^^^^^

.. code:: javascript
exchange.fetchClosedOrders (symbol = undefined, params = {})
exchange.fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {})
Trades / Transactions / Fills / Executions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions examples/js/exchange-capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ccxt = require ('../../ccxt.js')
'hasFetchOpenOrders',
'hasFetchClosedOrders',
'hasFetchMyTrades',
'hasFetchCurrencies',
'hasDeposit',
'hasWithdraw',

Expand Down
24 changes: 15 additions & 9 deletions js/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ module.exports = class Exchange {
this.hasPublicAPI = true
this.hasPrivateAPI = true
this.hasCORS = false
this.hasFetchTicker = true
this.hasFetchOrderBook = true
this.hasFetchTrades = true
this.hasFetchTickers = false
this.hasFetchOHLCV = false
this.hasDeposit = false
this.hasFetchBalance = true
this.hasFetchOrder = false
this.hasFetchOrders = false
this.hasFetchOpenOrders = false
this.hasFetchClosedOrders = false
this.hasFetchCurrencies = false
this.hasFetchMyTrades = false
this.hasDeposit = false
this.hasFetchOHLCV = false
this.hasFetchOpenOrders = false
this.hasFetchOrder = false
this.hasFetchOrderBook = true
this.hasFetchOrders = false
this.hasFetchTicker = true
this.hasFetchTickers = false
this.hasFetchTrades = true
this.hasWithdraw = false
this.hasCreateOrder = this.hasPrivateAPI
this.hasCancelOrder = this.hasPrivateAPI
Expand All @@ -98,6 +99,7 @@ module.exports = class Exchange {
'fetchOpenOrders': false,
'fetchClosedOrders': false,
'fetchMyTrades': false,
'fetchCurrencies': false,
'withdraw': false,
}

Expand Down Expand Up @@ -444,6 +446,10 @@ module.exports = class Exchange {
throw new NotSupported (this.id + ' fetchMyTrades not supported yet');
}

fetchCurrencies () {
throw new NotSupported (this.id + ' fetchCurrencies not supported yet');
}

fetchMarkets () {
return new Promise ((resolve, reject) => resolve (this.markets))
}
Expand Down
40 changes: 40 additions & 0 deletions js/bittrex.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = class bittrex extends Exchange {
'hasFetchClosedOrders': true,
'hasFetchOpenOrders': true,
'hasFetchMyTrades': false,
'hasFetchCurrencies': true,
'hasWithdraw': true,
// new metainfo interface
'has': {
Expand All @@ -35,6 +36,7 @@ module.exports = class bittrex extends Exchange {
'fetchClosedOrders': 'emulated',
'fetchOpenOrders': true,
'fetchMyTrades': false,
'fetchCurrencies': true,
'withdraw': true,
},
'timeframes': {
Expand Down Expand Up @@ -222,6 +224,44 @@ module.exports = class bittrex extends Exchange {
};
}

async fetchCurrencies () {
let response = await this.publicGetCurrencies ();
let currencies = response['result'];
let result = [];
for (let i = 0; c < currencies.length; i++) {
let currency = currencies[i];
let id = currency['Currency'];
// todo: will need to rethink the fees
// to add support for multiple withdrawal/deposit methods and
// differentiated fees for each particular method
result.push ({
'id': id,
'code': this.commonCurrencyCode (id),
'active': currency['IsActive'],
'fees': currency['TxFee'], // todo: redesign
'precision': {
'amount': 8, // default precision, todo: fix "magic constants"
'price': 8,
},
'limits': {
'amount': {
'min': undefined,
'max': undefined,
},
'price': {
'min': undefined,
'max': undefined,
},
'cost': {
'min': undefined,
'max': undefined,
}
},
});
}
return result;
}

async fetchTickers (symbols = undefined, params = {}) {
await this.loadMarkets ();
let response = await this.publicGetMarketsummaries (params);
Expand Down
17 changes: 17 additions & 0 deletions js/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,23 @@ let testMyTrades = async (exchange, symbol) => {

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

let testFetchCurrencies = async (exchange, symbol) => {

if (exchange.hasFetchCurrencies) {

// log ('fetching currencies...')
let currencies = await exchange.fetchCurrencies ()
log ('fetched', currencies.length.toString ().green, 'currencies')
// log (asTable (currencies))

} else {

log ('fetching currencies not supported')
}
}

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

let testBalance = async (exchange, symbol) => {

log ('fetching balance...')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"build": "npm run export-exchanges && npm run vss && npm run pandoc-python-readme && npm run pandoc-doc-readme && npm run pandoc-doc-manual && npm run pandoc-doc-install && npm run pandoc-doc-exchanges && npm run pandoc-doc-exchanges-by-country && npm run transpile && npm run update-badges && npm run browserify",
"test": "npm run build && node run-tests",
"fasttest": "node run-tests --js",
"fast-test": "node run-tests --js",
"test-base": "mocha --reporter spec js/test/test_base.js",
"export-exchanges": "node export-exchanges",
"update-badges": "node update-badges",
Expand Down
19 changes: 10 additions & 9 deletions php/base/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,19 +456,20 @@ public function __construct ($options = array ()) {
$this->hasPublicAPI = true;
$this->hasPrivateAPI = true;
$this->hasCORS = false;
$this->hasFetchTicker = true;
$this->hasFetchOrderBook = true;
$this->hasFetchTrades = true;
$this->hasFetchTickers = false;
$this->hasFetchOHLCV = false;
$this->hasDeposit = false;
$this->hasWithdraw = false;
$this->hasFetchBalance = true;
$this->hasFetchOrder = false;
$this->hasFetchOrders = false;
$this->hasFetchOpenOrders = false;
$this->hasFetchClosedOrders = false;
$this->hasFetchCurrencies = false;
$this->hasFetchMyTrades = false;
$this->hasFetchOHLCV = false;
$this->hasFetchOpenOrders = false;
$this->hasFetchOrder = false;
$this->hasFetchOrderBook = true;
$this->hasFetchOrders = false;
$this->hasFetchTicker = true;
$this->hasFetchTickers = false;
$this->hasFetchTrades = true;
$this->hasWithdraw = false;
$this->hasCreateOrder = $this->hasPrivateAPI;
$this->hasCancelOrder = $this->hasPrivateAPI;

Expand Down
18 changes: 10 additions & 8 deletions python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,25 @@ class Exchange(object):
hasFetchOpenOrders = False
hasFetchClosedOrders = False
hasFetchMyTrades = False
hasFetchCurrencies = False
hasCreateOrder = hasPrivateAPI
hasCancelOrder = hasPrivateAPI

# API method metainfo
has = {
'deposit': False,
'fetchTicker': True,
'fetchOrderBook': True,
'fetchTrades': True,
'fetchTickers': False,
'fetchOHLCV': False,
'fetchBalance': True,
'fetchOrder': False,
'fetchOrders': False,
'fetchOpenOrders': False,
'fetchClosedOrders': False,
'fetchCurrencies': False,
'fetchMyTrades': False,
'fetchOHLCV': False,
'fetchOpenOrders': False,
'fetchOrder': False,
'fetchOrderBook': True,
'fetchOrders': False,
'fetchTicker': True,
'fetchTickers': False,
'fetchTrades': True,
'withdraw': False,
}

Expand Down
Loading

0 comments on commit ab4ae3c

Please sign in to comment.