├── .dockerignore ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── .npmignore ├── .travis.yml ├── CONTRIBUTING.md ├── Dockerfile ├── ISSUE_TEMPLATE.md ├── LICENSE.txt ├── README.md ├── appveyor.yml ├── build ├── cleanup-old-tags.js ├── copy.js ├── countries.js ├── export-exchanges.js ├── fs.js ├── git-ignore-generated-files.js ├── inject-fields.js ├── push.sh ├── transpile.js ├── update-badges.js └── vss.js ├── ccxt.browser.js ├── ccxt.d.ts ├── ccxt.js ├── ccxt.php ├── composer.json ├── composer.lock ├── dist └── ccxt.browser.js ├── doc ├── .gitignore ├── FAQ.rst ├── Makefile ├── README.rst ├── _static │ └── css │ │ └── index.css ├── _templates │ └── layout.html ├── ccxt.pro.install.rst ├── ccxt.pro.manual.rst ├── ccxt.pro.rst ├── conf.py ├── exchanges-by-country.rst ├── exchanges.rst ├── index.rst ├── install.rst ├── make.bat └── manual.rst ├── docker-compose.yml ├── examples ├── README.md ├── ccxt.pro │ ├── js │ │ ├── many-exchanges-many-streams.js │ │ ├── one-exchange-many-streams-2.js │ │ ├── one-exchange-many-streams.js │ │ └── watch-vs-fetch.js │ ├── php │ │ └── one-exchange-many-streams.php │ └── py │ │ ├── binance-watch-margin-balance.py │ │ ├── bitmex_watch_ohlcv.py │ │ ├── bitmex_watch_ticker_and_ohlcv.py │ │ ├── coinbasepro-watch-all-trades.py │ │ ├── coinbasepro-watch-trades.py │ │ ├── gateio-watch-trades.py │ │ ├── many-exchanges-many-streams.py │ │ ├── many-exchanges.py │ │ ├── okex-watch-margin-balance-with-params.py │ │ ├── okex-watch-margin-balance.py │ │ ├── one-exchange-different-streams.py │ │ ├── one-exchange-many-streams.py │ │ └── watch-all-symbols.py ├── html │ ├── basic-cors-proxy.html │ ├── basic-inheritance.html │ ├── basic-poller.html │ ├── basic-rate-limiting.html │ ├── basic.html │ ├── bitmex-browser-cors-proxy.js │ └── bitmex-cors.html ├── js │ ├── README.md │ ├── arbitrage-pairs.js │ ├── balances.js │ ├── basic-chart.js │ ├── basic-orderbook-polling.js │ ├── bcc-vs-bch.js │ ├── binance-fetch-ohlcv.js │ ├── binance-server-time.js │ ├── bitfinex-fetch-trades.js │ ├── bitfinex2-fetch-trades.js │ ├── bitmex-browser-cors-proxy.js │ ├── bittrex-balance.js │ ├── bittrex-fetch-closed-orders-history.js │ ├── builtin-rate-limiting-rest-poller.js │ ├── bypass-cloudflare.js │ ├── cli.js │ ├── coinone-fetch-tickers.js │ ├── coinone-markets.js │ ├── cors-proxy.js │ ├── create-order-handle-errors.js │ ├── create-order-with-retry.js │ ├── credentials.json │ ├── custom-proxy-url.js │ ├── env-variables.js │ ├── error-handling.js │ ├── exchange-capabilities.js │ ├── exchanges-by-volume.js │ ├── exchanges.js │ ├── fetch-all-tickers-to-files.js │ ├── fetch-create-deposit-address.js │ ├── fetch-from-many-exchanges-simultaneously.js │ ├── fetch-ohlcv-cex.js │ ├── fetch-okex-futures.js │ ├── fetch-orders.js │ ├── fetch-ticker-from-multiple-exchanges.js │ ├── fetch-ticker-where-available.js │ ├── gdax-fetch-trades-pagination.js │ ├── hitbtc-fetch-all-ohlcvs.js │ ├── hitbtc2-withdraw.js │ ├── huobipro-market-buy-sell-fetch-trading-limits.js │ ├── instantiate-all-at-once.js │ ├── instantiate-all-from-json.js │ ├── kraken-fetch-order-trades.js │ ├── live-orderbook.js │ ├── live-ticker.js │ ├── live-tickers.js │ ├── load-all-symbols-at-once.js │ ├── load-all-tickers-at-once.js │ ├── looping-over-all-symbols-of-specific-exchanges.js │ ├── looping-over-specific-symbols-of-all-exchanges.js │ ├── market-status-and-currency-status.js │ ├── okex-fetch-ohlcv-since-limit.js │ ├── order-book-extra-level-depth-param.js │ ├── poloniex-fetch-order-books.js │ ├── poloniex-limits-amount-min.js │ ├── proxy-round-robin.js │ ├── search-all-exchanges.js │ ├── symbols.js │ ├── theocean.js │ └── tickers.js ├── php │ ├── README.md │ ├── arbitrage-pairs.php │ ├── basic-error-handling.php │ ├── binance-cancel-order.php │ ├── binance-fetch-ticker.php │ ├── binance-fetch-tickers.php │ ├── bitfinex2-fetch-ohlcv-since-limit.php │ ├── bitfinex2-fetch-ohlcv.php │ ├── bitfinex2-fetch-trades-since.php │ ├── bitmex-create-order.php │ ├── built-in-rate-limiting-poller.php │ ├── cli.php │ ├── cobinhood-fetch-balance.php │ ├── coinbasepro-cursor-pagination.php │ ├── coinbasepro-fetch-ticker.php │ ├── coinbasepro-sandbox-fetch-ticker.php │ ├── coinone-fetch-tickers.php │ ├── coinone-markets.php │ ├── error-handling-message.php │ ├── exchange-properties.php │ ├── fetch-order.php │ ├── gdax-fetch-ticker.php │ ├── gdax-sandbox-fetch-ticker.php │ ├── huobi-fetch-balance.php │ ├── indodax-fetch-balance-create-order-cancel-order.php │ ├── kraken-query-ledgers.php │ ├── kucoin-implicit-inner-transfer-v1.php │ ├── load-all-at-once.php │ ├── nonce-override.php │ ├── order-book-level-depth-extra-param.php │ ├── react-eventloop-with-rate-limiting.php │ ├── symbols.php │ ├── trading-view.php │ └── vaultoro-fetch-balance.php ├── py │ ├── README.md │ ├── arbitrage-pairs.py │ ├── asciichart.py │ ├── async-balance-coinbasepro.py │ ├── async-balance-gdax.py │ ├── async-balance.py │ ├── async-balances.py │ ├── async-basic-callchain.py │ ├── async-basic-orderbook.py │ ├── async-basic-rate-limiter.py │ ├── async-basic.py │ ├── async-binance-create-margin-order.py │ ├── async-binance-fetch-margin-balance-with-options.py │ ├── async-binance-fetch-margin-balance-with-params.py │ ├── async-binance-fetch-ticker-continuously.py │ ├── async-binance-futures-vs-spot.py │ ├── async-binance-margin-borrow.py │ ├── async-binance-margin-repay.py │ ├── async-bitfinex-public-get-symbols.py │ ├── async-bitstamp-create-limit-buy-order.py │ ├── async-bittrex-orderbook.py │ ├── async-fetch-balance.py │ ├── async-fetch-order-book-from-many-exchanges.py │ ├── async-fetch-ticker.py │ ├── async-gather-concurrency.py │ ├── async-gdax-fetch-order-book-continuously.py │ ├── async-generator-basic.py │ ├── async-generator-multiple-tickers.py │ ├── async-generator-ticker-poller.py │ ├── async-instantiate-all-at-once.py │ ├── async-multiple-accounts.py │ ├── async-okex-create-margin-order.py │ ├── async-okex-fetch-margin-balance-with-options.py │ ├── async-okex-fetch-margin-balance-with-params.py │ ├── async-okex-margin-borrow.py │ ├── async-okex-margin-repay.py │ ├── async-orderbooks-from-multiple-exchanges-at-once.py │ ├── async-orderbooks.py │ ├── async-theocean-orderbook.py │ ├── async-theocean-tickers.py │ ├── async-ticker.py │ ├── async-tickers-from-many-exchanges-at-once.py │ ├── async-tickers.py │ ├── async-with-threads.py │ ├── async.py │ ├── balance-coinbasepro.py │ ├── balance-gdax.py │ ├── balance-kraken.py │ ├── balances.py │ ├── basic-chart.py │ ├── basic-rate-limiting.py │ ├── binance-batch-orders.py │ ├── binance-fetch-ohlcv-to-csv.py │ ├── binance-fetch-ohlcv.py │ ├── binance-test-order.py │ ├── bitfinex-rate-limiting.py │ ├── bitmex-create-order.py │ ├── bitmex-fetch-ohlcv-with-extra-params.py │ ├── bitmex-ohlcv-convert-5m-to-15m.py │ ├── bittrex-fetch-closed-orders-history.py │ ├── builtin-rate-limiting-long-poller.py │ ├── bypass-cloudflare-with-aiocfscrape.py │ ├── bypass-cloudflare-with-cookies.py │ ├── bypass-cloudflare.py │ ├── cli.py │ ├── coinbasepro-fetch-my-trades-pagination.py │ ├── coinone-fetch-tickers.py │ ├── coinone-markets.py │ ├── exchanges.py │ ├── fetch-all-okex-ohclv.py │ ├── fetch-all-tickers.py │ ├── fetch-bitfinex-ohlcv-history.py │ ├── fetch-coinbasepro-ohlcv-sequentially.py │ ├── fetch-create-deposit-address.py │ ├── fetch-gdax-ohlcv-sequentially.py │ ├── fetch-ohlcv-cex.py │ ├── fetch-ohlcv-kraken.py │ ├── fetch-ohlcv-on-new-candle.py │ ├── fetch-ohlcv-sequentially.py │ ├── fetch-okex-futures.py │ ├── fetch-orders.py │ ├── gdax-fetch-my-trades-pagination.py │ ├── hitbtc2-withdraw.py │ ├── instantiate-all-at-once.py │ ├── kucoin-fetch-closed-orders-pagination.py │ ├── latoken-create-order.py │ ├── manual-rate-limiting-long-poller.py │ ├── margin-leverage-order-kraken.py │ ├── minimal-2-lines.py │ ├── normalize-sparse-candle-timestamps.py │ ├── okex-fetch-closed-orders-pagenumber-pagination.py │ ├── order-book-extra-level-depth-param.py │ ├── poloniex-fetch-order-books.py │ ├── poloniex-python2-memleak-test.py │ ├── poloniex-python3-memleak-test.py │ ├── proxy-asyncio-aiohttp-python-3.py │ ├── proxy-sync-python-requests-2-and-3.py │ ├── sign-in.py │ ├── symbols.py │ ├── test-server.py │ ├── theocean.py │ └── tickers.py └── ts │ ├── .gitignore │ ├── fetch-futures │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── prettier.config.js │ ├── src │ │ └── index.ts │ └── tsconfig.json │ └── fetch-tickers │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── prettier.config.js │ ├── src │ └── index.ts │ └── tsconfig.json ├── exchanges.cfg ├── js ├── .eslintrc ├── _1btcxe.js ├── acx.js ├── anxpro.js ├── aofex.js ├── base │ ├── .eslintrc.js │ ├── Exchange.js │ ├── errorHierarchy.js │ ├── errors.js │ ├── functions.js │ └── functions │ │ ├── crypto.js │ │ ├── encode.js │ │ ├── generic.js │ │ ├── misc.js │ │ ├── number.js │ │ ├── orders.js │ │ ├── platform.js │ │ ├── string.js │ │ ├── throttle.js │ │ ├── time.js │ │ └── type.js ├── bcex.js ├── bequant.js ├── bibox.js ├── bigone.js ├── binance.js ├── binanceje.js ├── binanceus.js ├── bit2c.js ├── bitbank.js ├── bitbay.js ├── bitfinex.js ├── bitfinex2.js ├── bitflyer.js ├── bitforex.js ├── bithumb.js ├── bitkk.js ├── bitmart.js ├── bitmax.js ├── bitmex.js ├── bitso.js ├── bitstamp.js ├── bitstamp1.js ├── bittrex.js ├── bitvavo.js ├── bitz.js ├── bl3p.js ├── bleutrade.js ├── braziliex.js ├── btcalpha.js ├── btcbox.js ├── btcmarkets.js ├── btctradeim.js ├── btctradeua.js ├── btcturk.js ├── buda.js ├── bw.js ├── bybit.js ├── bytetrade.js ├── cex.js ├── chilebit.js ├── coinbase.js ├── coinbaseprime.js ├── coinbasepro.js ├── coincheck.js ├── coinegg.js ├── coinex.js ├── coinfalcon.js ├── coinfloor.js ├── coingi.js ├── coinmarketcap.js ├── coinmate.js ├── coinone.js ├── coinspot.js ├── coolcoin.js ├── coss.js ├── crex24.js ├── currencycom.js ├── deribit.js ├── digifinex.js ├── dsx.js ├── eterbase.js ├── exmo.js ├── exx.js ├── fcoin.js ├── fcoinjp.js ├── flowbtc.js ├── foxbit.js ├── ftx.js ├── fybse.js ├── gateio.js ├── gemini.js ├── hbtc.js ├── hitbtc.js ├── hollaex.js ├── huobijp.js ├── huobipro.js ├── huobiru.js ├── ice3x.js ├── idex.js ├── independentreserve.js ├── indodax.js ├── itbit.js ├── kraken.js ├── kucoin.js ├── kuna.js ├── lakebtc.js ├── latoken.js ├── lbank.js ├── liquid.js ├── livecoin.js ├── luno.js ├── lykke.js ├── mercado.js ├── mixcoins.js ├── oceanex.js ├── okcoin.js ├── okex.js ├── paymium.js ├── phemex.js ├── poloniex.js ├── probit.js ├── qtrade.js ├── rightbtc.js ├── southxchange.js ├── static_dependencies │ ├── BN │ │ └── bn.js │ ├── README.md │ ├── crypto-js │ │ └── crypto-js.js │ ├── elliptic │ │ ├── lib │ │ │ ├── elliptic.js │ │ │ ├── elliptic │ │ │ │ ├── curve │ │ │ │ │ ├── base.js │ │ │ │ │ ├── edwards.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── mont.js │ │ │ │ │ └── short.js │ │ │ │ ├── curves.js │ │ │ │ ├── ec │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ └── signature.js │ │ │ │ ├── eddsa │ │ │ │ │ ├── index.js │ │ │ │ │ ├── key.js │ │ │ │ │ └── signature.js │ │ │ │ ├── precomputed │ │ │ │ │ └── secp256k1.js │ │ │ │ └── utils.js │ │ │ └── hmac-drbg │ │ │ │ └── hmac-drbg.js │ │ └── package.json │ ├── fetch-ponyfill │ │ └── fetch-node.js │ ├── node-fetch │ │ └── index.js │ ├── node-rsa │ │ ├── NodeRSA.js │ │ ├── asn1 │ │ │ ├── ber │ │ │ │ ├── errors.js │ │ │ │ ├── index.js │ │ │ │ ├── reader.js │ │ │ │ └── types.js │ │ │ └── index.js │ │ ├── encryptEngines │ │ │ └── js.js │ │ ├── formats │ │ │ ├── components.js │ │ │ ├── formats.js │ │ │ ├── pkcs1.js │ │ │ └── pkcs8.js │ │ ├── libs │ │ │ ├── jsbn.js │ │ │ └── rsa.js │ │ ├── schemes │ │ │ ├── pkcs1.js │ │ │ └── schemes.js │ │ └── utils.js │ └── qs │ │ ├── formats.js │ │ ├── index.js │ │ ├── parse.js │ │ ├── stringify.js │ │ └── utils.js ├── stex.js ├── stronghold.js ├── surbitcoin.js ├── test │ ├── .eslintrc.js │ ├── Exchange │ │ ├── test.balance.js │ │ ├── test.currency.js │ │ ├── test.fetchBalance.js │ │ ├── test.fetchClosedOrders.js │ │ ├── test.fetchCurrencies.js │ │ ├── test.fetchDeposits.js │ │ ├── test.fetchFundingFees.js │ │ ├── test.fetchL2OrderBook.js │ │ ├── test.fetchLedger.js │ │ ├── test.fetchMarkets.js │ │ ├── test.fetchMyTrades.js │ │ ├── test.fetchOHLCV.js │ │ ├── test.fetchOpenOrders.js │ │ ├── test.fetchOrderBook.js │ │ ├── test.fetchOrderBooks.js │ │ ├── test.fetchOrders.js │ │ ├── test.fetchStatus.js │ │ ├── test.fetchTicker.js │ │ ├── test.fetchTickers.js │ │ ├── test.fetchTrades.js │ │ ├── test.fetchTradingFees.js │ │ ├── test.fetchTransactions.js │ │ ├── test.fetchWithdrawals.js │ │ ├── test.ledgerItem.js │ │ ├── test.loadMarkets.js │ │ ├── test.market.js │ │ ├── test.ohlcv.js │ │ ├── test.order.js │ │ ├── test.orderbook.js │ │ ├── test.ticker.js │ │ ├── test.trade.js │ │ └── test.transaction.js │ ├── base │ │ ├── .eslintrc │ │ ├── functions │ │ │ ├── test.crypto.js │ │ │ ├── test.datetime.js │ │ │ ├── test.generic.js │ │ │ ├── test.number.js │ │ │ ├── test.time.js │ │ │ └── test.type.js │ │ └── test.base.js │ ├── errors │ │ ├── test.InsufficientFunds.js │ │ ├── test.InvalidNonce.js │ │ ├── test.InvalidOrder.js │ │ └── test.OrderNotFound.js │ ├── test.js │ └── test.timeout_hang.js ├── therock.js ├── tidebit.js ├── tidex.js ├── timex.js ├── upbit.js ├── vaultoro.js ├── vbtc.js ├── wavesexchange.js ├── whitebit.js ├── xbtce.js ├── yobit.js ├── zaif.js └── zb.js ├── keys.json ├── package-lock.json ├── package.json ├── php ├── _1btcxe.php ├── acx.php ├── anxpro.php ├── aofex.php ├── base │ ├── Exchange.php │ └── errors.php ├── bcex.php ├── bequant.php ├── bibox.php ├── bigone.php ├── binance.php ├── binanceje.php ├── binanceus.php ├── bit2c.php ├── bitbank.php ├── bitbay.php ├── bitfinex.php ├── bitfinex2.php ├── bitflyer.php ├── bitforex.php ├── bithumb.php ├── bitkk.php ├── bitmart.php ├── bitmax.php ├── bitmex.php ├── bitso.php ├── bitstamp.php ├── bitstamp1.php ├── bittrex.php ├── bitvavo.php ├── bitz.php ├── bl3p.php ├── bleutrade.php ├── braziliex.php ├── btcalpha.php ├── btcbox.php ├── btcmarkets.php ├── btctradeim.php ├── btctradeua.php ├── btcturk.php ├── buda.php ├── bw.php ├── bybit.php ├── bytetrade.php ├── cex.php ├── chilebit.php ├── coinbase.php ├── coinbaseprime.php ├── coinbasepro.php ├── coincheck.php ├── coinegg.php ├── coinex.php ├── coinfalcon.php ├── coinfloor.php ├── coingi.php ├── coinmarketcap.php ├── coinmate.php ├── coinone.php ├── coinspot.php ├── coolcoin.php ├── coss.php ├── crex24.php ├── currencycom.php ├── deribit.php ├── digifinex.php ├── dsx.php ├── eterbase.php ├── exmo.php ├── exx.php ├── fcoin.php ├── fcoinjp.php ├── flowbtc.php ├── foxbit.php ├── ftx.php ├── fybse.php ├── gateio.php ├── gemini.php ├── hbtc.php ├── hitbtc.php ├── hollaex.php ├── huobijp.php ├── huobipro.php ├── huobiru.php ├── ice3x.php ├── idex.php ├── independentreserve.php ├── indodax.php ├── itbit.php ├── kraken.php ├── kucoin.php ├── kuna.php ├── lakebtc.php ├── latoken.php ├── lbank.php ├── liquid.php ├── livecoin.php ├── luno.php ├── lykke.php ├── mercado.php ├── mixcoins.php ├── oceanex.php ├── okcoin.php ├── okex.php ├── paymium.php ├── phemex.php ├── poloniex.php ├── probit.php ├── qtrade.php ├── rightbtc.php ├── southxchange.php ├── static_dependencies │ ├── BI │ │ └── BigInteger.php │ ├── BN │ │ ├── BN.php │ │ └── Red.php │ ├── README.md │ ├── elliptic-php │ │ ├── LICENSE.md │ │ ├── composer.json │ │ └── lib │ │ │ ├── Curve │ │ │ ├── BaseCurve.php │ │ │ ├── BaseCurve │ │ │ │ └── Point.php │ │ │ ├── EdwardsCurve.php │ │ │ ├── EdwardsCurve │ │ │ │ └── Point.php │ │ │ ├── MontCurve.php │ │ │ ├── MontCurve │ │ │ │ └── Point.php │ │ │ ├── PresetCurve.php │ │ │ ├── ShortCurve.php │ │ │ └── ShortCurve │ │ │ │ ├── JPoint.php │ │ │ │ └── Point.php │ │ │ ├── Curves.php │ │ │ ├── EC.php │ │ │ ├── EC │ │ │ ├── KeyPair.php │ │ │ └── Signature.php │ │ │ ├── EdDSA.php │ │ │ ├── EdDSA │ │ │ ├── KeyPair.php │ │ │ └── Signature.php │ │ │ ├── HmacDRBG.php │ │ │ └── Utils.php │ └── kornrunner │ │ ├── keccak │ │ ├── LICENSE │ │ ├── README.md │ │ └── src │ │ │ └── Keccak.php │ │ └── solidity │ │ ├── LICENSE │ │ ├── README.md │ │ └── src │ │ └── Solidity.php ├── stex.php ├── stronghold.php ├── surbitcoin.php ├── test │ ├── ExchangeTest.php │ ├── bootstrap.php │ ├── decimal_to_precision.php │ ├── syntax.php │ ├── test.php │ ├── test_crypto.php │ └── test_exchange_datetime_functions.php ├── therock.php ├── tidebit.php ├── tidex.php ├── timex.php ├── upbit.php ├── vaultoro.php ├── vbtc.php ├── wavesexchange.php ├── whitebit.php ├── xbtce.php ├── yobit.php ├── zaif.php └── zb.php ├── phpunit.xml.dist ├── postinstall.js ├── python ├── LICENSE.txt ├── MANIFEST.in ├── README.md ├── README.rst ├── ccxt │ ├── _1btcxe.py │ ├── __init__.py │ ├── acx.py │ ├── anxpro.py │ ├── aofex.py │ ├── async_support │ │ ├── _1btcxe.py │ │ ├── __init__.py │ │ ├── acx.py │ │ ├── anxpro.py │ │ ├── aofex.py │ │ ├── base │ │ │ ├── __init__.py │ │ │ ├── exchange.py │ │ │ └── throttle.py │ │ ├── bcex.py │ │ ├── bequant.py │ │ ├── bibox.py │ │ ├── bigone.py │ │ ├── binance.py │ │ ├── binanceje.py │ │ ├── binanceus.py │ │ ├── bit2c.py │ │ ├── bitbank.py │ │ ├── bitbay.py │ │ ├── bitfinex.py │ │ ├── bitfinex2.py │ │ ├── bitflyer.py │ │ ├── bitforex.py │ │ ├── bithumb.py │ │ ├── bitkk.py │ │ ├── bitmart.py │ │ ├── bitmax.py │ │ ├── bitmex.py │ │ ├── bitso.py │ │ ├── bitstamp.py │ │ ├── bitstamp1.py │ │ ├── bittrex.py │ │ ├── bitvavo.py │ │ ├── bitz.py │ │ ├── bl3p.py │ │ ├── bleutrade.py │ │ ├── braziliex.py │ │ ├── btcalpha.py │ │ ├── btcbox.py │ │ ├── btcmarkets.py │ │ ├── btctradeim.py │ │ ├── btctradeua.py │ │ ├── btcturk.py │ │ ├── buda.py │ │ ├── bw.py │ │ ├── bybit.py │ │ ├── bytetrade.py │ │ ├── cex.py │ │ ├── chilebit.py │ │ ├── coinbase.py │ │ ├── coinbaseprime.py │ │ ├── coinbasepro.py │ │ ├── coincheck.py │ │ ├── coinegg.py │ │ ├── coinex.py │ │ ├── coinfalcon.py │ │ ├── coinfloor.py │ │ ├── coingi.py │ │ ├── coinmarketcap.py │ │ ├── coinmate.py │ │ ├── coinone.py │ │ ├── coinspot.py │ │ ├── coolcoin.py │ │ ├── coss.py │ │ ├── crex24.py │ │ ├── currencycom.py │ │ ├── deribit.py │ │ ├── digifinex.py │ │ ├── dsx.py │ │ ├── eterbase.py │ │ ├── exmo.py │ │ ├── exx.py │ │ ├── fcoin.py │ │ ├── fcoinjp.py │ │ ├── flowbtc.py │ │ ├── foxbit.py │ │ ├── ftx.py │ │ ├── fybse.py │ │ ├── gateio.py │ │ ├── gemini.py │ │ ├── hbtc.py │ │ ├── hitbtc.py │ │ ├── hollaex.py │ │ ├── huobijp.py │ │ ├── huobipro.py │ │ ├── huobiru.py │ │ ├── ice3x.py │ │ ├── idex.py │ │ ├── independentreserve.py │ │ ├── indodax.py │ │ ├── itbit.py │ │ ├── kraken.py │ │ ├── kucoin.py │ │ ├── kuna.py │ │ ├── lakebtc.py │ │ ├── latoken.py │ │ ├── lbank.py │ │ ├── liquid.py │ │ ├── livecoin.py │ │ ├── luno.py │ │ ├── lykke.py │ │ ├── mercado.py │ │ ├── mixcoins.py │ │ ├── oceanex.py │ │ ├── okcoin.py │ │ ├── okex.py │ │ ├── paymium.py │ │ ├── phemex.py │ │ ├── poloniex.py │ │ ├── probit.py │ │ ├── qtrade.py │ │ ├── rightbtc.py │ │ ├── southxchange.py │ │ ├── stex.py │ │ ├── stronghold.py │ │ ├── surbitcoin.py │ │ ├── therock.py │ │ ├── tidebit.py │ │ ├── tidex.py │ │ ├── timex.py │ │ ├── upbit.py │ │ ├── vaultoro.py │ │ ├── vbtc.py │ │ ├── wavesexchange.py │ │ ├── whitebit.py │ │ ├── xbtce.py │ │ ├── yobit.py │ │ ├── zaif.py │ │ └── zb.py │ ├── base │ │ ├── __init__.py │ │ ├── decimal_to_precision.py │ │ ├── errors.py │ │ └── exchange.py │ ├── bcex.py │ ├── bequant.py │ ├── bibox.py │ ├── bigone.py │ ├── binance.py │ ├── binanceje.py │ ├── binanceus.py │ ├── bit2c.py │ ├── bitbank.py │ ├── bitbay.py │ ├── bitfinex.py │ ├── bitfinex2.py │ ├── bitflyer.py │ ├── bitforex.py │ ├── bithumb.py │ ├── bitkk.py │ ├── bitmart.py │ ├── bitmax.py │ ├── bitmex.py │ ├── bitso.py │ ├── bitstamp.py │ ├── bitstamp1.py │ ├── bittrex.py │ ├── bitvavo.py │ ├── bitz.py │ ├── bl3p.py │ ├── bleutrade.py │ ├── braziliex.py │ ├── btcalpha.py │ ├── btcbox.py │ ├── btcmarkets.py │ ├── btctradeim.py │ ├── btctradeua.py │ ├── btcturk.py │ ├── buda.py │ ├── bw.py │ ├── bybit.py │ ├── bytetrade.py │ ├── cex.py │ ├── chilebit.py │ ├── coinbase.py │ ├── coinbaseprime.py │ ├── coinbasepro.py │ ├── coincheck.py │ ├── coinegg.py │ ├── coinex.py │ ├── coinfalcon.py │ ├── coinfloor.py │ ├── coingi.py │ ├── coinmarketcap.py │ ├── coinmate.py │ ├── coinone.py │ ├── coinspot.py │ ├── coolcoin.py │ ├── coss.py │ ├── crex24.py │ ├── currencycom.py │ ├── deribit.py │ ├── digifinex.py │ ├── dsx.py │ ├── eterbase.py │ ├── exmo.py │ ├── exx.py │ ├── fcoin.py │ ├── fcoinjp.py │ ├── flowbtc.py │ ├── foxbit.py │ ├── ftx.py │ ├── fybse.py │ ├── gateio.py │ ├── gemini.py │ ├── hbtc.py │ ├── hitbtc.py │ ├── hollaex.py │ ├── huobijp.py │ ├── huobipro.py │ ├── huobiru.py │ ├── ice3x.py │ ├── idex.py │ ├── independentreserve.py │ ├── indodax.py │ ├── itbit.py │ ├── kraken.py │ ├── kucoin.py │ ├── kuna.py │ ├── lakebtc.py │ ├── latoken.py │ ├── lbank.py │ ├── liquid.py │ ├── livecoin.py │ ├── luno.py │ ├── lykke.py │ ├── mercado.py │ ├── mixcoins.py │ ├── oceanex.py │ ├── okcoin.py │ ├── okex.py │ ├── paymium.py │ ├── phemex.py │ ├── poloniex.py │ ├── pro │ │ └── __init__.py │ ├── probit.py │ ├── qtrade.py │ ├── rightbtc.py │ ├── southxchange.py │ ├── static_dependencies │ │ ├── README.md │ │ ├── __init__.py │ │ └── ecdsa │ │ │ ├── __init__.py │ │ │ ├── _version.py │ │ │ ├── curves.py │ │ │ ├── der.py │ │ │ ├── ecdsa.py │ │ │ ├── ellipticcurve.py │ │ │ ├── keys.py │ │ │ ├── numbertheory.py │ │ │ ├── rfc6979.py │ │ │ └── util.py │ ├── stex.py │ ├── stronghold.py │ ├── surbitcoin.py │ ├── therock.py │ ├── tidebit.py │ ├── tidex.py │ ├── timex.py │ ├── upbit.py │ ├── vaultoro.py │ ├── vbtc.py │ ├── wavesexchange.py │ ├── whitebit.py │ ├── xbtce.py │ ├── yobit.py │ ├── zaif.py │ └── zb.py ├── deploy.sh ├── package.json ├── setup.cfg ├── setup.py ├── test │ ├── test.py │ ├── test_async.py │ ├── test_calculate_fee.py │ ├── test_crypto.py │ ├── test_decimal_to_precision.py │ ├── test_deep_extend.py │ ├── test_exchange_datetime_functions.py │ └── test_get_zeroex_order_hash_v2.py └── tox.ini ├── run-tests.js ├── setup.cfg └── wiki ├── Certification.md ├── Exchange-Markets-By-Country.md ├── Exchange-Markets.md ├── FAQ.md ├── Install.md ├── Integration-FAQ.md ├── Manual.md ├── README.md ├── Requirements.md ├── Stats.md ├── WebSocket-Support.md ├── ccxt.pro.install.md ├── ccxt.pro.manual.md └── ccxt.pro.md /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .dockerignore 3 | Dockerfile 4 | node_modules 5 | *.swp 6 | *.pyc 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.* text eol=lf 2 | php/test/*.php linguist-generated=true 3 | python/ccxt/*.py linguist-generated=true 4 | python/ccxt/__init__.py linguist-generated=false 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: ccxt 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # You shouldn't edit these files, as they're generated automatically from ccxt.js by build scripts. 3 | # Please read https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#multilanguage-support for details. 4 | # 5 | .vscode 6 | build/ccxt.wiki 7 | node_modules/ 8 | npm-debug.log 9 | .DS_Store 10 | config.js 11 | config.py 12 | config.php 13 | ccxt.egg-info/ 14 | tmp/ 15 | *.pyc 16 | .tox/ 17 | coverage 18 | .nyc_output 19 | travis-keys.sh 20 | exchanges.json 21 | ccxt.sublime-workspace 22 | .idea 23 | yarn.lock 24 | keys.local.json 25 | nbproject/ 26 | vendor/ 27 | python/build 28 | python/dist 29 | python/package-lock.json 30 | python/package.json 31 | python/keys.json 32 | python/LICENSE.txt 33 | .env 34 | *.swp 35 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | ccxt.egg-info/ 2 | build/**/* 3 | !build/countries.js 4 | !build/export-exchanges.js 5 | !build/fs.js 6 | !build/transpile.js 7 | !build/vss.js 8 | !build/cleanup-old-tags.js 9 | examples/ 10 | node_modules/ 11 | python/ 12 | php/ 13 | tmp/ 14 | doc/ 15 | vendor/ 16 | wiki/ 17 | .tox/ 18 | .github/ 19 | .DS_Store 20 | .nyc_output 21 | .travis.yml 22 | appveyor.yml 23 | *.php 24 | *.py 25 | *.pyc 26 | ccxt.sublime-workspace 27 | composer.* 28 | config.js 29 | coverage 30 | exchanges.json 31 | ISSUE_TEMPLATE.md 32 | keys.local.json 33 | keys.json 34 | npm-debug.log 35 | travis-keys.sh 36 | run-tests.js 37 | Dockerfile 38 | docker-compose.yml 39 | phpunit.xml.dist 40 | setup.cfg 41 | exchanges.cfg 42 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | MUST READ THIS BEFORE SUBMITTING ISSUES (read the links, then delete this message before submitting): 2 | 3 | https://github.com/ccxt/ccxt/blob/master/FAQ 4 | https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue 5 | 6 | Make sure your local version of CCXT is up to date. Check by comparing the output of `ccxt.version` to https://github.com/ccxt/ccxt/blob/master/package.json#L3 7 | 8 | - OS: 9 | - Programming Language version: 10 | - CCXT version: 11 | 12 | ``` 13 | REPLACE_THIS_WITH_YOUR_CODE_TO_REPRODUCE_THE_ISSUE_WITHOUT_YOUR_KEYS 14 | ``` 15 | 16 | ``` 17 | REPLACE_THIS_WITH_YOUR_OUTPUT_ERROR_EXCEPTION_IN_TEXT_NO_SCREENSHOTS 18 | ``` 19 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright © 2017 Igor Kroitor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/copy.js: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------------------------------- 2 | // Usage: 3 | // 4 | // node copy from to 5 | // ---------------------------------------------------------------------------- 6 | 7 | "use strict"; 8 | 9 | const ansi = require ('ansicolor').nice 10 | , log = require ('ololog').unlimited 11 | , { copyFile } = require ('./fs.js') 12 | 13 | // ---------------------------------------------------------------------------- 14 | 15 | if (!(process.argv[2] && process.argv[3])) { 16 | log.red ('Failed to copy file from', process.argv[2], 'to', process.argv[3]) 17 | process.exit () 18 | } 19 | 20 | copyFile (process.argv[2], process.argv[3]) 21 | log.green ('Copied', process.argv[2].yellow, '→', process.argv[3].yellow) -------------------------------------------------------------------------------- /build/update-badges.js: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // Usage: 3 | // 4 | // npm run update-badges 5 | // --------------------------------------------------------------------------- 6 | 7 | "use strict"; 8 | 9 | const fs = require ('fs') 10 | const ccxt = require ('../ccxt') 11 | const log = require ('ololog') 12 | const ansi = require ('ansicolor').nice 13 | 14 | //----------------------------------------------------------------------------- 15 | 16 | function updateExchangeCount (fileName) { 17 | 18 | log.bright.cyan ('Updating exchange count →', fileName.yellow) 19 | 20 | let oldContent = fs.readFileSync (fileName, 'utf8') 21 | let newContent = 22 | oldContent.replace (/shields\.io\/badge\/exchanges\-[0-9a-z]+\-blue/g, 'shields.io/badge/exchanges-' + ccxt.exchanges.length + '-blue') 23 | 24 | 25 | fs.truncateSync (fileName) 26 | fs.writeFileSync (fileName, newContent) 27 | 28 | } 29 | 30 | updateExchangeCount ('./README.md') 31 | updateExchangeCount ('./python/README.md') 32 | 33 | log.bright.green ('Badges updated successfully.') 34 | 35 | //----------------------------------------------------------------------------- -------------------------------------------------------------------------------- /ccxt.browser.js: -------------------------------------------------------------------------------- 1 | /* A entry point for the browser bundle version. This gets compiled by: 2 | 3 | browserify --debug ./ccxt.browser.js > ./dist/ccxt.browser.js 4 | */ 5 | 6 | window.ccxt = require ('./ccxt') -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = ccxt 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /doc/_static/css/index.css: -------------------------------------------------------------------------------- 1 | div.body p { 2 | hyphens: none; 3 | } 4 | 5 | #supported-cryptocurrency-exchange-markets td:first-child { 6 | width: 85px; 7 | } -------------------------------------------------------------------------------- /doc/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {% set css_files = css_files + [ "_static/css/index.css" ] %} 3 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=python -msphinx 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=ccxt 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed, 20 | echo.then set the SPHINXBUILD environment variable to point to the full 21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the 22 | echo.Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | 4 | # Runs a CCXT build & test environment with all the required dependencies installed: 5 | # 6 | # docker-compose run --rm ccxt 7 | # 8 | ccxt: 9 | build: 10 | context: . 11 | volumes: 12 | - .:/ccxt 13 | - /ccxt/node_modules/ # Prevents exposing container's node_modules to the host filesystem 14 | entrypoint: /bin/bash 15 | stdin_open: true 16 | tty: true 17 | -------------------------------------------------------------------------------- /examples/ccxt.pro/js/many-exchanges-many-streams.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const ccxtpro = require ('./ccxt.pro'); 4 | 5 | (async () => { 6 | 7 | const streams = { 8 | 'binance': 'BTC/USDT', 9 | 'bittrex': 'BTC/USDT', 10 | 'poloniex': 'BTC/USDT', 11 | 'bitfinex': 'BTC/USDT', 12 | 'hitbtc': 'BTC/USDT', 13 | 'upbit': 'BTC/USDT', 14 | 'coinbasepro': 'BTC/USD', 15 | 'ftx': 'BTC/USDT', 16 | 'okex': 'BTC/USDT', 17 | 'gateio': 'BTC/USDT', 18 | }; 19 | 20 | await Promise.all (Object.keys (streams).map (exchangeId => 21 | 22 | (async () => { 23 | 24 | const exchange = new ccxtpro[exchangeId] ({ enableRateLimit: true }) 25 | const symbol = streams[exchangeId] 26 | while (true) { 27 | try { 28 | const orderbook = await exchange.watchOrderBook (symbol) 29 | console.log (new Date (), exchange.id, symbol, orderbook['asks'][0], orderbook['bids'][0]) 30 | } catch (e) { 31 | console.log (symbol, e) 32 | } 33 | } 34 | 35 | }) ()) 36 | ) 37 | }) () 38 | -------------------------------------------------------------------------------- /examples/ccxt.pro/js/one-exchange-many-streams-2.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const ccxtpro = require ('ccxt.pro'); 4 | 5 | (async () => { 6 | 7 | const exchange = new ccxtpro.binance ({ enableRateLimit: true }) 8 | const symbols = [ 'BTC/USDT', 'ETH/BTC', 'ETH/USDT' ] 9 | 10 | const loop = async (symbol) => { 11 | while (true) { 12 | try { 13 | const orderbook = await exchange.watchOrderBook (symbol) 14 | console.log (new Date (), symbol, orderbook['asks'][0], orderbook['bids'][0]) 15 | } catch (e) { 16 | console.log (symbol, e) 17 | // do nothing and retry on next loop iteration 18 | // throw e // uncomment to break all loops in case of an error in any one of them 19 | // break // you can also break just this one loop if it fails 20 | } 21 | } 22 | } 23 | 24 | await Promise.all (symbols.map (symbol => loop (symbol))) 25 | 26 | }) () 27 | -------------------------------------------------------------------------------- /examples/ccxt.pro/js/one-exchange-many-streams.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const ccxtpro = require ('ccxt.pro'); 4 | 5 | (async () => { 6 | 7 | const exchange = new ccxtpro.binance ({ enableRateLimit: true }) 8 | const symbols = [ 'BTC/USDT', 'ETH/BTC', 'ETH/USDT' ] 9 | 10 | await Promise.all (symbols.map (symbol => 11 | 12 | (async () => { 13 | 14 | while (true) { 15 | try { 16 | const orderbook = await exchange.watchOrderBook (symbol) 17 | console.log (new Date (), symbol, orderbook['asks'][0], orderbook['bids'][0]) 18 | } catch (e) { 19 | console.log (symbol, e) 20 | // do nothing and retry on next loop iteration 21 | // throw e // uncomment to break all loops in case of an error in any one of them 22 | // break // you can also break just this one loop if it fails 23 | } 24 | } 25 | 26 | }) ()) 27 | ) 28 | }) () 29 | -------------------------------------------------------------------------------- /examples/ccxt.pro/js/watch-vs-fetch.js: -------------------------------------------------------------------------------- 1 | // see this issue for details 2 | // https://github.com/ccxt/ccxt/issues/6659 3 | 4 | const ccxtpro = require ('ccxt.pro') 5 | 6 | const exchange = new ccxtpro.kraken ({ 7 | 'enableRateLimit': true 8 | }) 9 | 10 | function yellow (s) { 11 | return '\x1b[33m' + s + '\x1b[0m' 12 | } 13 | 14 | async function runWs () { 15 | while (1) { 16 | const book = await exchange.watchOrderBook ('ETH/BTC') 17 | console.log (new Date (), 'WS ', book['datetime'], book['bids'][0][0], book['asks'][0][0]) 18 | } 19 | } 20 | 21 | async function runRest () { 22 | while (1) { 23 | const book = await exchange.fetchOrderBook ('ETH/BTC') 24 | const timestamp = new Date (exchange.last_response_headers['Date']).getTime () 25 | const datetime = exchange.iso8601 (timestamp) 26 | console.log (new Date (), 'REST', yellow (datetime), book['bids'][0][0], book['asks'][0][0]) 27 | } 28 | } 29 | 30 | runWs () 31 | runRest () -------------------------------------------------------------------------------- /examples/ccxt.pro/php/one-exchange-many-streams.php: -------------------------------------------------------------------------------- 1 | true, 13 | 'loop' => $loop, 14 | )); 15 | 16 | $exchange->load_markets(); 17 | 18 | $symbols = array('BTC/USDT', 'ETH/USDT', 'ETH/BTC'); 19 | 20 | function print_orderbook($orderbook, $symbol) { 21 | $id = isset($orderbook['nonce']) ? $orderbook['nonce'] : $orderbook['datetime']; 22 | echo $id, ' ', $symbol, ' ', 23 | count($orderbook['asks']), ' asks ', json_encode($orderbook['asks'][0]), ' ', 24 | count($orderbook['bids']), ' bids ', json_encode($orderbook['bids'][0]), "\n"; 25 | } 26 | 27 | function loop($exchange, $symbol) { 28 | $exchange->watch_order_book($symbol)->then(function($orderbook) use ($exchange, $symbol) { 29 | print_orderbook($orderbook, $symbol); 30 | loop($exchange, $symbol); 31 | }); 32 | }; 33 | 34 | $main = function () use ($exchange, $symbols) { 35 | foreach ($symbols as $symbol) { 36 | loop($exchange, $symbol); 37 | } 38 | }; 39 | 40 | $loop->futureTick($main); 41 | $loop->run (); 42 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/binance-watch-margin-balance.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import asyncio 4 | import ccxtpro as ccxt 5 | from pprint import pprint 6 | 7 | 8 | async def main(asyncio_loop): 9 | exchange = ccxt.binance({ 10 | 'asyncio_loop': asyncio_loop, 11 | 'enableRateLimit': True, 12 | 'apiKey': 'YOUR_API_KEY', 13 | 'secret': 'YOUR_SECRET', 14 | 'options': { 15 | 'defaultType': 'margin', 16 | }, 17 | # comment it out if you don't want debug output 18 | # this is for the demo purpose only (to show the communication) 19 | 'verbose': True, 20 | }) 21 | while True: 22 | try: 23 | balance = await exchange.watch_balance() 24 | # it will print the balance update when the balance changes 25 | # if the balance remains unchanged the exchange will not send it 26 | pprint(balance) 27 | except Exception as e: 28 | print('watch_balance() failed') 29 | print(e) 30 | break 31 | await exchange.close() 32 | 33 | if __name__ == '__main__': 34 | asyncio_loop = asyncio.get_event_loop() 35 | asyncio_loop.run_until_complete(main(asyncio_loop)) 36 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/coinbasepro-watch-all-trades.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import ccxtpro 4 | import asyncio 5 | 6 | async def main(loop): 7 | exchange = ccxtpro.coinbasepro({'enableRateLimit': False, 'asyncio_loop': loop}) 8 | method = 'watchTrades' 9 | print('CCXT Pro version', ccxtpro.__version__) 10 | if exchange.has[method]: 11 | last_id = '' 12 | while True: 13 | try: 14 | trades = await exchange.watch_trades('BTC/USD') 15 | for trade in trades: 16 | if trade['id'] > last_id: 17 | print(exchange.iso8601(exchange.milliseconds()), trade['symbol'], trade['datetime'], trade['price'], trade['amount']) 18 | last_id = trade['id'] 19 | 20 | except Exception as e: 21 | # stop 22 | await exchange.close() 23 | raise e 24 | # or retry 25 | # pass 26 | else: 27 | raise Exception(exchange.id + ' ' + method + ' is not supported or not implemented yet') 28 | 29 | loop = asyncio.new_event_loop() 30 | loop.run_until_complete(main(loop)) -------------------------------------------------------------------------------- /examples/ccxt.pro/py/coinbasepro-watch-trades.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import ccxtpro 4 | import asyncio 5 | 6 | async def main(loop): 7 | exchange = ccxtpro.coinbasepro({'enableRateLimit': False, 'asyncio_loop': loop}) 8 | method = 'watchTrades' 9 | print('CCXT Pro version', ccxtpro.__version__) 10 | if exchange.has[method]: 11 | while True: 12 | try: 13 | trades = await exchange.watch_trades('BTC/USD') 14 | num_trades = len(trades) 15 | trade = trades[-1] 16 | print(exchange.iso8601(exchange.milliseconds()), trade['symbol'], trade['datetime'], trade['price'], trade['amount'], 'stored', num_trades, 'trades in cache') 17 | except Exception as e: 18 | # stop 19 | await exchange.close() 20 | raise e 21 | # or retry 22 | # pass 23 | else: 24 | raise Exception(exchange.id + ' ' + method + ' is not supported or not implemented yet') 25 | 26 | loop = asyncio.new_event_loop() 27 | loop.run_until_complete(main(loop)) 28 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/gateio-watch-trades.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import asyncio 4 | import ccxtpro 5 | 6 | from datetime import datetime 7 | 8 | async def loop(exchange, symbol): 9 | since = datetime.utcnow() 10 | timestamp = int(since.timestamp() * 1000) 11 | while True: 12 | trades = await exchange.watch_trades(symbol, since=timestamp) 13 | print('--------------------------------------------------------------') 14 | print('Received', len(trades), 'after', exchange.iso8601 (timestamp)) 15 | print('waiting for next update...') 16 | 17 | 18 | async def main(): 19 | exchange = ccxtpro.gateio() 20 | await loop(exchange, 'BTC/USDT') 21 | await exchange.close() 22 | 23 | 24 | if __name__ == '__main__': 25 | asyncio.get_event_loop().run_until_complete(main()) 26 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/many-exchanges-many-streams.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import asyncio 4 | import ccxtpro 5 | 6 | 7 | async def loop(asyncio_loop, exchange_id, symbol): 8 | exchange = getattr(ccxtpro, exchange_id)({ 9 | 'enableRateLimit': True, 10 | 'asyncio_loop': asyncio_loop, 11 | }) 12 | while True: 13 | try: 14 | orderbook = await exchange.watch_order_book(symbol) 15 | now = exchange.milliseconds() 16 | print(exchange.iso8601(now), exchange.id, symbol, orderbook['asks'][0], orderbook['bids'][0]) 17 | except Exception as e: 18 | print(str(e)) 19 | # raise e # uncomment to break all loops in case of an error in any one of them 20 | break # you can break just this one loop if it fails 21 | await exchange.close() 22 | 23 | 24 | async def main(asyncio_loop): 25 | symbols = ['BTC/USDT', 'ETH/BTC'] 26 | # symbols = [] 27 | exchanges = { 28 | 'okex': symbols + ['ETH/USDT'], 29 | 'binance': symbols, 30 | } 31 | loops = [loop(asyncio_loop, exchange_id, symbol) for exchange_id, symbols in exchanges.items() for symbol in symbols] 32 | await asyncio.gather(*loops) 33 | 34 | 35 | if __name__ == '__main__': 36 | asyncio_loop = asyncio.get_event_loop() 37 | asyncio_loop.run_until_complete(main(asyncio_loop)) 38 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/many-exchanges.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import asyncio 4 | import ccxtpro 5 | 6 | 7 | async def loop(exchange_id, symbol): 8 | exchange = getattr(ccxtpro, exchange_id)({'enableRateLimit': True}) 9 | while True: 10 | try: 11 | orderbook = await exchange.watch_order_book(symbol) 12 | now = exchange.milliseconds() 13 | print(exchange.iso8601(now), exchange.id, symbol, orderbook['asks'][0], orderbook['bids'][0]) 14 | except Exception as e: 15 | print(str(e)) 16 | # raise e # uncomment to break all loops in case of an error in any one of them 17 | break # you can break just this one loop if it fails 18 | await exchange.close() 19 | 20 | 21 | async def main(): 22 | symbols = { 23 | 'poloniex': 'BTC/USDT', 24 | 'binance': 'BTC/USDT', 25 | 'bitmex': 'BTC/USD', 26 | } 27 | await asyncio.gather(*[loop(exchange_id, symbol) for exchange_id, symbol in symbols.items()]) 28 | 29 | if __name__ == '__main__': 30 | asyncio.get_event_loop().run_until_complete(main()) 31 | -------------------------------------------------------------------------------- /examples/ccxt.pro/py/one-exchange-different-streams.py: -------------------------------------------------------------------------------- 1 | import ccxtpro 2 | import asyncio 3 | 4 | 5 | async def watch_order_book(exchange, symbol): 6 | while True: 7 | orderbook = await exchange.watch_order_book(symbol) 8 | print(orderbook['datetime'], symbol, orderbook['asks'][0], orderbook['bids'][0]) 9 | 10 | 11 | async def watch_trades(exchange, symbol): 12 | while True: 13 | trades = await exchange.watch_trades(symbol) 14 | last = trades[-1] 15 | print(last['datetime'], last['price'], last['amount']) 16 | 17 | 18 | async def main(): 19 | exchange = ccxtpro.bitstamp({'enableRateLimit': True}) 20 | await exchange.load_markets() 21 | symbol = 'BTC/USD' 22 | while True: 23 | try: 24 | loops = [ 25 | watch_order_book(exchange, symbol), 26 | watch_trades(exchange, symbol) 27 | ] 28 | await asyncio.gather(*loops) 29 | except Exception as e: 30 | print(type(e).__name__, str(e)) 31 | break 32 | await exchange.close() 33 | 34 | 35 | asyncio.get_event_loop().run_until_complete(main()) -------------------------------------------------------------------------------- /examples/ccxt.pro/py/one-exchange-many-streams.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import asyncio 4 | import ccxtpro 5 | 6 | async def loop(exchange, symbol): 7 | while True: 8 | try: 9 | orderbook = await exchange.watch_order_book(symbol) 10 | now = exchange.milliseconds() 11 | print(exchange.iso8601(now), symbol, orderbook['asks'][0], orderbook['bids'][0]) 12 | except Exception as e: 13 | print(str(e)) 14 | # raise e # uncomment to break all loops in case of an error in any one of them 15 | # break # you can also break just this one loop if it fails 16 | 17 | async def main(): 18 | exchange = ccxtpro.poloniex({'enableRateLimit': True}) 19 | symbols = ['BTC/USDT', 'ETH/USDT', 'ETH/BTC'] 20 | await asyncio.gather(*[loop(exchange, symbol) for symbol in symbols]) 21 | await exchange.close() 22 | 23 | if __name__ == '__main__': 24 | asyncio.get_event_loop().run_until_complete(main()) 25 | -------------------------------------------------------------------------------- /examples/html/basic-cors-proxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CCXT Basic example for the browser 5 | 6 | 29 | 30 | 31 |

