Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ccxt/ccxt
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Mar 10, 2022
2 parents e8f39c0 + 7a9e72e commit 5e49319
Show file tree
Hide file tree
Showing 88 changed files with 2,610 additions and 268 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ console.log (ccxt.exchanges) // print all available exchanges

All-in-one browser bundle (dependencies included), served from a CDN of your choice:

* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].46/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].46/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].63/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].63/dist/ccxt.browser.js

CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.

```HTML
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].46/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].63/dist/ccxt.browser.js"></script>
```

Creates a global `ccxt` object:
Expand Down
2 changes: 1 addition & 1 deletion ccxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.75.46'
const version = '1.75.63'

Exchange.ccxtVersion = version

Expand Down
472 changes: 431 additions & 41 deletions dist/ccxt.browser.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions doc/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1999,14 +1999,14 @@ JavaScript (for use with the ``<script>`` tag):
All-in-one browser bundle (dependencies included), served from a CDN of your choice:


* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].46/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].46/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].63/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].63/dist/ccxt.browser.js

CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.

.. code-block:: HTML

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].46/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].63/dist/ccxt.browser.js"></script>

Creates a global ``ccxt`` object:

Expand Down
44 changes: 44 additions & 0 deletions examples/py/phemex-create-stop-order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt # noqa: E402

exchange = ccxt.phemex({
'apiKey': 'YOUR_API_KEY',
'secret': 'YOUR_SECRET',
'enableRateLimit': True,
})

# exchange.set_sandbox_mode(True)

# Example 1: Creating stop-market order
symbol = 'LTC/USDT'
type = 'market'
side = 'buy'
amount = 0.5

params = {
'stopPrice': 50,
}

stop_market = exchange.create_order(symbol, type, side, amount, None, params)
print(stop_market)

# Example 2: Create stop-limit order
symbol = 'LTC/USDT'
type = 'limit'
side = 'buy'
amount = 0.5
price = 70

params = {
'stopPrice': 50,
}

