Skip to main content
Core Concept5 min read
Available data sources in kScript for accessing market data, indicators, and financial information from exchanges and data providers.

Data Access Methods

kScript v2 provides two ways to access market data:

Available Data Sources

kScript provides access to many different data sources covering price data, derivatives, options, lending markets, and institutional flows.
Core market data including price, volume, and orderbook dynamics.
SourceDescription
ohlcv()Open, High, Low, Close, Volume data
buy_sell_volume()Separated buy and sell volume
orderbook()Order book depth data
Futures, perpetuals, and derivative market metrics.
SourceDescription
funding_rate()Perpetual futures funding rates
liquidations()Liquidation events and volumes
open_interest()Total open positions
long_short_ratio()Long vs short position ratio
Options data, implied volatility, and skew metrics.
SourceDescription
options_volume()Options trading volume
options_open_interest()Options open interest
deribit_implied_volatility()Deribit IV data
deribit_volatility_index()DVOL index
Margin rates, lending markets, and credit data.
SourceDescription
bitfinex_margin_rate()Bitfinex margin rates
bitfinex_active_credit_size()Active credit size
ETF flows, institutional holdings, and treasury data.
SourceDescription
etf_flow()ETF inflows/outflows
etf_holding()ETF holdings data
etf_premium_rate()ETF premium/discount

Common Usage Patterns

Basic Price Data

Access OHLCV data for price-based technical analysis:
//@version=2

define("Price Analysis", "onchart", true);

// Method 1: Direct function (recommended)
timeseries trade = ohlcv(symbol=currentSymbol, exchange=currentExchange);

// Method 2: Using source() function
// timeseries trade = source("ohlcv", currentSymbol, currentExchange);

// Calculate simple moving average on close prices
var sma20 = sma(trade, 20, 4);

plotLine(value=sma20, width=2, colors=["blue"], label=["SMA 20"], desc=["20-period Simple Moving Average"]);

Funding Rate Analysis

Monitor funding rates across perpetual futures markets:
//@version=2

define("Funding Rate Monitor", "offchart", true);

// Method 1: Direct function (recommended)
timeseries funding = funding_rate(symbol=currentSymbol, exchange=currentExchange);

// Plot funding rate
var width = input("width", "number", 2);

plotLine(value=funding, width=width, colors=["blue", "green", "red"], label=["Funding Rate"], desc=["Funding Rate Data"]);

Liquidation Monitoring

Track liquidation events and volumes for market sentiment:
//@version=2

define("Liquidation Tracker", "offchart", true);

// Method 1: Direct function (recommended)
timeseries liquidationData = liquidations(symbol=currentSymbol, exchange=currentExchange);

// Plot liquidations as bars
plotBar(value=liquidationData, width=1, colors=["green", "red"], label=["Liquidations"], desc=["Liquidation Data"]);

Best Practices

Choose Appropriate Sources

Select data sources that match your strategy timeframe and requirements.

Cache Data References

Store data source references to avoid repeated function calls:
timeseries ohlcvData = ohlcv(currentSymbol, currentExchange);
// Use ohlcvData throughout your script

Handle Data Availability

Not all data sources are available for every symbol/exchange combination. Check that your selected data source supports your target market.