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 Oct 2, 2021
2 parents 25f2471 + cdad3bd commit 2f6312a
Show file tree
Hide file tree
Showing 20 changed files with 295 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,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].31/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].31/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].33/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].33/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].31/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].33/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.57.31'
const version = '1.57.33'

Exchange.ccxtVersion = version

Expand Down
50 changes: 47 additions & 3 deletions dist/ccxt.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Exchange = require ('./js/base/Exchange')
//-----------------------------------------------------------------------------
// this is updated by vss.js when building

const version = '1.57.31'
const version = '1.57.33'

Exchange.ccxtVersion = version

Expand Down Expand Up @@ -68119,8 +68119,9 @@ module.exports = class ftx extends Exchange {
'fetchDepositAddress': true,
'fetchDeposits': true,
'fetchFundingFees': undefined,
'fetchFundingRate': false,
'fetchFundingRates': false,
'fetchFundingRate': undefined,
'fetchFundingRateHistory': true,
'fetchFundingRates': undefined,
'fetchIndexOHLCV': true,
'fetchMarkets': true,
'fetchMarkOHLCV': false,
Expand Down Expand Up @@ -69070,6 +69071,49 @@ module.exports = class ftx extends Exchange {
};
}

async fetchFundingRateHistory (symbol, limit = undefined, since = undefined, params = {}) {
//
// Gets a history of funding rates with their timestamps
// (param) symbol: Future currency pair (e.g. "BTC-PERP")
// (param) limit: Not used by ftx
// (param) since: Unix timestamp in miliseconds for the time of the earliest requested funding rate
// return: [{symbol, fundingRate, timestamp}]
//
await this.loadMarkets ();
const market = this.market (symbol);
const request = {
'future': market['id'],
};
if (since !== undefined) {
request['start_time'] = since / 1000;
}
const method = 'publicGetFundingRates';
const response = await this[method] (this.extend (request, params));
//
// {
// "success": true,
// "result": [
// {
// "future": "BTC-PERP",
// "rate": 0.0025,
// "time": "2019-06-02T08:00:00+00:00"
// }
// ]
// }
//
const result = this.safeValue (response, 'result');
const rates = [];
const length = result.length - 1;
for (let i = length; i >= 0; i--) {
rates.push ({
'symbol': this.safeString (result[i], 'future'),
'fundingRate': this.safeNumber (result[i], 'rate'),
'timestamp': this.parse8601 (this.safeString (result[i], 'time')),
});
}
return rates;
}

async fetchBalance (params = {}) {
await this.loadMarkets ();
const response = await this.privateGetWalletBalances (params);
Expand Down
6 changes: 3 additions & 3 deletions doc/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1928,14 +1928,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].31/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].31/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].33/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].33/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].31/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].33/dist/ccxt.browser.js"></script>

Creates a global ``ccxt`` object:

Expand Down
48 changes: 46 additions & 2 deletions js/ftx.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ module.exports = class ftx extends Exchange {
'fetchDepositAddress': true,
'fetchDeposits': true,
'fetchFundingFees': undefined,
'fetchFundingRate': false,
'fetchFundingRates': false,
'fetchFundingRate': undefined,
'fetchFundingRateHistory': true,
'fetchFundingRates': undefined,
'fetchIndexOHLCV': true,
'fetchMarkets': true,
'fetchMarkOHLCV': false,
Expand Down Expand Up @@ -995,6 +996,49 @@ module.exports = class ftx extends Exchange {
};
}