Hello, CCXT!

32 |

33 | 
34 | 


--------------------------------------------------------------------------------
/examples/html/bitmex-browser-cors-proxy.js:
--------------------------------------------------------------------------------
1 | // JavaScript CORS Proxy
2 | // Save this in a file like cors.js and run with `node cors [port]`
3 | // It will listen for your requests on the port you pass in command line or port 8080 by default
4 | let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 8080 // default
5 | require ('cors-anywhere').createServer ({
6 |     setHeaders: { 'origin': 'https://www.bitmex.com' }
7 | }).listen (port, '0.0.0.0')
8 | 


--------------------------------------------------------------------------------
/examples/js/README.md:
--------------------------------------------------------------------------------
 1 | # CCXT JavaScript Examples
 2 | 
 3 | These examples might require the following super-useful high-quality Node.js modules by [xpl](https://github.com/xpl):
 4 | 
 5 | - [ansicolor](https://github.com/xpl/ansicolor): A quality JavaScript library for the ANSI color/style management ([ansicolor @ npm](https://npmjs.com/package/ansicolor))
 6 | - [as-table](https://github.com/xpl/as-table): A simple function that prints objects as ASCII tables ([as-table @ npm](https://npmjs.com/package/as-table))
 7 | - [ololog](https://github.com/xpl/ololog): Platform-agnostic logging with blackjack and hookers ([ololog @ npm](https://npmjs.com/package/ololog))
 8 | 
 9 | All of the modules above are installed with the ccxt library devDependencies by npm automatically.
10 | 
11 | To run the ccxt JavaScript examples from any folder type in console:
12 | 
13 | ```shell
14 | node path/to/example.js # substitute for actual filename here
15 | ```
16 | 


--------------------------------------------------------------------------------
/examples/js/basic-chart.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt       = require ('../../ccxt.js')
 4 | const asciichart = require ('asciichart')
 5 | const asTable    = require ('as-table')
 6 | const log        = require ('ololog').configure ({ locate: false })
 7 | 
 8 | require ('ansicolor').nice
 9 | 
10 | //-----------------------------------------------------------------------------
11 | 
12 | ;(async function main () {
13 | 
14 |     // experimental, not yet implemented for all exchanges
15 |     // your contributions are welcome ;)
16 | 
17 |     const index = 4 // [ timestamp, open, high, low, close, volume ]
18 |     const ohlcv = await new ccxt.okcoin ().fetchOHLCV ('BTC/USD', '15m')
19 |     const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
20 |     const series = ohlcv.map (x => x[index])         // closing price
21 |     const bitcoinRate = ('₿ = $' + lastPrice).green
22 |     const chart = asciichart.plot (series, { height: 15, padding: '            ' })
23 |     log.yellow ("\n" + chart, bitcoinRate, "\n")
24 |     process.exit ()
25 | 
26 | }) ()


--------------------------------------------------------------------------------
/examples/js/basic-orderbook-polling.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt.js')
 4 |     , id = 'huobipro'
 5 |     , exchange = new ccxt[id] ({ enableRateLimit: true })
 6 |     , symbol = 'ETH/BTC'
 7 | 
 8 | ;(async function main () {
 9 | 
10 |     await exchange.loadMarkets ()
11 | 
12 |     for (let i = 0; i < 2000; i++) {
13 | 
14 |         const orderbook = await exchange.fetchOrderBook (symbol)
15 |         console.log (new Date (), i, symbol, orderbook.asks[0], orderbook.bids[0])
16 |     }
17 | 
18 | }) ()


--------------------------------------------------------------------------------
/examples/js/binance-fetch-ohlcv.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt       = require ('../../ccxt.js')
 4 | const asciichart = require ('asciichart')
 5 | const asTable    = require ('as-table')
 6 | const log        = require ('ololog').configure ({ locate: false })
 7 | 
 8 | require ('ansicolor').nice
 9 | 
10 | //-----------------------------------------------------------------------------
11 | 
12 | ;(async function main () {
13 | 
14 |     const index = 4 // [ timestamp, open, high, low, close, volume ]
15 | 
16 | 
17 |     const ohlcv = await new ccxt.binance ().fetchOHLCV ('BTC/USDT', '1h')
18 | 
19 | 
20 |     const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
21 |     const series = ohlcv.slice (-80).map (x => x[index])         // closing price
22 |     const bitcoinRate = ('₿ = $' + lastPrice).green
23 |     const chart = asciichart.plot (series, { height: 15, padding: '            ' })
24 |     log.yellow ("\n" + chart, bitcoinRate, "\n")
25 |     process.exit ()
26 | 
27 | }) ()


--------------------------------------------------------------------------------
/examples/js/bitfinex-fetch-trades.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const ccxt = require ('../../ccxt.js')
 6 |     , log  = require ('ololog')
 7 |     , asTable = require ('as-table').configure ({ delimiter: ' | ' })
 8 | 
 9 | // ----------------------------------------------------------------------------
10 | 
11 | ;(async () => {
12 | 
13 |     const exchange = new ccxt.bitfinex ({
14 |         'verbose': process.argv.includes ('--verbose'),
15 |         'timeout': 60000,
16 |     })
17 | 
18 |     try {
19 | 
20 |         const response = await exchange.fetchTrades ('ETH/BTC', 1518983548636 - 2 * 24 * 60 * 60 * 1000)
21 |         log (asTable (response))
22 |         log (response.length.toString (), 'trades')
23 |         log.green ('Succeeded.')
24 | 
25 |     } catch (e) {
26 | 
27 |         log.dim ('--------------------------------------------------------')
28 |         log (e.constructor.name, e.message)
29 |         log.dim ('--------------------------------------------------------')
30 |         log.dim (exchange.last_http_response)
31 |         log.error ('Failed.')
32 |     }
33 | 
34 | }) ()


--------------------------------------------------------------------------------
/examples/js/bitfinex2-fetch-trades.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const ccxt = require ('../../ccxt.js')
 6 |     , log  = require ('ololog')
 7 |     , asTable = require ('as-table').configure ({ delimiter: ' | ' })
 8 | 
 9 | // ----------------------------------------------------------------------------
10 | 
11 | ;(async () => {
12 | 
13 |     const exchange = new ccxt.bitfinex2 ({
14 |         'verbose': process.argv.includes ('--verbose'),
15 |         'timeout': 60000,
16 |     })
17 | 
18 |     try {
19 | 
20 |         const response = await exchange.fetchTrades ('ETH/BTC', 1518983548636 - 2 * 24 * 60 * 60 * 1000)
21 |         log (asTable (response))
22 |         log (response.length.toString (), 'trades')
23 |         log.green ('Succeeded.')
24 | 
25 |     } catch (e) {
26 | 
27 |         log.dim ('--------------------------------------------------------')
28 |         log (e.constructor.name, e.message)
29 |         log.dim ('--------------------------------------------------------')
30 |         log.dim (exchange.last_http_response)
31 |         log.error ('Failed.')
32 |     }
33 | 
34 | }) ()


--------------------------------------------------------------------------------
/examples/js/bitmex-browser-cors-proxy.js:
--------------------------------------------------------------------------------
1 | // JavaScript CORS Proxy
2 | // Save this in a file like cors.js and run with `node cors [port]`
3 | // It will listen for your requests on the port you pass in command line or port 8080 by default
4 | let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 8080 // default
5 | require ('cors-anywhere').createServer ({
6 |     setHeaders: { 'origin': 'https://www.bitmex.com' }
7 | }).listen (port, '0.0.0.0')
8 | 


--------------------------------------------------------------------------------
/examples/js/builtin-rate-limiting-rest-poller.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt    = require ('../../ccxt.js')
 4 | const log     = require ('ololog')
 5 | const ansi    = require ('ansicolor').nice
 6 | const asTable = require ('as-table')
 7 | 
 8 | const exchange = new ccxt.coinbasepro ({ enableRateLimit: true })
 9 | const repeat   = 100
10 | 
11 | async function test (symbol) {
12 | 
13 |     for (let i = 0; i < repeat; i++) {
14 |         let ticker = await exchange.fetchTicker (symbol)
15 |         log (exchange.id.green, exchange.iso8601 (exchange.milliseconds ()), ticker['datetime'], symbol.green, ticker['last'])
16 |     }
17 | }
18 | 
19 | const concurrent = [
20 |     test ('BTC/USD'),
21 |     test ('ETH/BTC'),
22 |     test ('ETH/USD')
23 | ]
24 | 
25 | Promise.all (concurrent)


--------------------------------------------------------------------------------
/examples/js/coinone-markets.js:
--------------------------------------------------------------------------------
 1 | "use strict"
 2 | 
 3 | const log = require ('ololog')
 4 |     , ccxt = require ('../../ccxt.js')
 5 | 
 6 | const exchange = new ccxt.coinone ({
 7 |     'enableRateLimit': true,
 8 |     'verbose': process.argv.includes ('--verbose'),
 9 | })
10 | 
11 | ;(async function main () {
12 | 
13 |     const markets = await exchange.loadMarkets ()
14 |     log (markets)
15 |     log ('\n' + exchange['name'] + ' supports ' + Object.keys (markets).length + ' pairs')
16 | 
17 | }) ()
18 | 


--------------------------------------------------------------------------------
/examples/js/cors-proxy.js:
--------------------------------------------------------------------------------
1 | // JavaScript CORS Proxy
2 | // Save this in a file like cors.js and run with `node cors [port]`
3 | // It will listen for your requests on the port you pass in command line or port 8080 by default
4 | let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 8080 // default
5 | require ('cors-anywhere').createServer ().listen (port, '0.0.0.0')
6 | 


--------------------------------------------------------------------------------
/examples/js/credentials.json:
--------------------------------------------------------------------------------
1 | {
2 |     "hitbtc":        { "apiKey": "b6aad581670b30fb25d1c91cdbe8ca5c", "secret": "fa394ced37a488f9b5826a2d9ce39ae3" },
3 |     "bitso":         { "apiKey": "xZnHRmdlgJ", "secret": "e156bb7f7ab3a831afbc7a80f7866b9e" },
4 |     "coincheck":     { "apiKey": "dCyzY2T6w0DFhaco", "secret": "JpI0eMmxfa0tEpk3X-dNwyclSASJkl-S" }
5 | }
6 | 


--------------------------------------------------------------------------------
/examples/js/custom-proxy-url.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt.js')
 4 | 
 5 | ;(async function main () {
 6 | 
 7 |     const kraken1 = new ccxt.kraken ({
 8 |         proxy: function (url) {
 9 |             return 'https://example.com/?url=' + encodeURIComponent (url)
10 |         },
11 |     })
12 | 
13 |     console.log (await kraken1.loadMarkets ())
14 | 
15 |     const kraken2 = new ccxt.kraken ({
16 |         proxy: function (url) {
17 |             return 'https://cors-anywhere.herokuapp.com/' + url
18 |         },
19 |     })
20 | 
21 |     console.log (await kraken2.loadMarkets ())
22 | 
23 | }) ()


--------------------------------------------------------------------------------
/examples/js/env-variables.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const ccxt = require("../../ccxt.js"),
 6 |     log = require ('ololog').handleNodeErrors (),
 7 |     asTable = require("as-table").configure({ delimiter: " | " });
 8 | 
 9 | // ----------------------------------------------------------------------------
10 | 
11 | (async () => {
12 | 
13 |     const exchange = new ccxt.coinbase ({
14 |         verbose: process.argv.includes ('--verbose'),
15 |         timeout: 60000,
16 |         apiKey: process.env.KEY,
17 |         secret: process.env.SECRET
18 |     });
19 | 
20 |     const balance = await exchange.fetchBalance ()
21 |     log.green (balance)
22 | 
23 | })()
24 | 


--------------------------------------------------------------------------------
/examples/js/exchanges.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt      = require ('../../ccxt.js')
 4 | const countries = require ('../../build/countries.js')
 5 | const asTable   = require ('as-table')
 6 | const log       = require ('ololog').configure ({ locate: false })
 7 | 
 8 | require ('ansicolor').nice
 9 | 
10 | process.on ('uncaughtException',  e => { log.bright.red.error (e); process.exit (1) })
11 | process.on ('unhandledRejection', e => { log.bright.red.error (e); process.exit (1) })
12 | 
13 | let exchanges = {}
14 | 
15 | ccxt.exchanges.forEach (id => { exchanges[id] = new (ccxt)[id] () })
16 | 
17 | log ('The ccxt library supports', (ccxt.exchanges.length.toString ()).green, 'exchanges:')
18 | 
19 | var countryName = function (code) {
20 |     return ((countries[code] !== undefined) ? countries[code] : code)
21 | }
22 | 
23 | log (asTable.configure ({ delimiter: ' | ' }) (Object.values (exchanges).map (exchange => {
24 | 
25 |     let countries = Array.isArray (exchange.countries) ?
26 |         exchange.countries.map (countryName).join (', ') :
27 |         countryName (exchange.countries)
28 | 
29 |     let website = Array.isArray (exchange.urls.www) ? exchange.urls.www[0] : exchange.urls.www
30 | 
31 |     return {
32 |         id: exchange.id,
33 |         name: exchange.name,
34 |         url: website,
35 |         countries: countries,
36 |     }
37 | 
38 | })))
39 | 


--------------------------------------------------------------------------------
/examples/js/fetch-from-many-exchanges-simultaneously.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | const ccxt = require ('../../ccxt.js')
 4 | const log  = require ('ololog')
 5 | 
 6 | const symbol = 'ETH/BTC'
 7 | const exchanges = [ 'coinbasepro', 'hitbtc2', 'poloniex' ]
 8 | 
 9 | ;(async () => {
10 | 
11 |     const result = await Promise.all (exchanges.map (async id => {
12 | 
13 |         const exchange = new ccxt[id] ({ 'enableRateLimit': true })
14 |         const ticker = await exchange.fetchTicker (symbol)
15 |         return exchange.extend ({ 'exchange': id }, ticker)
16 | 
17 |     }))
18 | 
19 |     log (result);
20 | 
21 | }) ()


--------------------------------------------------------------------------------
/examples/js/fetch-ohlcv-cex.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt       = require ('../../ccxt.js')
 4 | const asciichart = require ('asciichart')
 5 | const asTable    = require ('as-table')
 6 | const log        = require ('ololog').configure ({ locate: false })
 7 | 
 8 | require ('ansicolor').nice
 9 | 
10 | //-----------------------------------------------------------------------------
11 | 
12 | ;(async function main () {
13 | 
14 |     // experimental, not yet implemented for all exchanges
15 |     // your contributions are welcome ;)
16 | 
17 |     const index = 4 // [ timestamp, open, high, low, close, volume ]
18 |     const ohlcv = await new ccxt.cex ().fetchOHLCV ('BTC/USD', '1m')
19 |     const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
20 |     const series = ohlcv.slice (-80).map (x => x[index]) // closing price
21 |     const bitcoinRate = ('₿ = $' + lastPrice).green
22 |     const chart = asciichart.plot (series, { height: 15, padding: '            ' })
23 |     log.yellow ("\n" + chart, bitcoinRate, "\n")
24 |     process.exit ()
25 | 
26 | }) ()


--------------------------------------------------------------------------------
/examples/js/fetch-okex-futures.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt')
 4 | 
 5 | async function test () {
 6 | 
 7 |     const exchange = new ccxt.okex ()
 8 |     await exchange.loadMarkets ()
 9 | 
10 |     for (let symbol in exchange.markets) {
11 | 
12 |         const market = exchange.markets[symbol]
13 | 
14 |         if (market['future']) {
15 |             console.log ('----------------------------------------------------')
16 |             console.log (symbol, await exchange.fetchTicker (symbol))
17 |             await ccxt.sleep (exchange.rateLimit)
18 |         }
19 |     }
20 | }
21 | 
22 | test ()
23 | 


--------------------------------------------------------------------------------
/examples/js/fetch-orders.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt')
 4 | const asTable = require ('as-table')
 5 | const log = require ('ololog')
 6 | 
 7 | require ('ansicolor').nice
 8 | 
 9 | const exchange = new ccxt.bittrex ({
10 |     apiKey: "471b47a06c384e81b24072e9a8739064",
11 |     secret: "694025686e9445589787e8ca212b4cff",
12 |     enableRateLimit: true,
13 | })
14 | 
15 | async function test () {
16 | 
17 |     const orders = await exchange.fetchOrders ()
18 | 
19 |     log (asTable (orders.map (order => ccxt.omit (order, [ 'timestamp', 'info' ]))))
20 | 
21 |     const order = await exchange.fetchOrder (orders[0]['id'])
22 | 
23 |     log (order)
24 | }
25 | 
26 | test ()


--------------------------------------------------------------------------------
/examples/js/fetch-ticker-from-multiple-exchanges.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt.js')
 4 | 
 5 | ;(async () => {
 6 | 
 7 |     const exchanges = [
 8 |         'bittrex',
 9 |         'poloniex',
10 |     ]
11 | 
12 |     const symbol = 'BTC/USDT'
13 |     const tickers = {}
14 | 
15 |     await Promise.all (exchanges.map (exchangeId =>
16 | 
17 |         new Promise (async (resolve, reject) => {
18 | 
19 |             const exchange = new ccxt[exchangeId] ({ enableRateLimit: true })
20 | 
21 |             while (true) {
22 | 
23 |                 const ticker = await exchange.fetchTicker (symbol)
24 |                 tickers[exchangeId] = ticker
25 | 
26 |                 Object.keys (tickers).map (exchangeId => {
27 |                     const ticker = tickers[exchangeId]
28 |                     console.log (ticker['datetime'], exchangeId, ticker['bid'], ticker['ask'])
29 |                 })
30 |             }
31 | 
32 |         })
33 | 
34 |     ))
35 | 
36 | }) ()


--------------------------------------------------------------------------------
/examples/js/gdax-fetch-trades-pagination.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | 
 4 | const ccxt = require ('../../ccxt.js')
 5 |     , log  = require ('ololog').noLocate
 6 | 
 7 | const exchange = new ccxt.coinbasepro ({
 8 |     'enableRateLimit': true,  // required by the Manual
 9 | })
10 | 
11 | ;(async () => {
12 | 
13 |     const symbol = 'ETH/BTC'
14 |     const params = {}
15 |     await exchange.loadMarkets ()
16 |     while (true) {
17 |         const trades = await exchange.fetchTrades (symbol, undefined, undefined, params)
18 |         if (trades.length) {
19 |             const firstTrade = trades[0]
20 |             const lastTrade = trades[trades.length - 1]
21 |             log.yellow ('Fetched', trades.length, symbol, 'trades from', firstTrade['datetime'], 'to', lastTrade['datetime'])
22 |             if ('Cb-After' in exchange.last_response_headers) {
23 |                 params['after'] = exchange.last_response_headers['Cb-After'];
24 |             }
25 |         } else {
26 |             log.green ('Done.')
27 |             break;
28 |         }
29 |     }
30 | 
31 | }) ()
32 | 


--------------------------------------------------------------------------------
/examples/js/instantiate-all-from-json.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt     = require ('../../ccxt')
 4 |     , settings = require ('./credentials.json')
 5 | 
 6 | const enableRateLimit = true
 7 | 
 8 | async function test () {
 9 | 
10 |     const ids = ccxt.exchanges.filter (id => id in settings)
11 | 
12 |     const exchanges = ccxt.indexBy (await Promise.all (ids.map (async id => {
13 | 
14 |         // instantiate the exchange
15 |         let exchange = new ccxt[id] (ccxt.extend ({ enableRateLimit }, settings[id]))
16 | 
17 |         // load markets
18 |         await exchange.loadMarkets ()
19 | 
20 |         // check the balance
21 |         if (exchange.apiKey) {
22 |             let balance = await exchange.fetchBalance ()
23 |             console.log (exchange.id, balance['free'])
24 |         }
25 | 
26 |         return exchange
27 |     })), 'id')
28 | 
29 |     // when all of them are ready, do your other things
30 |     console.log ('Loaded exchanges:', Object.keys (exchanges).join (', '))
31 | }
32 | 
33 | test ()
34 | 


--------------------------------------------------------------------------------
/examples/js/kraken-fetch-order-trades.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | const ccxt = require ('../../ccxt.js');
 4 | 
 5 | (async () => {
 6 | 
 7 |     const exchange = new ccxt.kraken ({
 8 |         'enableRateLimit': true,
 9 |         'apiKey': 'YOUR_API_KEY',
10 |         'secret': 'YOUR_SECRET',
11 |         // 'verbose': true,
12 |     })
13 | 
14 |     const orders = await exchange.fetchClosedOrders ();
15 | 
16 |     for (let i = 0; i < orders.length; i++) {
17 |         const order = await exchange.fetchOrder (orders[i]['id']);
18 |         const trades = await exchange.fetchOrderTrades (order['id'], undefined, undefined, undefined, order);
19 |         console.log (trades);
20 |     }
21 | 
22 |     //
23 |     // alternatively:
24 |     //
25 |     // const params = {
26 |     //     'trades': [
27 |     //         'TT5UC3-GOIRW-6AZZ6R',
28 |     //         'TIY6G4-LKLAI-Y3GD4A',
29 |     //         'T57FVC-OB4LN-Z55WUL',
30 |     //         'TIMIRG-WUNNE-RRJ6GT',
31 |     //     ]
32 |     // }
33 |     //
34 |     // const trades = await exchange.fetchOrderTrades (order['id'], undefined, undefined, undefined, params);
35 | 
36 | }) ()
37 | 


--------------------------------------------------------------------------------
/examples/js/market-status-and-currency-status.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | const ccxt = require ('../../ccxt')
 4 |     , log = require ('ololog')
 5 |     , asTable = require ('as-table')
 6 | 
 7 | ;(async function main () {
 8 | 
 9 |     let kraken = new ccxt.kraken ({ enableRateLimit: true })
10 |     await kraken.loadMarkets ()
11 | 
12 |     const markets = Object.values (kraken.markets).map (market => ({
13 |         symbol: market.symbol,
14 |         active: market.active,
15 |     }))
16 | 
17 |     log.bright.green.noLocate ('Markets:')
18 |     log.green.noLocate (asTable (markets), '\n')
19 | 
20 |     const currencies = Object.values (kraken.currencies).map (currency => ({
21 |         code: currency.code,
22 |         active: currency.active,
23 |         status: currency.status,
24 |     }))
25 | 
26 |     log.bright.yellow.noLocate ('Currencies:')
27 |     log.yellow.noLocate (asTable (currencies))
28 | 
29 | }) ()
30 | 


--------------------------------------------------------------------------------
/examples/js/order-book-extra-level-depth-param.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | const ccxt = require ('../../ccxt')
 4 | const asTable = require ('as-table')
 5 | const log = require ('ololog')
 6 | 
 7 | require ('ansicolor').nice
 8 | 
 9 | ;(async function test () {
10 | 
11 |     const exchange = new ccxt.bitfinex ()
12 |     const limit = 5
13 |     const orders = await exchange.fetchOrderBook ('BTC/USD', limit, {
14 |         // this parameter is exchange-specific, all extra params have unique names per exchange
15 |         'group': 1, // 1 = orders are grouped by price, 0 = orders are separate
16 |     })
17 | 
18 |     log (orders)
19 | }) ()


--------------------------------------------------------------------------------
/examples/js/poloniex-fetch-order-books.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const ccxt = require ('../../ccxt.js')
 6 | 
 7 | // ----------------------------------------------------------------------------
 8 | 
 9 | ;(async () => {
10 | 
11 |     const exchange = new ccxt.poloniex ({
12 |         'verbose': process.argv.includes ('--verbose'),
13 |         'timeout': 60000,
14 |     })
15 | 
16 |     try {
17 | 
18 |         const response = await exchange.fetchOrderBooks ([
19 |             'ETH/BTC',
20 |             'LTC/BTC',
21 |             'OMG/BTC',
22 |         ])
23 |         console.log (response);
24 |         console.log ('Succeeded.')
25 | 
26 |     } catch (e) {
27 | 
28 |         console.log ('--------------------------------------------------------')
29 |         console.log (e.constructor.name, e.message)
30 |         console.log ('--------------------------------------------------------')
31 |         console.log (exchange.last_http_response)
32 |         console.log ('Failed.')
33 |     }
34 | 
35 | }) ()
36 | 


--------------------------------------------------------------------------------
/examples/php/README.md:
--------------------------------------------------------------------------------
1 | # CCXT PHP Examples
2 | 
3 | To run PHP examples from any folder type in console:
4 | 
5 | ```shell
6 | php -f path/to/example.php # substitute for actual filename here
7 | ```


--------------------------------------------------------------------------------
/examples/php/basic-error-handling.php:
--------------------------------------------------------------------------------
 1 | fetch_ticker ('NONEXISTENT_SYMBOL');
16 |     var_dump ($result);
17 | 
18 | } catch (Exception $e) {
19 | 
20 |     // print it
21 |     echo $e->getMessage () . "\n";
22 | 
23 |     // save to $message (for whatever needs)
24 |     $message = $e->getMessage ();
25 | }
26 | 
27 | ?>
28 | 


--------------------------------------------------------------------------------
/examples/php/binance-cancel-order.php:
--------------------------------------------------------------------------------
 1 |  'YOUR_API_KEY', // ←------------ replace with your keys
11 |     'secret' => 'YOUR_SECRET',
12 |     'verbose' => true,
13 | ));
14 | 
15 | try {
16 | 
17 |     $orderId = 'xxxxxxxx'; // ←--------- replace with your order id
18 |     $symbol = 'XRP/BTC'; // ←--------- replace with your symbol
19 | 
20 |     $exchange->cancelOrder ($orderId, $symbol);
21 | 
22 | } catch (\ccxt\NetworkError $e) {
23 |     echo '[Network Error] ' . $e->getMessage () . "\n";
24 | } catch (\ccxt\ExchangeError $e) {
25 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
26 | } catch (Exception $e) {
27 |     echo '[Error] ' . $e->getMessage () . "\n";
28 | }
29 | 
30 | ?>


--------------------------------------------------------------------------------
/examples/php/binance-fetch-ticker.php:
--------------------------------------------------------------------------------
 1 |  true,
11 |     'timeout' => 30000,
12 | ));
13 | 
14 | try {
15 | 
16 |     $symbol = 'ETH/BTC';
17 |     $result = $exchange->fetch_ticker ($symbol);
18 | 
19 |     var_dump ($result);
20 | 
21 | } catch (\ccxt\NetworkError $e) {
22 |     echo '[Network Error] ' . $e->getMessage () . "\n";
23 | } catch (\ccxt\ExchangeError $e) {
24 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
25 | } catch (Exception $e) {
26 |     echo '[Error] ' . $e->getMessage () . "\n";
27 | }
28 | 
29 | ?>


