Skip to content

Commit

Permalink
removed old metainfo interface for python and PHP, fixed failing test…
Browse files Browse the repository at this point in the history
…s, temporarily returned legacy number.js implementation (to be able to merge current work with the master branch and then continue re-working it)
  • Loading branch information
xpl committed Jan 21, 2018
1 parent 38fcf19 commit 28d611f
Show file tree
Hide file tree
Showing 310 changed files with 2,325 additions and 2,326 deletions.
2,141 changes: 1,122 additions & 1,019 deletions build/ccxt.browser.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,11 @@ Here's an overview of base exchange properties with values added for example:
},
'version': 'v1', // string ending with digits
'api': { ... }, // dictionary of api endpoints
'hasFetchTickers': true, // true if the exchange implements fetchTickers ()
'hasFetchOHLCV': false, // true if the exchange implements fetchOHLCV ()
'timeframes': { // empty if the exchange !hasFetchOHLCV
'has': {
'fetchTickers': true, // true if the exchange implements fetchTickers ()
'fetchOHLCV': false, // true if the exchange implements fetchOHLCV ()
},
'timeframes': { // empty if the exchange !has.fetchOHLCV
'1m': '1minute',
'1h': '1hour',
'1d': '1day',
Expand Down Expand Up @@ -1157,7 +1159,7 @@ You can call the unified ``fetchOHLCV`` / ``fetch_ohlcv`` method to get the list
// JavaScript
let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms));
if (exchange.hasFetchOHLCV) {
if (exchange.has.fetchOHLCV) {
(async () => {
for (symbol in exchange.markets) {
await sleep (exchange.rateLimit) // milliseconds
Expand Down
2 changes: 1 addition & 1 deletion examples/js/fetch-ticker-where-available.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let printUsage = function () {
let id = ccxt.exchanges[i]

const exchange = new ccxt[id] ()
if (exchange.hasPublicAPI) {
if (exchange.has.publicAPI) {

try {

Expand Down
2 changes: 1 addition & 1 deletion examples/js/search-all-exchanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const checkAgainst = strict ?
// instantiate the exchange
let exchange = new ccxt[id] ()

if (exchange.hasPublicAPI) {
if (exchange.has.publicAPI) {

try {

Expand Down
19 changes: 6 additions & 13 deletions js/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

/* ------------------------------------------------------------------------ */

<<<<<<< HEAD
const functions = require ('./functions')
=======
const isNode = (typeof window === 'undefined') && !(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
, functions = require ('./functions')
, throttle = require ('./throttle')
, defaultFetch = isNode ? require ('fetch-ponyfill')().fetch : fetch
>>>>>>> master
, Market = require ('./Market')

const { isNode
Expand All @@ -28,9 +21,9 @@ const { isNode
, throttle
, capitalize } = functions

const { sleep
const { now
, sleep
, timeout
, time
, TimedOut } = require ('./functions/time')

const { ExchangeError
Expand All @@ -40,7 +33,7 @@ const { ExchangeError
, RequestTimeout
, ExchangeNotAvailable } = require ('./errors')

const fetchImplementation = isNode ? require ('fetch-ponyfill')().fetch : fetch
const defaultFetch = isNode ? require ('fetch-ponyfill')().fetch : fetch

const journal = undefined // isNode && require ('./journal') // stub until we get a better solution for Webpack and React

Expand Down Expand Up @@ -95,9 +88,9 @@ module.exports = class Exchange {

this.iso8601 = timestamp => new Date (timestamp).toISOString ()
this.parse8601 = x => Date.parse (((x.indexOf ('+') >= 0) || (x.slice (-1) == 'Z')) ? x : (x + 'Z'))
this.milliseconds = () => Math.floor (time.now ())
this.microseconds = () => Math.floor (time.now () * 1000)
this.seconds = () => Math.floor (time.now () / 1000)
this.milliseconds = now
this.microseconds = () => now () * 1000 // TODO: utilize performance.now for that purpose
this.seconds = () => Math.floor (now () / 1000)
this.id = undefined

// rate limiter settings
Expand Down
46 changes: 13 additions & 33 deletions js/base/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,18 @@ const unCamelCasePropertyNames = x => {

/* ------------------------------------------------------------------------ */

module.exports = unCamelCasePropertyNames ({

...require ('./functions/platform'),
...require ('./functions/generic'),
...require ('./functions/string'),
...require ('./functions/type'),
...require ('./functions/number'),
...require ('./functions/encode'),
...require ('./functions/crypto'),
...require ('./functions/time'),
...require ('./functions/throttle'),

/* ............................................. */

json: JSON.stringify,
unjson: JSON.parse,

/* ............................................. */

aggregate (bidasks) {

let result = {}

for (const [price, volume] of bidasks) {
if (volume > 0)
result[price] = (result[price] || 0) + volume
}

return Object.keys (result)
.map (price => [parseFloat (price),
parseFloat (result[price])])
}
})
module.exports = unCamelCasePropertyNames (Object.assign ({}

, require ('./functions/platform')
, require ('./functions/generic')
, require ('./functions/string')
, require ('./functions/type')
, require ('./functions/number')
, require ('./functions/encode')
, require ('./functions/crypto')
, require ('./functions/time')
, require ('./functions/throttle')
, require ('./functions/misc')
))

/* ------------------------------------------------------------------------ */
14 changes: 9 additions & 5 deletions js/base/functions/encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

/* ------------------------------------------------------------------------ */

const qs = require ('qs') // querystring (TODO: get rid of that dependency)
const CryptoJS = require ('crypto-js')
const qs = require ('qs') // querystring (TODO: get rid of that dependency)

/* ------------------------------------------------------------------------ */

module.exports = {

stringToBinary (str) {
module.exports =

{ json: JSON.stringify
, unjson: JSON.parse

, stringToBinary (str) {
const arr = new Uint8Array (str.length)
for (let i = 0; i < str.length; i++) { arr[i] = str.charCodeAt(i); }
for (let i = 0; i < str.length; i++) { arr[i] = str.charCodeAt (i); }
return CryptoJS.lib.WordArray.create (arr)
}

Expand Down
22 changes: 22 additions & 0 deletions js/base/functions/misc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

/* ------------------------------------------------------------------------ */

module.exports = {

aggregate (bidasks) {

let result = {}

for (const [price, volume] of bidasks) {
if (volume > 0)
result[price] = (result[price] || 0) + volume
}

return Object.keys (result)
.map (price => [parseFloat (price),
parseFloat (result[price])])
}
}

/* ------------------------------------------------------------------------ */
Loading

0 comments on commit 28d611f

Please sign in to comment.