async fetchFundingRateHistory (symbol, limit = undefined, since = undefined, params = {}) {
//
// Gets a history of funding rates with their timestamps
// (param) symbol: Future currency pair (e.g. "BTC-PERP")
// (param) limit: Not used by ftx
// (param) since: Unix timestamp in miliseconds for the time of the earliest requested funding rate
// return: [{symbol, fundingRate, timestamp}]
//
await this.loadMarkets ();
const market = this.market (symbol);
const request = {
'future': market['id'],
};
if (since !== undefined) {
request['start_time'] = since / 1000;
}
const method = 'publicGetFundingRates';
const response = await this[method] (this.extend (request, params));
//
// {
// "success": true,
// "result": [
// {
// "future": "BTC-PERP",
// "rate": 0.0025,
// "time": "2019-06-02T08:00:00+00:00"
// }
// ]
// }
//
const result = this.safeValue (response, 'result');
const rates = [];
const length = result.length - 1;
for (let i = length; i >= 0; i--) {
rates.push ({
'symbol': this.safeString (result[i], 'future'),
'fundingRate': this.safeNumber (result[i], 'rate'),
'timestamp': this.parse8601 (this.safeString (result[i], 'time')),
});
}
return rates;
}

async fetchBalance (params = {}) {
await this.loadMarkets ();
const response = await this.privateGetWalletBalances (params);
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ccxt",
"version": "1.57.31",
"version": "1.57.33",
"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/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
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

include 'Throttle.php';

$version = '1.57.31';
$version = '1.57.33';

class Exchange extends \ccxt\Exchange {

const VERSION = '1.57.31';
const VERSION = '1.57.33';

public static $loop;
public static $kernel;
Expand Down
48 changes: 46 additions & 2 deletions php/async/ftx.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public function describe() {
'fetchDepositAddress' => true,
'fetchDeposits' => true,
'fetchFundingFees' => null,
'fetchFundingRate' => false,
'fetchFundingRates' => false,
'fetchFundingRate' => null,
'fetchFundingRateHistory' => true,
'fetchFundingRates' => null,
'fetchIndexOHLCV' => true,
'fetchMarkets' => true,
'fetchMarkOHLCV' => false,
Expand Down Expand Up @@ -999,6 +1000,49 @@ public function fetch_trading_fees($params = array ()) {
);
}

public function fetch_funding_rate_history($symbol, $limit = null, $since = null, $params = array ()) {
//
// Gets a history of funding $rates with their timestamps
// (param) $symbol => Future currency pair (e.g. "BTC-PERP")
// (param) $limit => Not used by ftx
// (param) $since => Unix timestamp in miliseconds for the time of the earliest requested funding rate
// return => [array($symbol, fundingRate, timestamp)]
//
yield $this->load_markets();
$market = $this->market($symbol);
$request = array(
'future' => $market['id'],
);
if ($since !== null) {
$request['start_time'] = $since / 1000;
}
$method = 'publicGetFundingRates';
$response = yield $this->$method (array_merge($request, $params));
//
// {
// "success" => true,
// "$result" => array(
// {
// "future" => "BTC-PERP",
// "rate" => 0.0025,
// "time" => "2019-06-02T08:00:00+00:00"
// }
// )
// }
//
$result = $this->safe_value($response, 'result');
$rates = array();
$length = strlen($result) - 1;
for ($i = $length; $i >= 0; $i--) {
$rates[] = array(
'symbol' => $this->safe_string($result[$i], 'future'),
'fundingRate' => $this->safe_number($result[$i], 'rate'),
'timestamp' => $this->parse8601($this->safe_string($result[$i], 'time')),
);
}
return $rates;
}

public function fetch_balance($params = array ()) {
yield $this->load_markets();
$response = yield $this->privateGetWalletBalances ($params);
Expand Down
48 changes: 46 additions & 2 deletions php/ftx.php

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

6 changes: 3 additions & 3 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,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].31/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].31/dist/ccxt.browser.js
* jsDelivr: https://cdn.jsdelivr.net/npm/[email protected].33/dist/ccxt.browser.js
* unpkg: https://unpkg.com/[email protected].33/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].31/dist/ccxt.browser.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected].33/dist/ccxt.browser.js"></script>
```

Creates a global `ccxt` object:
Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# ----------------------------------------------------------------------------

__version__ = '1.57.31'
__version__ = '1.57.33'

# ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async_support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.57.31'
__version__ = '1.57.33'

# -----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion python/ccxt/async_support/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# -----------------------------------------------------------------------------

__version__ = '1.57.31'
__version__ = '1.57.33'

# -----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 2f6312a

Please sign in to comment.