提交 4f8a50a8 编写于 作者: T Travis CI

1.62.96

[ci skip]
上级 2420c26b
......@@ -219,13 +219,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.62.95/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.62.95/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.62.96/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.62.96/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.62.95/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@1.62.96/dist/ccxt.browser.js"></script>
```
Creates a global `ccxt` object:
......
......@@ -36,7 +36,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building
const version = '1.62.95'
const version = '1.62.96'
Exchange.ccxtVersion = version
......
......@@ -44,7 +44,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building
const version = '1.62.95'
const version = '1.62.96'
Exchange.ccxtVersion = version
......@@ -75687,6 +75687,135 @@ module.exports = class gateio extends Exchange {
return response;
}
parsePosition (position, market = undefined) {
//
// {
// value: "12.475572",
// leverage: "0",
// mode: "single",
// realised_point: "0",
// contract: "BTC_USDT",
// entry_price: "62422.6",
// mark_price: "62377.86",
// history_point: "0",
// realised_pnl: "-0.00624226",
// close_order: null,
// size: "2",
// cross_leverage_limit: "25",
// pending_orders: "0",
// adl_ranking: "5",
// maintenance_rate: "0.005",
// unrealised_pnl: "-0.008948",
// user: "663337",
// leverage_max: "100",
// history_pnl: "14.98868396636",
// risk_limit: "1000000",
// margin: "0.740721495056",
// last_close_pnl: "-0.041996015",
// liq_price: "59058.58"
// }
//
const contract = this.safeValue (position, 'contract');
market = this.safeMarket (contract, market);
const now = this.milliseconds ();
const size = this.safeString (position, 'size');
let side = undefined;
if (size > 0) {
side = 'buy';
} else if (size < 0) {
side = 'sell';
}
const maintenanceRate = this.safeString (position, 'maintenance_rate');
const notional = this.safeString (position, 'value');
const initialMargin = this.safeString (position, 'margin');
// const marginRatio = Precise.stringDiv (maintenanceRate, collateral);
const unrealisedPnl = this.safeString (position, 'unrealised_pnl');
return {
'info': position,
'symbol': this.safeString (market, 'symbol'),
'timestamp': now,
'datetime': this.iso8601 (now),
'initialMargin': this.parseNumber (initialMargin),
'initialMarginPercentage': this.parseNumber (Precise.stringDiv (initialMargin, notional)),
'maintenanceMargin': this.parseNumber (Precise.stringMul (maintenanceRate, notional)),
'maintenanceMarginPercentage': this.parseNumber (maintenanceRate),
'entryPrice': this.safeNumber (position, 'entry_price'),
'notional': this.parseNumber (notional),
'leverage': this.safeNumber (position, 'leverage'),
'unrealizedPnl': this.parseNumber (unrealisedPnl),
'contracts': this.parseNumber (size),
'contractSize': this.safeNumber (market, 'contractSize'),
// realisedPnl: position['realised_pnl'],
'marginRatio': undefined,
'liquidationPrice': this.safeNumber (position, 'liq_price'),
'markPrice': this.safeNumber (position, 'mark_price'),
'collateral': undefined,
'marginType': undefined,
'side': side,
'percentage': this.parseNumber (Precise.stringDiv (unrealisedPnl, initialMargin)),
};
}
parsePositions (positions) {
const result = [];
for (let i = 0; i < positions.length; i++) {
result.push (this.parsePosition (positions[i]));
}
return result;
}
async fetchPositions (symbols = undefined, params = {}) {
// :param symbols: Not used by Gateio
// :param params:
// settle: The currency that derivative contracts are settled in
// Other exchange specific params
//
await this.loadMarkets ();
const defaultType = this.safeString2 (this.options, 'fetchPositions', 'defaultType', 'swap');
const type = this.safeString (params, 'type', defaultType);
const method = this.getSupportedMapping (type, {
'swap': 'privateFuturesGetSettlePositions',
'futures': 'privateDeliveryGetSettlePositions',
});
const defaultSettle = type === 'swap' ? 'usdt' : 'btc';
const settle = this.safeString (params, 'settle', defaultSettle);
const request = {
'settle': settle,
};
const response = await this[method] (request);
//
// [
// {
// value: "12.475572",
// leverage: "0",
// mode: "single",
// realised_point: "0",
// contract: "BTC_USDT",
// entry_price: "62422.6",
// mark_price: "62377.86",
// history_point: "0",
// realised_pnl: "-0.00624226",
// close_order: null,
// size: "2",
// cross_leverage_limit: "25",
// pending_orders: "0",
// adl_ranking: "5",
// maintenance_rate: "0.005",
// unrealised_pnl: "-0.008948",
// user: "6693577",
// leverage_max: "100",
// history_pnl: "14.98868396636",
// risk_limit: "1000000",
// margin: "0.740721495056",
// last_close_pnl: "-0.041996015",
// liq_price: "59058.58"
// }
// ]
//
const result = this.parsePositions (response);
return this.filterByArray (result, 'symbol', symbols, false);
}
sign (path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
const authentication = api[0]; // public, private
const type = api[1]; // spot, margin, futures, delivery
{
"name": "ccxt",
"version": "1.62.95",
"version": "1.62.96",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "ccxt",
"version": "1.62.95",
"version": "1.62.96",
"description": "A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges",
"main": "./ccxt.js",
"unpkg": "dist/ccxt.browser.js",
......
......@@ -36,7 +36,7 @@ use Elliptic\EdDSA;
use BN\BN;
use Exception;
$version = '1.62.95';
$version = '1.62.96';
// rounding mode
const TRUNCATE = 0;
......@@ -55,7 +55,7 @@ const PAD_WITH_ZERO = 1;
class Exchange {
const VERSION = '1.62.95';
const VERSION = '1.62.96';
private static $base58_alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
private static $base58_encoder = null;
......
......@@ -28,11 +28,11 @@ use Exception;
include 'Throttle.php';
$version = '1.62.95';
$version = '1.62.96';
class Exchange extends \ccxt\Exchange {
const VERSION = '1.62.95';
const VERSION = '1.62.96';
public static $loop;
public static $kernel;
......
......@@ -2832,6 +2832,135 @@ class gateio extends Exchange {
return $response;
}
public function parse_position($position, $market = null) {
//
// {
// value => "12.475572",
// leverage => "0",
// mode => "single",
// realised_point => "0",
// $contract => "BTC_USDT",
// entry_price => "62422.6",
// mark_price => "62377.86",
// history_point => "0",
// realised_pnl => "-0.00624226",
// close_order => null,
// $size => "2",
// cross_leverage_limit => "25",
// pending_orders => "0",
// adl_ranking => "5",
// maintenance_rate => "0.005",
// unrealised_pnl => "-0.008948",
// user => "663337",
// leverage_max => "100",
// history_pnl => "14.98868396636",
// risk_limit => "1000000",
// margin => "0.740721495056",
// last_close_pnl => "-0.041996015",
// liq_price => "59058.58"
// }
//
$contract = $this->safe_value($position, 'contract');
$market = $this->safe_market($contract, $market);
$now = $this->milliseconds();
$size = $this->safe_string($position, 'size');
$side = null;
if ($size > 0) {
$side = 'buy';
} else if ($size < 0) {
$side = 'sell';
}
$maintenanceRate = $this->safe_string($position, 'maintenance_rate');
$notional = $this->safe_string($position, 'value');
$initialMargin = $this->safe_string($position, 'margin');
// $marginRatio = Precise::string_div($maintenanceRate, collateral);
$unrealisedPnl = $this->safe_string($position, 'unrealised_pnl');
return array(
'info' => $position,
'symbol' => $this->safe_string($market, 'symbol'),
'timestamp' => $now,
'datetime' => $this->iso8601($now),
'initialMargin' => $this->parse_number($initialMargin),
'initialMarginPercentage' => $this->parse_number(Precise::string_div($initialMargin, $notional)),
'maintenanceMargin' => $this->parse_number(Precise::string_mul($maintenanceRate, $notional)),
'maintenanceMarginPercentage' => $this->parse_number($maintenanceRate),
'entryPrice' => $this->safe_number($position, 'entry_price'),
'notional' => $this->parse_number($notional),
'leverage' => $this->safe_number($position, 'leverage'),
'unrealizedPnl' => $this->parse_number($unrealisedPnl),
'contracts' => $this->parse_number($size),
'contractSize' => $this->safe_number($market, 'contractSize'),
// realisedPnl => $position['realised_pnl'],
'marginRatio' => null,
'liquidationPrice' => $this->safe_number($position, 'liq_price'),
'markPrice' => $this->safe_number($position, 'mark_price'),
'collateral' => null,
'marginType' => null,
'side' => $side,
'percentage' => $this->parse_number(Precise::string_div($unrealisedPnl, $initialMargin)),
);
}
public function parse_positions($positions) {
$result = array();
for ($i = 0; $i < count($positions); $i++) {
$result[] = $this->parse_position($positions[$i]);
}
return $result;
}
public function fetch_positions($symbols = null, $params = array ()) {
// :param $symbols => Not used by Gateio
// :param $params:
// $settle => The currency that derivative contracts are settled in
// Other exchange specific $params
//
yield $this->load_markets();
$defaultType = $this->safe_string_2($this->options, 'fetchPositions', 'defaultType', 'swap');
$type = $this->safe_string($params, 'type', $defaultType);
$method = $this->get_supported_mapping($type, array(
'swap' => 'privateFuturesGetSettlePositions',
'futures' => 'privateDeliveryGetSettlePositions',
));
$defaultSettle = $type === 'swap' ? 'usdt' : 'btc';
$settle = $this->safe_string($params, 'settle', $defaultSettle);
$request = array(
'settle' => $settle,
);
$response = yield $this->$method ($request);
//
// array(
// {
// value => "12.475572",
// leverage => "0",
// mode => "single",
// realised_point => "0",
// contract => "BTC_USDT",
// entry_price => "62422.6",
// mark_price => "62377.86",
// history_point => "0",
// realised_pnl => "-0.00624226",
// close_order => null,
// size => "2",
// cross_leverage_limit => "25",
// pending_orders => "0",
// adl_ranking => "5",
// maintenance_rate => "0.005",
// unrealised_pnl => "-0.008948",
// user => "6693577",
// leverage_max => "100",
// history_pnl => "14.98868396636",
// risk_limit => "1000000",
// margin => "0.740721495056",
// last_close_pnl => "-0.041996015",
// liq_price => "59058.58"
// }
// )
//
$result = $this->parse_positions($response);
return $this->filter_by_array($result, 'symbol', $symbols, false);
}
public function sign($path, $api = [], $method = 'GET', $params = array (), $headers = null, $body = null) {
$authentication = $api[0]; // public, private
$type = $api[1]; // spot, margin, futures, delivery
......
......@@ -2831,6 +2831,135 @@ class gateio extends Exchange {
return $response;
}
public function parse_position($position, $market = null) {
//
// {
// value => "12.475572",
// leverage => "0",
// mode => "single",
// realised_point => "0",
// $contract => "BTC_USDT",
// entry_price => "62422.6",
// mark_price => "62377.86",
// history_point => "0",
// realised_pnl => "-0.00624226",
// close_order => null,
// $size => "2",
// cross_leverage_limit => "25",
// pending_orders => "0",
// adl_ranking => "5",
// maintenance_rate => "0.005",
// unrealised_pnl => "-0.008948",
// user => "663337",
// leverage_max => "100",
// history_pnl => "14.98868396636",
// risk_limit => "1000000",
// margin => "0.740721495056",
// last_close_pnl => "-0.041996015",
// liq_price => "59058.58"
// }
//
$contract = $this->safe_value($position, 'contract');
$market = $this->safe_market($contract, $market);
$now = $this->milliseconds();
$size = $this->safe_string($position, 'size');
$side = null;
if ($size > 0) {
$side = 'buy';
} else if ($size < 0) {
$side = 'sell';
}
$maintenanceRate = $this->safe_string($position, 'maintenance_rate');
$notional = $this->safe_string($position, 'value');
$initialMargin = $this->safe_string($position, 'margin');
// $marginRatio = Precise::string_div($maintenanceRate, collateral);
$unrealisedPnl = $this->safe_string($position, 'unrealised_pnl');
return array(
'info' => $position,
'symbol' => $this->safe_string($market, 'symbol'),
'timestamp' => $now,
'datetime' => $this->iso8601($now),
'initialMargin' => $this->parse_number($initialMargin),
'initialMarginPercentage' => $this->parse_number(Precise::string_div($initialMargin, $notional)),
'maintenanceMargin' => $this->parse_number(Precise::string_mul($maintenanceRate, $notional)),
'maintenanceMarginPercentage' => $this->parse_number($maintenanceRate),
'entryPrice' => $this->safe_number($position, 'entry_price'),
'notional' => $this->parse_number($notional),
'leverage' => $this->safe_number($position, 'leverage'),
'unrealizedPnl' => $this->parse_number($unrealisedPnl),
'contracts' => $this->parse_number($size),
'contractSize' => $this->safe_number($market, 'contractSize'),
// realisedPnl => $position['realised_pnl'],
'marginRatio' => null,
'liquidationPrice' => $this->safe_number($position, 'liq_price'),
'markPrice' => $this->safe_number($position, 'mark_price'),
'collateral' => null,
'marginType' => null,
'side' => $side,
'percentage' => $this->parse_number(Precise::string_div($unrealisedPnl, $initialMargin)),
);
}
public function parse_positions($positions) {
$result = array();
for ($i = 0; $i < count($positions); $i++) {
$result[] = $this->parse_position($positions[$i]);
}
return $result;
}
public function fetch_positions($symbols = null, $params = array ()) {
// :param $symbols => Not used by Gateio
// :param $params:
// $settle => The currency that derivative contracts are settled in
// Other exchange specific $params
//
$this->load_markets();
$defaultType = $this->safe_string_2($this->options, 'fetchPositions', 'defaultType', 'swap');
$type = $this->safe_string($params, 'type', $defaultType);
$method = $this->get_supported_mapping($type, array(
'swap' => 'privateFuturesGetSettlePositions',
'futures' => 'privateDeliveryGetSettlePositions',
));
$defaultSettle = $type === 'swap' ? 'usdt' : 'btc';
$settle = $this->safe_string($params, 'settle', $defaultSettle);
$request = array(
'settle' => $settle,
);
$response = $this->$method ($request);
//
// array(
// {
// value => "12.475572",
// leverage => "0",
// mode => "single",
// realised_point => "0",
// contract => "BTC_USDT",
// entry_price => "62422.6",
// mark_price => "62377.86",
// history_point => "0",
// realised_pnl => "-0.00624226",
// close_order => null,
// size => "2",
// cross_leverage_limit => "25",
// pending_orders => "0",
// adl_ranking => "5",
// maintenance_rate => "0.005",
// unrealised_pnl => "-0.008948",
// user => "6693577",
// leverage_max => "100",
// history_pnl => "14.98868396636",
// risk_limit => "1000000",
// margin => "0.740721495056",
// last_close_pnl => "-0.041996015",
// liq_price => "59058.58"
// }
// )
//
$result = $this->parse_positions($response);
return $this->filter_by_array($result, 'symbol', $symbols, false);
}
public function sign($path, $api = [], $method = 'GET', $params = array (), $headers = null, $body = null) {
$authentication = $api[0]; // public, private
$type = $api[1]; // spot, margin, futures, delivery
......
......@@ -219,13 +219,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.62.95/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.62.95/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@1.62.96/dist/ccxt.browser.js
* unpkg: https://unpkg.com/ccxt@1.62.96/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.62.95/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@1.62.96/dist/ccxt.browser.js"></script>
```
Creates a global `ccxt` object:
......
......@@ -22,7 +22,7 @@
# ----------------------------------------------------------------------------
__version__ = '1.62.95'
__version__ = '1.62.96'
# ----------------------------------------------------------------------------
......
......@@ -4,7 +4,7 @@
# -----------------------------------------------------------------------------
__version__ = '1.62.95'
__version__ = '1.62.96'
# -----------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
# -----------------------------------------------------------------------------
__version__ = '1.62.95'
__version__ = '1.62.96'
# -----------------------------------------------------------------------------
......
......@@ -2704,6 +2704,130 @@ class gateio(Exchange):
#
return response
def parse_position(self, position, market=None):
#
# {
# value: "12.475572",
# leverage: "0",
# mode: "single",
# realised_point: "0",
# contract: "BTC_USDT",
# entry_price: "62422.6",
# mark_price: "62377.86",
# history_point: "0",
# realised_pnl: "-0.00624226",
# close_order: null,
# size: "2",
# cross_leverage_limit: "25",
# pending_orders: "0",
# adl_ranking: "5",
# maintenance_rate: "0.005",
# unrealised_pnl: "-0.008948",
# user: "663337",
# leverage_max: "100",
# history_pnl: "14.98868396636",
# risk_limit: "1000000",
# margin: "0.740721495056",
# last_close_pnl: "-0.041996015",
# liq_price: "59058.58"
# }
#
contract = self.safe_value(position, 'contract')
market = self.safe_market(contract, market)
now = self.milliseconds()
size = self.safe_string(position, 'size')
side = None
if size > 0:
side = 'buy'
elif size < 0:
side = 'sell'
maintenanceRate = self.safe_string(position, 'maintenance_rate')
notional = self.safe_string(position, 'value')
initialMargin = self.safe_string(position, 'margin')
# marginRatio = Precise.string_div(maintenanceRate, collateral)
unrealisedPnl = self.safe_string(position, 'unrealised_pnl')
return {
'info': position,
'symbol': self.safe_string(market, 'symbol'),
'timestamp': now,
'datetime': self.iso8601(now),
'initialMargin': self.parse_number(initialMargin),
'initialMarginPercentage': self.parse_number(Precise.string_div(initialMargin, notional)),
'maintenanceMargin': self.parse_number(Precise.string_mul(maintenanceRate, notional)),
'maintenanceMarginPercentage': self.parse_number(maintenanceRate),
'entryPrice': self.safe_number(position, 'entry_price'),
'notional': self.parse_number(notional),
'leverage': self.safe_number(position, 'leverage'),
'unrealizedPnl': self.parse_number(unrealisedPnl),
'contracts': self.parse_number(size),
'contractSize': self.safe_number(market, 'contractSize'),
# realisedPnl: position['realised_pnl'],
'marginRatio': None,
'liquidationPrice': self.safe_number(position, 'liq_price'),
'markPrice': self.safe_number(position, 'mark_price'),
'collateral': None,
'marginType': None,
'side': side,
'percentage': self.parse_number(Precise.string_div(unrealisedPnl, initialMargin)),
}
def parse_positions(self, positions):
result = []
for i in range(0, len(positions)):
result.append(self.parse_position(positions[i]))
return result
async def fetch_positions(self, symbols=None, params={}):
# :param symbols: Not used by Gateio
# :param params:
# settle: The currency that derivative contracts are settled in
# Other exchange specific params
#
await self.load_markets()
defaultType = self.safe_string_2(self.options, 'fetchPositions', 'defaultType', 'swap')
type = self.safe_string(params, 'type', defaultType)
method = self.get_supported_mapping(type, {
'swap': 'privateFuturesGetSettlePositions',
'futures': 'privateDeliveryGetSettlePositions',
})
defaultSettle = type == 'usdt' if 'swap' else 'btc'
settle = self.safe_string(params, 'settle', defaultSettle)
request = {
'settle': settle,