Skip to content

Commit

Permalink
Merge branch 'master' into ticksize-wavesexchange
Browse files Browse the repository at this point in the history
  • Loading branch information
ttodua committed Sep 8, 2022
2 parents 68ce9ef + 2471d06 commit 7aa8861
Show file tree
Hide file tree
Showing 668 changed files with 87,041 additions and 87,455 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ python/LICENSE.txt
.env
*.swp
.cache
*.un~
68 changes: 32 additions & 36 deletions README.md

Large diffs are not rendered by default.

42 changes: 32 additions & 10 deletions build/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ class Transpiler {
[ /Precise\.stringGe\s/g, 'Precise.string_ge' ],
[ /Precise\.stringLt\s/g, 'Precise.string_lt' ],
[ /Precise\.stringLe\s/g, 'Precise.string_le' ],
[ /\.padEnd\s/g, '.ljust'],
[ /\.padStart\s/g, '.rjust' ],

// insert common regexes in the middle (critical)
].concat (this.getCommonRegexes ()).concat ([
Expand Down Expand Up @@ -350,8 +352,8 @@ class Transpiler {
[ /JSON\.parse\s*/g, "json.loads" ],
// [ /([^\(\s]+)\.includes\s+\(([^\)]+)\)/g, '$2 in $1' ],
// [ /\'%([^\']+)\'\.sprintf\s*\(([^\)]+)\)/g, "'{:$1}'.format($2)" ],
[ /([^\s]+)\.toFixed\s*\(([0-9]+)\)/g, "'{:.$2f}'.format($1)" ],
[ /([^\s]+)\.toFixed\s*\(([^\)]+)\)/g, "('{:.' + str($2) + 'f}').format($1)" ],
[ /([^\s]+)\.toFixed\s*\(([0-9]+)\)/g, "format($1, '.$2f')" ],
[ /([^\s]+)\.toFixed\s*\(([^\)]+)\)/g, "format($1, '.' + str($2) + 'f')" ],
[ /parseFloat\s*/g, 'float'],
[ /parseInt\s*/g, 'int'],
[ /self\[([^\]+]+)\]/g, 'getattr(self, $1)' ],
Expand Down Expand Up @@ -398,6 +400,8 @@ class Transpiler {
[ /(\s+) \* @description (.*)/g, '$1$2' ], // docstring description
[ /\s+\* @name .*/g, '' ], // docstring @name
[ /(\s+) \* @see( .*)/g, '$1see$2' ], // docstring @see
[ /(\s+ \* @(param|returns) {[^}]*)string([^}]*}.*)/g, '$1str$3' ], // docstring type conversion
[ /(\s+ \* @(param|returns) {[^}]*)object([^}]*}.*)/g, '$1dict$3' ], // doctstrubg type conversion
[ /(\s+) \* @returns ([^\{])/g, '$1:returns: $2' ], // docstring return
[ /(\s+) \* @returns \{(.+)\}/g, '$1:returns $2:' ], // docstring return
[ /(\s+ \* @param \{[\]\[\|a-zA-Z]+\} )([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+) (.*)/g, '$1$2[\'$3\'] $4' ], // docstring params.anything
Expand Down Expand Up @@ -512,6 +516,8 @@ class Transpiler {
[ /Precise\.stringGe\s/g, 'Precise::string_ge' ],
[ /Precise\.stringLt\s/g, 'Precise::string_lt' ],
[ /Precise\.stringLe\s/g, 'Precise::string_le' ],
[ /(\w+)\.padEnd\s*\(([^,]+),\s*([^)]+)\)/g, 'str_pad($1, $2, $3, STR_PAD_RIGHT)' ],
[ /(\w+)\.padStart\s*\(([^,]+),\s*([^)]+)\)/g, 'str_pad($1, $2, $3, STR_PAD_LEFT)' ],

// insert common regexes in the middle (critical)
].concat (this.getCommonRegexes ()).concat ([
Expand Down Expand Up @@ -540,7 +546,7 @@ class Transpiler {
[ /\}\s+catch \(([\S]+)\) {/g, '} catch (Exception $$$1) {' ],
[ /for\s+\(([a-zA-Z0-9_]+)\s*=\s*([^\;\s]+\s*)\;[^\<\>\=]+(\<=|\>=|<|>)\s*(.*)\.length\s*\;([^\)]+)\)\s*{/g, 'for ($1 = $2; $1 $3 count($4);$5) {' ],
[ /for\s+\(([a-zA-Z0-9_]+)\s*=\s*([^\;\s]+\s*)\;[^\<\>\=]+(\<=|\>=|<|>)\s*(.*)\s*\;([^\)]+)\)\s*{/g, 'for ($1 = $2; $1 $3 $4;$5) {' ],
[ /([^\s]+)\.length\;/g, 'is_array($1) ? count($1) : 0;' ],
[ /([^\s]+)\.length\;/g, 'count($1);' ],
[ /\.push\s*\(([\s\S]+?)\)\;/g, '[] = $1;' ],
[ /(\b)await(\b)/g, 'yield' ],
[ /([\S])\: /g, '$1 => ' ],
Expand Down Expand Up @@ -592,6 +598,7 @@ class Transpiler {
[ /super\./g, 'parent::'],
[ /\sdelete\s([^\n]+)\;/g, ' unset($1);' ],
[ /\~([\]\[\|@\.\s+\:\/#\-a-zA-Z0-9_-]+?)\~/g, '{$1}' ], // resolve the "arrays vs url params" conflict (both are in {}-brackets)
[ /(\s+ \* @(param|return) {[^}]*)object([^}]*}.*)/g, '$1array$3' ], // docstring type conversion
])
}

Expand Down Expand Up @@ -718,12 +725,12 @@ class Transpiler {

header = header.concat (asyncioImports, libraries, errorImports, precisionImports)

methods = methods.concat (this.getPythonBaseMethods ())

// transpile camelCase base method names to underscore base method names
const baseMethods = this.getPythonBaseMethods ()
methods = methods.concat (baseMethods)
for (let method of methods) {
const regex = new RegExp ('self\\.(' + method + ')([^a-zA-Z0-9_])', 'g')
bodyAsString = bodyAsString.replace (regex,
(match, p1, p2) => ('self.' + unCamelCase (p1) + p2))
const regex = new RegExp ('(self|super\\([^)]+\\))\\.(' + method + ')([^a-zA-Z0-9_])', 'g')
bodyAsString = bodyAsString.replace (regex, (match, p1, p2, p3) => (p1 + '.' + unCamelCase (p2) + p3))
}

header.push ("\n\n" + this.createPythonClassDeclaration (className, baseClass))
Expand Down Expand Up @@ -882,16 +889,26 @@ class Transpiler {

header = header.concat (errorImports).concat (precisionImports)

methods = methods.concat (this.getPHPBaseMethods ())
// transpile camelCase base method names to underscore base method names
const baseMethods = this.getPHPBaseMethods ()
methods = methods.concat (baseMethods)

for (let method of methods) {
const regex = new RegExp ('\\$this->(' + method + ')\\s?(\\(|[^a-zA-Z0-9_])', 'g')
let regex = new RegExp ('\\$this->(' + method + ')\\s?(\\(|[^a-zA-Z0-9_])', 'g')
bodyAsString = bodyAsString.replace (regex,
(match, p1, p2) => {
return ((p2 === '(') ?
('$this->' + unCamelCase (p1) + p2) : // support direct php calls
("array($this, '" + unCamelCase (p1) + "')" + p2)) // as well as passing instance methods as callables
})

regex = new RegExp ('parent::(' + method + ')\\s?(\\(|[^a-zA-Z0-9_])', 'g')
bodyAsString = bodyAsString.replace (regex,
(match, p1, p2) => {
return ((p2 === '(') ?
('parent::' + unCamelCase (p1) + p2) : // support direct php calls
("array($this, '" + unCamelCase (p1) + "')" + p2)) // as well as passing instance methods as callables
})
}

header.push ("\n" + this.createPHPClassDeclaration (className, baseClass))
Expand Down Expand Up @@ -1680,6 +1697,7 @@ class Transpiler {
"hash = Exchange.hash",
"ecdsa = Exchange.ecdsa",
"jwt = Exchange.jwt",
"crc32 = Exchange.crc32",
"encode = Exchange.encode",
"",
"",
Expand All @@ -1706,6 +1724,10 @@ class Transpiler {
" return Exchange::jwt(...$args);",
"}",
"",
"function crc32(...$arg) {",
" return Exchange::crc32(...$arg);",
"}",
"",
"function equals($a, $b) {",
" return $a === $b;",
"}",
Expand Down
12 changes: 6 additions & 6 deletions ccxt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ declare module 'ccxt' {
createLimitBuyOrder (symbol: string, amount: number, price: number, params?: Params): Promise<Order>;
createLimitSellOrder (symbol: string, amount: number, price: number, params?: Params): Promise<Order>;
createMarketOrder (symbol: string, side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>;
createMarketBuyOrder (symbol: string, amount: number, params?: Params): Promise<Order>;
createMarketSellOrder (symbol: string, amount: number, params?: Params): Promise<Order>;
createOrder (symbol: string, type: Order['type'], side: Order['side'], amount: number, price?: number, params?: Params): Promise<Order>;
decode (str: string): string;
defaults (): any;
Expand Down Expand Up @@ -447,6 +449,7 @@ declare module 'ccxt' {
/* tslint:disable */

export class aax extends Exchange {}
export class alpaca extends Exchange {}
export class ascendex extends Exchange {}
export class bequant extends hitbtc {}
export class bibox extends Exchange {}
Expand Down Expand Up @@ -497,7 +500,6 @@ declare module 'ccxt' {
export class coincheck extends Exchange {}
export class coinex extends Exchange {}
export class coinfalcon extends Exchange {}
export class coinflex extends Exchange {}
export class coinmate extends Exchange {}
export class coinone extends Exchange {}
export class coinspot extends Exchange {}
Expand Down Expand Up @@ -557,13 +559,12 @@ declare module 'ccxt' {
export class tidebit extends Exchange {}
export class tidex extends Exchange {}
export class timex extends Exchange {}
export class tokocrypto extends Exchange {}
export class upbit extends Exchange {}
export class vcc extends Exchange {}
export class wavesexchange extends Exchange {}
export class wazirx extends Exchange {}
export class whitebit extends Exchange {}
export class woo extends Exchange {}
export class xena extends Exchange {}
export class yobit extends Exchange {}
export class zaif extends Exchange {}
export class zb extends Exchange {}
Expand All @@ -574,6 +575,7 @@ declare module 'ccxt' {

export type ExchangeId =
| 'aax'
| 'alpaca'
| 'ascendex'
| 'bequant'
| 'bibox'
Expand Down Expand Up @@ -624,7 +626,6 @@ declare module 'ccxt' {
| 'coincheck'
| 'coinex'
| 'coinfalcon'
| 'coinflex'
| 'coinmate'
| 'coinone'
| 'coinspot'
Expand Down Expand Up @@ -684,13 +685,12 @@ declare module 'ccxt' {
| 'tidebit'
| 'tidex'
| 'timex'
| 'tokocrypto'
| 'upbit'
| 'vcc'
| 'wavesexchange'
| 'wazirx'
| 'whitebit'
| 'woo'
| 'xena'
| 'yobit'
| 'zaif'
| 'zb'
Expand Down
7 changes: 3 additions & 4 deletions ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.89.98'
const version = '1.93.14'

Exchange.ccxtVersion = version

//-----------------------------------------------------------------------------

const exchanges = {
'aax': require ('./js/aax.js'),
'alpaca': require ('./js/alpaca.js'),
'ascendex': require ('./js/ascendex.js'),
'bequant': require ('./js/bequant.js'),
'bibox': require ('./js/bibox.js'),
Expand Down Expand Up @@ -94,7 +95,6 @@ const exchanges = {
'coincheck': require ('./js/coincheck.js'),
'coinex': require ('./js/coinex.js'),
'coinfalcon': require ('./js/coinfalcon.js'),
'coinflex': require ('./js/coinflex.js'),
'coinmate': require ('./js/coinmate.js'),
'coinone': require ('./js/coinone.js'),
'coinspot': require ('./js/coinspot.js'),
Expand Down Expand Up @@ -154,13 +154,12 @@ const exchanges = {
'tidebit': require ('./js/tidebit.js'),
'tidex': require ('./js/tidex.js'),
'timex': require ('./js/timex.js'),
'tokocrypto': require ('./js/tokocrypto.js'),
'upbit': require ('./js/upbit.js'),
'vcc': require ('./js/vcc.js'),
'wavesexchange': require ('./js/wavesexchange.js'),
'wazirx': require ('./js/wazirx.js'),
'whitebit': require ('./js/whitebit.js'),
'woo': require ('./js/woo.js'),
'xena': require ('./js/xena.js'),
'yobit': require ('./js/yobit.js'),
'zaif': require ('./js/zaif.js'),
'zb': require ('./js/zb.js'),
Expand Down
12 changes: 11 additions & 1 deletion cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
#!/bin/bash
git checkout HEAD package.json README.md ccxt.d.ts ccxt.js wiki python php dist doc
git checkout HEAD package.json
git checkout HEAD package-lock.json
git checkout HEAD yarn.lock
git checkout HEAD README.md
git checkout HEAD ccxt.d.ts
git checkout HEAD ccxt.js
git checkout HEAD wiki
git checkout HEAD python
git checkout HEAD php
git checkout HEAD dist
git checkout HEAD doc
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"files": [ "ccxt.php" ]
},
"require": {
"php": ">=5.5",
"php": ">=7.0",
"ext-bcmath": "*",
"ext-curl": "*",
"ext-iconv": "*",
Expand Down
19 changes: 10 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7aa8861

Please sign in to comment.