Skip to content

Instantly share code, notes, and snippets.

View kroitor's full-sized avatar

Igor Kroitor kroitor

View GitHub Profile
"use strict";
/* ------------------------------------------------------------------------ */
const blessed = require ('blessed')
, ccxt = require ('ccxt')
, log = require ('ololog')
, ansi = require ('ansicolor').nice
, StackTracey = require ('stacktracey')
, asciichart = require ('asciichart')
@kroitor
kroitor / fetching-ohlcv.md
Created February 25, 2020 22:56
How to fetch OHLCV as a table
mbp:ccxt igorkroitor$ node examples/js/cli binance fetchOHLCV ETH/USDT 1d 2020-01-01T00:00:00Z --table --iso8601
binance.fetchOHLCV (ETH/USDT, 1d, 1577836800000)
2020-01-01T00:00:00.000Z | 129.16 | 133.05 | 128.68 | 130.77 |  144770.52197
2020-01-02T00:00:00.000Z | 130.72 | 130.78 | 126.38 | 127.19 |  213757.05806
2020-01-03T00:00:00.000Z | 127.19 | 135.14 | 125.88 | 134.35 |  413055.18895
2020-01-04T00:00:00.000Z | 134.37 | 135.85 |  132.5 |  134.2 |  184276.17102
2020-01-05T00:00:00.000Z |  134.2 | 138.19 | 134.19 | 135.37 |  254120.45343
2020-01-06T00:00:00.000Z | 135.37 | 144.41 | 134.86 | 144.15 |  408020.27375
2020-01-07T00:00:00.000Z | 144.14 | 145.31 | 138.76 |  142.8 |  447762.17281
@kroitor
kroitor / fetching-all-markets-table.md
Created February 25, 2020 22:52
Fetching all markets as a table
mbp:ccxt igorkroitor$ node examples/js/cli binance markets --table
                                                                                            limits |                                 precision | tierBased | percentage | taker | maker |          id |       symbol |    base | quote |  baseId | quoteId | type | spot | future | active
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"amount":{"min":0.001,"max":100000},"price":{"min":0.000001,"max":100000},"cost":{"min":0.0001}} | {"base":8,"quote":8,"amount":3,"price":6} |     false |       true | 0.001 | 0.001 |      ETHBTC |      ETH/BTC |     ETH |   BTC |     ETH |     BTC | spot | true |  false |   true
  {"amount":{"min":0.01,"max":100000},"price":{"min":0.000001,"max":100000},"cost":{"min":0.0001}} | {"b
@kroitor
kroitor / fetching-all-tickers-table.md
Created February 25, 2020 22:51
Fetching all tickers as a table
mbp:ccxt igorkroitor$ node examples/js/cli binance fetchTickers --table
binance.fetchTickers ()
      symbol |     timestamp |                 datetime |       high |        low |        bid |  bidVolume |        ask | askVolume |             vwap |       open |      close |       last | previousClose |      change | percentage | average |    baseVolume |        quoteVolume
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     ETH/BTC | 1582671023716 | 2020-02-25T22:50:23.716Z |    0.02755 |   0.026423 |   0.026825 |      0.477 |   0.026836 |     0.481 |       0.02698746 |   0.027361 |   0.026826 |   0.026826 |      0.027361 |   -0.000535 |     -1.955 |         |    189367.979 |      5110.56109696
     LTC/BTC | 1582671023699 | 2020-02-25T22:50:23.699Z |   0.007867 |     0.0075
@kroitor
kroitor / fetching-one-ticker.md
Created February 25, 2020 22:50
How to fetch one ticker by symbol
mbp:ccxt igorkroitor$ node examples/js/cli binance fetchTicker BTC/USDT
binance.fetchTicker (BTC/USDT)
{        symbol:   "BTC/USDT",
      timestamp:    1582670961115,
       datetime:   "2020-02-25T22:49:21.115Z",
           high:    9675,
            low:    9250,
            bid:    9372.03,
      bidVolume:    0.312134,
@kroitor
kroitor / fetching-one-market.md
Created February 25, 2020 22:48
How to fetch a market by symbol from an exchange
mbp:ccxt igorkroitor$ node examples/js/cli binance market ETH/USDC
binance.market (ETH/USDC)
{     limits: { amount: { min: 0.00001, max: 900000 },
                 price: { min: 0.01, max: 100000 },
                  cost: { min: 10, max: undefined }    },
   precision: { base: 8, quote: 8, amount: 5, price: 2 },
   tierBased:    false,
  percentage:    true,
       taker:    0.001,
@kroitor
kroitor / searching-all-exchanges-markets.md
Created February 25, 2020 22:47
How to search all exchanges markets by currency or symbol
mbp:ccxt igorkroitor$ node examples/js/search-all-exchanges.js USDC --markets
Looking up for: USDC (non-strict search)
---------------------------------------------------------------
Markets And Symbols:
tierBased  percentage  taker   maker    id            symbol      base   quote  baseId                                      quoteId                                     active  exchange       type  spot   future  fee  swap   futures  normalSymbol  lot      step      darkpool  altname   numericId  lowercaseId  contractType  baseNumericId  quoteNumericId
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
false      true        0.002   0.001    BTCUSDC       BTC/USDC    BTC    USDC   BTC                         
@kroitor
kroitor / searching-all-exchanges.md
Created February 25, 2020 22:44
How to search a token on all exchanges with CCXT
mbp:ccxt igorkroitor$ node examples/js/search-all-exchanges.js USDT --strict --currencies
Looking up for: USDT (strict search)
---------------------------------------------------------------
Currencies:
id    numericId  code  exchange            name        active  fee    type          payin  payout  transfer  address                                     funding
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
usdt             USDT  acx
USDT             USDT  adara               Tether      true    2
USD              USDT  bequant             Tether      true    2      crypto        true   true    true
mbp:ccxt igorkroitor$ node
Welcome to Node.js v12.2.0.
Type ".help" for more information.
> const ccxt = require ('./ccxt')
undefined
> ;(async () => {
...     const exchange = new ccxt.okex3 ({
.....         enableRateLimit: true, // required by the Manual
.....     })
mbp:ccxt igorkroitor$ python3 examples/py/cli.py indodax fetchTrades USDT/IDR --verbose

Request: GET https://indodax.com/api/usdt_idr/trades {'User-Agent': 'python-requests/2.21.0', 'Accept-Encoding': 'gzip, deflate'} None

Response: GET https://indodax.com/api/usdt_idr/trades 200 {'Date': 'Wed, 12 Feb 2020 22:42:11 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=d522eeaf4ac56b2a65f6628efae762f181581547330; expires=Fri, 13-Mar-20 22:42:10 GMT; path=/; domain=.indodax.com; HttpOnly; SameSite=Lax; Secure', 'X-Powered-By': 'INDODAX', 'v': '2', 'Access-Control-Allow-Origin': '', 'X-Served-By': 'PA-SG', 'X-Frame-Options': 'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'CF-Cache-Status': 'DYNAMIC', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Server': 'cloudf