Skip to content

Commit

Permalink
moved js tests to js/, fixed cryptopia
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 1, 2017
1 parent 11ad29d commit ce9be20
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
42 changes: 21 additions & 21 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ Below is a detailed description of each of the base exchange properties:

- ``proxy``: A string literal containing base URL of http(s) proxy, ``''`` by default. For use with web browsers and from blocked locations. An example of a proxy string is ``'http://crossorigin.me/'``. The absolute exchange endpoint URL is appended to this string before sending the HTTP request.

- ``apiKey``: This is your public API key string literal. Most exchanges require this for trading (`see below <https://github.com/ccxt/ccxt/wiki/Manual#api-keys-setup>`__).
- ``apiKey``: This is your public API key string literal. Most exchanges require this for trading (`see below <https://github.com/kroitor/ccxt/wiki/Manual#api-keys-setup>`__).

- ``secret``: Your private secret API key string literal. Most exchanges require this as well together with the apiKey.

Expand Down Expand Up @@ -433,9 +433,9 @@ In case your calls hit a rate limit or get nonce errors, the ccxt library will t

A later retry is usually enough to handle that. More on that here:

- `Authentication <https://github.com/ccxt/ccxt/wiki/Manual#authentication>`__
- `Troubleshooting <https://github.com/ccxt/ccxt/wiki/Manual#troubleshooting>`__
- `Overriding The Nonce <https://github.com/ccxt/ccxt/wiki/Manual#overriding-the-nonce>`__
- `Authentication <https://github.com/ccxt-dev/ccxt/wiki/Manual#authentication>`__
- `Troubleshooting <https://github.com/ccxt-dev/ccxt/wiki/Manual#troubleshooting>`__
- `Overriding The Nonce <https://github.com/ccxt-dev/ccxt/wiki/Manual#overriding-the-nonce>`__

Markets
=======
Expand Down Expand Up @@ -859,13 +859,13 @@ Note, that most of methods of the unified API accept an optional ``params`` para
Market Data
===========

- `Order Book / Market Depth <https://github.com/ccxt/ccxt/wiki/Manual#order-book--market-depth>`__
- `Market Price <https://github.com/ccxt/ccxt/wiki/Manual#market-price>`__
- `Price Tickers <https://github.com/ccxt/ccxt/wiki/Manual#price-tickers>`__
- `Individually By Symbol <https://github.com/ccxt/ccxt/wiki/Manual#individually-by-symbol>`__
- `All At Once <https://github.com/ccxt/ccxt/wiki/Manual#all-at-once>`__
- `OHLCV Candlestick Charts <https://github.com/ccxt/ccxt/wiki/Manual#ohlcv-candlestick-charts>`__
- `Public Trades And Closed Orders <https://github.com/ccxt/ccxt/wiki/Manual#trades-orders-executions-transactions>`__
- `Order Book / Market Depth <https://github.com/kroitor/ccxt/wiki/Manual#order-book--market-depth>`__
- `Market Price <https://github.com/kroitor/ccxt/wiki/Manual#market-price>`__
- `Price Tickers <https://github.com/kroitor/ccxt/wiki/Manual#price-tickers>`__
- `Individually By Symbol <https://github.com/kroitor/ccxt/wiki/Manual#individually-by-symbol>`__
- `All At Once <https://github.com/kroitor/ccxt/wiki/Manual#all-at-once>`__
- `OHLCV Candlestick Charts <https://github.com/kroitor/ccxt/wiki/Manual#ohlcv-candlestick-charts>`__
- `Public Trades And Closed Orders <https://github.com/kroitor/ccxt/wiki/Manual#trades-orders-executions-transactions>`__

Order Book / Market Depth
-------------------------
Expand Down Expand Up @@ -1063,7 +1063,7 @@ To get the individual ticker data from an exchange for each particular trading p
All At Once
~~~~~~~~~~~

Some markets (not all of them) also support fetching all tickers at once. See `their docs <https://github.com/ccxt/ccxt/wiki/Manual#exchanges>`__ for details. You can fetch all tickers with a single call like so:
Some markets (not all of them) also support fetching all tickers at once. See `their docs <https://github.com/kroitor/ccxt/wiki/Manual#exchanges>`__ for details. You can fetch all tickers with a single call like so:

.. code:: javascript
Expand Down Expand Up @@ -1270,8 +1270,8 @@ The API credentials usually include the following:

