Skip to content

Commit

Permalink
1.72.79
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Feb 11, 2022
1 parent 8058956 commit 4d9169f
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 55 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -227,13 +227,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/ccxt@1.72.78/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.72.78/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.72.79/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.72.79/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/ccxt@1.72.78/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@1.72.79/dist/ccxt.browser.js"></script>
```

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

const version = '1.72.78'
const version = '1.72.79'

Exchange.ccxtVersion = version

Expand Down
77 changes: 73 additions & 4 deletions dist/ccxt.browser.js
Expand Up @@ -44,7 +44,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.72.78'
const version = '1.72.79'

Exchange.ccxtVersion = version

Expand Down Expand Up @@ -112257,7 +112257,7 @@ module.exports = class mexc extends Exchange {
};
const response = await this.fetchPositions (this.extend (request, params));
const firstPosition = this.safeValue (response, 0);
return firstPosition;
return this.parsePosition (firstPosition, market);
}

async fetchPositions (symbols = undefined, params = {}) {
Expand Down Expand Up @@ -112293,9 +112293,78 @@ module.exports = class mexc extends Exchange {
// ]
// }
//
// todo add parsePositions, parsePosition
const data = this.safeValue (response, 'data', []);
return data;
return this.parsePositions (data);
}

parsePosition (position, market = undefined) {
//
// {
// "positionId": 1394650,
// "symbol": "ETH_USDT",
// "positionType": 1,
// "openType": 1,
// "state": 1,
// "holdVol": 1,
// "frozenVol": 0,
// "closeVol": 0,
// "holdAvgPrice": 1217.3,
// "openAvgPrice": 1217.3,
// "closeAvgPrice": 0,
// "liquidatePrice": 1211.2,
// "oim": 0.1290338,
// "im": 0.1290338,
// "holdFee": 0,
// "realised": -0.0073,
// "leverage": 100,
// "createTime": 1609991676000,
// "updateTime": 1609991676000,
// "autoAddIm": false
// }
//
market = this.safeMarket (this.safeString (position, 'symbol'), market);
const symbol = market['symbol'];
const contracts = this.safeString (position, 'holdVol');
const entryPrice = this.safeNumber (position, 'openAvgPrice');
const initialMargin = this.safeString (position, 'im');
const rawSide = this.safeString (position, 'positionType');
const side = (rawSide === '1') ? 'long' : 'short';
const openType = this.safeString (position, 'margin_mode');
const marginType = (openType === '1') ? 'isolated' : 'cross';
const leverage = this.safeString (position, 'leverage');
const liquidationPrice = this.safeNumber (position, 'liquidatePrice');
const timestamp = this.safeNumber (position, 'updateTime');
return {
'info': position,
'symbol': symbol,
'contracts': this.parseNumber (contracts),
'contractSize': undefined,
'entryPrice': entryPrice,
'collateral': undefined,
'side': side,
'unrealizedProfit': undefined,
'leverage': this.parseNumber (leverage),
'percentage': undefined,
'marginType': marginType,
'notional': undefined,
'markPrice': undefined,
'liquidationPrice': liquidationPrice,
'initialMargin': this.parseNumber (initialMargin),
'initialMarginPercentage': undefined,
'maintenanceMargin': undefined,
'maintenanceMarginPercentage': undefined,
'marginRatio': undefined,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
};
}

parsePositions (positions) {
const result = [];
for (let i = 0; i < positions.length; i++) {
result.push (this.parsePosition (positions[i]));
}
return result;
}

async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
Expand Down
6 changes: 3 additions & 3 deletions doc/readme.rst
Expand Up @@ -2033,14 +2033,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/ccxt@1.72.78/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.72.78/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.72.79/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.72.79/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/ccxt@1.72.78/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@1.72.79/dist/ccxt.browser.js"></script>

Creates a global ``ccxt`` object:

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

16 changes: 8 additions & 8 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.72.78",
"version": "1.72.79",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges",
"main": "./ccxt.js",
"unpkg": "dist/ccxt.browser.js",
Expand Down Expand Up @@ -212,7 +212,7 @@
"ccex",
"C-CEX",
"cex",
"CEX.IO",
"cex.io",
"CHBTC",
"ChileBit",
"chilebit.net",
Expand Down Expand Up @@ -382,7 +382,7 @@
"fybse.se",
"fybsg.com",
"gatecoin.com",
"gate.io",
"Gate.io",
"gdax.com",
"gemini.com",
"getbtc.org",
Expand Down Expand Up @@ -499,8 +499,8 @@
"dsxglobal.com",
"bitvavo.com",
"Bitvavo",
"currency.com",
"waves.exchange",
"Currency.com",
"Waves.Exchange",
"phemex.com",
"Phemex",
"huobi.co.jp",
Expand Down Expand Up @@ -549,7 +549,7 @@
"Binance USDⓈ-M",
"eqonex.com",
"EQONEX",
"fmfw.io",
"FMFW.io",
"mexc.com",
"MEXC Global",
"bitrue.com",
Expand All @@ -563,8 +563,8 @@
"Zonda",
"futures.kucoin.com",
"KuCoin Futures",
"blockchain.com",
"crypto.com",
"Blockchain.com",
"Crypto.com",
"wazirx.com",
"WazirX",
"woo.org",
Expand Down
4 changes: 2 additions & 2 deletions php/Exchange.php

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

4 changes: 2 additions & 2 deletions php/async/Exchange.php
Expand Up @@ -28,11 +28,11 @@

include 'Throttle.php';

$version = '1.72.78';
$version = '1.72.79';

class Exchange extends \ccxt\Exchange {

const VERSION = '1.72.78';
const VERSION = '1.72.79';

public static $loop;
public static $kernel;
Expand Down
75 changes: 72 additions & 3 deletions php/async/mexc.php
Expand Up @@ -1554,7 +1554,7 @@ public function fetch_position($symbol, $params = array ()) {
);
$response = yield $this->fetch_positions(array_merge($request, $params));
$firstPosition = $this->safe_value($response, 0);
return $firstPosition;
return $this->parse_position($firstPosition, $market);
}

public function fetch_positions($symbols = null, $params = array ()) {
Expand Down Expand Up @@ -1590,9 +1590,78 @@ public function fetch_positions($symbols = null, $params = array ()) {
// )
// }
//
// todo add parsePositions, parsePosition
$data = $this->safe_value($response, 'data', array());
return $data;
return $this->parse_positions($data);
}

public function parse_position($position, $market = null) {
//
// {
// "positionId" => 1394650,
// "symbol" => "ETH_USDT",
// "positionType" => 1,
// "openType" => 1,
// "state" => 1,
// "holdVol" => 1,
// "frozenVol" => 0,
// "closeVol" => 0,
// "holdAvgPrice" => 1217.3,
// "openAvgPrice" => 1217.3,
// "closeAvgPrice" => 0,
// "liquidatePrice" => 1211.2,
// "oim" => 0.1290338,
// "im" => 0.1290338,
// "holdFee" => 0,
// "realised" => -0.0073,
// "leverage" => 100,
// "createTime" => 1609991676000,
// "updateTime" => 1609991676000,
// "autoAddIm" => false
// }
//
$market = $this->safe_market($this->safe_string($position, 'symbol'), $market);
$symbol = $market['symbol'];
$contracts = $this->safe_string($position, 'holdVol');
$entryPrice = $this->safe_number($position, 'openAvgPrice');
$initialMargin = $this->safe_string($position, 'im');
$rawSide = $this->safe_string($position, 'positionType');
$side = ($rawSide === '1') ? 'long' : 'short';
$openType = $this->safe_string($position, 'margin_mode');
$marginType = ($openType === '1') ? 'isolated' : 'cross';
$leverage = $this->safe_string($position, 'leverage');
$liquidationPrice = $this->safe_number($position, 'liquidatePrice');
$timestamp = $this->safe_number($position, 'updateTime');
return array(
'info' => $position,
'symbol' => $symbol,
'contracts' => $this->parse_number($contracts),
'contractSize' => null,
'entryPrice' => $entryPrice,
'collateral' => null,
'side' => $side,
'unrealizedProfit' => null,
'leverage' => $this->parse_number($leverage),
'percentage' => null,
'marginType' => $marginType,
'notional' => null,
'markPrice' => null,
'liquidationPrice' => $liquidationPrice,
'initialMargin' => $this->parse_number($initialMargin),
'initialMarginPercentage' => null,
'maintenanceMargin' => null,
'maintenanceMarginPercentage' => null,
'marginRatio' => null,
'timestamp' => $timestamp,
'datetime' => $this->iso8601($timestamp),
);
}

public function parse_positions($positions) {
$result = array();
for ($i = 0; $i < count($positions); $i++) {
$result[] = $this->parse_position($positions[$i]);
}
return $result;
}

public function create_order($symbol, $type, $side, $amount, $price = null, $params = array ()) {
Expand Down

0 comments on commit 4d9169f

Please sign in to comment.