stop_limit = exchange.create_order(symbol, type, side, amount, price, params)
print(stop_limit)
28 changes: 11 additions & 17 deletions js/binance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4452,9 +4452,7 @@ module.exports = class binance extends Exchange {
let entryPrice = this.parseNumber (entryPriceString);
const notionalString = this.safeString2 (position, 'notional', 'notionalValue');
const notionalStringAbs = Precise.stringAbs (notionalString);
const notionalFloat = parseFloat (notionalString);
const notionalFloatAbs = parseFloat (notionalStringAbs);
const notional = this.parseNumber (Precise.stringAbs (notionalString));
const notional = this.parseNumber (notionalStringAbs);
let contractsString = this.safeString (position, 'positionAmt');
let contractsStringAbs = Precise.stringAbs (contractsString);
if (contractsString === undefined) {
Expand All @@ -4469,7 +4467,7 @@ module.exports = class binance extends Exchange {
let maintenanceMarginPercentageString = undefined;
for (let i = 0; i < leverageBracket.length; i++) {
const bracket = leverageBracket[i];
if (notionalFloatAbs < bracket[0]) {
if (Precise.stringLt (notionalStringAbs, bracket[0])) {
break;
}
maintenanceMarginPercentageString = bracket[1];
Expand Down Expand Up @@ -4502,10 +4500,10 @@ module.exports = class binance extends Exchange {
let liquidationPrice = undefined;
const contractSize = this.safeValue (market, 'contractSize');
const contractSizeString = this.numberToString (contractSize);
if (notionalFloat === 0.0) {
if (Precise.stringEquals (notionalString, '0')) {
entryPrice = undefined;
} else {
side = (notionalFloat < 0) ? 'short' : 'long';
side = Precise.stringLt (notionalString, '0') ? 'short' : 'long';
marginRatio = this.parseNumber (Precise.stringDiv (Precise.stringAdd (Precise.stringDiv (maintenanceMarginString, collateralString), '5e-5'), '1', 4));
percentage = this.parseNumber (Precise.stringMul (Precise.stringDiv (unrealizedPnlString, initialMarginString, 4), '100'));
if (usdm) {
Expand Down Expand Up @@ -4634,12 +4632,10 @@ module.exports = class binance extends Exchange {
const leverageBracket = this.safeValue (leverageBrackets, symbol, []);
const notionalString = this.safeString2 (position, 'notional', 'notionalValue');
const notionalStringAbs = Precise.stringAbs (notionalString);
const notionalFloatAbs = parseFloat (notionalStringAbs);
const notionalFloat = parseFloat (notionalString);
let maintenanceMarginPercentageString = undefined;
for (let i = 0; i < leverageBracket.length; i++) {
const bracket = leverageBracket[i];
if (notionalFloatAbs < bracket[0]) {
if (Precise.stringLt (notionalStringAbs, bracket[0])) {
break;
}
maintenanceMarginPercentageString = bracket[1];
Expand All @@ -4656,9 +4652,9 @@ module.exports = class binance extends Exchange {
let collateralString = undefined;
const marginType = this.safeString (position, 'marginType');
let side = undefined;
if (notionalFloat > 0) {
if (Precise.stringGt (notionalString, '0')) {
side = 'long';
} else if (notionalFloat < 0) {
} else if (Precise.stringLt (notionalString, '0')) {
side = 'short';
}
const entryPriceString = this.safeString (position, 'entryPrice');
Expand Down Expand Up @@ -4703,7 +4699,6 @@ module.exports = class binance extends Exchange {
collateralString = this.safeString (position, 'isolatedMargin');
}
collateralString = (collateralString === undefined) ? '0' : collateralString;
const collateralFloat = parseFloat (collateralString);
const collateral = this.parseNumber (collateralString);
const markPrice = this.parseNumber (this.omitZero (this.safeString (position, 'markPrice')));
let timestamp = this.safeInteger (position, 'updateTime');
Expand All @@ -4722,7 +4717,7 @@ module.exports = class binance extends Exchange {
const initialMargin = this.parseNumber (initialMarginString);
let marginRatio = undefined;
let percentage = undefined;
if (collateralFloat !== 0.0) {
if (!Precise.stringEquals (collateralString, '0')) {
marginRatio = this.parseNumber (Precise.stringDiv (Precise.stringAdd (Precise.stringDiv (maintenanceMarginString, collateralString), '5e-5'), '1', 4));
percentage = this.parseNumber (Precise.stringMul (Precise.stringDiv (unrealizedPnlString, initialMarginString, 4), '100'));
}
Expand Down Expand Up @@ -4781,8 +4776,7 @@ module.exports = class binance extends Exchange {
const result = [];
for (let j = 0; j < brackets.length; j++) {
const bracket = brackets[j];
// we use floats here internally on purpose
const floorValue = this.safeFloat2 (bracket, 'notionalFloor', 'qtyFloor');
const floorValue = this.safeString2 (bracket, 'notionalFloor', 'qtyFloor');
const maintenanceMarginPercentage = this.safeString (bracket, 'maintMarginRatio');
result.push ([ floorValue, maintenanceMarginPercentage ]);
}
Expand Down Expand Up @@ -4854,7 +4848,7 @@ module.exports = class binance extends Exchange {
tiers.push ({
'tier': this.safeNumber (bracket, 'bracket'),
'currency': market['quote'],
'notionalFloor': this.safeFloat2 (bracket, 'notionalFloor', 'qtyFloor'),
'notionalFloor': this.safeNumber2 (bracket, 'notionalFloor', 'qtyFloor'),
'notionalCap': this.safeNumber (bracket, 'notionalCap'),
'maintenanceMarginRate': this.safeNumber (bracket, 'maintMarginRatio'),
'maxLeverage': this.safeNumber (bracket, 'initialLeverage'),
Expand Down Expand Up @@ -5211,7 +5205,7 @@ module.exports = class binance extends Exchange {
throw new InvalidOrder (this.id + ' order amount should be evenly divisible by lot size ' + body);
}
if (body.indexOf ('PRICE_FILTER') >= 0) {
throw new InvalidOrder (this.id + ' order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid float value in general, use this.priceToPrecision (symbol, amount) ' + body);
throw new InvalidOrder (this.id + ' order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) ' + body);
}
}
if (response === undefined) {
Expand Down
139 changes: 139 additions & 0 deletions js/bitso.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module.exports = class bitso extends Exchange {
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchDepositAddress': true,
'fetchFundingFee': false,
'fetchFundingFees': true,
'fetchFundingHistory': false,
'fetchFundingRate': false,
'fetchFundingRateHistory': false,
Expand All @@ -55,6 +57,8 @@ module.exports = class bitso extends Exchange {
'fetchPremiumIndexOHLCV': false,
'fetchTicker': true,
'fetchTrades': true,
'fetchTradingFee': false,
'fetchTradingFees': true,
'reduceMargin': false,
'setLeverage': false,
'setMarginMode': false,
Expand Down Expand Up @@ -514,6 +518,71 @@ module.exports = class bitso extends Exchange {
return this.parseTrades (response['payload'], market, since, limit);
}

async fetchTradingFees (params = {}) {
await this.loadMarkets ();
const response = await this.privateGetFees (params);
//
// {
// success: true,
// payload: {
// fees: [
// {
// book: 'btc_mxn',
// fee_percent: '0.6500',
// fee_decimal: '0.00650000',
// taker_fee_percent: '0.6500',
// taker_fee_decimal: '0.00650000',
// maker_fee_percent: '0.5000',
// maker_fee_decimal: '0.00500000',
// volume_currency: 'mxn',
// current_volume: '0.00',
// next_volume: '1500000.00',
// next_maker_fee_percent: '0.490',
// next_taker_fee_percent: '0.637',
// nextVolume: '1500000.00',
// nextFee: '0.490',
// nextTakerFee: '0.637'
// },
// ...
// ],
// deposit_fees: [
// {
// currency: 'btc',
// method: 'rewards',
// fee: '0.00',
// is_fixed: false
// },
// ...
// ],
// withdrawal_fees: {
// ada: '0.20958100',
// bch: '0.00009437',
// ars: '0',
// btc: '0.00001209',
// ...
// }
// }
// }
//
const payload = this.safeValue (response, 'payload', {});
const fees = this.safeValue (payload, 'fees', []);
const result = {};
for (let i = 0; i < fees.length; i++) {
const fee = fees[i];
const marketId = this.safeString (fee, 'book');
const symbol = this.safeSymbol (marketId, undefined, '_');
result[symbol] = {
'info': fee,
'symbol': symbol,
'maker': this.safeNumber (fee, 'maker_fee_decimal'),
'taker': this.safeNumber (fee, 'taker_fee_decimal'),
'percentage': true,
'tierBased': true,
};
}
return result;
}

async fetchMyTrades (symbol = undefined, since = undefined, limit = 25, params = {}) {
await this.loadMarkets ();
const market = this.market (symbol);
Expand Down Expand Up @@ -692,6 +761,76 @@ module.exports = class bitso extends Exchange {
};
}

async fetchFundingFees (params = {}) {
await this.loadMarkets ();
const response = await this.privateGetFees (params);
//
// {
// success: true,
// payload: {
// fees: [
// {
// book: 'btc_mxn',
// fee_percent: '0.6500',
// fee_decimal: '0.00650000',
// taker_fee_percent: '0.6500',
// taker_fee_decimal: '0.00650000',
// maker_fee_percent: '0.5000',
// maker_fee_decimal: '0.00500000',
// volume_currency: 'mxn',
// current_volume: '0.00',
// next_volume: '1500000.00',
// next_maker_fee_percent: '0.490',
// next_taker_fee_percent: '0.637',
// nextVolume: '1500000.00',
// nextFee: '0.490',
// nextTakerFee: '0.637'
// },
// ...
// ],
// deposit_fees: [
// {
// currency: 'btc',
// method: 'rewards',
// fee: '0.00',
// is_fixed: false
// },
// ...
// ],
// withdrawal_fees: {
// ada: '0.20958100',
// bch: '0.00009437',
// ars: '0',
// btc: '0.00001209',
// ...
// }
// }
// }
//
const payload = this.safeValue (response, 'payload', {});
const depositFees = this.safeValue (payload, 'deposit_fees', []);
const deposit = {};
for (let i = 0; i < depositFees.length; i++) {
const depositFee = depositFees[i];
const currencyId = this.safeString (depositFee, 'currency');
const code = this.safeCurrencyCode (currencyId);
deposit[code] = this.safeNumber (depositFee, 'fee');
}
const withdraw = {};
const withdrawalFees = this.safeValue (payload, 'withdrawal_fees', []);
const currencyIds = Object.keys (withdrawalFees);
for (let i = 0; i < currencyIds.length; i++) {
const currencyId = currencyIds[i];
const code = this.safeCurrencyCode (currencyId);
withdraw[code] = this.safeNumber (withdrawalFees, currencyId);
}
return {
'info': response,
'deposit': deposit,
'withdraw': withdraw,
};
}

async withdraw (code, amount, address, tag = undefined, params = {}) {
[ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
this.checkAddress (address);
Expand Down
4 changes: 4 additions & 0 deletions js/bitstamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ module.exports = class bitstamp extends Exchange {
'amp_address/',
'sgb_withdrawal/',
'sgb_address/',
'avax_withdrawal/',
'avax_address/',
'wbtc_withdrawal/',
'wbtc_address/',
'transfer-to-main/',
'transfer-from-main/',
'withdrawal-requests/',
Expand Down
Loading

0 comments on commit 5e49319

Please sign in to comment.