--------------------------------------------------------------------------------
/examples/php/binance-fetch-tickers.php:
--------------------------------------------------------------------------------
 1 |  true, // for debugging
11 |     'timeout' => 30000,
12 | ));
13 | 
14 | try {
15 | 
16 |     // WARNING !!!
17 | 
18 |     // DO NOT CALL THIS MORE THAN ONCE IN 2 MINUTES OR YOU WILL GET BANNED BY BINANCE!
19 | 
20 |     // https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#limits
21 | 
22 |     $result = $exchange->fetch_tickers ();
23 | 
24 |     print_r ($result);
25 | 
26 | } catch (\ccxt\NetworkError $e) {
27 |     echo '[Network Error] ' . $e->getMessage () . "\n";
28 | } catch (\ccxt\ExchangeError $e) {
29 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
30 | } catch (Exception $e) {
31 |     echo '[Error] ' . $e->getMessage () . "\n";
32 | }
33 | 
34 | ?>


--------------------------------------------------------------------------------
/examples/php/bitfinex2-fetch-ohlcv-since-limit.php:
--------------------------------------------------------------------------------
 1 |  true));
12 | 
13 | // load all markets from the exchange
14 | $markets = $exchange->load_markets ();
15 | 
16 | function run ($exchange, $symbol, $timeframe, $since, $limit) {
17 |     $ohlcvs = $exchange->fetchOHLCV ($symbol, $timeframe, $since, $limit);
18 |     foreach ($ohlcvs as $v) {
19 |         printf ("%s O:%.8f H:%.8f L:%.8f C:%.8f V:%.8f\n", $exchange->iso8601 ($v[0]), $v[1], $v[2], $v[3], $v[4], $v[5]);
20 |     }
21 | }
22 | 
23 | printf ("--------------------------------------------------------------\n");
24 | run ($exchange, 'ETH/BTC', '1m', 1518842513569, 5);
25 | printf ("--------------------------------------------------------------\n");
26 | run ($exchange, 'ETH/BTC', '1m', 1518842513569, 10);
27 | printf ("--------------------------------------------------------------\n");
28 | 
29 | ?>