- ``apiKey``. This is your public API Key and/or Token. This part is *non-secret*, it is included in your request header or body and sent over HTTPS in open text to identify your request. It is often a string in Hex or Base64 encoding or an UUID identifier.
- ``secret``. This is your private key. Keep it secret, don't tell it to anybody. It is used to sign your requests locally before sending them to exchanges. The secret key does not get sent over the internet in the request-response process and should not be published or emailed. It is used together with the nonce to generate a cryptographically strong signature. That signature is sent with your public key to authenticate your identity. Each request has a unique nonce and therefore a unique cryptographic signature.
- ``uid``. Some exchanges (not all of them) also generate a user id or *uid* for short. It can be a string or numeric literal. You should set it, if that is explicitly required by your exchange. See `their docs <https://github.com/ccxt/ccxt/wiki/Manual#exchanges>`__ for details.
- ``password``. Some exchanges (not all of them) also require your password/phrase for trading. You should set this string, if that is explicitly required by your exchange. See `their docs <https://github.com/ccxt/ccxt/wiki/Manual#exchanges>`__ for details.
- ``uid``. Some exchanges (not all of them) also generate a user id or *uid* for short. It can be a string or numeric literal. You should set it, if that is explicitly required by your exchange. See `their docs <https://github.com/kroitor/ccxt/wiki/Manual#exchanges>`__ for details.
- ``password``. Some exchanges (not all of them) also require your password/phrase for trading. You should set this string, if that is explicitly required by your exchange. See `their docs <https://github.com/kroitor/ccxt/wiki/Manual#exchanges>`__ for details.

In order to create API keys find the API tab or button in your user settings on the exchange website. Then create your keys and copy-paste them to your config file. Your config file permissions should be set appropriately, unreadable to anyone except the owner.

Expand Down Expand Up @@ -1537,7 +1537,7 @@ A successful call to a unified method for placing market or limit orders returns
'info': { ... }, // decoded original JSON response from the exchange as is
}
**Some exchanges will allow to trade with limit orders only.** See `their docs <https://github.com/ccxt/ccxt/wiki/Manual#exchanges>`__ for details.
**Some exchanges will allow to trade with limit orders only.** See `their docs <https://github.com/kroitor/ccxt/wiki/Manual#exchanges>`__ for details.

Market Orders
^^^^^^^^^^^^^
Expand Down Expand Up @@ -1648,7 +1648,7 @@ The withdraw method returns a dictionary containing the withdrawal id, which is

Some exchanges require a manual approval of each withdrawal by means of 2FA (2-factor authentication). In order to approve your withdrawal you usually have to either click their secret link in your email inbox or enter a Google Authenticator code or an Authy code on their website to verify that withdrawal transaction was requested intentionally.

In some cases you can also use the withdrawal id to check withdrawal status later (whether it succeeded or not) and to submit 2FA confirmation codes, where this is supported by the exchange. See `their docs <https://github.com/ccxt/ccxt/wiki/Manual#exchanges>`__ for details.
In some cases you can also use the withdrawal id to check withdrawal status later (whether it succeeded or not) and to submit 2FA confirmation codes, where this is supported by the exchange. See `their docs <https://github.com/kroitor/ccxt/wiki/Manual#exchanges>`__ for details.

Ledger
~~~~~~
Expand All @@ -1658,7 +1658,7 @@ Ledger
Overriding The Nonce
--------------------

**The default nonce is a 32-bit Unix Timestamp in seconds. You should override it with a milliseconds-nonce if you want to make private requests more frequently than once per second! Most exchanges will throttle your requests if you hit their rate limits, read `API docs for your exchange <https://github.com/ccxt/ccxt/wiki/Exchanges>`__ carefully!**
**The default nonce is a 32-bit Unix Timestamp in seconds. You should override it with a milliseconds-nonce if you want to make private requests more frequently than once per second! Most exchanges will throttle your requests if you hit their rate limits, read `API docs for your exchange <https://github.com/kroitor/ccxt/wiki/Exchanges>`__ carefully!**

In case you need to reset the nonce it is much easier to create another pair of keys for using with private APIs. Creating new keys and setting up a fresh unused keypair in your config is usually enough for that.

Expand Down Expand Up @@ -1838,14 +1838,14 @@ Troubleshooting

In case you experience any difficulty connecting to a particular exchange, do the following in order of precedence:

