Skip to content

Commit

Permalink
1.10.851
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Jan 26, 2018
1 parent d4796c1 commit 59c7f9a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build/ccxt.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.10.850'
const version = '1.10.851'

Exchange.ccxtVersion = version

Expand Down
34 changes: 30 additions & 4 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,39 @@ The endpoint URLs are predefined in the ``api`` property for each exchange. You
Implicit API Methods
--------------------

In the code for each exchange, you'll notice that functions that make API requests aren't explicitly defined. This is because the ``api`` definition in the exchange description JSON is used to create *magic functions* (aka *partial functions* or *closures*) inside the exchange subclass. That implicit injection is done by the ``defineRestApi/define_rest_api`` base exchange method.
ccxt uses a declarative approach for defining exchange's native (non-unified) API methods.
These methods are declared in exchange's ``api`` property in the following manner:

Each partial function takes a dictionary of ``params`` and returns the API response. For example, if an exchange offers a HTTP GET URL for querying prices like ``https://example.com/public/quotes``, it is converted to a method named ``example.publicGetQuotes (params = {}) / $example->publicGetQuotes ($params = array ())``.
::

'api': {
'public': { // type
'get': [ // http method
'products', // path
'open/tick', // another path
...
],
},
'private': {
'post': [
'order/{id}',
...
],
'put': [
'order/{id}/cancel',
...
],
},
},

Upon exchange instantiation ``defineRestApi/define_rest_api`` base exchange method will use these declarations to create
*magic functions* (aka *partial functions* or *closures*) inside the exchange subclass.

Taken the example above these magic functions will take the names of ``publicGetProducts``, ``publicGetOpenTick``, ``privatePostOrderId``, ``privatePutOrdersIdCancel``.

Upon instantiation the base exchange class takes each URL from its list of endpoints, splits it into words, and then makes up a callable function name from those words by using a partial construct.
When you call one of these magic functions (e.g. ``privatePutOrdersIdCancel ({ id: 100 })``), it will call ccxt's ``request`` method with ``type``, ``http method``, ``path`` and ``params`` arguments. In turn, ``request`` then implodes ``params`` into ``path`` (and ``query`` if necessary), adds ``scheme`` ([http\|https]) / ``host`` and performs actual ``fetch`` which will return raw API response.

The endpoint definition is a **full list of ALL API URLs** exposed by an exchange. This list gets converted to callable methods upon exchange instantiation. Each URL in the API endpoint list gets a corresponding callable method. This is done automatically for all exchanges, therefore the ccxt library supports **all possible URLs** offered by crypto exchanges.
The endpoints definition is a **full list of ALL API URLs** exposed by an exchange. This list gets converted to callable methods upon exchange instantiation. Each URL in the API endpoint list gets a corresponding callable method. This is done automatically for all exchanges, therefore the ccxt library supports **all possible URLs** offered by crypto exchanges.

Public/Private API
------------------
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.10.850",
"version": "1.10.851",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 90+ exchanges",
"main": "./ccxt.js",
"unpkg": "build/ccxt.browser.js",
Expand Down
2 changes: 1 addition & 1 deletion php/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace ccxt;

$version = '1.10.850';
$version = '1.10.851';

abstract class Exchange {

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# ----------------------------------------------------------------------------

__version__ = '1.10.850'
__version__ = '1.10.851'

# ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.850'
__version__ = '1.10.851'

# -----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.850'
__version__ = '1.10.851'

# -----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.10.850'
__version__ = '1.10.851'

# -----------------------------------------------------------------------------

Expand Down

0 comments on commit 59c7f9a

Please sign in to comment.