--------------------------------------------------------------------------------
/examples/php/bitfinex2-fetch-ohlcv.php:
--------------------------------------------------------------------------------
 1 |  true,
12 |     'rateLimit' => 12000,
13 | ));
14 | 
15 | // bitfinex2 breaks occasionally
16 | 
17 | for ($i = 0; $i < 1000; $i++) {
18 |     $ohlcv = $exchange->fetch_ohlcv ('BTC/USD', '1m');
19 |     print_r ($exchange->iso8601 ($ohlcv[0][0]) . "\t" . count($ohlcv) . "\n");
20 | }
21 | 
22 | ?>


--------------------------------------------------------------------------------
/examples/php/bitfinex2-fetch-trades-since.php:
--------------------------------------------------------------------------------
 1 | fetch_trades ('ETH/BTC', 1518983548636 - 2 * 24 * 60 * 60 * 1000);
17 | 
18 | foreach ($trades as $trade) {
19 |     echo $trade['datetime'] . "\n";
20 | }
21 | echo count ($trades) . " trades\n";
22 | 
23 | ?>


--------------------------------------------------------------------------------
/examples/php/bitmex-create-order.php:
--------------------------------------------------------------------------------
 1 |  'YOUR_API_KEY', // ←------------ replace with your keys
11 |     'secret' => 'YOUR_SECRET',
12 |     'enableRateLimit' => true,
13 | ));
14 | 
15 | $symbol = 'XBTM18'; // bitcoin contract according to bitmex futures coding
16 | $type = 'StopLimit'; // # or 'market', or 'Stop' or 'StopLimit'
17 | $side = 'sell'; // or 'buy'
18 | $amount = 1.0;
19 | $price = 6500.0; // or None
20 | 
21 | // extra params and overrides
22 | $params = array (
23 |     'stopPx' => 6000.0, // if needed
24 | );
25 | 
26 | $order = $exchange->create_order ($symbol, $type, $side, $amount, $price, $params);
27 | 
28 | print_r ($order);
29 | 


--------------------------------------------------------------------------------
/examples/php/built-in-rate-limiting-poller.php:
--------------------------------------------------------------------------------
 1 |  true,
12 | ));
13 | 
14 | $symbol = 'DOGE/BTC';
15 | 
16 | while (true) {
17 |     $order_book = $exchange->fetch_order_book ($symbol);
18 |     echo "----------------------------------------------------------------\n";
19 |     echo date ('c') . "\n";
20 |     echo count ($order_book['bids']) . " bids and " . count ($order_book['asks']) . " asks\n";
21 |     echo sprintf ("bid: %.8f ask: %.8f", $order_book['bids'][0][0], $order_book['asks'][0][0]) . "\n";
22 | }
23 | 


--------------------------------------------------------------------------------
/examples/php/coinbasepro-fetch-ticker.php:
--------------------------------------------------------------------------------
 1 |  true,
11 | ));
12 | 
13 | echo "CCXT v." . \ccxt\Exchange::VERSION . "\n";
14 | 
15 | try {
16 | 
17 |     $symbol = 'ETH/BTC';
18 |     $result = $exchange->fetch_ticker ($symbol);
19 | 
20 |     var_dump ($result);
21 | 
22 | } catch (\ccxt\NetworkError $e) {
23 |     echo '[Network Error] ' . $e->getMessage () . "\n";
24 | } catch (\ccxt\ExchangeError $e) {
25 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
26 | } catch (Exception $e) {
27 |     echo '[Error] ' . $e->getMessage () . "\n";
28 | }
29 | 
30 | ?>
31 | 


--------------------------------------------------------------------------------
/examples/php/coinone-fetch-tickers.php:
--------------------------------------------------------------------------------
 1 |  true,
 9 |     // 'verbose' => true, // uncomment for verbose output
10 | ));
11 | 
12 | // fetch all
13 | $tickers = $exchange->fetch_tickers();
14 | var_dump ($tickers);
15 | 
16 | echo "\n";
17 | 
18 | // fetch one by one
19 | $markets = $exchange->load_markets();
20 | foreach ($markets as $symbol => $m) {
21 |     var_dump($exchange->fetch_ticker($symbol));
22 | }
23 | 
24 | ?>
25 | 


--------------------------------------------------------------------------------
/examples/php/coinone-markets.php:
--------------------------------------------------------------------------------
 1 |  true,
 9 |     // 'verbose' => true, // uncomment for verbose output
10 | ));
11 | 
12 | $markets = $exchange->load_markets();
13 | 
14 | var_dump ($markets);
15 | echo "\n" . $exchange->name . " supports " . count($markets) . " pairs\n";
16 | 
17 | ?>
18 | 


--------------------------------------------------------------------------------
/examples/php/gdax-fetch-ticker.php:
--------------------------------------------------------------------------------
 1 |  true,
11 | ));
12 | 
13 | echo "CCXT v." . \ccxt\Exchange::VERSION . "\n";
14 | 
15 | try {
16 | 
17 |     $symbol = 'ETH/BTC';
18 |     $result = $exchange->fetch_ticker ($symbol);
19 | 
20 |     var_dump ($result);
21 | 
22 | } catch (\ccxt\NetworkError $e) {
23 |     echo '[Network Error] ' . $e->getMessage () . "\n";
24 | } catch (\ccxt\ExchangeError $e) {
25 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
26 | } catch (Exception $e) {
27 |     echo '[Error] ' . $e->getMessage () . "\n";
28 | }
29 | 
30 | ?>
31 | 


--------------------------------------------------------------------------------
/examples/php/huobi-fetch-balance.php:
--------------------------------------------------------------------------------
 1 |  'YOUR_API_KEY', // ←------------ replace with your keys
11 |     'secret' => 'YOUR_SECRET',
12 |     // 'verbose' => true, // uncomment if debug output is needed
13 | ));
14 | 
15 | try {
16 | 
17 |     $balance = $exchange->fetch_balance ();
18 |     var_dump ($balance);
19 | 
20 | } catch (\ccxt\NetworkError $e) {
21 |     echo '[Network Error] ' . $e->getMessage () . "\n";
22 | } catch (\ccxt\ExchangeError $e) {
23 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
24 | } catch (Exception $e) {
25 |     echo '[Error] ' . $e->getMessage () . "\n";
26 | }
27 | 
28 | ?>
29 | 


--------------------------------------------------------------------------------
/examples/php/kraken-query-ledgers.php:
--------------------------------------------------------------------------------
 1 |  'YOUR_API_KEY',
15 |     'secret' => 'YOUR_SECRET_KEY',
16 | ));
17 | 
18 | // get ledgers
19 | $ledgers = $exchange->privatePostLedgers ();
20 | 
21 | // get ledger ids
22 | $ids = array_keys ($ledgers['result']['ledger']);
23 | 
24 | // get ledger entries for ledger id
25 | $ledger_entries = $exchange->privatePostQueryLedgers (array (
26 |     'id' =>  $ids[0],
27 | ));
28 | 
29 | var_dump ($ledger_entries);
30 | 
31 | ?>


--------------------------------------------------------------------------------
/examples/php/nonce-override.php:
--------------------------------------------------------------------------------
 1 | milliseconds();
12 |     }
13 | }
14 | 
15 | $exchange = new MillisecondsNonceExchange (array (
16 |     'enableRateLimit' => true,
17 |     'apiKey' => 'YOUR_API_KEY',
18 |     'secret' => 'YOUR_SECRET',
19 | ));
20 | 
21 | try {
22 |     $symbol = 'ETH/BTC';
23 |     $result = $exchange->fetch_balance ($symbol);
24 |     var_dump ($result);
25 | } catch (\ccxt\NetworkError $e) {
26 |     echo '[Network Error] ' . $e->getMessage () . "\n";
27 | } catch (\ccxt\ExchangeError $e) {
28 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
29 | } catch (Exception $e) {
30 |     echo '[Error] ' . $e->getMessage () . "\n";
31 | }
32 | 
33 | ?>


--------------------------------------------------------------------------------
/examples/php/order-book-level-depth-extra-param.php:
--------------------------------------------------------------------------------
 1 | fetch_order_book ('BTC/USD', $limit));
14 | 
15 | 
16 | ?>


--------------------------------------------------------------------------------
/examples/php/react-eventloop-with-rate-limiting.php:
--------------------------------------------------------------------------------
 1 | fetch_order_book ($symbol);
20 |     echo "----------------------------------------------------------------\n";
21 |     echo date ('c') . "\n";
22 |     echo count ($order_book['bids']) . " bids and " . count ($order_book['asks']) . " asks\n";
23 |     echo sprintf ("bid: %.8f ask: %.8f", $order_book['bids'][0][0], $order_book['asks'][0][0]) . "\n";
24 | 
25 |     $loop->futureTick ($tick_function);
26 | };
27 | 
28 | $loop->futureTick ($tick_function);
29 | $loop->run ();


--------------------------------------------------------------------------------
/examples/php/trading-view.php:
--------------------------------------------------------------------------------
 1 |  true,
19 | ));
20 | 
21 | // OHLCV format by default
22 | $ohlcv = $exchange->fetch_ohlcv ($symbol);
23 | 
24 | // convert OHLCV → TradingView
25 | $trading_view = $exchange->convert_ohlcv_to_trading_view ($ohlcv);
26 | 
27 | // convert TradingView → OHCLV
28 | $restored_ohlcvs = $exchange->convert_trading_view_to_ohlcv ($trading_view);
29 | 
30 | print_r ($restored_ohlcvs);
31 | 
32 | ?>


--------------------------------------------------------------------------------
/examples/php/vaultoro-fetch-balance.php:
--------------------------------------------------------------------------------
 1 |  true, // for debugging
11 |     // 'timeout' => 30000,
12 |     "apiKey" => "CEwxqNb3GzixcrhzrPkn47JkdsDpff6z",
13 |     "secret" => "ZXRBWURDN3NSVFNJSmFIRHlOWUVfd1d6UjZwSFdiTGI=",
14 | ));
15 | 
16 | try {
17 | 
18 |     $result = $exchange->fetch_balance ();
19 | 
20 |     print_r ($result);
21 | 
22 | } catch (\ccxt\NetworkError $e) {
23 |     echo '[Network Error] ' . $e->getMessage () . "\n";
24 | } catch (\ccxt\ExchangeError $e) {
25 |     echo '[Exchange Error] ' . $e->getMessage () . "\n";
26 | } catch (Exception $e) {
27 |     echo '[Error] ' . $e->getMessage () . "\n";
28 | }
29 | 
30 | ?>


--------------------------------------------------------------------------------
/examples/py/README.md:
--------------------------------------------------------------------------------
 1 | # CCXT Python Examples
 2 | 
 3 | To run Python examples from any folder, type in console:
 4 | 
 5 | ```shell
 6 | python path/to/example.py # substitute for actual filename here
 7 | ```
 8 | 
 9 | Example files starting with `async-` require Python 3.6 with `async`/`await` and async generators support.