1. Check the `CHANGELOG <https://github.com/ccxt/ccxt/blob/master/CHANGELOG.md>`__ for recent updates.
1. Check the `CHANGELOG <https://github.com/kroitor/ccxt/blob/master/CHANGELOG.md>`__ for recent updates.
2. Turn ``verbose = true`` to get more detail about it.
3. Check you API credentials. Try a fresh new keypair if possible.
4. Check your nonce. If you used your API keys with other software, you most likely should `override your nonce function <#overriding-the-nonce>`__ to match your previous nonce value. A nonce usually can be easily reset by generating a new unused keypair.
5. Check your request rate if you are getting nonce errors. Your private requests should not follow one another quickly. You should not send them one after another in a split second or in short time. The exchange will most likely ban you if you don't make a delay before sending each new request. In other words, you should not hit their rate limit by sending unlimited private requests too frequently. Add a delay to your subsequent requests, like show in the long-poller `examples <https://github.com/ccxt/ccxt/tree/master/examples>`__, also `here <https://github.com/ccxt/ccxt/wiki/Manual#order-book--market-depth>`__.
6. Read the `docs for your exchange <https://github.com/ccxt/ccxt/wiki/Exchanges>`__ and compare your verbose output to the docs.
5. Check your request rate if you are getting nonce errors. Your private requests should not follow one another quickly. You should not send them one after another in a split second or in short time. The exchange will most likely ban you if you don't make a delay before sending each new request. In other words, you should not hit their rate limit by sending unlimited private requests too frequently. Add a delay to your subsequent requests, like show in the long-poller `examples <https://github.com/ccxt-dev/ccxt/tree/master/examples>`__, also `here <https://github.com/ccxt-dev/ccxt/wiki/Manual#order-book--market-depth>`__.
6. Read the `docs for your exchange <https://github.com/kroitor/ccxt/wiki/Exchanges>`__ and compare your verbose output to the docs.
7. Check your connectivity with the exchange by accessing it with your browser.
8. Check your connection with the exchange through a proxy. Read the `Proxy <https://github.com/ccxt/ccxt/wiki/Install#proxy>`__ section for more details.
8. Check your connection with the exchange through a proxy. Read the `Proxy <https://github.com/kroitor/ccxt/wiki/Install#proxy>`__ section for more details.
9. Try accesing the exchange from a different computer or a remote server, to see if this is a local or global issue with the exchange.
10. Check if there were any news from the exchange recently regarding downtime for maintenance. Some exchanges go offline for updates regularly (like once a week).

Expand Down
2 changes: 2 additions & 0 deletions js/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ module.exports = class Exchange {
this.fee_to_precision = this.feeToPrecision
this.cost_to_precision = this.costToPrecision

this.encodeURIComponent = encodeURIComponent

// merge configs
const config = deepExtend (this.describe (), userConfig)

Expand Down
2 changes: 1 addition & 1 deletion js/cryptopia.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ module.exports = class cryptopia extends Exchange {
body = this.json (query);
let hash = this.hash (this.encode (body), 'md5', 'base64');
let secret = this.base64ToBinary (this.secret);
let uri = encodeURIComponent (url);
let uri = this.encodeURIComponent (url);
let lowercase = uri.toLowerCase ();
let payload = this.apiKey + method + lowercase + nonce + this.binaryToString (hash);
let signature = this.hmac (this.encode (payload), secret, 'sha256', 'base64');
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "npm run export-exchanges && npm run vss && npm run convert-md-2-rst && npm run transpile && npm run update-badges && npm run browserify",
"test": "npm run build && node run-tests",
"fasttest": "node run-tests --js",
"test-base": "mocha --reporter spec test/test_base.js",
"test-base": "mocha --reporter spec js/test/test_base.js",
"export-exchanges": "node export-exchanges",
"update-badges": "node update-badges",
"convert-md-2-rst": "./convert-md-2-rst",
Expand Down
2 changes: 1 addition & 1 deletion run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const testExchange = async (exchange) => {
const args = [exchange, ...symbol === 'all' ? [] : symbol]
, allTests = [

{ language: 'JavaScript', key: '--js', exec: ['node', 'test/test.js', ...args] },
{ language: 'JavaScript', key: '--js', exec: ['node', 'js/test/test.js', ...args] },
{ language: 'Python', key: '--python', exec: ['python2', 'python/test/test.py', ...args] },
{ language: 'Python 3', key: '--python3', exec: ['python3', 'python/test/test_async.py', ...args] },
{ language: 'PHP', key: '--php', exec: ['php', '-f', 'php/test/test.php', ...args] }
Expand Down

0 comments on commit ce9be20

Please sign in to comment.