Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
exchange.SetContractType
exchange.GetContractType
exchange.SetDirection
exchange.SetMarginLevel
exchange.GetPositions
exchange.GetFundings
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Obtains the funding rate data for the current period.

exchange.GetFundings()
exchange.GetFundings(symbol)

Examples

  • Query funding rates (default scope when no argument is given) and print each one.

    javascript
    function main() { var fundings = exchange.GetFundings() if (!fundings) return for (var f of fundings) { Log(f.Symbol, "Rate", f.Rate * 100, "%", "Interval", f.Interval / 3600000, "h", _D(f.Time)) } // Output: one line per symbol: symbol, funding rate (%), settlement interval (hours), time }
    python
    def main(): fundings = exchange.GetFundings() if fundings is None: return for f in fundings: hours = f["Interval"] / 3600000 Log(f["Symbol"], "Rate", f["Rate"] * 100, "%", "Interval", hours, "h", _D(f["Time"] / 1000)) # Output: one line per symbol: symbol, funding rate (%), settlement interval (hours), time
    rust
    fn main() { let Ok(fundings) = exchange.GetFundings(None) else { return }; for f in &fundings { let hours = f.Interval as f64 / 3600000.0; Log!(f.Symbol, "Rate", f.Rate * 100.0, "%", "Interval", hours, "h", _D(f.Time)); } // Output: one line per symbol: symbol, funding rate (%), settlement interval (hours), time }
  • Using the futures exchange object, call the exchange.GetFundings() function in the backtesting system. Before any market data function is called, GetFundings returns only the Funding data of the current default trading pair; after a market data function is called, it returns the Funding data of all symbols that have been requested. Refer to the following test example.

    javascript
    /*backtest start: 2024-10-01 00:00:00 end: 2024-10-23 00:05:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDC"}] */ function main() { // LPT_USDT.swap 4-hour interval var symbols = ["SOL_USDT.swap", "ETH_USDT.swap", "LTC_USDT.swap", "SOL_USDC.swap", "ETH_USDC.swap", "BTC_USD.swap", "BTC_USDT.quarter", "LPT_USDT.swap"] for (var symbol of symbols) { exchange.GetTicker(symbol) } var arr = [] var arrParams = ["no param", "LTC_USDT.swap", "USDT.swap", "USD.swap", "USDC.swap", "USDT.futures", "BTC_USDT.quarter"] for (var p of arrParams) { if (p == "no param") { arr.push(exchange.GetFundings()) } else { arr.push(exchange.GetFundings(p)) } } var tbls = [] var index = 0 for (var fundings of arr) { var tbl = { "type": "table", "title": arrParams[index], "cols": ["Symbol", "Interval", "Time", "Rate"], "rows": [], } for (var f of fundings) { tbl["rows"].push([f.Symbol, f.Interval / 3600000, _D(f.Time), f.Rate * 100 + " %"]) } tbls.push(tbl) index++ } LogStatus(_D(), "\n Requested symbols:", symbols, "\n`" + JSON.stringify(tbls) + "`") }
    python
    '''backtest start: 2024-10-01 00:00:00 end: 2024-10-23 00:05:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDC"}] ''' import json def main(): # LPT_USDT.swap 4-hour interval symbols = ["SOL_USDT.swap", "ETH_USDT.swap", "LTC_USDT.swap", "SOL_USDC.swap", "ETH_USDC.swap", "BTC_USD.swap", "BTC_USDT.quarter", "LPT_USDT.swap"] for symbol in symbols: exchange.GetTicker(symbol) arr = [] arrParams = ["no param", "LTC_USDT.swap", "USDT.swap", "USD.swap", "USDC.swap", "USDT.futures", "BTC_USDT.quarter"] for p in arrParams: if p == "no param": arr.append(exchange.GetFundings()) else: arr.append(exchange.GetFundings(p)) tbls = [] index = 0 for fundings in arr: tbl = { "type": "table", "title": arrParams[index], "cols": ["Symbol", "Interval", "Time", "Rate"], "rows": [], } for f in fundings: tbl["rows"].append([f["Symbol"], f["Interval"] / 3600000, _D(f["Time"]), str(f["Rate"] * 100) + " %"]) tbls.append(tbl) index += 1 LogStatus(_D(), "\n Requested symbols:", symbols, "\n`" + json.dumps(tbls) + "`")
    rust
    /*backtest start: 2024-10-01 00:00:00 end: 2024-10-23 00:05:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDC"}] */ fn main() { // LPT_USDT.swap 4-hour interval let symbols = ["SOL_USDT.swap", "ETH_USDT.swap", "LTC_USDT.swap", "SOL_USDC.swap", "ETH_USDC.swap", "BTC_USD.swap", "BTC_USDT.quarter", "LPT_USDT.swap"]; for symbol in symbols { exchange.GetTicker(symbol); } let mut arr: Vec<Vec<Funding>> = Vec::new(); let arrParams = ["no param", "LTC_USDT.swap", "USDT.swap", "USD.swap", "USDC.swap", "USDT.futures", "BTC_USDT.quarter"]; for p in arrParams { if p == "no param" { arr.push(exchange.GetFundings(None).unwrap()); } else { arr.push(exchange.GetFundings(p).unwrap()); } } // The Rust SDK has no JSON serialization; use format! to concatenate the table's JSON text let mut tbls: Vec<String> = Vec::new(); for (index, fundings) in arr.iter().enumerate() { let mut rows: Vec<String> = Vec::new(); for f in fundings { rows.push(format!(r#"["{}", {}, "{}", "{} %"]"#, f.Symbol, f.Interval as f64 / 3600000.0, _D(f.Time), f.Rate * 100.0)); } let tbl = format!(r#"{{"type": "table", "title": "{}", "cols": ["Symbol", "Interval", "Time", "Rate"], "rows": [{}]}}"#, arrParams[index], rows.join(",")); tbls.push(tbl); } LogStatus!(_D(None), "\n Requested symbols:", format!("{:?}", symbols), format!("\n`[{}]`", tbls.join(","))); }

Returns

TypeDescription

Funding array / null value

When the exchange.GetFundings() function successfully requests data, it returns a Funding structure array; when the data request fails, it returns a null value.

Arguments

NameTypeRequiredDescription

symbol

string

No

The instrument (for example BTC_USDT.swap) or range of instruments (for example USDT.swap) to query. If omitted or an empty string, the range of the current quote currency and contract type is queried (USDT.swap when the current instrument is BTC_USDT.swap). The full rules for ranges and the default range are described in Symbols.

See Also

Remarks

For futures exchanges that do not support batch querying of funding rate data, if the symbol parameter is specified as a query range (for example USDT.swap) or is not passed in, the interface will report an error. When calling the GetFundings() function on such futures exchange objects, the symbol parameter must be specified as a specific perpetual contract in order to query the current-period funding rate data for that trading pair.

The exchange.GetFundings() function supports both live trading and the backtesting system.

Which futures exchanges cannot query funding rates in batch and need a concrete symbol (for example ETH_USDT.swap) is noted on each exchange page (all exchanges are listed in Capability Matrix).

Exchanges that do not support this function: Futures_Polymarket, Futures_Futu, Futures_IB. The call fails with an error and returns null; for all exchanges see Capability Matrix.