10 | 
11 | ![basic-chart](https://user-images.githubusercontent.com/1294454/29979754-6d62354c-8f4f-11e7-9e0a-22e87b4a093b.jpg)
12 | 
13 | ## See Also
14 | 
15 | [co3k-crypto-currency-note](https://github.com/co3k/co3k-crypto-currency-note/blob/master/Untitled.ipynb) – an example of using ccxt to fetch OHLCV candles from Kraken and charting them with matplotlib in a Jupyter Notebook, made by [co3k](https://github.com/co3k).
16 | 


--------------------------------------------------------------------------------
/examples/py/async-balance-coinbasepro.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 |     exchange = ccxt.coinbasepro({
15 |         'apiKey': "a43edfe629bc5991acc83a536ac6358e",
16 |         'secret': "xOvq+iH8NT07TheFB/fmY3GcnMZMwP7Xct9zwWtAZxsCbJh8rxeEe/0BGxfbV2em7P9iqQD7/TJGqmsDO8B/kw==",
17 |         'password': 'zdmj8o7byla',
18 |         'verbose': True,  # switch it to False if you don't want the HTTP log
19 |     })
20 |     # move to sandbox
21 |     exchange.urls['api'] = exchange.urls['test']
22 |     print(await exchange.fetch_balance())
23 | 
24 | 
25 | asyncio.get_event_loop().run_until_complete(test())
26 | 


--------------------------------------------------------------------------------
/examples/py/async-balance-gdax.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 |     gdax = ccxt.gdax({
15 |         'apiKey': "a43edfe629bc5991acc83a536ac6358e",
16 |         'secret': "xOvq+iH8NT07TheFB/fmY3GcnMZMwP7Xct9zwWtAZxsCbJh8rxeEe/0BGxfbV2em7P9iqQD7/TJGqmsDO8B/kw==",
17 |         'password': 'zdmj8o7byla',
18 |         'verbose': True,  # switch it to False if you don't want the HTTP log
19 |     })
20 |     # move gdax to sandbox
21 |     gdax.urls['api'] = 'https://api-public.sandbox.gdax.com'
22 |     print(await gdax.fetch_balance())
23 | 
24 | 
25 | asyncio.get_event_loop().run_until_complete(test())
26 | 


--------------------------------------------------------------------------------
/examples/py/async-balance.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 |     bittrex = ccxt.bittrex({
15 |         'apiKey': "c5af1d0ceeaa4729ad87da1b05d9dfc3",
16 |         'secret': "d055d8e47fdf4c3bbd0ec6c289ea8ffd",
17 |         'verbose': True,  # switch it to False if you don't want the HTTP log
18 |     })
19 |     print(await bittrex.fetch_balance())
20 |     await bittrex.close()
21 | 
22 | 
23 | asyncio.get_event_loop().run_until_complete(test())
24 | 


--------------------------------------------------------------------------------
/examples/py/async-balances.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test(exchange):
14 |     print(await exchange.fetch_balance())
15 |     await exchange.close()
16 | 
17 | 
18 | kraken = ccxt.kraken({
19 |     'apiKey': "hEvQNMDIeoCJbr7W/ZBb5CGOrx3G0lWF5B3zqa1JBxdZlEaL8EK+D0Mw",
20 |     'secret': "JaE9wI6Nwgh5oRxiHcVxurwzwBxwc05W/qv/k1srGg4s3EYuXPpNkLLM5NYbbWpM8rCyijIeDavRuqWbU0ZV9A==",
21 |     'verbose': True,  # switch it to False if you don't want the HTTP log
22 | })
23 | bitfinex = ccxt.bitfinex({
24 |     'apiKey': "4FlEDtxDl35gdEiobnfZ72vJeZteE4Bb7JdvqzjIjHq",
25 |     'secret': "D4DXM8DZdHuAq9YptUsb42aWT1XBnGlIJgLi8a7tzFH",
26 |     'verbose': True,  # switch it to False if you don't want the HTTP log
27 | })
28 | 
29 | [asyncio.ensure_future(test(exchange)) for exchange in [kraken, bitfinex]]
30 | pending = asyncio.Task.all_tasks()
31 | loop = asyncio.get_event_loop()
32 | loop.run_until_complete(asyncio.gather(*pending))
33 | 


--------------------------------------------------------------------------------
/examples/py/async-basic-orderbook.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 | 
15 |     exchange = ccxt.okex({
16 | 
17 |         # 'proxy': 'https://cors-anywhere.herokuapp.com/',
18 |         # 'origin': 'foobar',  # when using CORS proxies, set this to some random string
19 | 
20 |         'enableRateLimit': True,  # required accoding to the Manual
21 |     })
22 | 
23 |     try:
24 |         orderbook = await exchange.fetch_order_book('BTC/USDT')
25 |         await exchange.close()
26 |         return orderbook
27 |     except ccxt.BaseError as e:
28 |         print(type(e).__name__, str(e), str(e.args))
29 |         raise e
30 | 
31 | 
32 | if __name__ == '__main__':
33 |     print(asyncio.get_event_loop().run_until_complete(test()))
34 | 


--------------------------------------------------------------------------------
/examples/py/async-basic-rate-limiter.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def main():
14 |     exchange = ccxt.binance({
15 |         'enableRateLimit': True,  # required by the Manual
16 |     })
17 |     for i in range(0, 100):
18 |         # this can be any call instead of fetch_ticker, really
19 |         print(await exchange.fetch_ticker('ETH/BTC'))
20 |     await exchange.close()
21 | 
22 | 
23 | asyncio.get_event_loop().run_until_complete(main())
24 | 


--------------------------------------------------------------------------------
/examples/py/async-basic.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test_binance():
14 |     exchange = ccxt.binance({'enableRateLimit': True})
15 |     markets = await exchange.load_markets()
16 |     await exchange.close()
17 |     return markets
18 | 
19 | if __name__ == '__main__':
20 |     print(asyncio.get_event_loop().run_until_complete(test_binance()))
21 | 


--------------------------------------------------------------------------------
/examples/py/async-binance-fetch-margin-balance-with-options.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def main(asyncio_loop):
15 |     exchange = ccxt.binance({
16 |         'asyncio_loop': asyncio_loop,
17 |         'enableRateLimit': True,
18 |         'apiKey': 'YOUR_API_KEY',
19 |         'secret': 'YOUR_SECRET',
20 |         "options": {
21 |             "fetchBalance": "margin",
22 |         },
23 |         # set verbose mode to True for debugging output
24 |         # 'verbose': True,
25 |     })
26 |     while True:
27 |         try:
28 |             balance = await exchange.fetch_balance()
29 |             pprint(balance)
30 |         except Exception as e:
31 |             print('fetch_balance() failed')
32 |             print(e)
33 |             break
34 |     await exchange.close()
35 | 
36 | if __name__ == '__main__':
37 |     asyncio_loop = asyncio.get_event_loop()
38 |     asyncio_loop.run_until_complete(main(asyncio_loop))
39 | 


--------------------------------------------------------------------------------
/examples/py/async-binance-fetch-margin-balance-with-params.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def main(asyncio_loop):
15 |     exchange = ccxt.binance({
16 |         'asyncio_loop': asyncio_loop,
17 |         'enableRateLimit': True,
18 |         'apiKey': 'YOUR_API_KEY',
19 |         'secret': 'YOUR_SECRET',
20 |     })
21 |     while True:
22 |         try:
23 |             balance = await exchange.fetch_balance({'type': 'margin'})
24 |             pprint(balance)
25 |         except Exception as e:
26 |             print('fetch_balance() failed')
27 |             print(e)
28 |             break
29 |     await exchange.close()
30 | 
31 | if __name__ == '__main__':
32 |     asyncio_loop = asyncio.get_event_loop()
33 |     asyncio_loop.run_until_complete(main(asyncio_loop))
34 | 


--------------------------------------------------------------------------------
/examples/py/async-binance-margin-repay.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def main(asyncio_loop):
15 |     exchange = ccxt.binance({
16 |         'asyncio_loop': asyncio_loop,
17 |         'enableRateLimit': True,
18 |         'apiKey': 'YOUR_API_KEY',
19 |         'secret': 'YOUR_SECRET',
20 |         'verbose': True,  # for debug output
21 |     })
22 |     await exchange.load_markets()
23 |     code = 'BTC'
24 |     amount = 1
25 |     currency = exchange.currency(code)
26 |     try:
27 |         response = await exchange.sapi_post_margin_repay({
28 |             'asset': currency['id'],
29 |             'amount': exchange.currency_to_precision(code, amount)
30 |         })
31 |         pprint(response)
32 |     except Exception as e:
33 |         print('sapi_post_margin_repay() failed')
34 |         print(e)
35 |     await exchange.close()
36 | 
37 | if __name__ == '__main__':
38 |     asyncio_loop = asyncio.get_event_loop()
39 |     asyncio_loop.run_until_complete(main(asyncio_loop))
40 | 


--------------------------------------------------------------------------------
/examples/py/async-bitfinex-public-get-symbols.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 |     bitfinex = ccxt.bitfinex({
15 |         'apiKey': "4FlEDtxDl35gdEiobnfZ72vJeZteE4Bb7JdvqzjIjHq",
16 |         'secret': "D4DXM8DZdHuAq9YptUsb42aWT1XBnGlIJgLi8a7tzFH",
17 |         'verbose': True,  # switch it to False if you don't want the HTTP log
18 |     })
19 |     print(await bitfinex.public_get_symbols())
20 |     await bitfinex.close()
21 | 
22 | loop = asyncio.get_event_loop()
23 | loop.run_until_complete(test())
24 | 


--------------------------------------------------------------------------------
/examples/py/async-bittrex-orderbook.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | if not sys.version >= '3.6':
 8 |     print('This script requires Python 3.6+')
 9 |     sys.exit()
10 | 
11 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12 | sys.path.append(root + '/python')
13 | 
14 | import ccxt.async_support as ccxt  # noqa: E402
15 | 
16 | 
17 | async def poll():
18 |     exchange = ccxt.bittrex()
19 |     while True:
20 |         yield await exchange.fetch_order_book('BTC/USDT')
21 |         await asyncio.sleep(exchange.rateLimit / 1000)
22 | 
23 | 
24 | async def main():
25 |     async for orderbook in poll():
26 |         print(orderbook['bids'][0], orderbook['asks'][0])
27 | 
28 | 
29 | asyncio.get_event_loop().run_until_complete(main())
30 | 


--------------------------------------------------------------------------------
/examples/py/async-fetch-balance.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def test():
14 |     exchange = ccxt.bitstamp({
15 |         'enableRateLimit': True,  # as required by the Manual
16 |         # "verbose": True,  # useful for debugging purposes, uncomment if needed
17 |         'apiKey': 'YOUR_API_KEY',
18 |         'secret': 'YOUR_SECRET',
19 |         'uid': 'YOUR_UID',
20 |         # i'm adding a CORS proxy here, because my country is blocked by bitstamp
21 |         # you don't need this, so it's safe to comment it out
22 |         # "proxy": "https://cors-anywhere.herokuapp.com/",
23 |         # "origin": "bitstamp"
24 |     })
25 |     print(await exchange.fetch_balance())
26 |     await exchange.close()  # don't forget to close it when you're done
27 |     return True
28 | 
29 | if __name__ == '__main__':
30 |     print('CCXT version:', ccxt.__version__)
31 |     print(asyncio.get_event_loop().run_until_complete(test()))
32 | 


--------------------------------------------------------------------------------
/examples/py/async-fetch-ticker.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | pprint(asyncio.get_event_loop().run_until_complete(ccxt.binance().fetch_ticker('ETH/BTC')))
14 | 


--------------------------------------------------------------------------------
/examples/py/async-gdax-fetch-order-book-continuously.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def main(symbol):
14 |     # you can set enableRateLimit = True to enable the built-in rate limiter
15 |     # this way you request rate will never hit the limit of an exchange
16 |     # the library will throttle your requests to avoid that
17 |     exchange = ccxt.binance({
18 |         'enableRateLimit': True,  # this option enables the built-in rate limiter
19 |     })
20 |     while True:
21 |         print('--------------------------------------------------------------')
22 |         print(exchange.iso8601(exchange.milliseconds()), 'fetching', symbol, 'ticker from', exchange.name)
23 |         # this can be any call really
24 |         ticker = await exchange.fetch_order_book(symbol)
25 |         print(exchange.iso8601(exchange.milliseconds()), 'fetched', symbol, 'ticker from', exchange.name)
26 |         print(ticker)
27 | 
28 | 
29 | asyncio.get_event_loop().run_until_complete(main('BTC/USDT'))
30 | 


--------------------------------------------------------------------------------
/examples/py/async-generator-basic.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def poll():
14 |     exchange = ccxt.poloniex({
15 |         'enableRateLimit': True,
16 |         # don't remove this line or they might ban you: https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
17 |     })
18 |     while True:
19 |         yield await exchange.fetch_ticker('ETH/BTC')
20 | 
21 | 
22 | async def main():
23 |     async for ticker in poll():
24 |         print(ticker)
25 | 
26 | 
27 | asyncio.get_event_loop().run_until_complete(main())
28 | 


--------------------------------------------------------------------------------
/examples/py/async-generator-multiple-tickers.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import ccxt.async_support as ccxt
 5 | 
 6 | 
 7 | async def poll(tickers):
 8 |     i = 0
 9 |     kraken = ccxt.kraken()
10 |     while True:
11 |         symbol = tickers[i % len(tickers)]
12 |         yield (symbol, await kraken.fetch_ticker(symbol))
13 |         i += 1
14 |         await asyncio.sleep(kraken.rateLimit / 1000)
15 | 
16 | 
17 | async def main():
18 |     async for (symbol, ticker) in poll(['BTC/USD', 'ETH/BTC', 'BTC/EUR']):
19 |         print(symbol, ticker)
20 | 
21 | 
22 | asyncio.get_event_loop().run_until_complete(main())
23 | 


--------------------------------------------------------------------------------
/examples/py/async-generator-ticker-poller.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def poll():
14 |     kraken = ccxt.kraken({
15 |         'apiKey': "hEvQNMDIeoCJbr7W/ZBb5CGOrx3G0lWF5B3zqa1JBxdZlEaL8EK+D0Mw",
16 |         'secret': "JaE9wI6Nwgh5oRxiHcVxurwzwBxwc05W/qv/k1srGg4s3EYuXPpNkLLM5NYbbWpM8rCyijIeDavRuqWbU0ZV9A==",
17 |         # 'verbose': True, # switch it to False if you don't want the HTTP log
18 |     })
19 |     while True:
20 |         yield await kraken.fetch_ticker('BTC/USD')
21 |         await asyncio.sleep(kraken.rateLimit / 1000)
22 | 
23 | 
24 | async def main():
25 |     async for ticker in poll():
26 |         print(ticker)
27 | 
28 | 
29 | asyncio.get_event_loop().run_until_complete(main())
30 | 


--------------------------------------------------------------------------------
/examples/py/async-instantiate-all-at-once.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import asyncio
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | exchanges = {}  # a placeholder for your instances
13 | 
14 | 
15 | async def main():
16 |     for id in ccxt.exchanges:
17 |         exchange = getattr(ccxt, id)
18 |         exchanges[id] = exchange()
19 |     # now exchanges dictionary contains all exchange instances...
20 |     print(await exchanges['bittrex'].fetch_order_book('ETH/BTC'))
21 |     # close the aiohttp session object
22 |     for id in exchanges:
23 |         await exchanges[id].close()
24 | 
25 | asyncio.get_event_loop().run_until_complete(main())
26 | 


--------------------------------------------------------------------------------
/examples/py/async-multiple-accounts.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt.async_support as ccxt  # noqa: E402
11 | 
12 | 
13 | async def fetch_balance_n_times(code, account, n):
14 |     exchange_class = getattr(ccxt, account['exchange_id'])
15 |     exchange = exchange_class(account['params'])
16 |     for i in range(0, n):
17 |         balance = await exchange.fetch_balance()
18 |         print(exchange.id, code, 'balance:', balance[code])
19 |     await exchange.close()
20 | 
21 | 
22 | async def test():
23 |     n = 10  # fetch 10 times
24 |     code = 'BTC'
25 |     accounts = [
26 |         {'exchange_id': 'binance', 'params': {'id': 'Binance1', 'apiKey': 'YOUR_API_KEY_1', 'secret': 'YOUR_API_SECRET_1'}},
27 |         {'exchange_id': 'binance', 'params': {'id': 'Binance2', 'apiKey': 'YOUR_API_KEY_2', 'secret': 'YOUR_API_SECRET_2'}},
28 |     ]
29 |     coroutines = [fetch_balance_n_times(code, account, n) for account in accounts]
30 |     await asyncio.gather(*coroutines)
31 | 
32 | if __name__ == '__main__':
33 |     asyncio.get_event_loop().run_until_complete(test())
34 | 


--------------------------------------------------------------------------------
/examples/py/async-okex-fetch-margin-balance-with-options.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def loop(exchange):
15 |     while True:
16 |         try:
17 |             balance = await exchange.fetch_balance()
18 |             pprint(balance)
19 |         except Exception as e:
20 |             print('fetch_balance() failed')
21 |             print(e)
22 | 
23 | 
24 | async def main():
25 |     exchange = ccxt.okex({
26 |         'enableRateLimit': True,
27 |         'apiKey': 'YOUR_API_KEY',
28 |         'secret': 'YOUR_SECRET',
29 |         # okex requires this: https://github.com/ccxt/ccxt/wiki/Manual#authentication
30 |         'password': 'YOUR_API_PASSWORD',
31 |         # to always default to 'margin' balance type
32 |         'options': {
33 |             'fetchBalance': 'margin',
34 |         },
35 |     })
36 |     await loop(exchange)
37 |     await exchange.close()
38 | 
39 | if __name__ == '__main__':
40 |     asyncio.get_event_loop().run_until_complete(main())
41 | 


--------------------------------------------------------------------------------
/examples/py/async-okex-fetch-margin-balance-with-params.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def loop(exchange):
15 |     while True:
16 |         try:
17 |             balance = await exchange.fetch_balance({
18 |                 'type': 'margin',
19 |             })
20 |             pprint(balance)
21 |         except Exception as e:
22 |             print('fetch_balance() failed')
23 |             print(e)
24 | 
25 | 
26 | async def main():
27 |     exchange = ccxt.okex({
28 |         'enableRateLimit': True,
29 |         'apiKey': 'YOUR_API_KEY',
30 |         'secret': 'YOUR_SECRET',
31 |         # okex requires this: https://github.com/ccxt/ccxt/wiki/Manual#authentication
32 |         'password': 'YOUR_API_PASSWORD'
33 |     })
34 |     await loop(exchange)
35 |     await exchange.close()
36 | 
37 | if __name__ == '__main__':
38 |     asyncio.get_event_loop().run_until_complete(main())
39 | 


--------------------------------------------------------------------------------
/examples/py/async-theocean-orderbook.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | 
 7 | if not sys.version >= '3.6':
 8 |     print('This script requires Python 3.6+')
 9 |     sys.exit()
10 | 
11 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12 | sys.path.append(root + '/python')
13 | 
14 | import ccxt.async_support as ccxt  # noqa: E402
15 | 
16 | 
17 | async def poll():
18 |     exchange = ccxt.theocean()
19 |     while True:
20 |         yield await exchange.fetch_order_book('WETH/TUSD')
21 |         await asyncio.sleep(exchange.rateLimit / 1000)
22 | 
23 | 
24 | async def main():
25 |     async for orderbook in poll():
26 |         print(orderbook['bids'][0], orderbook['asks'][0])
27 | 
28 | 
29 | asyncio.get_event_loop().run_until_complete(main())
30 | 


--------------------------------------------------------------------------------
/examples/py/async-ticker.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import os
 5 | import sys
 6 | from pprint import pprint
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def test(id, symbol):
15 |     exchange = getattr(ccxt, id)({
16 |         'enableRateLimit': True,  # required according to the Manual
17 |     })
18 |     ticker = await exchange.fetch_ticker(symbol)
19 |     await exchange.close()
20 |     return ticker
21 | 
22 | if __name__ == '__main__':
23 |     id = 'binance'
24 |     symbol = 'ETH/BTC'
25 |     pprint(asyncio.get_event_loop().run_until_complete(test(id, symbol)))
26 | 


--------------------------------------------------------------------------------
/examples/py/async-with-threads.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import threading
 5 | import os
 6 | import sys
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def test(loop):
15 |     exchange = ccxt.bittrex({
16 |         'asyncio_loop': loop,
17 |         'enableRateLimit': True,  # as required by https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
18 |     })
19 |     print(await exchange.fetch_ticker('ETH/BTC'))
20 |     await exchange.close()
21 | 
22 | 
23 | def function_in_a_thread():
24 |     # get_event_loop doesn't work inside a thread
25 |     loop = asyncio.new_event_loop()
26 |     loop.run_until_complete(test(loop))
27 | 
28 | 
29 | def another_threaded_function():
30 |     global_loop.run_until_complete(test(global_loop))
31 | 
32 | 
33 | global_loop = asyncio.get_event_loop()
34 | thread = threading.Thread(target=function_in_a_thread)
35 | thread2 = threading.Thread(target=another_threaded_function)
36 | thread.start()
37 | thread2.start()
38 | thread.join()
39 | thread2.join()
40 | 


--------------------------------------------------------------------------------
/examples/py/async.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import asyncio
 4 | import functools
 5 | import os
 6 | import sys
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt.async_support as ccxt  # noqa: E402
12 | 
13 | 
14 | async def print_ticker(symbol, id):
15 |     # verbose mode will show the order of execution to verify concurrency
16 |     exchange = getattr(ccxt, id)({'verbose': True})
17 |     print(await exchange.fetch_ticker(symbol))
18 |     await exchange.close()
19 | 
20 | 
21 | if __name__ == '__main__':
22 | 
23 |     symbol = 'ETH/BTC'
24 |     print_ethbtc_ticker = functools.partial(print_ticker, symbol)
25 |     [asyncio.ensure_future(print_ethbtc_ticker(id)) for id in [
26 |         'bitfinex',
27 |         'poloniex',
28 |         'kraken',
29 |         'bittrex',
30 |         'hitbtc',
31 |     ]]
32 |     pending = asyncio.Task.all_tasks()
33 |     loop = asyncio.get_event_loop()
34 |     loop.run_until_complete(asyncio.gather(*pending))
35 | 


--------------------------------------------------------------------------------
/examples/py/balance-coinbasepro.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | exchange = ccxt.coinbasepro({
12 |     'apiKey': "a43edfe629bc5991acc83a536ac6358e",
13 |     'secret': "xOvq+iH8NT07TheFB/fmY3GcnMZMwP7Xct9zwWtAZxsCbJh8rxeEe/0BGxfbV2em7P9iqQD7/TJGqmsDO8B/kw==",
14 |     'password': 'zdmj8o7byla',
15 |     'verbose': True,  # switch it to False if you don't want the HTTP log
16 | })
17 | 
18 | # move to sandbox
19 | exchange.urls['api'] = exchange.urls['test']
20 | 
21 | print(exchange.fetch_balance())
22 | 


--------------------------------------------------------------------------------
/examples/py/balance-gdax.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | gdax = ccxt.gdax({
12 |     'apiKey': "a43edfe629bc5991acc83a536ac6358e",
13 |     'secret': "xOvq+iH8NT07TheFB/fmY3GcnMZMwP7Xct9zwWtAZxsCbJh8rxeEe/0BGxfbV2em7P9iqQD7/TJGqmsDO8B/kw==",
14 |     'password': 'zdmj8o7byla',
15 |     'verbose': True,  # switch it to False if you don't want the HTTP log
16 | })
17 | 
18 | # move gdax to sandbox
19 | gdax.urls['api'] = 'https://api-public.sandbox.gdax.com'
20 | 
21 | print(gdax.fetch_balance())
22 | 


--------------------------------------------------------------------------------
/examples/py/balance-kraken.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | kraken = ccxt.kraken({
12 |     'apiKey': "hEvQNMDIeoCJbr7W/ZBb5CGOrx3G0lWF5B3zqa1JBxdZlEaL8EK+D0Mw",
13 |     'secret': "JaE9wI6Nwgh5oRxiHcVxurwzwBxwc05W/qv/k1srGg4s3EYuXPpNkLLM5NYbbWpM8rCyijIeDavRuqWbU0ZV9A==",
14 |     'verbose': True,  # switch it to False if you don't want the HTTP log
15 | })
16 | 
17 | print(kraken.fetch_balance())
18 | 


--------------------------------------------------------------------------------
/examples/py/basic-rate-limiting.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | from pprint import pprint
 4 | 
 5 | import os
 6 | import sys
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt  # noqa: E402
12 | 
13 | 
14 | symbol = 'ETH/BTC'
15 | 
16 | exchange = ccxt.poloniex({
17 |     'enableRateLimit': True,  # or .enableRateLimit = True later
18 | })
19 | 
20 | # print 10 times with appropriate delay
21 | for i in range(0, 10):
22 |     print('--------------------------------------------------------------------')
23 |     ticker = exchange.fetch_ticker(symbol)
24 |     ticker = exchange.omit(ticker, 'info')
25 |     pprint(ticker)
26 | 


--------------------------------------------------------------------------------
/examples/py/binance-batch-orders.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | exchange = ccxt.binance({
13 |     "apiKey": "YOUR_API_KEY",
14 |     "secret": "YOUR_SECRET",
15 |     'enableRateLimit': True,
16 | })
17 | 
18 | 
19 | orders = [
20 |     {
21 |         "symbol" : "BTCUSDT",
22 |         "side" : "BUY",
23 |         "positionSide" : "LONG",
24 |         "type" : "MARKET",
25 |         "quantity": float(0.005)
26 |     }
27 | ]
28 | 
29 | orders = [exchange.encode_uri_component(exchange.json(order), safe=",") for order in orders]
30 | response = exchange.fapiPrivatePostBatchOrders({
31 |     'batchOrders': '[' + ','.join(orders) + ']'
32 | })
33 | 
34 | print(response)
35 | 


--------------------------------------------------------------------------------
/examples/py/binance-test-order.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | exchange = ccxt.binance({
13 |     'apiKey': 'YOUR_API_KEY',
14 |     'secret': 'YOUR_SECRET',
15 |     'enableRateLimit': True,
16 | })
17 | 
18 | symbol = 'ETH/BTC'
19 | type = 'limit'  # or 'market'
20 | side = 'sell'  # or 'buy'
21 | amount = 1.0
22 | price = 0.060154  # or None
23 | 
24 | # extra params and overrides if needed
25 | params = {
26 |     'test': True,  # test if it's valid, but don't actually place it
27 | }
28 | 
29 | order = exchange.create_order(symbol, type, side, amount, price, params)
30 | 
31 | print(order)
32 | 


--------------------------------------------------------------------------------
/examples/py/bitfinex-rate-limiting.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | symbol = 'ETH/BTC'
13 | 
14 | exchange = ccxt.bitfinex({
15 | 
16 |     'enableRateLimit': True,  # or .enableRateLimit = True later
17 | 
18 |     # BITFINEX RATELIMITS DON'T CORRESPOND TO THEIR DOCUMENTATION!
19 | 
20 |     # their actual rate limit is significantly more strict than documented!
21 |     'rateLimit': 3000,  # once every 3 seconds, 20 times per minute – will work
22 | 
23 |     # this is their documented ratelimit according to this page:
24 |     # https://docs.bitfinex.com/v1/reference#rest-public-orderbook
25 |     # 'rateLimit': 1000,  # once every second, 60 times per minute – won't work, will throw DDoSProtection
26 | })
27 | 
28 | for i in range(0, 100):
29 |     print('--------------------------------------------------------------------')
30 |     print(i)
31 |     print('sent:', exchange.iso8601(exchange.milliseconds()))
32 |     orderbook = exchange.fetch_order_book(symbol)
33 |     print('received:', exchange.iso8601(exchange.milliseconds()), 'bid:', orderbook['bids'][0], 'ask:', orderbook['asks'][0])
34 | 


--------------------------------------------------------------------------------
/examples/py/bitmex-create-order.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | exchange = ccxt.bitmex({
13 |     'apiKey': 'YOUR_API_KEY',
14 |     'secret': 'YOUR_SECRET',
15 |     'enableRateLimit': True,
16 | })
17 | 
18 | symbol = 'XBTM18'  # bitcoin contract according to https://github.com/ccxt/ccxt/wiki/Manual#symbols-and-market-ids
19 | type = 'StopLimit'  # or 'Market', or 'Stop' or 'StopLimit'
20 | side = 'sell'  # or 'buy'
21 | amount = 1.0
22 | price = 6500.0  # or None
23 | 
24 | # extra params and overrides
25 | params = {
26 |     'stopPx': 6000.0,  # if needed
27 | }
28 | 
29 | order = exchange.create_order(symbol, type, side, amount, price, params)
30 | print(order)
31 | 


--------------------------------------------------------------------------------
/examples/py/bitmex-fetch-ohlcv-with-extra-params.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import time
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | bitmex = ccxt.bitmex()
13 | 
14 | # params:
15 | symbol = 'BTC/USD'
16 | timeframe = '1m'
17 | limit = 100
18 | params = {'partial': False}  # ←--------  no reversal
19 | 
20 | while True:
21 | 
22 |     # pay attention to since with respect to limit if you're doing it in a loop
23 |     since = bitmex.milliseconds() - limit * 60 * 1000
24 | 
25 |     candles = bitmex.fetch_ohlcv(symbol, timeframe, since, limit, params)
26 |     num_candles = len(candles)
27 |     print('{}: O: {} H: {} L:{} C:{}'.format(
28 |         bitmex.iso8601(candles[num_candles - 1][0]),
29 |         candles[num_candles - 1][1],
30 |         candles[num_candles - 1][2],
31 |         candles[num_candles - 1][3],
32 |         candles[num_candles - 1][4]))
33 |     # * 5 to make distinct delay and to avoid too much load
34 |     # / 1000 to convert milliseconds to fractional seconds
35 |     time.sleep(bitmex.rateLimit * 5 / 1000)
36 | 


--------------------------------------------------------------------------------
/examples/py/builtin-rate-limiting-long-poller.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | # if you imported the ccxt library with `import ccxt` you can
12 | # set enableRateLimit = True to enable the rate limit in synchronous version of ccxt
13 | # this way you request rate will never hit the limit of an exchange
14 | # the library will throttle your requests to avoid that
15 | 
16 | exchange = ccxt.bitfinex({
17 |     'enableRateLimit': True,  # this option enables the built-in rate limiter
18 | })
19 | 
20 | for i in range(0, 10):
21 |     # this can be any call instead of fetch_ticker, really
22 |     print(exchange.fetch_ticker('BTC/USD'))
23 | 


--------------------------------------------------------------------------------
/examples/py/coinbasepro-fetch-my-trades-pagination.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 6 | sys.path.append(root + '/python')
 7 | 
 8 | import ccxt  # noqa: E402
 9 | 
10 | '''
11 | Example snippet to traverse CoinBase Pro pagination.
12 | Useful for reaching back more than 100 myTrades, the same works
13 | for fetchClosedOrders
14 | '''
15 | 
16 | exchange = ccxt.coinbasepro({
17 |     "apiKey": "123456",
18 |     "secret": "/abcdefghijklmnop/w==",
19 |     "password": "987654321",
20 |     "enableRateLimit": True
21 | })
22 | 
23 | param_key = ''
24 | param_value = ''
25 | allMyTrades = []
26 | 
27 | while True:
28 |     myTrades = exchange.fetch_my_trades(symbol='BTC/USD', params={param_key: param_value})
29 | 
30 |     # Handle with pagination ...
31 |     if exchange.last_response_headers._store.get('cb-after'):
32 |         param_key = 'after'
33 |         param_value = exchange.last_response_headers._store['cb-after'][1]
34 | 
35 |         allMyTrades.extend(myTrades)
36 | 
37 |     else:
38 |         allMyTrades.extend(myTrades)
39 |         break
40 | 
41 | for trade in allMyTrades:
42 |     print(trade)
43 | 


--------------------------------------------------------------------------------
/examples/py/coinone-fetch-tickers.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | from pprint import pprint
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | exchange = ccxt.coinone({
13 |     'enableRateLimit': True,
14 |     # 'verbose': True,  # uncomment for verbose output
15 | })
16 | 
17 | # fetch all
18 | tickers = exchange.fetch_tickers()
19 | for symbol, ticker in tickers.items():
20 |     print(ticker)
21 | 
22 | print("\n")
23 | 
24 | # fetch one by one
25 | markets = exchange.load_markets()
26 | for symbol in markets.keys():
27 |     ticker = exchange.fetch_ticker(symbol)
28 |     print(ticker)
29 | 


--------------------------------------------------------------------------------
/examples/py/coinone-markets.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | from pprint import pprint
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | exchange = ccxt.coinone({
13 |     'enableRateLimit': True,
14 |     # 'verbose': True,  # uncomment for verbose output
15 | })
16 | 
17 | markets = exchange.load_markets()
18 | pprint(markets)
19 | print('\n', exchange.name, 'supports', len(markets), 'pairs')
20 | 


--------------------------------------------------------------------------------
/examples/py/fetch-okex-futures.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import time
 6 | 
 7 | # ------------------------------------------------------------------------------
 8 | 
 9 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 | sys.path.append(root + '/python')
11 | 
12 | # ------------------------------------------------------------------------------
13 | 
14 | import ccxt  # noqa: E402
15 | 
16 | # ------------------------------------------------------------------------------
17 | 
18 | exchange = ccxt.okex()
19 | exchange.load_markets()
20 | for symbol in exchange.markets:
21 |     market = exchange.markets[symbol]
22 |     if market['future']:
23 |         print('----------------------------------------------------')
24 |         print(symbol, exchange.fetchTicker(symbol))
25 |         time.sleep(exchange.rateLimit / 1000)
26 | 


--------------------------------------------------------------------------------
/examples/py/fetch-orders.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | exchange = ccxt.bittrex({
12 |     "apiKey": "471b47a06c384e81b24072e9a8739064",
13 |     "secret": "694025686e9445589787e8ca212b4cff",
14 |     "enableRateLimit": True,
15 | })
16 | 
17 | orders = exchange.fetch_orders()
18 | print(orders)
19 | 
20 | order = exchange.fetch_order(orders[0]['id'])
21 | print(order)
22 | 


--------------------------------------------------------------------------------
/examples/py/gdax-fetch-my-trades-pagination.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 6 | sys.path.append(root + '/python')
 7 | 
 8 | import ccxt  # noqa: E402
 9 | 
10 | '''
11 | Example snippet to traverse GDAX / CoinBase Pro pagination.
12 | Useful for reaching back more than 100 myTrades, the same works
13 | for fetchClosedOrders
14 | '''
15 | 
16 | exchange = ccxt.gdax({
17 |     "apiKey": "123456",
18 |     "secret": "/abcdefghijklmnop/w==",
19 |     "password": "987654321",
20 |     "enableRateLimit": True
21 | })
22 | 
23 | param_key = ''
24 | param_value = ''
25 | allMyTrades = []
26 | 
27 | while True:
28 |     myTrades = exchange.fetch_my_trades(symbol='BTC/USD', params={param_key: param_value})
29 | 
30 |     # Handle gdax with pagination ...
31 |     if exchange.last_response_headers._store.get('cb-after'):
32 |         param_key = 'after'
33 |         param_value = exchange.last_response_headers._store['cb-after'][1]
34 | 
35 |         allMyTrades.extend(myTrades)
36 | 
37 |     else:
38 |         allMyTrades.extend(myTrades)
39 |         break
40 | 
41 | for trade in allMyTrades:
42 |     print(trade)
43 | 


--------------------------------------------------------------------------------
/examples/py/hitbtc2-withdraw.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | from pprint import pprint
 4 | 
 5 | import os
 6 | import sys
 7 | 
 8 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 9 | sys.path.append(root + '/python')
10 | 
11 | import ccxt  # noqa: E402
12 | 
13 | 
14 | def get_positive_accounts(balance):
15 |     result = {}
16 |     currencies = list(balance.keys())
17 |     for currency in currencies:
18 |         if balance[currency] and balance[currency] > 0:
19 |             result[currency] = balance[currency]
20 |     return result
21 | 
22 | 
23 | exchange = ccxt.hitbtc2({
24 |     "apiKey": "a34ca826b430bdfcca969241b0f7bd2d",
25 |     "secret": "7b28d6b17aea18ae39903add0dae048a",
26 |     "enableRateLimit": True,
27 | })
28 | 
29 | 
30 | trading_balance = exchange.fetch_balance()
31 | account_balance = exchange.fetch_balance({'type': 'account'})
32 | 
33 | pprint('Trading balance:')
34 | pprint(get_positive_accounts(trading_balance['total']))
35 | pprint('Account balance:')
36 | pprint(get_positive_accounts(account_balance['total']))
37 | 
38 | 
39 | withdraw = exchange.withdraw('ETH', 0.01, '0x811DCfeb6dC0b9ed825808B6B060Ca469b83fB81')
40 | 
41 | 
42 | pprint('Withdraw:')
43 | pprint(withdraw)
44 | 


--------------------------------------------------------------------------------
/examples/py/instantiate-all-at-once.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | exchanges = {}  # a placeholder for your instances
12 | 
13 | for id in ccxt.exchanges:
14 |     exchange = getattr(ccxt, id)
15 |     exchanges[id] = exchange()
16 | 
17 | # now exchanges dictionary contains all exchange instances...
18 | exchanges['bittrex'].fetch_order_book('ETH/BTC')
19 | 


--------------------------------------------------------------------------------
/examples/py/kucoin-fetch-closed-orders-pagination.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | exchange = ccxt.kucoin({
12 |     "apiKey": "YOUR_API_KEY",
13 |     "secret": "YOUR_SECRET",
14 |     "password": "YOUR_PASSWORD"
15 | })
16 | 
17 | symbol = 'ETH/USDT'
18 | now = exchange.milliseconds()
19 | day = 24 * 3600 * 1000
20 | week = 7 * day
21 | since = now - 365 * day  # start one year back
22 | limit = 20
23 | 
24 | while since < now:
25 | 
26 |     end = max(since + week, now)
27 |     params = {'endAt': end}
28 |     orders = exchange.fetch_closed_orders(symbol, since, limit, params)
29 |     print(exchange.iso8601(since), '-', exchange.iso8601(end), len(orders), 'orders')
30 |     if len(orders) == limit:
31 |         since = orders[-1]['timestamp']
32 |     else:
33 |         since += week


--------------------------------------------------------------------------------
/examples/py/latoken-create-order.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | exchange = ccxt.latoken({
13 |     'apiKey': 'YOUR_API_KEY',
14 |     'secret': 'YOUR_SECRET',
15 |     'enableRateLimit': True, # this is required, as documented in the Manual!
16 | })
17 | 
18 | symbol = 'ETH/BTC'
19 | type = 'limit'  # only support limit
20 | side = 'buy'  # or 'sell'
21 | amount = 0.01
22 | price = 0.015881  # or None
23 | 
24 | order = exchange.create_order(symbol, type, side, amount, price)
25 | 
26 | print(order)
27 | 


--------------------------------------------------------------------------------
/examples/py/manual-rate-limiting-long-poller.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import time
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | # if you imported the ccxt library with `import ccxt` you can
13 | # throttle your requests manually, by using the rateLimit property of an exchange
14 | # to delay each request by waiting for some time to stay below request rate limits
15 | 
16 | exchange = ccxt.bitfinex()
17 | 
18 | # the rateLimit is in milliseconds → divide it by a thousand to get seconds
19 | delay = exchange.rateLimit / 1000
20 | 
21 | for i in range(0, 10):
22 |     # this can be any call instead of fetch_ticker, really
23 |     print(exchange.fetch_ticker('BTC/USD'))
24 |     time.sleep(delay)  # sleep a little before sending each next request
25 | 


--------------------------------------------------------------------------------
/examples/py/margin-leverage-order-kraken.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | 
12 | kraken = ccxt.kraken({
13 |     'apiKey': 'YOUR_API_KEY',
14 |     'secret': 'YOUR_SECRET',
15 | })
16 | 
17 | kraken.load_markets()
18 | 
19 | for symbol in kraken.symbols:
20 |     print(
21 |         symbol,
22 |         'Available leverage levels',
23 |         'Buy:', kraken.markets[symbol]['info']['leverage_buy'],
24 |         'Sell:', kraken.markets[symbol]['info']['leverage_sell']
25 |     )
26 | 
27 | # THIS IS A KRAKEN-SPECIFIC EXAMPLE.
28 | # THE LEVERAGE WILL NOT WORK WITH OTHER EXCHANGES THE SAME WAY.
29 | # USE IMPLICIT METHODS FOR MARGIN/LEVERAGED ORDERS WITH OTHER EXCHANGES:
30 | # https://github.com/ccxt/ccxt/wiki/Manual#implicit-api-methods
31 | 
32 | # with create_order all params (including the price=None) are needed!
33 | # the extra param should be "leverage", not "leverage_sell" nor "leverage-sell"
34 | kraken.create_order('BTC/USD', 'market', 'sell', 0.01, None, {'leverage': 3})
35 | 
36 | # or use a shorthand create_market_sell_order (no "price" param)
37 | kraken.create_market_sell_order('BTC/USD', 0.01, {'leverage': 3})
38 | 


--------------------------------------------------------------------------------
/examples/py/minimal-2-lines.py:
--------------------------------------------------------------------------------
1 | import ccxt
2 | print(ccxt.bitfinex().fetch_ticker('BTC/USDT'))
3 | 


--------------------------------------------------------------------------------
/examples/py/normalize-sparse-candle-timestamps.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | from pprint import pprint
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | exchange = ccxt.binance({'enableRateLimit': True})
13 | 
14 | symbol = 'ETH/BTC'
15 | timeframe = '1h'
16 | 
17 | candles = exchange.fetch_ohlcv(symbol, timeframe)
18 | 
19 | # timeframe duration in seconds
20 | duration = exchange.parse_timeframe(timeframe)
21 | 
22 | # timeframe duration in milliseconds
23 | duration *= 1000
24 | 
25 | pprint([[
26 |     exchange.iso8601(int(round(candle[0] / duration)) * duration),
27 |     candle[1],  # o
28 |     candle[2],  # h
29 |     candle[3],  # l
30 |     candle[4],  # c
31 |     candle[5]   # v
32 | ] for candle in candles])
33 | 


--------------------------------------------------------------------------------
/examples/py/order-book-extra-level-depth-param.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | # return up to ten bidasks on each side of the order book stack
12 | limit = 10
13 | print(ccxt.cex().fetch_order_book('BTC/USD', limit))
14 | 


--------------------------------------------------------------------------------
/examples/py/poloniex-fetch-order-books.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | from pprint import pprint
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | id = 'poloniex'
13 | 
14 | # instantiate the exchange by id
15 | exchange = getattr(ccxt, id)({
16 |     # 'proxy':'https://cors-anywhere.herokuapp.com/',
17 | })
18 | 
19 | # load all markets from the exchange
20 | markets = exchange.load_markets()
21 | 
22 | # this will work (a limited number of symbols)
23 | result = exchange.fetch_order_books(['ETH/BTC', 'LTC/BTC'])
24 | pprint(result)
25 | 
26 | # this will also work (a limited number of symbols)
27 | result = exchange.fetch_order_books(exchange.symbols[0:10])
28 | pprint(result)
29 | 
30 | # this will not work (too many symbols)
31 | result = exchange.fetch_order_books(exchange.symbols)
32 | pprint(result)
33 | 


--------------------------------------------------------------------------------
/examples/py/poloniex-python2-memleak-test.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import psutil
 6 | 
 7 | 
 8 | # -----------------------------------------------------------------------------
 9 | 
10 | this_folder = os.path.dirname(os.path.abspath(__file__))
11 | root_folder = os.path.dirname(os.path.dirname(this_folder))
12 | sys.path.append(root_folder + '/python')
13 | sys.path.append(this_folder)
14 | 
15 | # -----------------------------------------------------------------------------
16 | 
17 | import ccxt  # noqa: E402
18 | 
19 | # -----------------------------------------------------------------------------
20 | 
21 | exchange = ccxt.poloniex({
22 |     'enableRateLimit': True,
23 | })
24 | 
25 | while True:
26 |     orderbook = exchange.fetch_order_book('ETH/BTC')
27 |     process = psutil.Process(os.getpid())
28 |     print(exchange.iso8601(exchange.milliseconds()), process.memory_info()[0])
29 | 


--------------------------------------------------------------------------------
/examples/py/poloniex-python3-memleak-test.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | import psutil
 6 | 
 7 | 
 8 | # -----------------------------------------------------------------------------
 9 | 
10 | this_folder = os.path.dirname(os.path.abspath(__file__))
11 | root_folder = os.path.dirname(os.path.dirname(this_folder))
12 | sys.path.append(root_folder + '/python')
13 | sys.path.append(this_folder)
14 | 
15 | # -----------------------------------------------------------------------------
16 | 
17 | import ccxt  # noqa: E402
18 | 
19 | # -----------------------------------------------------------------------------
20 | 
21 | exchange = ccxt.poloniex({
22 |     'enableRateLimit': True,
23 | })
24 | 
25 | while True:
26 |     orderbook = exchange.fetch_order_book('ETH/BTC')
27 |     process = psutil.Process(os.getpid())
28 |     print(exchange.iso8601(exchange.milliseconds()), process.memory_info().rss)
29 | 


--------------------------------------------------------------------------------
/examples/py/sign-in.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | from pprint import pprint
 6 | 
 7 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 8 | sys.path.append(root + '/python')
 9 | 
10 | import ccxt  # noqa: E402
11 | 
12 | 
13 | exchange = ccxt.bitmart({
14 |     'apiKey': 'YOUR_API_KEY',
15 |     'secret': 'YOUR_SECRET',
16 |     'uid': 'YOUR_UID',
17 |     # at least some rate-limiting is required
18 |     # https://github.com/ccxt/ccxt/wiki/Manual#rate-limit
19 |     'enableRateLimit': True,  # ←- REQUIRED
20 | })
21 | 
22 | while True:
23 |     try:
24 |         print('---------------------------------------------------------------')
25 |         datetime = exchange.iso8601 (exchange.milliseconds ())
26 |         print(datetime)
27 |         balance = exchange.fetch_balance()  # this will trigger a sign_in when needed
28 |         pprint(balance)
29 |         # handle the response how you want or do other calls...
30 |     except ccxt.AuthenticationError as e:
31 |         error_message = str(e)
32 |         if 'accessToken' in error_message:
33 |             exchange.sign_in()
34 |         else:
35 |             print(str(e))
36 |             sys.exit()
37 | 


--------------------------------------------------------------------------------
/examples/py/theocean.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | import os
 4 | import sys
 5 | 
 6 | root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 7 | sys.path.append(root + '/python')
 8 | 
 9 | import ccxt  # noqa: E402
10 | 
11 | walletAddress = os.environ['WALLET_ADDRESS']
12 | privateKey = os.environ['PRIVATE_KEY']
13 | apiKey = os.environ['API_KEY']
14 | secret = os.environ['SECRET']
15 | ocean = ccxt.theocean({
16 |     'walletAddress': walletAddress,
17 |     'privateKey': privateKey,
18 |     'apiKey': apiKey,
19 |     'secret': secret
20 | })
21 | 
22 | # get balance
23 | balance = ocean.fetch_balance_by_code('REP')
24 | print('REP balance: ', balance)
25 | 
26 | # get order book
27 | order_book = ocean.fetch_order_book('REP/ZRX')
28 | print('REP/ZRX orderbook: ', order_book)
29 | 
30 | # placing order
31 | place_result = ocean.create_order('REP/ZRX', 'limit', 'sell', '0.5', '30')
32 | id = place_result['id']
33 | print('result of placing order: ', place_result)
34 | 
35 | # cancel order
36 | if place_result['remaining'] > 0:
37 |     cancel_result = ocean.cancel_order(id)
38 |     print('cancel result: ', cancel_result)
39 | 
40 | # cancel all open user orders
41 | cancel_all_orders_result = ocean.cancel_all_orders()
42 | print('cancel all orders result: ', cancel_all_orders_result)
43 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-futures/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-futures/package.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "name": "fetch-futures",
 3 |   "version": "0.1.0",
 4 |   "description": "ccxt example code in typescript.",
 5 |   "main": "build/src/index.js",
 6 |   "types": "build/src/index.d.ts",
 7 |   "files": [
 8 |     "build/src"
 9 |   ],
10 |   "license": "MIT",
11 |   "repository": {
12 |     "type": "git",
13 |     "url": "git+https://github.com/ccxt/ccxt.git"
14 |   },
15 |   "keywords": [],
16 |   "scripts": {
17 |     "test": "echo \"Error: no test specified\" && exit 1",
18 |     "build": "tsc -p .",
19 |     "start": "node ./build/index"
20 |   },
21 |   "dependencies": {
22 |     "ansicolor": "^1.1.92",
23 |     "as-table": "^1.0.55",
24 |     "ccxt": "^1.18.1145",
25 |     "ololog": "^1.1.146"
26 |   },
27 |   "devDependencies": {
28 |     "typescript": "~3.5.0",
29 |     "@types/node": "^10.0.3"
30 |   },
31 |   "engines": {
32 |     "node": ">=7.6.0"
33 |   }
34 | }
35 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-futures/prettier.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |   singleQuote: true,
3 |   trailingComma: 'es5',
4 | };
5 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-futures/src/index.ts:
--------------------------------------------------------------------------------
 1 | // Example code in typescript
 2 | // Based on /examples/js/fetch-okex-futures.js
 3 | 
 4 | import * as ccxt from 'ccxt';
 5 | const log = require('ololog');
 6 | 
 7 | const fetchFutures = async () => {
 8 |     const exchange = new ccxt.bitmex();
 9 |     exchange.markets = await exchange.loadMarkets(true);
10 | 
11 |     for (let symbol in exchange.markets) {
12 |         log('----------------------------------------------------');
13 |         log(`symbol = ${symbol}`);
14 |         try {
15 |             const market = exchange.markets[symbol];
16 |             if (market['future']) {
17 |                 const ticker = await exchange.fetchTicker(symbol);
18 |                 log('----------------------------------------------------');
19 |                 log(symbol, ticker);
20 |                 await (ccxt as any).sleep(exchange.rateLimit); // Missing type information.
21 |             }
22 |         } catch (error) {
23 |             log('error =', error);
24 |         }
25 |     }
26 | };
27 | 
28 | fetchFutures();
29 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-futures/tsconfig.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "compilerOptions": {
 3 |     "rootDir": "src",
 4 |     "outDir": "build",
 5 |     "allowUnreachableCode": false,
 6 |     "allowUnusedLabels": false,
 7 |     "declaration": true,
 8 |     "forceConsistentCasingInFileNames": true,
 9 |     "lib": [
10 |       "es2016"
11 |     ],
12 |     "module": "commonjs",
13 |     "noEmitOnError": true,
14 |     "noFallthroughCasesInSwitch": true,
15 |     "noImplicitReturns": true,
16 |     "pretty": true,
17 |     "sourceMap": true,
18 |     "strict": true,
19 |     "target": "es2017"
20 |   },
21 |   "include": [
22 |     "src/**/*.ts",
23 |     "test/**/*.ts"
24 |   ],
25 |   "exclude": [
26 |     "node_modules"
27 |   ]
28 | }


