Skip to content

Commit

Permalink
1.37.43
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
Travis CI committed Nov 10, 2020
1 parent 238153e commit 7def6e5
Show file tree
Hide file tree
Showing 16 changed files with 994 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -226,13 +226,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.37.42/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.37.42/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.37.43/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.37.43/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.37.42/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@1.37.43/dist/ccxt.browser.js"></script>
```

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

const version = '1.37.42'
const version = '1.37.43'

Exchange.ccxtVersion = version

Expand Down
248 changes: 247 additions & 1 deletion dist/ccxt.browser.js
Expand Up @@ -43,7 +43,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.37.42'
const version = '1.37.43'

Exchange.ccxtVersion = version

Expand Down Expand Up @@ -90133,6 +90133,7 @@ module.exports = class okex extends Exchange {
'option': {
'get': [
'accounts',
'position',
'{underlying}/position',
'accounts/{underlying}',
'orders/{underlying}',
Expand Down Expand Up @@ -92800,6 +92801,251 @@ module.exports = class okex extends Exchange {
return await this.fetchMyTrades (symbol, since, limit, this.extend (request, params));
}

async fetchPositions (symbol = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets ();
let method = undefined;
let market = undefined;
const request = {
// 'instrument_id': market['id'],
// 'order_id': id, // string
// 'after': '1', // pagination of data to return records earlier than the requested ledger_id
// 'before': '1', // P=pagination of data to return records newer than the requested ledger_id
// 'limit': limit, // optional, number of results per request, default = maximum = 100
};
let type = undefined;
if (symbol === undefined) {
const defaultType = this.safeString2 (this.options, 'fetchPositions', 'defaultType');
type = this.safeString (params, 'type', defaultType);
} else {
market = this.market (symbol);
type = market['type'];
request['instrument_id'] = market['id'];
}
if ((type === 'futures') || (type === 'swap')) {
if (market === undefined) {
method = type + 'GetPosition';
} else {
method = type + 'GetInstrumentIdPosition';
}
} else if (type === 'option') {
const underlying = this.safeString (params, 'underlying');
if (underlying === undefined) {
throw new ArgumentsRequired (this.id + ' fetchPositions() requires an underlying parameter for ' + type + ' market ' + symbol);
}
method = type + 'GetUnderlyingPosition';
} else {
throw new NotSupported (this.id + ' fetchPositions() does not support ' + type + ' market ' + symbol + ', supported market types are futures, swap or option');
}
params = this.omit (params, 'type');
const response = await this[method] (this.extend (request, params));
//
// futures
//
// symbol not specified
//
// {
// "result": true,
// "holding": [
// [
// { ... },
// ]
// ]
// }
//
// symbol specified, crossed margin mode
//
// {
// "result": true,
// "holding": [
// {
// "long_qty": "2",
// "long_avail_qty": "2",
// "long_avg_cost": "8260",
// "long_settlement_price": "8260",
// "realised_pnl": "0.00020928",
// "short_qty": "2",
// "short_avail_qty": "2",
// "short_avg_cost": "8259.99",
// "short_settlement_price": "8259.99",
// "liquidation_price": "113.81",
// "instrument_id": "BTC-USD-191227",
// "leverage": "10",
// "created_at": "2019-09-25T07:58:42.129Z",
// "updated_at": "2019-10-08T14:02:51.029Z",
// "margin_mode": "crossed",
// "short_margin": "0.00242197",
// "short_pnl": "6.63E-6",
// "short_pnl_ratio": "0.002477997",
// "short_unrealised_pnl": "6.63E-6",
// "long_margin": "0.00242197",
// "long_pnl": "-6.65E-6",
// "long_pnl_ratio": "-0.002478",
// "long_unrealised_pnl": "-6.65E-6",
// "long_settled_pnl": "0",
// "short_settled_pnl": "0",
// "last": "8257.57"
// }
// ],
// "margin_mode": "crossed"
// }
//
// symbol specified, fixed margin mode
//
// {
// "result": true,
// "holding": [
// {
// "long_qty": "4",
// "long_avail_qty": "4",
// "long_margin": "0.00323844",
// "long_liqui_price": "7762.09",
// "long_pnl_ratio": "0.06052306",
// "long_avg_cost": "8234.43",
// "long_settlement_price": "8234.43",
// "realised_pnl": "-0.00000296",
// "short_qty": "2",
// "short_avail_qty": "2",
// "short_margin": "0.00241105",
// "short_liqui_price": "9166.74",
// "short_pnl_ratio": "0.03318052",
// "short_avg_cost": "8295.13",
// "short_settlement_price": "8295.13",
// "instrument_id": "BTC-USD-191227",
// "long_leverage": "15",
// "short_leverage": "10",
// "created_at": "2019-09-25T07:58:42.129Z",
// "updated_at": "2019-10-08T13:12:09.438Z",
// "margin_mode": "fixed",
// "short_margin_ratio": "0.10292507",
// "short_maint_margin_ratio": "0.005",
// "short_pnl": "7.853E-5",
// "short_unrealised_pnl": "7.853E-5",
// "long_margin_ratio": "0.07103743",
// "long_maint_margin_ratio": "0.005",
// "long_pnl": "1.9841E-4",
// "long_unrealised_pnl": "1.9841E-4",
// "long_settled_pnl": "0",
// "short_settled_pnl": "0",
// "last": "8266.99"
// }
// ],
// "margin_mode": "fixed"
// }
//
// swap
//
// symbol not specified
//
// [
// {
// "margin_mode": "fixed",
// "timestamp": "2019-09-27T03:47:37.230Z",
// "holding": [
// { ... }
// ]
// },
// {
// "margin_mode": "crossed",
// "timestamp": "2019-09-27T03:49:02.018Z",
// "holding": [
// { ... },
// ]
// }
// ]
//
// symbol specified, fixed margin mode
//
// {
// "margin_mode": "fixed",
// "timestamp": "2019-09-27T03:47:37.230Z",
// "holding": [
// {
// "avail_position": "20",
// "avg_cost": "8025.0",
// "instrument_id": "BTC-USD-SWAP",
// "last": "8113.1",
// "leverage": "15.00",
// "liquidation_price": "7002.6",
// "maint_margin_ratio": "0.0050",
// "margin": "0.0454",
// "position": "20",
// "realized_pnl": "-0.0001",
// "unrealized_pnl": "0",
// "settled_pnl": "0.0076",
// "settlement_price": "8279.2",
// "side": "long",
// "timestamp": "2019-09-27T03:47:37.230Z"
// }
// ]
// }
//
// symbol specified, crossed margin mode
//
// {
// "margin_mode": "crossed",
// "timestamp": "2019-09-27T03:49:02.018Z",
// "holding": [
// {
// "avail_position": "3",
// "avg_cost": "59.49",
// "instrument_id": "LTC-USD-SWAP",
// "last": "55.98",
// "leverage": "10.00",
// "liquidation_price": "4.37",
// "maint_margin_ratio": "0.0100",
// "margin": "0.0536",
// "position": "3",
// "realized_pnl": "0.0000",
// "unrealized_pnl": "0",
// "settled_pnl": "-0.0330",
// "settlement_price": "55.84",
// "side": "long",
// "timestamp": "2019-09-27T03:49:02.018Z"
// },
// ]
// }
//
// option
//
// {
// "holding":[
// {
// "instrument_id":"BTC-USD-190927-12500-C",
// "position":"20",
// "avg_cost":"3.26",
// "avail_position":"20",
// "settlement_price":"0.017",
// "total_pnl":"50",
// "pnl_ratio":"0.3",
// "realized_pnl":"40",
// "unrealized_pnl":"10",
// "pos_margin":"100",
// "option_value":"70",
// "created_at":"2019-08-30T03:09:20.315Z",
// "updated_at":"2019-08-30T03:40:18.318Z"
// },
// {
// "instrument_id":"BTC-USD-190927-12500-P",
// "position":"20",
// "avg_cost":"3.26",
// "avail_position":"20",
// "settlement_price":"0.019",
// "total_pnl":"50",
// "pnl_ratio":"0.3",
// "realized_pnl":"40",
// "unrealized_pnl":"10",
// "pos_margin":"100",
// "option_value":"70",
// "created_at":"2019-08-30T03:09:20.315Z",
// "updated_at":"2019-08-30T03:40:18.318Z"
// }
// ]
// }
//
// todo unify parsePosition/parsePositions
return response;
}

async fetchLedger (code = undefined, since = undefined, limit = undefined, params = {}) {
await this.loadMarkets ();
const defaultType = this.safeString2 (this.options, 'fetchLedger', 'defaultType');
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.37.42",
"version": "1.37.43",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges",
"main": "./ccxt.js",
"unpkg": "dist/ccxt.browser.js",
Expand Down
4 changes: 2 additions & 2 deletions php/base/Exchange.php
Expand Up @@ -36,7 +36,7 @@
use Elliptic\EdDSA;
use BN\BN;

$version = '1.37.42';
$version = '1.37.43';

// rounding mode
const TRUNCATE = 0;
Expand All @@ -55,7 +55,7 @@

class Exchange {

const VERSION = '1.37.42';
const VERSION = '1.37.43';

private static $base58_alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
private static $base58_encoder = null;
Expand Down

0 comments on commit 7def6e5

Please sign in to comment.