--------------------------------------------------------------------------------
/examples/ts/fetch-tickers/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-tickers/package.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "name": "fetch-tickers",
 3 |   "version": "0.1.0",
 4 |   "description": "ccxt example code in typescript.",
 5 |   "main": "build/src/index.js",
 6 |   "types": "build/src/index.d.ts",
 7 |   "files": [
 8 |     "build/src"
 9 |   ],
10 |   "license": "MIT",
11 |   "repository": {
12 |     "type": "git",
13 |     "url": "git+https://github.com/ccxt/ccxt.git"
14 |   },
15 |   "keywords": [],
16 |   "scripts": {
17 |     "test": "echo \"Error: no test specified\" && exit 1",
18 |     "build": "tsc -p .",
19 |     "start": "node ./build/index"
20 |   },
21 |   "dependencies": {
22 |     "ansicolor": "^1.1.92",
23 |     "as-table": "^1.0.55",
24 |     "ccxt": "^1.18.1145",
25 |     "ololog": "^1.1.146"
26 |   },
27 |   "devDependencies": {
28 |     "typescript": "~3.5.0",
29 |     "@types/node": "^10.0.3"
30 |   },
31 |   "engines": {
32 |     "node": ">=7.6.0"
33 |   }
34 | }
35 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-tickers/prettier.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 |   singleQuote: true,
3 |   trailingComma: 'es5',
4 | };
5 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-tickers/src/index.ts:
--------------------------------------------------------------------------------
 1 | // Example code in typescript
 2 | // Based on /examples/js/fetch-from-many-exchanges-simultaneously.js
 3 | 
 4 | import * as ccxt from 'ccxt';
 5 | const log = require('ololog');
 6 | 
 7 | const symbol = 'BTC/USD';
 8 | const exchanges = ['coinbasepro', 'gemini', 'kraken'];
 9 | 
10 | const fetchTickers = async (symbol: string) => {
11 |     const result = await Promise.all(exchanges.map(async (id: string): Promise => {
12 |         const CCXT = ccxt as any; // Hack!
13 |         const exchange = new CCXT[id]({ 'enableRateLimit': true }) as ccxt.Exchange;
14 |         const ticker = await exchange.fetchTicker(symbol);
15 |         const exchangeExtended = exchange.extend({ 'exchange': id }, ticker) as ccxt.Exchange;
16 |         return exchangeExtended;
17 |     }));
18 |     log(result);
19 | };
20 | 
21 | fetchTickers(symbol);
22 | 


--------------------------------------------------------------------------------
/examples/ts/fetch-tickers/tsconfig.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "compilerOptions": {
 3 |     "rootDir": "src",
 4 |     "outDir": "build",
 5 |     "allowUnreachableCode": false,
 6 |     "allowUnusedLabels": false,
 7 |     "declaration": true,
 8 |     "forceConsistentCasingInFileNames": true,
 9 |     "lib": [
10 |       "es2016"
11 |     ],
12 |     "module": "commonjs",
13 |     "noEmitOnError": true,
14 |     "noFallthroughCasesInSwitch": true,
15 |     "noImplicitReturns": true,
16 |     "pretty": true,
17 |     "sourceMap": true,
18 |     "strict": true,
19 |     "target": "es2017"
20 |   },
21 |   "include": [
22 |     "src/**/*.ts",
23 |     "test/**/*.ts"
24 |   ],
25 |   "exclude": [
26 |     "node_modules"
27 |   ]
28 | }


--------------------------------------------------------------------------------
/exchanges.cfg:
--------------------------------------------------------------------------------
 1 | # -------------------------------------------------------------------------------
 2 | # You can create a custom bundle of CCXT including only the exchanges you need.
 3 | # Add or uncomment ids below and launch `npm run build`.
 4 | # Leaving this config empty will build all exchanges.
 5 | # -------------------------------------------------------------------------------
 6 | 
 7 | # binance
 8 | # huobi
 9 | # kraken
10 | 


--------------------------------------------------------------------------------
/js/base/functions.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | /*  ------------------------------------------------------------------------ */
 4 | 
 5 | const { unCamelCase } = require ('./functions/string')
 6 | 
 7 | const unCamelCasePropertyNames = x => {
 8 |     for (const k in x) x[unCamelCase (k)] = x[k] // camel_case_method = camelCaseMethod
 9 |     return x
10 | }
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = unCamelCasePropertyNames (Object.assign ({}
15 | 
16 |     , require ('./functions/platform')
17 |     , require ('./functions/generic')
18 |     , require ('./functions/string')
19 |     , require ('./functions/type')
20 |     , require ('./functions/number')
21 |     , require ('./functions/encode')
22 |     , require ('./functions/crypto')
23 |     , require ('./functions/time')
24 |     , require ('./functions/throttle')
25 |     , require ('./functions/misc')
26 | ))
27 | 
28 | /*  ------------------------------------------------------------------------ */
29 | 


--------------------------------------------------------------------------------
/js/base/functions/string.js:
--------------------------------------------------------------------------------
 1 | "use strict";
 2 | 
 3 | /*  ------------------------------------------------------------------------ */
 4 | 
 5 | const uuid = a => a ? (a ^ Math.random () * 16 >> a / 4).toString (16)
 6 |                     : ([1e7]+-1e3+-4e3+-8e3+-1e11).replace (/[018]/g, uuid)
 7 | 
 8 | module.exports =
 9 | 
10 |     { uuid
11 | 
12 |       // hasFetchOHLCV → has_fetch_ohlcv; parseHTTPResponse → parse_http_response
13 |     , unCamelCase: s => s.match (/^[A-Z0-9_]+$/) ? s : (s.replace (/[a-z0-9][A-Z]/g, x => x[0] + '_' + x[1]).replace(/[A-Z0-9][A-Z0-9][a-z]/g, x => x[0] + '_' + x[1] + x[2]).toLowerCase ())
14 | 
15 |     , capitalize: s => s.length
16 |                             ? (s.charAt (0).toUpperCase () + s.slice (1))
17 |                             : s
18 |     , strip: s => s.replace(/^\s+|\s+$/g, '')
19 |     }
20 | 
21 | /*  ------------------------------------------------------------------------ */
22 | 


--------------------------------------------------------------------------------
/js/bequant.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const hitbtc = require ('./hitbtc');
 6 | // ---------------------------------------------------------------------------
 7 | 
 8 | module.exports = class bequant extends hitbtc {
 9 |     describe () {
10 |         return this.deepExtend (super.describe (), {
11 |             'id': 'bequant',
12 |             'name': 'Bequant',
13 |             'countries': [ 'MT' ], // Malta
14 |             'pro': true,
15 |             'urls': {
16 |                 'logo': 'https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg',
17 |                 'api': {
18 |                     'public': 'https://api.bequant.io',
19 |                     'private': 'https://api.bequant.io',
20 |                 },
21 |                 'www': 'https://bequant.io',
22 |                 'doc': [
23 |                     'https://api.bequant.io/',
24 |                 ],
25 |                 'fees': [
26 |                     'https://bequant.io/fees-and-limits',
27 |                 ],
28 |                 'referral': 'https://bequant.io',
29 |             },
30 |         });
31 |     }
32 | };
33 | 


--------------------------------------------------------------------------------
/js/bitkk.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | //  ---------------------------------------------------------------------------
 4 | 
 5 | const zb = require ('./zb.js');
 6 | 
 7 | //  ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class bitkk extends zb {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'bitkk',
13 |             'name': 'bitkk',
14 |             'comment': 'a Chinese ZB clone',
15 |             'urls': {
16 |                 'api': {
17 |                     'public': 'http://api.bitkk.com/data', // no https for public API
18 |                     'private': 'https://trade.bitkk.com/api',
19 |                 },
20 |                 'www': 'https://www.bitkk.com',
21 |                 'doc': 'https://www.bitkk.com/i/developer',
22 |                 'fees': 'https://www.bitkk.com/i/rate',
23 |             },
24 |         });
25 |     }
26 | };
27 | 


--------------------------------------------------------------------------------
/js/chilebit.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const foxbit = require ('./foxbit.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class chilebit extends foxbit {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'chilebit',
13 |             'name': 'ChileBit',
14 |             'countries': [ 'CL' ],
15 |             'has': {
16 |                 'CORS': false,
17 |             },
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg',
20 |                 'api': {
21 |                     'public': 'https://api.blinktrade.com/api',
22 |                     'private': 'https://api.blinktrade.com/tapi',
23 |                 },
24 |                 'www': 'https://chilebit.net',
25 |                 'doc': 'https://blinktrade.com/docs',
26 |             },
27 |             'options': {
28 |                 'brokerId': '9', // https://blinktrade.com/docs/#brokers
29 |             },
30 |         });
31 |     }
32 | };
33 | 


--------------------------------------------------------------------------------
/js/coinbaseprime.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const coinbasepro = require ('./coinbasepro.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class coinbaseprime extends coinbasepro {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'coinbaseprime',
13 |             'name': 'Coinbase Prime',
14 |             'pro': true,
15 |             'urls': {
16 |                 'test': {
17 |                     'public': 'https://api-public.sandbox.prime.coinbase.com',
18 |                     'private': 'https://api-public.sandbox.prime.coinbase.com',
19 |                 },
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/44539184-29f26e00-a70c-11e8-868f-e907fc236a7c.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.prime.coinbase.com',
23 |                     'private': 'https://api.prime.coinbase.com',
24 |                 },
25 |                 'www': 'https://prime.coinbase.com',
26 |                 'doc': 'https://docs.prime.coinbase.com',
27 |                 'fees': 'https://support.prime.coinbase.com/customer/en/portal/articles/2945629-fees?b_id=17475',
28 |             },
29 |         });
30 |     }
31 | };
32 | 


--------------------------------------------------------------------------------
/js/fcoinjp.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const fcoin = require ('./fcoin.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class fcoinjp extends fcoin {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'fcoinjp',
13 |             'name': 'FCoinJP',
14 |             'countries': [ 'JP' ],
15 |             'hostname': 'fcoinjp.com',
16 |             'urls': {
17 |                 'logo': 'https://user-images.githubusercontent.com/1294454/54219174-08b66b00-4500-11e9-862d-f522d0fe08c6.jpg',
18 |                 'fees': 'https://fcoinjp.zendesk.com/hc/en-us/articles/360018727371',
19 |                 'www': 'https://www.fcoinjp.com',
20 |                 'referral': undefined,
21 |             },
22 |         });
23 |     }
24 | };
25 | 


--------------------------------------------------------------------------------
/js/huobiru.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const huobipro = require ('./huobipro.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class huobiru extends huobipro {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'huobiru',
13 |             'name': 'Huobi Russia',
14 |             'countries': [ 'RU' ],
15 |             'hostname': 'www.huobi.com.ru',
16 |             'pro': true,
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg',
19 |                 'api': {
20 |                     'market': 'https://{hostname}/api',
21 |                     'public': 'https://{hostname}/api',
22 |                     'private': 'https://{hostname}/api',
23 |                 },
24 |                 'www': 'https://www.huobi.com.ru/ru-ru',
25 |                 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74',
26 |                 'doc': 'https://github.com/cloudapidoc/API_Docs_en',
27 |                 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/',
28 |             },
29 |         });
30 |     }
31 | };
32 | 


--------------------------------------------------------------------------------
/js/okcoin.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const okex = require ('./okex.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class okcoin extends okex {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'okcoin',
13 |             'name': 'OKCoin',
14 |             'countries': [ 'CN', 'US' ],
15 |             'hostname': 'okcoin.com',
16 |             'pro': true,
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27766791-89ffb502-5ee5-11e7-8a5b-c5950b68ac65.jpg',
19 |                 'www': 'https://www.okcoin.com',
20 |                 'doc': 'https://www.okcoin.com/docs/en/',
21 |                 'fees': 'https://www.okcoin.com/coin-fees',
22 |                 'referral': 'https://www.okcoin.com/account/register?flag=activity&channelId=600001513',
23 |             },
24 |             'fees': {
25 |                 'trading': {
26 |                     'taker': 0.002,
27 |                     'maker': 0.001,
28 |                 },
29 |             },
30 |             'options': {
31 |                 'fetchMarkets': [ 'spot' ],
32 |             },
33 |         });
34 |     }
35 | };
36 | 


--------------------------------------------------------------------------------
/js/static_dependencies/README.md:
--------------------------------------------------------------------------------
1 | // TODO: add web3 and cryptoJS here
2 | 


--------------------------------------------------------------------------------
/js/static_dependencies/elliptic/lib/elliptic.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | var elliptic = exports;
 4 | 
 5 | // hello ladies ;)
 6 | function inherits (ctor, superCtor) {
 7 |     ctor.super_ = superCtor;
 8 |     var TempCtor = function () {};
 9 |     TempCtor.prototype = superCtor.prototype;
10 |     ctor.prototype = new TempCtor();
11 |     ctor.prototype.constructor = ctor;
12 | }
13 | 
14 | elliptic.inherits = inherits
15 | elliptic.version = '6.5.0';
16 | elliptic.utils = require('./elliptic/utils');
17 | elliptic.curve = require('./elliptic/curve');
18 | elliptic.curves = require('./elliptic/curves');
19 | 
20 | // Protocols
21 | elliptic.ec = require('./elliptic/ec');
22 | elliptic.eddsa = require('./elliptic/eddsa');
23 | 


--------------------------------------------------------------------------------
/js/static_dependencies/elliptic/lib/elliptic/curve/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | 
3 | var curve = exports;
4 | 
5 | curve.base = require('./base');
6 | curve.short = require('./short');
7 | curve.mont = require('./mont');
8 | curve.edwards = require('./edwards');
9 | 


--------------------------------------------------------------------------------
/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | var BN = require('../../../../BN/bn');
 4 | 
 5 | var elliptic = require('../../elliptic');
 6 | var utils = elliptic.utils;
 7 | var assert = utils.assert;
 8 | 
 9 | function Signature(options, enc) {
10 |   if (options instanceof Signature)
11 |     return options;
12 | 
13 |   //if (this._importDER(options, enc))
14 |   //  return;
15 | 
16 |   assert(options.r && options.s, 'Signature without r or s');
17 |   this.r = new BN(options.r, 16);
18 |   this.s = new BN(options.s, 16);
19 |   if (options.recoveryParam === undefined)
20 |     this.recoveryParam = null;
21 |   else
22 |     this.recoveryParam = options.recoveryParam;
23 | }
24 | module.exports = Signature;
25 | 


--------------------------------------------------------------------------------
/js/static_dependencies/fetch-ponyfill/fetch-node.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | var fetch = require('../node-fetch/index');
 4 | 
 5 | function wrapFetchForNode(fetch) {
 6 |   // Support schemaless URIs on the server for parity with the browser.
 7 |   // https://github.com/matthew-andrews/isomorphic-fetch/pull/10
 8 |   const f = function (u, options) {
 9 |     if (typeof u === 'string' && u.slice(0, 2) === '//') {
10 |       return fetch('https:' + u, options);
11 |     }
12 | 
13 |     return fetch(u, options);
14 |   };
15 |   // Igor Kroitor 2019 Dec 30
16 |   // expose http and https
17 |   // https://github.com/ccxt/ccxt/issues/6327
18 |   f.http = fetch.http;
19 |   f.https = fetch.https;
20 |   return f;
21 | }
22 | 
23 | module.exports = function (context) {
24 |   // This modifies the global `node-fetch` object, which isn't great, since
25 |   // different callers to `fetch-ponyfill` which pass a different Promise
26 |   // implementation would each expect to have their implementation used. But,
27 |   // given the way `node-fetch` is implemented, this is the only way to make
28 |   // it work at all.
29 |   if (context && context.Promise) {
30 |     fetch.Promise = context.Promise;
31 |   }
32 | 
33 |   return {
34 |     fetch: wrapFetchForNode(fetch),
35 |     Headers: fetch.Headers,
36 |     Request: fetch.Request,
37 |     Response: fetch.Response
38 |   };
39 | };
40 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/asn1/ber/errors.js:
--------------------------------------------------------------------------------
 1 | // Copyright 2011 Mark Cavage  All rights reserved.
 2 | 
 3 | 
 4 | module.exports = {
 5 | 
 6 |   newInvalidAsn1Error: function (msg) {
 7 |     var e = new Error();
 8 |     e.name = 'InvalidAsn1Error';
 9 |     e.message = msg || '';
10 |     return e;
11 |   }
12 | 
13 | };
14 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/asn1/ber/index.js:
--------------------------------------------------------------------------------
 1 | // Copyright 2011 Mark Cavage  All rights reserved.
 2 | 
 3 | var errors = require('./errors');
 4 | var types = require('./types');
 5 | 
 6 | var Reader = require('./reader');
 7 | 
 8 | // --- Exports
 9 | 
10 | module.exports = {
11 |   Reader: Reader,
12 | };
13 | 
14 | for (var t in types) {
15 |   if (types.hasOwnProperty(t))
16 |     module.exports[t] = types[t];
17 | }
18 | for (var e in errors) {
19 |   if (errors.hasOwnProperty(e))
20 |     module.exports[e] = errors[e];
21 | }
22 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/asn1/ber/types.js:
--------------------------------------------------------------------------------
 1 | // Copyright 2011 Mark Cavage  All rights reserved.
 2 | 
 3 | 
 4 | module.exports = {
 5 |   EOC: 0,
 6 |   Boolean: 1,
 7 |   Integer: 2,
 8 |   BitString: 3,
 9 |   OctetString: 4,
10 |   Null: 5,
11 |   OID: 6,
12 |   ObjectDescriptor: 7,
13 |   External: 8,
14 |   Real: 9, // float
15 |   Enumeration: 10,
16 |   PDV: 11,
17 |   Utf8String: 12,
18 |   RelativeOID: 13,
19 |   Sequence: 16,
20 |   Set: 17,
21 |   NumericString: 18,
22 |   PrintableString: 19,
23 |   T61String: 20,
24 |   VideotexString: 21,
25 |   IA5String: 22,
26 |   UTCTime: 23,
27 |   GeneralizedTime: 24,
28 |   GraphicString: 25,
29 |   VisibleString: 26,
30 |   GeneralString: 28,
31 |   UniversalString: 29,
32 |   CharacterString: 30,
33 |   BMPString: 31,
34 |   Constructor: 32,
35 |   Context: 128
36 | };
37 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/asn1/index.js:
--------------------------------------------------------------------------------
 1 | // Copyright 2011 Mark Cavage  All rights reserved.
 2 | 
 3 | // If you have no idea what ASN.1 or BER is, see this:
 4 | // ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
 5 | 
 6 | var Ber = require('./ber/index');
 7 | 
 8 | 
 9 | 
10 | // --- Exported API
11 | 
12 | module.exports = {
13 | 
14 |   Ber: Ber,
15 | 
16 |   BerReader: Ber.Reader,
17 | };
18 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/formats/formats.js:
--------------------------------------------------------------------------------
 1 | var _ = require('../utils')._;
 2 | 
 3 | module.exports = {
 4 |     pkcs1: require('./pkcs1'),
 5 |     pkcs8: require('./pkcs8'),
 6 |     components: require('./components'),
 7 | 
 8 |     detectAndImport: function (key, data, format) {
 9 |         if (format === undefined) {
10 |             for (var scheme in module.exports) {
11 |                 if (typeof module.exports[scheme].autoImport === 'function' && module.exports[scheme].autoImport(key, data)) {
12 |                     return true;
13 |                 }
14 |             }
15 |         } else if (format) {
16 |             var fmt = formatParse(format);
17 | 
18 |             if (module.exports[fmt.scheme]) {
19 |                 if (fmt.keyType === 'private') {
20 |                     module.exports[fmt.scheme].privateImport(key, data, fmt.keyOpt);
21 |                 } else {
22 |                     module.exports[fmt.scheme].publicImport(key, data, fmt.keyOpt);
23 |                 }
24 |             } else {
25 |                 throw Error('Unsupported key format');
26 |             }
27 |         }
28 | 
29 |         return false;
30 |     },
31 | };
32 | 


--------------------------------------------------------------------------------
/js/static_dependencies/node-rsa/schemes/schemes.js:
--------------------------------------------------------------------------------
 1 | module.exports = {
 2 |     pkcs1: require('./pkcs1'),
 3 | 
 4 |     /**
 5 |      * Check if scheme has padding methods
 6 |      * @param scheme {string}
 7 |      * @returns {Boolean}
 8 |      */
 9 |     isEncryption: function (scheme) {
10 |         return module.exports[scheme] && module.exports[scheme].isEncryption;
11 |     },
12 | 
13 |     /**
14 |      * Check if scheme has sign/verify methods
15 |      * @param scheme {string}
16 |      * @returns {Boolean}
17 |      */
18 |     isSignature: function (scheme) {
19 |         return module.exports[scheme] && module.exports[scheme].isSignature;
20 |     }
21 | };
22 | 


--------------------------------------------------------------------------------
/js/static_dependencies/qs/formats.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | var replace = String.prototype.replace;
 4 | var percentTwenties = /%20/g;
 5 | 
 6 | module.exports = {
 7 |     'default': 'RFC3986',
 8 |     formatters: {
 9 |         RFC1738: function (value) {
10 |             return replace.call(value, percentTwenties, '+');
11 |         },
12 |         RFC3986: function (value) {
13 |             return value;
14 |         }
15 |     },
16 |     RFC1738: 'RFC1738',
17 |     RFC3986: 'RFC3986'
18 | };
19 | 


--------------------------------------------------------------------------------
/js/static_dependencies/qs/index.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | var stringify = require('./stringify');
 4 | var parse = require('./parse');
 5 | var formats = require('./formats');
 6 | 
 7 | module.exports = {
 8 |     formats: formats,
 9 |     parse: parse,
10 |     stringify: stringify
11 | };
12 | 


--------------------------------------------------------------------------------
/js/surbitcoin.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const foxbit = require ('./foxbit.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class surbitcoin extends foxbit {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'surbitcoin',
13 |             'name': 'SurBitcoin',
14 |             'countries': [ 'VE' ],
15 |             'has': {
16 |                 'CORS': false,
17 |             },
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991511-f0a50194-6481-11e7-99b5-8f02932424cc.jpg',
20 |                 'api': {
21 |                     'public': 'https://api.blinktrade.com/api',
22 |                     'private': 'https://api.blinktrade.com/tapi',
23 |                 },
24 |                 'www': 'https://surbitcoin.com',
25 |                 'doc': 'https://blinktrade.com/docs',
26 |             },
27 |             'options': {
28 |                 'brokerId': '1', // https://blinktrade.com/docs/#brokers
29 |             },
30 |         });
31 |     }
32 | };
33 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchBalance.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log = require ('ololog')
 6 |     , testBalance = require ('./test.balance.js')
 7 | 
 8 | // ----------------------------------------------------------------------------
 9 | 
10 | module.exports = async (exchange) => {
11 | 
12 |     if (!(exchange.has.fetchBalance)) {
13 |         log (exchange.id.green, ' does not have fetchBalance')
14 |         return
15 |     }
16 | 
17 |     log ('fetching balance...')
18 | 
19 |     const response = await exchange.fetchBalance ()
20 | 
21 |     testBalance (exchange, response)
22 | 
23 |     return response
24 | }
25 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchClosedOrders.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testOrder = require ('./test.order.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     if (exchange.has.fetchClosedOrders) {
17 | 
18 |         // log ('fetching closed orders...')
19 | 
20 |         let orders = await exchange.fetchClosedOrders (symbol)
21 | 
22 |         log ('fetched', orders.length.toString ().green, 'closed orders, testing each')
23 | 
24 |         assert (orders instanceof Array)
25 | 
26 |         let now = Date.now ()
27 | 
28 |         for (let i = 0; i < orders.length; i++) {
29 |             let order = orders[i]
30 |             testOrder (exchange, order, symbol, now)
31 |             assert (order.status === 'closed' || order.status === 'canceled')
32 |         }
33 | 
34 |         // log (asTable (orders))
35 | 
36 |     } else {
37 | 
38 |         log ('fetching closed orders not supported')
39 |     }
40 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchCurrencies.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testCurrency = require ('./test.currency.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange) => {
15 | 
16 |     const skippedExchanges = [
17 |     ]
18 | 
19 |     if (skippedExchanges.includes (exchange.id)) {
20 |         log (exchange.id, 'found in ignored exchanges, skipping fetchCurrencies...')
21 |         return
22 |     }
23 | 
24 |     if (exchange.has.fetchCurrencies) {
25 | 
26 |         // log ('fetching currencies...')
27 | 
28 |         const method = 'fetchCurrencies'
29 |         const currencies = await exchange[method] ()
30 |         Object.values (currencies).forEach (currency => testCurrency (exchange, currency, method))
31 |         return currencies
32 | 
33 |     } else {
34 | 
35 |         log ('fetching currencies not supported')
36 |     }
37 | }
38 | 
39 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchDeposits.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testTransaction = require ('./test.transaction.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, code) => {
15 | 
16 |     if (exchange.has.fetchDeposits) {
17 | 
18 |         // log ('fetching deposits...')
19 | 
20 |         let transactions = await exchange.fetchDeposits (code)
21 | 
22 |         log ('fetched', transactions.length.toString ().green, 'deposits, asserting each...')
23 | 
24 |         assert (transactions instanceof Array)
25 | 
26 |         let now = Date.now ()
27 | 
28 |         for (let i = 0; i < transactions.length; i++) {
29 |             let transaction = transactions[i]
30 |             testTransaction (exchange, transaction, code, now)
31 |         }
32 | 
33 |         // log (asTable (transactions))
34 | 
35 |     } else {
36 | 
37 |         log ('fetching deposits not supported')
38 |     }
39 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchFundingFees.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 | 
11 | /*  ------------------------------------------------------------------------ */
12 | 
13 | module.exports = async (exchange) => {
14 | 
15 |     const skippedExchanges = [
16 |         'bibox', // fetchFundingFees should be rewritten to fetchFundingFee
17 |     ]
18 | 
19 |     if (skippedExchanges.includes (exchange.id)) {
20 |         log (exchange.id, 'found in ignored exchanges, skipping fetchFundingFees...')
21 |         return
22 |     }
23 | 
24 |     if (exchange.has.fetchFundingFees) {
25 | 
26 |         // log ('fetching funding fees...')
27 | 
28 |         const method = 'fetchFundingFees'
29 |         const fees = await exchange[method] ()
30 |         log.green (fees)
31 |         return fees
32 | 
33 |     } else {
34 | 
35 |         log ('fetching funding fees not supported')
36 |     }
37 | }
38 | 
39 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchL2OrderBook.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testOrderBook = require ('./test.orderbook.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     // log (symbol.green, 'fetching order book...')
17 | 
18 |     const method = 'fetchL2OrderBook'
19 | 
20 |     if (exchange.has[method]) {
21 | 
22 |         let orderbook = await exchange[method] (symbol)
23 |         testOrderBook (exchange, orderbook, method, symbol)
24 |         return orderbook
25 | 
26 |     } else {
27 | 
28 |         log (method + '() not supported')
29 |     }
30 | 
31 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchMarkets.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testMarket = require ('./test.market.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange) => {
15 | 
16 |     const skippedExchanges = [
17 |         'bitforex',
18 |     ]
19 | 
20 |     if (skippedExchanges.includes (exchange.id)) {
21 |         log (exchange.id, 'found in ignored exchanges, skipping fetchMarkets...')
22 |         return
23 |     }
24 | 
25 |     if (exchange.has.fetchMarkets) {
26 | 
27 |         // log ('fetching markets...')
28 | 
29 |         const method = 'fetchMarkets'
30 |         const markets = await exchange[method] ()
31 |         Object.values (markets).forEach (market => testMarket (exchange, market, method))
32 |         return markets
33 | 
34 |     } else {
35 | 
36 |         log ('fetching markets not supported')
37 |     }
38 | }
39 | 
40 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchOpenOrders.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testOrder = require ('./test.order.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     if (exchange.has.fetchOpenOrders) {
17 | 
18 |         // log ('fetching open orders...')
19 | 
20 |         let orders = await exchange.fetchOpenOrders (symbol)
21 | 
22 |         assert (orders instanceof Array)
23 | 
24 |         log ('fetched', orders.length.toString ().green, 'open orders')
25 | 
26 |         let now = Date.now ()
27 | 
28 |         for (let i = 0; i < orders.length; i++) {
29 |             let order = orders[i]
30 |             testOrder (exchange, order, symbol, now)
31 |             assert (order.status === 'open')
32 |         }
33 | 
34 |         // log (asTable (orders))
35 | 
36 |     } else {
37 | 
38 |         log ('fetching open orders not supported')
39 |     }
40 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchOrderBook.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testOrderBook = require ('./test.orderbook.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     // log (symbol.green, 'fetching order book...')
17 | 
18 |     const method = 'fetchOrderBook'
19 | 
20 |     if (exchange.has[method]) {
21 | 
22 |         let orderbook = await exchange[method] (symbol)
23 | 
24 |         testOrderBook (exchange, orderbook, method, symbol)
25 | 
26 |         return orderbook
27 | 
28 |     } else {
29 | 
30 |         log (method + '() not supported')
31 |     }
32 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchStatus.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 | 
11 | /*  ------------------------------------------------------------------------ */
12 | 
13 | module.exports = async (exchange) => {
14 | 
15 |     if (exchange.has.fetchStatus) {
16 | 
17 |         // log ('fetching status...')
18 | 
19 |         const method = 'fetchStatus'
20 |         const status = await exchange[method] ()
21 | 
22 |         const sampleStatus = {
23 |             'status': 'ok', // 'ok', 'shutdown', 'error', 'maintenance'
24 |             'updated': undefined, // integer, last updated timestamp in milliseconds if updated via the API
25 |             'eta': undefined, // when the maintenance or outage is expected to end
26 |             'url': undefined, // a link to a GitHub issue or to an exchange post on the subject
27 |         }
28 | 
29 |         assert.containsAllKeys (status, sampleStatus)
30 | 
31 |         return status
32 | 
33 |     } else {
34 | 
35 |         log ('fetching status not supported')
36 |     }
37 | }
38 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchTradingFees.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 | 
11 | /*  ------------------------------------------------------------------------ */
12 | 
13 | module.exports = async (exchange) => {
14 | 
15 |     const skippedExchanges = [
16 |     ]
17 | 
18 |     if (skippedExchanges.includes (exchange.id)) {
19 |         log (exchange.id, 'found in ignored exchanges, skipping fetchTradingFees...')
20 |         return
21 |     }
22 | 
23 |     if (exchange.has.fetchTradingFees) {
24 | 
25 |         // log ('fetching trading fees...')
26 | 
27 |         const method = 'fetchTradingFees'
28 |         const fees = await exchange[method] ()
29 |         log.green ({ 'maker': fees['maker'], 'taker': fees['taker'] })
30 |         return fees
31 | 
32 |     } else {
33 | 
34 |         log ('fetching trading fees not supported')
35 |     }
36 | }
37 | 
38 | 


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchTransactions.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testTransaction = require ('./test.transaction.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, code) => {
15 | 
16 |     if (exchange.has.fetchTransactions) {
17 | 
18 |         // log ('fetching transactions...')
19 | 
20 |         let transactions = await exchange.fetchTransactions (code)
21 | 
22 |         log ('fetched', transactions.length.toString ().green, 'transactions, asserting each...')
23 | 
24 |         assert (transactions instanceof Array)
25 | 
26 |         let now = Date.now ()
27 | 
28 |         for (let i = 0; i < transactions.length; i++) {
29 |             let transaction = transactions[i]
30 |             testTransaction (exchange, transaction, code, now)
31 |         }
32 | 
33 |         // log (asTable (transactions))
34 | 
35 |     } else {
36 | 
37 |         log ('fetching transactions not supported')
38 |     }
39 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.fetchWithdrawals.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testTransaction = require ('./test.transaction.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, code) => {
15 | 
16 |     if (exchange.has.fetchWithdrawals) {
17 | 
18 |         // log ('fetching deposits...')
19 | 
20 |         let transactions = await exchange.fetchWithdrawals (code)
21 | 
22 |         log ('fetched', transactions.length.toString ().green, 'withdrawals, asserting each...')
23 | 
24 |         assert (transactions instanceof Array)
25 | 
26 |         let now = Date.now ()
27 | 
28 |         for (let i = 0; i < transactions.length; i++) {
29 |             let transaction = transactions[i]
30 |             testTransaction (exchange, transaction, code, now)
31 |         }
32 | 
33 |         // log (asTable (transactions))
34 | 
35 |     } else {
36 | 
37 |         log ('fetching withdrawals not supported')
38 |     }
39 | }


--------------------------------------------------------------------------------
/js/test/Exchange/test.loadMarkets.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , expect    = chai.expect
 9 |     , assert    = chai.assert
10 |     , testMarket = require ('./test.market.js')
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange) => {
15 | 
16 |     const skippedExchanges = [
17 |         'bitforex',
18 |     ]
19 | 
20 |     if (skippedExchanges.includes (exchange.id)) {
21 |         log (exchange.id, 'found in ignored exchanges, skipping loadMarkets...')
22 |         return
23 |     }
24 | 
25 |     if (exchange.has.loadMarkets) {
26 | 
27 |         // log ('loading markets...')
28 | 
29 |         const method = 'loadMarkets'
30 |         const markets = await exchange[method] ()
31 |         Object.values (markets).forEach ((market) => testMarket (exchange, market, method))
32 |         return markets
33 | 
34 |     } else {
35 | 
36 |         log ('loading markets not supported')
37 |     }
38 | }
39 | 
40 | 


--------------------------------------------------------------------------------
/js/test/base/.eslintrc:
--------------------------------------------------------------------------------
 1 | {
 2 |   "env": {
 3 |     "node": true,
 4 |     "mocha": true
 5 |   },
 6 |   "parserOptions": {
 7 |     "ecmaVersion": 2017,
 8 |     "sourceType": "script",
 9 |   },
10 |   "rules": {
11 |       "semi": ["error", "never"],
12 |       "no-unused-vars": ["off"],
13 |       "quotes": ["off", "single"],
14 |       "func-call-spacing": ["error", "always"],
15 |       "one-var": "off",
16 |       "indent": ["warn", 4, { "ignoredNodes": ["ObjectPattern"] }],
17 |       "comma-style": "off",
18 |       "no-multi-spaces": "off",
19 |       "comma-dangle": "off",
20 |       "spaced-comment": "off",
21 |       "camelcase": "off",
22 |       "padded-blocks": "off",
23 |       "multiline-comment-style": "off",
24 |       "curly": "off",
25 |       "rest-spread-spacing": "off",
26 |       "no-multiple-empty-lines": "off",
27 |       "no-undef-init": "off",
28 |       "no-useless-return": "off",
29 |       "no-console": "off",
30 |       "operator-linebreak": "off",
31 |       "key-spacing": "off",
32 |       "brace-style": "off",
33 |       "padding-line-between-statements": ["off",
34 |         {"blankLine": "always", "prev":"function", "next": "*" },
35 |         {"blankLine": "always", "prev":"directive", "next": "*" },
36 |         {"blankLine": "always", "prev":"*", "next": "cjs-export" },
37 |       ],
38 |   },
39 | }
40 | 


--------------------------------------------------------------------------------
/js/test/errors/test.InvalidOrder.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , ccxt      = require ('../../../ccxt.js')
 9 |     , expect    = chai.expect
10 |     , assert    = chai.assert
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     if (!exchange.has.createOrder) {
17 |         log ('createOrder not supported')
18 |         return
19 |     }
20 | 
21 |     try {
22 | 
23 |         await exchange.createLimitBuyOrder (symbol, 0, 0)
24 |         assert.fail ()
25 | 
26 |     } catch (e) {
27 | 
28 |         if (e instanceof ccxt.InvalidOrder) {
29 | 
30 |             log ('InvalidOrder thrown as expected')
31 |             return
32 | 
33 |         } else {
34 | 
35 |             log ('InvalidOrder failed, exception follows:')
36 |             throw e
37 |         }
38 |     }
39 | }


--------------------------------------------------------------------------------
/js/test/errors/test.OrderNotFound.js:
--------------------------------------------------------------------------------
 1 | 'use strict'
 2 | 
 3 | // ----------------------------------------------------------------------------
 4 | 
 5 | const log       = require ('ololog')
 6 |     , ansi      = require ('ansicolor').nice
 7 |     , chai      = require ('chai')
 8 |     , ccxt      = require ('../../../ccxt.js')
 9 |     , expect    = chai.expect
10 |     , assert    = chai.assert
11 | 
12 | /*  ------------------------------------------------------------------------ */
13 | 
14 | module.exports = async (exchange, symbol) => {
15 | 
16 |     if (!exchange.has.createOrder) {
17 |         log ('createOrder not supported -> test skipped')
18 |         return
19 |     }
20 | 
21 |     let id = 1
22 | 
23 |     try {
24 | 
25 |         await exchange.cancelOrder (id, symbol)
26 | 
27 |         log ('test failed')
28 | 
29 |         assert.fail ()
30 | 
31 |     } catch (e) {
32 | 
33 |         if (e instanceof ccxt.OrderNotFound) {
34 | 
35 |             log ('OrderNotFound thrown as expected')
36 | 
37 |         } else {
38 | 
39 |             log ('OrderNotFound test failed')
40 |             throw e
41 |         }
42 |     }
43 | }


--------------------------------------------------------------------------------
/js/test/test.timeout_hang.js:
--------------------------------------------------------------------------------
 1 | // run with `node test_timeout_hang`
 2 | // TODO: integrate with CI tests somehow...
 3 | 
 4 | const { timeout } = require ('../base/functions')
 5 | 
 6 | ;(async function () {
 7 | 
 8 |     await timeout (10000, Promise.resolve ('foo'))
 9 | 
10 |     console.log ('Look ma, no hangs!') // should terminate the process immediately..
11 | 
12 | }) ()


--------------------------------------------------------------------------------
/js/vbtc.js:
--------------------------------------------------------------------------------
 1 | 'use strict';
 2 | 
 3 | // ---------------------------------------------------------------------------
 4 | 
 5 | const foxbit = require ('./foxbit.js');
 6 | 
 7 | // ---------------------------------------------------------------------------
 8 | 
 9 | module.exports = class vbtc extends foxbit {
10 |     describe () {
11 |         return this.deepExtend (super.describe (), {
12 |             'id': 'vbtc',
13 |             'name': 'VBTC',
14 |             'countries': [ 'VN' ],
15 |             'has': {
16 |                 'CORS': false,
17 |             },
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg',
20 |                 'api': {
21 |                     'public': 'https://api.blinktrade.com/api',
22 |                     'private': 'https://api.blinktrade.com/tapi',
23 |                 },
24 |                 'www': 'https://vbtc.exchange',
25 |                 'doc': 'https://blinktrade.com/docs',
26 |             },
27 |             'options': {
28 |                 'brokerId': '3', // https://blinktrade.com/docs/#brokers
29 |             },
30 |         });
31 |     }
32 | };
33 | 


--------------------------------------------------------------------------------
/php/bequant.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'bequant',
15 |             'name' => 'Bequant',
16 |             'countries' => array( 'MT' ), // Malta
17 |             'pro' => true,
18 |             'urls' => array(
19 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg',
20 |                 'api' => array(
21 |                     'public' => 'https://api.bequant.io',
22 |                     'private' => 'https://api.bequant.io',
23 |                 ),
24 |                 'www' => 'https://bequant.io',
25 |                 'doc' => array(
26 |                     'https://api.bequant.io/',
27 |                 ),
28 |                 'fees' => array(
29 |                     'https://bequant.io/fees-and-limits',
30 |                 ),
31 |                 'referral' => 'https://bequant.io',
32 |             ),
33 |         ));
34 |     }
35 | }
36 | 


--------------------------------------------------------------------------------
/php/bitkk.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'bitkk',
15 |             'name' => 'bitkk',
16 |             'comment' => 'a Chinese ZB clone',
17 |             'urls' => array(
18 |                 'api' => array(
19 |                     'public' => 'http://api.bitkk.com/data', // no https for public API
20 |                     'private' => 'https://trade.bitkk.com/api',
21 |                 ),
22 |                 'www' => 'https://www.bitkk.com',
23 |                 'doc' => 'https://www.bitkk.com/i/developer',
24 |                 'fees' => 'https://www.bitkk.com/i/rate',
25 |             ),
26 |         ));
27 |     }
28 | }
29 | 


--------------------------------------------------------------------------------
/php/chilebit.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'chilebit',
15 |             'name' => 'ChileBit',
16 |             'countries' => array( 'CL' ),
17 |             'has' => array(
18 |                 'CORS' => false,
19 |             ),
20 |             'urls' => array(
21 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg',
22 |                 'api' => array(
23 |                     'public' => 'https://api.blinktrade.com/api',
24 |                     'private' => 'https://api.blinktrade.com/tapi',
25 |                 ),
26 |                 'www' => 'https://chilebit.net',
27 |                 'doc' => 'https://blinktrade.com/docs',
28 |             ),
29 |             'options' => array(
30 |                 'brokerId' => '9', // https://blinktrade.com/docs/#brokers
31 |             ),
32 |         ));
33 |     }
34 | }
35 | 


--------------------------------------------------------------------------------
/php/fcoinjp.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'fcoinjp',
15 |             'name' => 'FCoinJP',
16 |             'countries' => array( 'JP' ),
17 |             'hostname' => 'fcoinjp.com',
18 |             'urls' => array(
19 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/54219174-08b66b00-4500-11e9-862d-f522d0fe08c6.jpg',
20 |                 'fees' => 'https://fcoinjp.zendesk.com/hc/en-us/articles/360018727371',
21 |                 'www' => 'https://www.fcoinjp.com',
22 |                 'referral' => null,
23 |             ),
24 |         ));
25 |     }
26 | }
27 | 


--------------------------------------------------------------------------------
/php/huobiru.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'huobiru',
15 |             'name' => 'Huobi Russia',
16 |             'countries' => array( 'RU' ),
17 |             'hostname' => 'www.huobi.com.ru',
18 |             'pro' => true,
19 |             'urls' => array(
20 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg',
21 |                 'api' => array(
22 |                     'market' => 'https://{hostname}/api',
23 |                     'public' => 'https://{hostname}/api',
24 |                     'private' => 'https://{hostname}/api',
25 |                 ),
26 |                 'www' => 'https://www.huobi.com.ru/ru-ru',
27 |                 'referral' => 'https://www.huobi.com.ru/invite?invite_code=esc74',
28 |                 'doc' => 'https://github.com/cloudapidoc/API_Docs_en',
29 |                 'fees' => 'https://www.huobi.com.ru/ru-ru/about/fee/',
30 |             ),
31 |         ));
32 |     }
33 | }
34 | 


--------------------------------------------------------------------------------
/php/static_dependencies/README.md:
--------------------------------------------------------------------------------
1 | // TODO: add web3 here
2 | 


--------------------------------------------------------------------------------
/php/static_dependencies/elliptic-php/LICENSE.md:
--------------------------------------------------------------------------------
 1 | 
 2 | ## MIT LICENSE
 3 | 
 4 | Copyright (C) 2016 Simplito
 5 | 
 6 | Permission is hereby granted, free of charge, to any person obtaining a
 7 | copy of this software and associated documentation files (the
 8 | "Software"), to deal in the Software without restriction, including
 9 | without limitation the rights to use, copy, modify, merge, publish,
10 | distribute, sublicense, and/or sell copies of the Software, and to permit
11 | persons to whom the Software is furnished to do so, subject to the
12 | following conditions:
13 | 
14 | The above copyright notice and this permission notice shall be included
15 | in all copies or substantial portions of the Software.
16 | 
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
20 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 | USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | 


--------------------------------------------------------------------------------
/php/static_dependencies/elliptic-php/composer.json:
--------------------------------------------------------------------------------
 1 | {
 2 |     "name": "simplito/elliptic-php",
 3 |     "description": "Fast elliptic curve cryptography",
 4 |     "type": "library",
 5 |     "homepage": "https://github.com/simplito/elliptic-php",
 6 |     "keywords": ["elliptic", "curve", "cryptography", "ECC", 
 7 |                  "ECDH", "ECDSA", "EdDSA", 
 8 |                  "secp256k1", "curve25519", "ed25519", 
 9 |                  "nistp192", "nistp224", "nistp256", "nistp384", "nistp521"],
10 |     "license": "MIT",
11 |     "authors": [
12 |         {
13 |             "name": "Simplito Team",
14 |             "email": "s.smyczynski@simplito.com",
15 |             "homepage": "https://simplito.com"
16 |         }
17 |     ],
18 |     "require": {
19 |         "ext-gmp": "*",
20 |         "simplito/bn-php": "~1.1.0"
21 |     },
22 |     "require-dev": {
23 |         "phpunit/phpunit": "*",
24 |         "phpbench/phpbench": "@dev"
25 |     },
26 |     "autoload": {
27 |         "psr-4": {
28 |             "Elliptic\\": "lib/"
29 |         }
30 |     },
31 |     "scripts": {
32 |         "test": "phpunit --verbose"
33 |     }
34 | }
35 | 


--------------------------------------------------------------------------------
/php/static_dependencies/elliptic-php/lib/Curve/PresetCurve.php:
--------------------------------------------------------------------------------
 1 | curve = new ShortCurve($options);
16 |         elseif ( $options["type"] === "edwards" )
17 |             $this->curve = new EdwardsCurve($options);
18 |         else
19 |             $this->curve = new MontCurve($options);
20 | 
21 |         $this->g = $this->curve->g;
22 |         $this->n = $this->curve->n;
23 |         $this->hash = isset($options["hash"]) ? $options["hash"] : null;
24 |     }
25 | }
26 | 
27 | ?>
28 | 


--------------------------------------------------------------------------------
/php/static_dependencies/kornrunner/keccak/LICENSE:
--------------------------------------------------------------------------------
 1 | MIT License
 2 | 
 3 | Copyright (c) 2018 Boris Momčilović
 4 | 
 5 | Permission is hereby granted, free of charge, to any person obtaining a copy
 6 | of this software and associated documentation files (the "Software"), to deal
 7 | in the Software without restriction, including without limitation the rights
 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 | 
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 | 
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | 


--------------------------------------------------------------------------------
/php/static_dependencies/kornrunner/keccak/README.md:
--------------------------------------------------------------------------------
 1 | # php-keccak [![Build Status](https://travis-ci.org/kornrunner/php-keccak.svg?branch=master)](https://travis-ci.org/kornrunner/php-keccak)  [![Coverage Status](https://coveralls.io/repos/github/kornrunner/php-keccak/badge.svg?branch=master)](https://coveralls.io/github/kornrunner/php-keccak?branch=master)
 2 | Pure PHP implementation of Keccak (SHA-3)
 3 | 
 4 | ## Usage
 5 | 
 6 | ```php
 7 | deep_extend(parent::describe (), array(
14 |             'id' => 'surbitcoin',
15 |             'name' => 'SurBitcoin',
16 |             'countries' => array( 'VE' ),
17 |             'has' => array(
18 |                 'CORS' => false,
19 |             ),
20 |             'urls' => array(
21 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/27991511-f0a50194-6481-11e7-99b5-8f02932424cc.jpg',
22 |                 'api' => array(
23 |                     'public' => 'https://api.blinktrade.com/api',
24 |                     'private' => 'https://api.blinktrade.com/tapi',
25 |                 ),
26 |                 'www' => 'https://surbitcoin.com',
27 |                 'doc' => 'https://blinktrade.com/docs',
28 |             ),
29 |             'options' => array(
30 |                 'brokerId' => '1', // https://blinktrade.com/docs/#brokers
31 |             ),
32 |         ));
33 |     }
34 | }
35 | 


--------------------------------------------------------------------------------
/php/test/bootstrap.php:
--------------------------------------------------------------------------------
1 |  false));
22 | }
23 | 


--------------------------------------------------------------------------------
/php/vbtc.php:
--------------------------------------------------------------------------------
 1 | deep_extend(parent::describe (), array(
14 |             'id' => 'vbtc',
15 |             'name' => 'VBTC',
16 |             'countries' => array( 'VN' ),
17 |             'has' => array(
18 |                 'CORS' => false,
19 |             ),
20 |             'urls' => array(
21 |                 'logo' => 'https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg',
22 |                 'api' => array(
23 |                     'public' => 'https://api.blinktrade.com/api',
24 |                     'private' => 'https://api.blinktrade.com/tapi',
25 |                 ),
26 |                 'www' => 'https://vbtc.exchange',
27 |                 'doc' => 'https://blinktrade.com/docs',
28 |             ),
29 |             'options' => array(
30 |                 'brokerId' => '3', // https://blinktrade.com/docs/#brokers
31 |             ),
32 |         ));
33 |     }
34 | }
35 | 


--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
13 | 
14 |     
15 |         
16 |             php/test
17 |         
18 |     
19 | 
20 |     
21 |         
22 |             php
23 |         
24 |     
25 | 
26 |     
27 |         
28 |     
29 | 
30 | 


--------------------------------------------------------------------------------
/python/LICENSE.txt:
--------------------------------------------------------------------------------
 1 | MIT License
 2 | 
 3 | Copyright © 2017 Igor Kroitor
 4 | 
 5 | Permission is hereby granted, free of charge, to any person obtaining a copy
 6 | of this software and associated documentation files (the "Software"), to deal
 7 | in the Software without restriction, including without limitation the rights
 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 | 
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 | 
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | 


--------------------------------------------------------------------------------
/python/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # Include the license file
2 | include LICENSE.txt
3 | 
4 | # Include the package.json file
5 | include package.json


--------------------------------------------------------------------------------
/python/ccxt/async_support/bequant.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.hitbtc import hitbtc
 7 | 
 8 | 
 9 | class bequant(hitbtc):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(bequant, self).describe(), {
13 |             'id': 'bequant',
14 |             'name': 'Bequant',
15 |             'countries': ['MT'],  # Malta
16 |             'pro': True,
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg',
19 |                 'api': {
20 |                     'public': 'https://api.bequant.io',
21 |                     'private': 'https://api.bequant.io',
22 |                 },
23 |                 'www': 'https://bequant.io',
24 |                 'doc': [
25 |                     'https://api.bequant.io/',
26 |                 ],
27 |                 'fees': [
28 |                     'https://bequant.io/fees-and-limits',
29 |                 ],
30 |                 'referral': 'https://bequant.io',
31 |             },
32 |         })
33 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/bitkk.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.zb import zb
 7 | 
 8 | 
 9 | class bitkk(zb):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(bitkk, self).describe(), {
13 |             'id': 'bitkk',
14 |             'name': 'bitkk',
15 |             'comment': 'a Chinese ZB clone',
16 |             'urls': {
17 |                 'api': {
18 |                     'public': 'http://api.bitkk.com/data',  # no https for public API
19 |                     'private': 'https://trade.bitkk.com/api',
20 |                 },
21 |                 'www': 'https://www.bitkk.com',
22 |                 'doc': 'https://www.bitkk.com/i/developer',
23 |                 'fees': 'https://www.bitkk.com/i/rate',
24 |             },
25 |         })
26 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/chilebit.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.foxbit import foxbit
 7 | 
 8 | 
 9 | class chilebit(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(chilebit, self).describe(), {
13 |             'id': 'chilebit',
14 |             'name': 'ChileBit',
15 |             'countries': ['CL'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://chilebit.net',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '9',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/fcoinjp.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.fcoin import fcoin
 7 | 
 8 | 
 9 | class fcoinjp(fcoin):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(fcoinjp, self).describe(), {
13 |             'id': 'fcoinjp',
14 |             'name': 'FCoinJP',
15 |             'countries': ['JP'],
16 |             'hostname': 'fcoinjp.com',
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/54219174-08b66b00-4500-11e9-862d-f522d0fe08c6.jpg',
19 |                 'fees': 'https://fcoinjp.zendesk.com/hc/en-us/articles/360018727371',
20 |                 'www': 'https://www.fcoinjp.com',
21 |                 'referral': None,
22 |             },
23 |         })
24 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/huobiru.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.huobipro import huobipro
 7 | 
 8 | 
 9 | class huobiru(huobipro):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(huobiru, self).describe(), {
13 |             'id': 'huobiru',
14 |             'name': 'Huobi Russia',
15 |             'countries': ['RU'],
16 |             'hostname': 'www.huobi.com.ru',
17 |             'pro': True,
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg',
20 |                 'api': {
21 |                     'market': 'https://{hostname}/api',
22 |                     'public': 'https://{hostname}/api',
23 |                     'private': 'https://{hostname}/api',
24 |                 },
25 |                 'www': 'https://www.huobi.com.ru/ru-ru',
26 |                 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74',
27 |                 'doc': 'https://github.com/cloudapidoc/API_Docs_en',
28 |                 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/',
29 |             },
30 |         })
31 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/okcoin.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.okex import okex
 7 | 
 8 | 
 9 | class okcoin(okex):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(okcoin, self).describe(), {
13 |             'id': 'okcoin',
14 |             'name': 'OKCoin',
15 |             'countries': ['CN', 'US'],
16 |             'hostname': 'okcoin.com',
17 |             'pro': True,
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27766791-89ffb502-5ee5-11e7-8a5b-c5950b68ac65.jpg',
20 |                 'www': 'https://www.okcoin.com',
21 |                 'doc': 'https://www.okcoin.com/docs/en/',
22 |                 'fees': 'https://www.okcoin.com/coin-fees',
23 |                 'referral': 'https://www.okcoin.com/account/register?flag=activity&channelId=600001513',
24 |             },
25 |             'fees': {
26 |                 'trading': {
27 |                     'taker': 0.002,
28 |                     'maker': 0.001,
29 |                 },
30 |             },
31 |             'options': {
32 |                 'fetchMarkets': ['spot'],
33 |             },
34 |         })
35 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/surbitcoin.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.foxbit import foxbit
 7 | 
 8 | 
 9 | class surbitcoin(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(surbitcoin, self).describe(), {
13 |             'id': 'surbitcoin',
14 |             'name': 'SurBitcoin',
15 |             'countries': ['VE'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991511-f0a50194-6481-11e7-99b5-8f02932424cc.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://surbitcoin.com',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '1',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/ccxt/async_support/vbtc.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.async_support.foxbit import foxbit
 7 | 
 8 | 
 9 | class vbtc(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(vbtc, self).describe(), {
13 |             'id': 'vbtc',
14 |             'name': 'VBTC',
15 |             'countries': ['VN'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://vbtc.exchange',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '3',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/ccxt/bequant.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.hitbtc import hitbtc
 7 | 
 8 | 
 9 | class bequant(hitbtc):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(bequant, self).describe(), {
13 |             'id': 'bequant',
14 |             'name': 'Bequant',
15 |             'countries': ['MT'],  # Malta
16 |             'pro': True,
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/55248342-a75dfe00-525a-11e9-8aa2-05e9dca943c6.jpg',
19 |                 'api': {
20 |                     'public': 'https://api.bequant.io',
21 |                     'private': 'https://api.bequant.io',
22 |                 },
23 |                 'www': 'https://bequant.io',
24 |                 'doc': [
25 |                     'https://api.bequant.io/',
26 |                 ],
27 |                 'fees': [
28 |                     'https://bequant.io/fees-and-limits',
29 |                 ],
30 |                 'referral': 'https://bequant.io',
31 |             },
32 |         })
33 | 


--------------------------------------------------------------------------------
/python/ccxt/bitkk.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.zb import zb
 7 | 
 8 | 
 9 | class bitkk(zb):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(bitkk, self).describe(), {
13 |             'id': 'bitkk',
14 |             'name': 'bitkk',
15 |             'comment': 'a Chinese ZB clone',
16 |             'urls': {
17 |                 'api': {
18 |                     'public': 'http://api.bitkk.com/data',  # no https for public API
19 |                     'private': 'https://trade.bitkk.com/api',
20 |                 },
21 |                 'www': 'https://www.bitkk.com',
22 |                 'doc': 'https://www.bitkk.com/i/developer',
23 |                 'fees': 'https://www.bitkk.com/i/rate',
24 |             },
25 |         })
26 | 


--------------------------------------------------------------------------------
/python/ccxt/chilebit.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.foxbit import foxbit
 7 | 
 8 | 
 9 | class chilebit(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(chilebit, self).describe(), {
13 |             'id': 'chilebit',
14 |             'name': 'ChileBit',
15 |             'countries': ['CL'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991414-1298f0d8-647f-11e7-9c40-d56409266336.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://chilebit.net',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '9',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/ccxt/coinbaseprime.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.coinbasepro import coinbasepro
 7 | 
 8 | 
 9 | class coinbaseprime(coinbasepro):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(coinbaseprime, self).describe(), {
13 |             'id': 'coinbaseprime',
14 |             'name': 'Coinbase Prime',
15 |             'pro': True,
16 |             'urls': {
17 |                 'test': {
18 |                     'public': 'https://api-public.sandbox.prime.coinbase.com',
19 |                     'private': 'https://api-public.sandbox.prime.coinbase.com',
20 |                 },
21 |                 'logo': 'https://user-images.githubusercontent.com/1294454/44539184-29f26e00-a70c-11e8-868f-e907fc236a7c.jpg',
22 |                 'api': {
23 |                     'public': 'https://api.prime.coinbase.com',
24 |                     'private': 'https://api.prime.coinbase.com',
25 |                 },
26 |                 'www': 'https://prime.coinbase.com',
27 |                 'doc': 'https://docs.prime.coinbase.com',
28 |                 'fees': 'https://support.prime.coinbase.com/customer/en/portal/articles/2945629-fees?b_id=17475',
29 |             },
30 |         })
31 | 


--------------------------------------------------------------------------------
/python/ccxt/fcoinjp.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.fcoin import fcoin
 7 | 
 8 | 
 9 | class fcoinjp(fcoin):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(fcoinjp, self).describe(), {
13 |             'id': 'fcoinjp',
14 |             'name': 'FCoinJP',
15 |             'countries': ['JP'],
16 |             'hostname': 'fcoinjp.com',
17 |             'urls': {
18 |                 'logo': 'https://user-images.githubusercontent.com/1294454/54219174-08b66b00-4500-11e9-862d-f522d0fe08c6.jpg',
19 |                 'fees': 'https://fcoinjp.zendesk.com/hc/en-us/articles/360018727371',
20 |                 'www': 'https://www.fcoinjp.com',
21 |                 'referral': None,
22 |             },
23 |         })
24 | 


--------------------------------------------------------------------------------
/python/ccxt/huobiru.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.huobipro import huobipro
 7 | 
 8 | 
 9 | class huobiru(huobipro):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(huobiru, self).describe(), {
13 |             'id': 'huobiru',
14 |             'name': 'Huobi Russia',
15 |             'countries': ['RU'],
16 |             'hostname': 'www.huobi.com.ru',
17 |             'pro': True,
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/52978816-e8552e00-33e3-11e9-98ed-845acfece834.jpg',
20 |                 'api': {
21 |                     'market': 'https://{hostname}/api',
22 |                     'public': 'https://{hostname}/api',
23 |                     'private': 'https://{hostname}/api',
24 |                 },
25 |                 'www': 'https://www.huobi.com.ru/ru-ru',
26 |                 'referral': 'https://www.huobi.com.ru/invite?invite_code=esc74',
27 |                 'doc': 'https://github.com/cloudapidoc/API_Docs_en',
28 |                 'fees': 'https://www.huobi.com.ru/ru-ru/about/fee/',
29 |             },
30 |         })
31 | 


--------------------------------------------------------------------------------
/python/ccxt/okcoin.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.okex import okex
 7 | 
 8 | 
 9 | class okcoin(okex):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(okcoin, self).describe(), {
13 |             'id': 'okcoin',
14 |             'name': 'OKCoin',
15 |             'countries': ['CN', 'US'],
16 |             'hostname': 'okcoin.com',
17 |             'pro': True,
18 |             'urls': {
19 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27766791-89ffb502-5ee5-11e7-8a5b-c5950b68ac65.jpg',
20 |                 'www': 'https://www.okcoin.com',
21 |                 'doc': 'https://www.okcoin.com/docs/en/',
22 |                 'fees': 'https://www.okcoin.com/coin-fees',
23 |                 'referral': 'https://www.okcoin.com/account/register?flag=activity&channelId=600001513',
24 |             },
25 |             'fees': {
26 |                 'trading': {
27 |                     'taker': 0.002,
28 |                     'maker': 0.001,
29 |                 },
30 |             },
31 |             'options': {
32 |                 'fetchMarkets': ['spot'],
33 |             },
34 |         })
35 | 


--------------------------------------------------------------------------------
/python/ccxt/pro/__init__.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | """CCXT Pro Wrapper (Async)"""
 4 | 
 5 | # -----------------------------------------------------------------------------
 6 | 
 7 | # will throw a standard ImportError exception
 8 | # with a slightly better human-friendlymessage
 9 | try:
10 |     import ccxtpro
11 | except ImportError:
12 |     raise ImportError('CCXT Pro is not installed, access and install at https://ccxt.pro')
13 | 
14 | __all__ = ccxtpro.__all__
15 | 


--------------------------------------------------------------------------------
/python/ccxt/static_dependencies/README.md:
--------------------------------------------------------------------------------
1 | // TODO: add web3
2 | 


--------------------------------------------------------------------------------
/python/ccxt/static_dependencies/__init__.py:
--------------------------------------------------------------------------------
1 | __all__ = ['ecdsa']
2 | 


--------------------------------------------------------------------------------
/python/ccxt/static_dependencies/ecdsa/__init__.py:
--------------------------------------------------------------------------------
 1 | from .keys import SigningKey, VerifyingKey, BadSignatureError, BadDigestError
 2 | from .curves import NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1
 3 | 
 4 | # This code comes from http://github.com/warner/python-ecdsa
 5 | #from ._version import get_versions
 6 | __version__ = 'ccxt'  # custom ccxt version
 7 | #del get_versions
 8 | 
 9 | __all__ = ["curves", "der", "ecdsa", "ellipticcurve", "keys", "numbertheory",
10 |            "test_pyecdsa", "util", "six"]
11 | 
12 | _hush_pyflakes = [SigningKey, VerifyingKey, BadSignatureError, BadDigestError,
13 |                   NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1]
14 | del _hush_pyflakes
15 | 


--------------------------------------------------------------------------------
/python/ccxt/surbitcoin.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.foxbit import foxbit
 7 | 
 8 | 
 9 | class surbitcoin(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(surbitcoin, self).describe(), {
13 |             'id': 'surbitcoin',
14 |             'name': 'SurBitcoin',
15 |             'countries': ['VE'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991511-f0a50194-6481-11e7-99b5-8f02932424cc.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://surbitcoin.com',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '1',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/ccxt/vbtc.py:
--------------------------------------------------------------------------------
 1 | # -*- coding: utf-8 -*-
 2 | 
 3 | # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
 4 | # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
 5 | 
 6 | from ccxt.foxbit import foxbit
 7 | 
 8 | 
 9 | class vbtc(foxbit):
10 | 
11 |     def describe(self):
12 |         return self.deep_extend(super(vbtc, self).describe(), {
13 |             'id': 'vbtc',
14 |             'name': 'VBTC',
15 |             'countries': ['VN'],
16 |             'has': {
17 |                 'CORS': False,
18 |             },
19 |             'urls': {
20 |                 'logo': 'https://user-images.githubusercontent.com/1294454/27991481-1f53d1d8-6481-11e7-884e-21d17e7939db.jpg',
21 |                 'api': {
22 |                     'public': 'https://api.blinktrade.com/api',
23 |                     'private': 'https://api.blinktrade.com/tapi',
24 |                 },
25 |                 'www': 'https://vbtc.exchange',
26 |                 'doc': 'https://blinktrade.com/docs',
27 |             },
28 |             'options': {
29 |                 'brokerId': '3',  # https://blinktrade.com/docs/#brokers
30 |             },
31 |         })
32 | 


--------------------------------------------------------------------------------
/python/deploy.sh:
--------------------------------------------------------------------------------
1 | python setup.py sdist bdist_wheel
2 | twine upload dist/* -u x84 -p ${PYPI_PASSWORD}


--------------------------------------------------------------------------------
/python/setup.cfg:
--------------------------------------------------------------------------------
 1 | [bdist_wheel]
 2 | # This flag says that the code is written to work on both Python 2 and Python
 3 | # 3. If at all possible, it is good practice to do this. If you cannot, you
 4 | # will need to generate wheels for each Python version that you support.
 5 | universal=1
 6 | 
 7 | [flake8]
 8 | ignore = E501
 9 | exclude =
10 |     .ropeproject,
11 |     .tox,
12 |     .eggs,
13 |     # No need to traverse our git directory
14 |     .git,
15 |     # There's no value in checking cache directories
16 |     __pycache__,
17 |     # Other special cases
18 |     node_modules,
19 |     .nyc_output,
20 |     build,
21 |     tmp,
22 |     # No need to check the basecode
23 |     ccxt.py
24 | 


--------------------------------------------------------------------------------
/python/tox.ini:
--------------------------------------------------------------------------------
 1 | [tox]
 2 | envlist = py{27,35,36,37},qa
 3 | skipsdist = True
 4 | skip_missing_interpreters = True
 5 | 
 6 | [testenv]
 7 | setenv =
 8 |     PYTHONPATH = {toxinidir}:{toxinidir}
 9 | commands =
10 |     python test.py
11 | 
12 | [testenv:qa]
13 | basepython = python3
14 | changedir = {toxinidir}
15 | commands = flake8 --ignore=F841,W504,E501 --exclude static_dependencies,node_modules,.tox
16 | deps = .[qa]
17 | 
18 | [testenv:doc]
19 | changedir = {toxinidir}/../doc
20 | deps = .[doc]
21 | commands=
22 |     sphinx-build -W -b html -d {envtmpdir}/doctrees .  {envtmpdir}/html
23 | 


--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
 1 | [flake8]
 2 | ignore = E501
 3 | exclude =
 4 |     .ropeproject,
 5 |     .tox,
 6 |     .eggs,
 7 |     # No need to traverse our git directory
 8 |     .git,
 9 |     # There's no value in checking cache directories
10 |     __pycache__,
11 |     # Other special cases
12 |     node_modules,
13 |     .nyc_output,
14 |     build,
15 |     tmp,
16 |     # No need to check the basecode
17 |     ccxt.py
18 | 


--------------------------------------------------------------------------------
/wiki/Certification.md:
--------------------------------------------------------------------------------
 1 | # CCXT Certification Program · ![CCXT Certified](https://img.shields.io/badge/CCXT-certified-green.svg)
 2 | 
 3 | The structure of CCXT defines a good, portable and cross-compatible standard for exchanges' API interfaces, that is implemented in the CCXT Unified API. Exchanges are welcome to apply for our certification program. Certification is technically supervised and quality-assured by members of the CCXT Dev Team. That implies that an exchange having a "certified" badge is properly implemented and tested by the authors of CCXT. Certification means less bugs, more functionality, priority support and a much more stable and efficient implementation in general.
 4 | 
 5 | ## Requirements
 6 | 
 7 | Getting integrated and certified requires the exchange to implement a quality API. Please, see the full list of technical requirements here: https://github.com/ccxt/ccxt/wiki/Requirements
 8 | 
 9 | ## Contact Us
10 | 
11 | For inquiries on getting your exchange integrated, listed and certified: info@ccxt.trade
12 | 


--------------------------------------------------------------------------------