Skip to content

Tastytrade

Query your tastytrade brokerage accounts and market data from SQL, read-only

Connector software
Free and open source
Service credentials
Required
Query Farm hosting
Not available yet
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/tastytrade/index.md to help me query Tastytrade with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

See your open positions

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT symbol, underlying_symbol, instrument_type, quantity, mark
FROM tastytrade.main.positions()
ORDER BY underlying_symbol, symbol

Quick start

Choose where to run Tastytrade, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'tastytrade' AS tastytrade (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-tastytrade-typescript'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

tastytrade credentials

Tastytrade OAuth credentials (client_secret, refresh_token, optional is_test)

Get these credentials →
secret.sql
CREATE SECRET tastytrade (
    TYPE tastytrade,
    client_secret '<TASTYTRADE_CLIENT_SECRET>',  -- secret
    refresh_token '<REFRESH_TOKEN>',  -- secret
    is_test       '<is_test>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT symbol, underlying_symbol, instrument_type, quantity, mark
FROM tastytrade.main.positions()
ORDER BY underlying_symbol, symbol
More example queries →
Technical details
Verified connector release
v0.1.2
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'tastytrade' AS tastytrade (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Read-only tastytrade brokerage data (accounts, instruments, market metrics, live quotes) for SQL

ATTACH options

account_number
Default account number for account-scoped functions (else all accounts are queried)VARCHAR

Catalog

Everything tastytrade exposes once attached — read straight from the worker's released build.

tastytrade 1 schema
main 52 functions

Read-only tastytrade account, instrument, market-metric, and live-quote functions

Schema examples (11)
Examples (11)

List the accounts available to the session

SELECT account_number, nickname, account_type_name
FROM tastytrade.main.accounts();

Net liquidating value and buying power for the default account

SELECT net_liquidating_value, equity_buying_power
FROM tastytrade.main.balances();

Open positions for the default account

SELECT symbol, quantity, mark FROM tastytrade.main.positions();

Six months of net-liquidating-value history

SELECT time, close
FROM tastytrade.main.nlv_history(lookback => INTERVAL '6 months')
ORDER BY time;
7 more examples

Equity reference data for several symbols, one per input row

SELECT e.symbol, e.is_etf, e.description
FROM (VALUES ('SPY'), ('AAPL')) t(sym),
     LATERAL tastytrade.main.equities(t.sym) e;

List all actively traded ETFs

SELECT symbol, description FROM tastytrade.main.all_equities() WHERE is_etf;

Search instruments matching a phrase

SELECT symbol, description FROM tastytrade.main.search(query => 'apple');

Flattened SPY option chain

SELECT expiration_date, strike_price, option_type
FROM tastytrade.main.option_chain('SPY');

IV rank and beta for every underlying held

SELECT m.symbol, m.implied_volatility_index_rank, m.beta
FROM (SELECT DISTINCT underlying_symbol AS sym FROM tastytrade.main.positions()) p,
     LATERAL tastytrade.main.market_metrics(p.sym) m;

Live bid/ask snapshot (requires a production session)

SELECT symbol, bid_price, ask_price FROM tastytrade.main.quotes('SPY');

Today's 5-minute QQQ OHLC bars (requires a production session)

SELECT time, open, high, low, close, volume
FROM tastytrade.main.candles('QQQ', period => '5m')
ORDER BY time;
Table functions
accounts () 1 example

Tastytrade accounts available to the authenticated session

No arguments
Returns columns
account_number VARCHAR
Tastytrade account number.
nickname VARCHAR
User-assigned account nickname; null if unset.
account_type_name VARCHAR
Account type (e.g. Individual, Roth IRA, Margin).
margin_or_cash VARCHAR
Whether the account is a Margin or Cash account.
is_closed BOOLEAN
True if the account is closed.
day_trader_status BOOLEAN
True if flagged as a pattern day trader.
is_futures_approved BOOLEAN
True if approved to trade futures.
suitable_options_level VARCHAR
Approved options trading level; null if none.
opened_at DATE
Date the account was opened; null if unknown.
created_at TIMESTAMP WITH TIME ZONE
Timestamp the account record was created (UTC).
Example

List open accounts

SELECT account_number, nickname, margin_or_cash
FROM tastytrade.main.accounts()
WHERE NOT is_closed;
Link
all_cryptocurrencies () 1 example

Enumerate all tradeable cryptocurrencies

No arguments
Returns columns
symbol VARCHAR
Cryptocurrency symbol (e.g. BTC/USD).
instrument_type VARCHAR
Instrument type (Cryptocurrency).
description VARCHAR
Description of the cryptocurrency.
short_description VARCHAR
Short description; null if none.
active BOOLEAN
True if the instrument is active.
is_closing_only BOOLEAN
True if only closing trades are allowed.
tick_size DOUBLE
Minimum tick size.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Example

All tradeable cryptocurrencies

SELECT symbol, description FROM tastytrade.main.all_cryptocurrencies();
Link
all_equities (lendability := VARCHAR) 2 examples

Enumerate all actively traded equities (optionally filtered by lendability)

Named arguments
lendability := VARCHAR
Optional lendability filter: 'Easy To Borrow', 'Locate Required', or 'Preborrow'. Empty for no filter. · default ""
Returns columns
symbol VARCHAR
Equity symbol.
instrument_type VARCHAR
Instrument type (Equity).
description VARCHAR
Human-readable description of the equity.
is_index BOOLEAN
True if the symbol represents an index.
is_etf BOOLEAN
True if the symbol is an ETF.
listed_market VARCHAR
Primary listing market; null if unknown.
lendability VARCHAR
Share lendability classification; null if unknown.
borrow_rate DOUBLE
Borrow rate for short selling; null if n/a.
active BOOLEAN
True if the instrument is active.
is_illiquid BOOLEAN
True if flagged as illiquid.
cusip VARCHAR
CUSIP identifier; null if unavailable.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Examples (2)

All active ETFs

SELECT symbol, description, is_etf
FROM tastytrade.main.all_equities()
WHERE is_etf;

Active equities that are easy to borrow

SELECT symbol
FROM tastytrade.main.all_equities(lendability => 'Easy To Borrow');
Link
all_future_option_products () 1 example

Enumerate all future-option products (option families on futures) with their underlying future product

No arguments
Returns columns
root_symbol VARCHAR
Option product root symbol.
code VARCHAR
Option product code.
exchange VARCHAR
Listing exchange.
product_type VARCHAR
Product type.
market_sector VARCHAR
Market sector.
expiration_type VARCHAR
Expiration type.
cash_settled BOOLEAN
True if cash-settled.
is_rollover BOOLEAN
True if a rollover product.
settlement_delay_days INTEGER
Days between expiration and settlement.
display_factor DOUBLE
Display factor for price formatting.
clearing_code VARCHAR
Clearing code.
clearing_price_multiplier DOUBLE
Clearing price multiplier.
future_root_symbol VARCHAR
Root symbol of the underlying future product (e.g. /ES).
future_description VARCHAR
Description of the underlying future product.
Example

Option products on /ES (weeklies, end-of-month, quarterlies)

SELECT root_symbol, code, expiration_type, future_root_symbol
FROM tastytrade.main.all_future_option_products()
WHERE future_root_symbol = '/ES';
Link
all_future_products () 1 example

Enumerate all available future products (a product is a family of futures, e.g. /ES)

No arguments
Returns columns
root_symbol VARCHAR
Future product root symbol (e.g. /ES).
code VARCHAR
Product code (e.g. ES).
description VARCHAR
Description of the future product.
exchange VARCHAR
Listing exchange (CME, CFE, etc.).
product_type VARCHAR
Product type.
market_sector VARCHAR
Market sector.
notional_multiplier DOUBLE
Notional multiplier per contract.
tick_size DOUBLE
Minimum tick size.
display_factor DOUBLE
Display factor for price formatting.
streamer_exchange_code VARCHAR
DXLink streamer exchange code.
cash_settled BOOLEAN
True if the product is cash-settled.
small_notional BOOLEAN
True if a small-notional (Smalls) product.
first_notice BOOLEAN
True if the product has a first-notice date.
product_subtype VARCHAR
Product subtype; null if none.
clearing_code VARCHAR
Clearing code; null if unknown.
Example

All future products

SELECT root_symbol, code, description, exchange
FROM tastytrade.main.all_future_products();
Link
balance_snapshots (account_number := VARCHAR, end_date := DATE, start_date := DATE) 1 example

Historical daily balance snapshots for an account over a date range

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
end_date := DATE
Latest snapshot day to include; null for no upper bound. · default null
start_date := DATE
Earliest snapshot day to include; null for recent snapshots only. · default null
Returns columns
account_number VARCHAR
Tastytrade account number.
snapshot_date DATE
Date of the balance snapshot.
time_of_day VARCHAR
Snapshot time of day (BOD or EOD).
net_liquidating_value DECIMAL(38,12)
Net liquidating value at the snapshot.
cash_balance DECIMAL(38,12)
Cash balance at the snapshot.
equity_buying_power DECIMAL(38,12)
Equity buying power at the snapshot.
derivative_buying_power DECIMAL(38,12)
Derivative buying power at the snapshot.
maintenance_requirement DECIMAL(38,12)
Maintenance requirement at the snapshot.
long_equity_value DECIMAL(38,12)
Long equity value at the snapshot.
short_equity_value DECIMAL(38,12)
Short equity value at the snapshot.
Example

Daily net-liq since the start of the year

SELECT snapshot_date, net_liquidating_value
FROM tastytrade.main.balance_snapshots(start_date => DATE '2026-01-01')
ORDER BY snapshot_date;
Link
balances (account_number := VARCHAR) 2 examples

Current cash, margin, and buying-power balances for an account

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
Returns columns
account_number VARCHAR
Tastytrade account number.
net_liquidating_value DECIMAL(38,12)
Total net liquidating value of the account.
cash_balance DECIMAL(38,12)
Settled cash balance.
equity_buying_power DECIMAL(38,12)
Buying power available for equities.
derivative_buying_power DECIMAL(38,12)
Buying power available for derivatives.
day_trading_buying_power DECIMAL(38,12)
Buying power available for day trading.
used_derivative_buying_power DECIMAL(38,12)
Derivative buying power currently in use.
maintenance_requirement DECIMAL(38,12)
Total maintenance margin requirement.
maintenance_excess DECIMAL(38,12)
Maintenance margin excess (cushion).
cash_available_to_withdraw DECIMAL(38,12)
Cash currently available to withdraw.
long_equity_value DECIMAL(38,12)
Market value of long equity positions.
short_equity_value DECIMAL(38,12)
Market value of short equity positions.
long_derivative_value DECIMAL(38,12)
Market value of long derivative positions.
short_derivative_value DECIMAL(38,12)
Market value of short derivative positions.
long_futures_value DECIMAL(38,12)
Market value of long futures positions.
short_futures_value DECIMAL(38,12)
Market value of short futures positions.
margin_equity DECIMAL(38,12)
Margin equity.
pending_cash DECIMAL(38,12)
Pending (unsettled) cash.
snapshot_date DATE
Date of this balance snapshot; null if live.
updated_at TIMESTAMP WITH TIME ZONE
Timestamp the balance was last updated (UTC).
Examples (2)

Key balances for the default account

SELECT net_liquidating_value, cash_balance, derivative_buying_power
FROM tastytrade.main.balances();

Net liquidating value for a specific account

SELECT net_liquidating_value
FROM tastytrade.main.balances(account_number => '5WX01234');
Link
candles (symbol VARCHAR, end_time := TIMESTAMP, extended_hours := BOOLEAN, include_empty := BOOLEAN, period := VARCHAR, start_time := TIMESTAMP) 3 examples

Historical OHLC candles (price bars) for symbols at a given period (DXLink)

Positional arguments
symbol VARCHAR
Streamer symbol to fetch candles for (for options/futures use the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Named arguments
end_time := TIMESTAMP
End of the range, interpreted as UTC (inclusive). Defaults to none — bars run to the latest available. · default null
extended_hours := BOOLEAN
Include pre/post-market candles. Defaults to true. · default true
include_empty := BOOLEAN
Include empty candles (no trades, zero/NULL OHLC) that dxFeed emits for non-trading days. Defaults to false. · default false
period := VARCHAR
Candle width as a count plus a unit (s, m, h, d, w, mo) such as 5m, 1h, or 1d. Defaults to 5m. · default "5m"
start_time := TIMESTAMP
Start of the range, interpreted as UTC. Defaults to midnight UTC of the current day (today's bars). · default null
Returns columns
symbol VARCHAR
Symbol the candle is for.
time TIMESTAMP WITH TIME ZONE
Start timestamp of the candle bucket (UTC).
open DECIMAL(38,12)
Open price of the candle; null if no trades.
high DECIMAL(38,12)
High price of the candle; null if no trades.
low DECIMAL(38,12)
Low price of the candle; null if no trades.
close DECIMAL(38,12)
Close price of the candle; null if no trades.
volume DOUBLE
Total volume traded during the candle; null if no trades.
vwap DECIMAL(38,12)
Volume-weighted average price during the candle; null if n/a.
count BIGINT
Number of trades/events aggregated into the candle.
Examples (3)

Today's 5-minute QQQ bars (incl. extended hours)

SELECT time, open, high, low, close, volume
FROM tastytrade.main.candles('QQQ', period => '5m')
ORDER BY time;

Regular-hours hourly SPY closes for one bounded day

SELECT time, close
FROM tastytrade.main.candles('SPY', period => '1h', start_time => TIMESTAMP '2026-06-01 00:00:00', end_time => TIMESTAMP '2026-06-02 00:00:00', extended_hours => false)
ORDER BY time;

Today's high/low for several symbols

SELECT c.symbol, max(c.high) AS day_high, min(c.low) AS day_low
FROM (VALUES ('SPY'), ('QQQ')) t(sym),
     LATERAL tastytrade.main.candles(t.sym, period => '1h') c
GROUP BY c.symbol;
Link
complex_orders (account_number := VARCHAR, live := BOOLEAN) 1 example

Complex (OCO, OTOCO, OTO) orders for an account with their child order ids (read-only)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
live := BOOLEAN
true for today's live complex orders instead of the complex-order history. · default false
Returns columns
id BIGINT
Complex order id.
account_number VARCHAR
Tastytrade account number.
type VARCHAR
Complex order type (OCO, OTOCO, OTO, …).
order_count INTEGER
Number of child orders.
order_ids VARCHAR[]
Ids of the child orders.
trigger_order_id BIGINT
Id of the triggering order (OTO/OTOCO); null if none.
statuses VARCHAR[]
Statuses of the child orders, in order.
terminal_at TIMESTAMP WITH TIME ZONE
When the complex order reached a terminal state (UTC); null while working.
ratio_price_threshold DECIMAL(38,12)
Ratio price threshold; null if unused.
Example

Bracket and OCO orders with the statuses of their child orders

SELECT id, type, order_count, statuses
FROM tastytrade.main.complex_orders();
Link
cryptocurrencies (symbol VARCHAR) 1 example

Cryptocurrency instrument reference data (description, tick size, streamer symbol)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
Cryptocurrency symbol (e.g. BTC/USD).
instrument_type VARCHAR
Instrument type (Cryptocurrency).
description VARCHAR
Description of the cryptocurrency.
short_description VARCHAR
Short description; null if none.
active BOOLEAN
True if the instrument is active.
is_closing_only BOOLEAN
True if only closing trades are allowed.
tick_size DOUBLE
Minimum tick size.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Example

Look up two cryptocurrencies

SELECT symbol, description
FROM (VALUES ('BTC/USD'), ('ETH/USD')) t(sym),
     LATERAL tastytrade.main.cryptocurrencies(t.sym);
Link
currency_pairs () 1 example

Enumerate currency pairs with their DXLink streamer symbols

No arguments
Returns columns
symbol VARCHAR
Currency pair symbol.
description VARCHAR
Description of the pair.
instrument_type VARCHAR
Instrument type (Currency Pair).
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Example

Every currency pair and the streamer symbol to quote it

SELECT symbol, description, streamer_symbol
FROM tastytrade.main.currency_pairs()
ORDER BY symbol;
Link
customer () 1 example

The authenticated customer's profile: name, email and account flags (no tax, address or financial data)

No arguments
Returns columns
first_name VARCHAR
Customer first name.
last_name VARCHAR
Customer last name.
email VARCHAR
Customer email address.
regulatory_domain VARCHAR
Regulatory domain of the customer (e.g. USA).
usa_citizenship_type VARCHAR
US citizenship type.
is_professional BOOLEAN
True if classified as a professional market-data subscriber.
has_delayed_quotes BOOLEAN
True if the customer receives delayed quotes.
agreed_to_margining BOOLEAN
True if the customer agreed to margin terms.
has_pending_or_approved_application BOOLEAN
True if an account application is pending or approved.
permitted_account_types VARCHAR[]
Account types the customer may open.
Example

Who the session belongs to and whether quotes are delayed

SELECT first_name, last_name, is_professional, has_delayed_quotes
FROM tastytrade.main.customer();
Link
dividends (symbol VARCHAR) 2 examples

Dividend history per symbol (ex-dividend date and amount)

Arguments
symbol VARCHAR
Symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Symbol the dividend was paid on.
occurred_date DATE
Date of the dividend event.
amount DECIMAL(38,12)
Dividend amount per share.
Examples (2)

SPY dividends since 2025

SELECT occurred_date, amount
FROM tastytrade.main.dividends('SPY')
WHERE occurred_date >= DATE '2025-01-01'
ORDER BY occurred_date;

Dividend income from current equity holdings over 2025

SELECT p.symbol, sum(d.amount * p.quantity) AS income_2025
FROM tastytrade.main.positions() p,
     LATERAL tastytrade.main.dividends(p.symbol) d
WHERE p.instrument_type = 'Equity' AND year(d.occurred_date) = 2025
GROUP BY p.symbol;
Link
earnings (symbol VARCHAR, start_date := DATE) 1 example

Reported earnings per share per symbol since a start date

Positional arguments
symbol VARCHAR
Symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Named arguments
start_date := DATE
Earliest report day to include; defaults to five years back. · default null
Returns columns
symbol VARCHAR
Symbol the earnings are for.
occurred_date DATE
Date of the earnings report.
eps DECIMAL(38,12)
Reported earnings per share.
normalized_eps DECIMAL(38,12)
Normalized earnings per share; null if unavailable.
Example

Apple's reported EPS since 2024

SELECT occurred_date, eps
FROM tastytrade.main.earnings('AAPL', start_date => DATE '2024-01-01')
ORDER BY occurred_date;
Link
earnings_report (symbol VARCHAR) 2 examples

Next (or latest) earnings report per symbol: expected date, time of day, consensus and actual EPS

Arguments
symbol VARCHAR
Symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Symbol the report is for.
expected_report_date DATE
Expected (or actual) date of the next earnings report.
time_of_day VARCHAR
When the report is released (BTO before open, AMC after close).
estimated BOOLEAN
True if the report date is an estimate.
visible BOOLEAN
True if the report is published as visible.
late_flag INTEGER
Late-report flag.
quarter_end_date DATE
Fiscal quarter end the report covers.
actual_eps DECIMAL(38,12)
Actual EPS of the most recent report; null before it is released.
consensus_estimate DECIMAL(38,12)
Consensus EPS estimate.
updated_at TIMESTAMP WITH TIME ZONE
When the report data was last updated (UTC).
Examples (2)

Upcoming earnings dates and consensus EPS

SELECT symbol, expected_report_date, time_of_day, consensus_estimate
FROM (VALUES ('AAPL'), ('MSFT')) t(s),
     LATERAL tastytrade.main.earnings_report(t.s)
ORDER BY expected_report_date;

When each holding next reports

SELECT p.symbol, e.expected_report_date
FROM (SELECT DISTINCT underlying_symbol AS symbol FROM tastytrade.main.positions()) p,
     LATERAL tastytrade.main.earnings_report(p.symbol) e
ORDER BY e.expected_report_date;
Link
equities (symbol VARCHAR) 3 examples

Equity instrument reference data (description, ETF/index flags, streamer symbol)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
Equity symbol.
instrument_type VARCHAR
Instrument type (Equity).
description VARCHAR
Human-readable description of the equity.
is_index BOOLEAN
True if the symbol represents an index.
is_etf BOOLEAN
True if the symbol is an ETF.
listed_market VARCHAR
Primary listing market; null if unknown.
lendability VARCHAR
Share lendability classification; null if unknown.
borrow_rate DOUBLE
Borrow rate for short selling; null if n/a.
active BOOLEAN
True if the instrument is active.
is_illiquid BOOLEAN
True if flagged as illiquid.
cusip VARCHAR
CUSIP identifier; null if unavailable.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Examples (3)

Look up one equity

SELECT symbol, description, is_etf FROM tastytrade.main.equities('SPY');

Look up a list of equities, one per input row

SELECT e.symbol, e.description, e.is_etf
FROM (VALUES ('SPY'), ('AAPL')) t(sym),
     LATERAL tastytrade.main.equities(t.sym) e;

Describe each equity position

SELECT p.symbol, p.quantity, e.description
FROM tastytrade.main.positions() p,
     LATERAL tastytrade.main.equities(p.symbol) e
WHERE p.instrument_type = 'Equity';
Link
future_contracts (product_code VARCHAR) 2 examples

Every listed futures contract of a product code (e.g. ES), one product per input row

Arguments
product_code VARCHAR
Future product code such as 'ES' or '/ES'. Pass a literal for one product, or a column (FROM t, f(t.code) or LATERAL) for one product per input row.
Returns columns
symbol VARCHAR
Future contract symbol.
instrument_type VARCHAR
Instrument type (Future).
product_code VARCHAR
Future product code (e.g. ES, CL).
expiration_date DATE
Expiration date of the contract.
last_trade_date DATE
Last trade date of the contract.
active_month BOOLEAN
True if this is the active contract month.
next_active_month BOOLEAN
True if this is the next active month.
notional_multiplier DOUBLE
Notional multiplier for the contract.
tick_size DOUBLE
Minimum tick size.
display_factor DOUBLE
Display factor for price formatting.
contract_size DOUBLE
Contract size; null if unknown.
exchange VARCHAR
Listing exchange; null if unknown.
product_group VARCHAR
Product group; null if unknown.
is_tradeable BOOLEAN
True if currently tradeable.
stops_trading_at TIMESTAMP WITH TIME ZONE
Timestamp trading stops (UTC); null if unknown.
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp (UTC); null if unknown.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Examples (2)

Every listed E-mini S&P 500 contract by expiration

SELECT symbol, expiration_date, active_month
FROM tastytrade.main.future_contracts('ES')
ORDER BY expiration_date;

The active-month contract of several products

SELECT p.code, f.symbol
FROM (VALUES ('ES'), ('CL')) p(code),
     LATERAL tastytrade.main.future_contracts(p.code) f
WHERE f.active_month;
Link
future_option_chain (underlying_symbol VARCHAR) 1 example

Flattened future-option chain for a future product (every expiration and strike)

Arguments
underlying_symbol VARCHAR
Underlying symbol whose chain to return. Pass a literal for one chain, or a column (FROM t, f(t.underlying_symbol) or LATERAL) for one chain per input row.
Returns columns
underlying_symbol VARCHAR
Underlying future symbol.
symbol VARCHAR
Future-option symbol.
root_symbol VARCHAR
Future-option root symbol.
option_root_symbol VARCHAR
Option root symbol.
expiration_date DATE
Expiration date of the option.
strike_price DECIMAL(38,12)
Strike price of the option.
option_type VARCHAR
Option type (C for call, P for put).
exchange VARCHAR
Listing exchange.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
days_to_expiration INTEGER
Calendar days until expiration.
exercise_style VARCHAR
Exercise style (American/European).
is_vanilla BOOLEAN
True if a vanilla option.
active BOOLEAN
True if the option is active.
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp (UTC); null if unknown.
Example

All listed /ES future-option contracts

SELECT expiration_date, strike_price, option_type, streamer_symbol
FROM tastytrade.main.future_option_chain('/ES');
Link
future_options (symbol VARCHAR) 1 example

Future-option reference data by symbol (strike, expiration, multiplier, streamer symbol)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
Future-option symbol.
underlying_symbol VARCHAR
Underlying future symbol.
product_code VARCHAR
Future-option product code.
root_symbol VARCHAR
Future root symbol (e.g. /ES).
option_root_symbol VARCHAR
Option root symbol.
option_type VARCHAR
Option type (C for call, P for put).
strike_price DECIMAL(38,12)
Strike price.
expiration_date DATE
Expiration date.
days_to_expiration INTEGER
Calendar days until expiration.
exercise_style VARCHAR
Exercise style (American/European).
settlement_type VARCHAR
Settlement type.
exchange VARCHAR
Listing exchange.
multiplier DOUBLE
Contract multiplier.
notional_value DOUBLE
Notional value per contract.
display_factor DOUBLE
Display factor for price formatting.
strike_factor DOUBLE
Strike factor.
maturity_date DATE
Maturity date of the underlying.
is_vanilla BOOLEAN
True if a vanilla option.
active BOOLEAN
True if the option is active.
stops_trading_at TIMESTAMP WITH TIME ZONE
When trading stops (UTC).
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp (UTC).
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Example

Reference data for three listed /ES options

SELECT o.symbol, o.strike_price, o.expiration_date, o.multiplier
FROM (SELECT symbol FROM tastytrade.main.future_option_chain('/ES') ORDER BY expiration_date, strike_price LIMIT 3) c,
     LATERAL tastytrade.main.future_options(c.symbol) o;
Link
futures (symbol VARCHAR) 1 example

Futures instrument reference data (product code, expiration, tick/notional, streamer symbol)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
Future contract symbol.
instrument_type VARCHAR
Instrument type (Future).
product_code VARCHAR
Future product code (e.g. ES, CL).
expiration_date DATE
Expiration date of the contract.
last_trade_date DATE
Last trade date of the contract.
active_month BOOLEAN
True if this is the active contract month.
next_active_month BOOLEAN
True if this is the next active month.
notional_multiplier DOUBLE
Notional multiplier for the contract.
tick_size DOUBLE
Minimum tick size.
display_factor DOUBLE
Display factor for price formatting.
contract_size DOUBLE
Contract size; null if unknown.
exchange VARCHAR
Listing exchange; null if unknown.
product_group VARCHAR
Product group; null if unknown.
is_tradeable BOOLEAN
True if currently tradeable.
stops_trading_at TIMESTAMP WITH TIME ZONE
Timestamp trading stops (UTC); null if unknown.
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp (UTC); null if unknown.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Example

Look up an E-mini S&P future

SELECT symbol, product_code, expiration_date
FROM tastytrade.main.futures('/ESZ6');
Link
greeks (streamer_symbol VARCHAR) 2 examples

One-shot live option greeks snapshot for streamer symbols (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Streamer symbol the greeks are for.
price DECIMAL(38,12)
Theoretical option price.
volatility DOUBLE
Implied volatility used for the greeks.
delta DOUBLE
Option delta.
gamma DOUBLE
Option gamma.
theta DOUBLE
Option theta.
vega DOUBLE
Option vega.
rho DOUBLE
Option rho.
event_time BIGINT
DXLink event time (epoch ms); 0 if unknown.
sequence BIGINT
DXLink sequence number.
Examples (2)

Latest greeks for one listed option contract

SELECT g.symbol, g.delta, g.theta, g.volatility
FROM (SELECT streamer_symbol FROM tastytrade.main.option_chain('SPY') WHERE option_type = 'C' ORDER BY expiration_date, strike_price LIMIT 1) c,
     LATERAL tastytrade.main.greeks(c.streamer_symbol) g;

Greeks for the five nearest SPY calls, joined to the chain

SELECT c.strike_price, g.delta, g.volatility
FROM (SELECT * FROM tastytrade.main.option_chain('SPY') WHERE option_type = 'C' ORDER BY expiration_date, strike_price LIMIT 5) c,
     LATERAL tastytrade.main.greeks(c.streamer_symbol) g;
Link
margin_requirements (account_number := VARCHAR) 1 example

Current margin requirements for an account (requirement, equity, buying power, excess)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
Returns columns
account_number VARCHAR
Tastytrade account number.
description VARCHAR
Margin calculation description.
margin_calculation_type VARCHAR
Margin calculation type.
option_level VARCHAR
Option trading level.
margin_requirement DECIMAL(38,12)
Total margin requirement.
maintenance_requirement DECIMAL(38,12)
Maintenance margin requirement.
margin_equity DECIMAL(38,12)
Margin equity.
option_buying_power DECIMAL(38,12)
Option buying power.
reg_t_margin_requirement DECIMAL(38,12)
Reg-T margin requirement.
reg_t_option_buying_power DECIMAL(38,12)
Reg-T option buying power.
maintenance_excess DECIMAL(38,12)
Maintenance excess (cushion).
initial_requirement DECIMAL(38,12)
Initial margin requirement; null if n/a.
Example

Margin snapshot for the default account

SELECT margin_requirement, maintenance_excess, option_buying_power
FROM tastytrade.main.margin_requirements();
Link
market_calendar (exchange := VARCHAR) 2 examples

Equity market holidays (closed) and half-days (early close)

Named arguments
exchange := VARCHAR
Which calendar: 'Equity' (NYSE, the default), or the futures exchanges 'CME' or 'CFE'. · default "Equity"
Returns columns
date DATE
Calendar date.
day_type VARCHAR
Either 'holiday' (market closed) or 'half_day' (early close).
Examples (2)

Upcoming and past market holidays

SELECT date
FROM tastytrade.main.market_calendar()
WHERE day_type = 'holiday'
ORDER BY date;

CME futures holidays and early closes

SELECT date, day_type
FROM tastytrade.main.market_calendar(exchange => 'CME')
ORDER BY date;
Link
market_metrics (symbol VARCHAR) 2 examples

Market metrics per symbol: IV rank/percentile, beta, HV, liquidity, dividends

Arguments
symbol VARCHAR
Underlying symbol to fetch metrics for. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Underlying symbol.
implied_volatility_index DOUBLE
Current implied volatility index value.
implied_volatility_index_rank DOUBLE
IV index rank (0-1) over the trailing year.
implied_volatility_percentile DOUBLE
IV percentile (0-1) over the trailing year.
implied_volatility_30_day DOUBLE
30-day implied volatility.
historical_volatility_30_day DOUBLE
30-day historical volatility.
historical_volatility_60_day DOUBLE
60-day historical volatility.
historical_volatility_90_day DOUBLE
90-day historical volatility.
iv_hv_30_day_difference DOUBLE
IV minus HV over 30 days.
beta DOUBLE
Beta versus the broad market; null if unknown.
corr_spy_3month DOUBLE
3-month correlation with SPY; null if unknown.
market_cap DECIMAL(38,12)
Market capitalization; null if unknown.
price_earnings_ratio DOUBLE
Price/earnings ratio; null if unknown.
earnings_per_share DECIMAL(38,12)
Earnings per share; null if unknown.
dividend_rate_per_share DECIMAL(38,12)
Dividend rate per share; null if none.
dividend_yield DOUBLE
Dividend yield; null if none.
liquidity_rating INTEGER
Liquidity rating bucket; null if unknown.
liquidity_rank DOUBLE
Liquidity rank; null if unknown.
liquidity_value DOUBLE
Liquidity value; null if unknown.
lendability VARCHAR
Share lendability classification; null if unknown.
borrow_rate DOUBLE
Borrow rate for short selling; null if n/a.
updated_at TIMESTAMP WITH TIME ZONE
Timestamp the metrics were last updated (UTC).
Examples (2)

IV rank and beta for one symbol

SELECT symbol, implied_volatility_index_rank, beta
FROM tastytrade.main.market_metrics('SPY');

IV rank for every underlying held, highest first

SELECT m.symbol, m.implied_volatility_index_rank
FROM (SELECT DISTINCT underlying_symbol AS sym FROM tastytrade.main.positions()) p,
     LATERAL tastytrade.main.market_metrics(p.sym) m
ORDER BY m.implied_volatility_index_rank DESC;
Link
market_sessions (exchanges := VARCHAR[]) 1 example

Current market status and session timing for exchanges (Equity/CME/CFE)

Named arguments
exchanges := VARCHAR[]
Exchanges to report: 'Equity' (NYSE), 'CME', or 'CFE'. Defaults to ['Equity']. · default ["Equity"]
Returns columns
instrument_collection VARCHAR
Instrument collection / exchange (Equity, CME, CFE).
status VARCHAR
Current market status (Open, Closed, Pre-market, Extended).
open_at TIMESTAMP WITH TIME ZONE
Regular session open (UTC); null if not in session.
close_at TIMESTAMP WITH TIME ZONE
Regular session close (UTC); null if not in session.
close_at_ext TIMESTAMP WITH TIME ZONE
Extended session close (UTC); null if n/a.
next_session_date DATE
Date of the next session; null if unknown.
next_open_at TIMESTAMP WITH TIME ZONE
Next session open (UTC); null if unknown.
next_close_at TIMESTAMP WITH TIME ZONE
Next session close (UTC); null if unknown.
Example

Is the equities market open, and when does it next open?

SELECT instrument_collection, status, next_open_at
FROM tastytrade.main.market_sessions();
Link
market_snapshot (symbol VARCHAR, instrument_type := VARCHAR) 2 examples

REST market-data snapshot per symbol (bid/ask/mark/last, day OHLC, volume); works in sandbox

Positional arguments
symbol VARCHAR
Symbol to snapshot. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Named arguments
instrument_type := VARCHAR
Instrument type of the symbols: one of equity, option, future, future_option, index, cryptocurrency. Defaults to 'equity'. · default "equity"
Returns columns
symbol VARCHAR
Instrument symbol.
updated_at TIMESTAMP WITH TIME ZONE
Timestamp the snapshot was last updated (UTC).
bid DECIMAL(38,12)
Best bid price; null if unavailable.
ask DECIMAL(38,12)
Best ask price; null if unavailable.
mark DECIMAL(38,12)
Mark price (mid of bid/ask); null if unavailable.
last DECIMAL(38,12)
Last trade price; null if unavailable.
mid DECIMAL(38,12)
Midpoint price; null if unavailable.
bid_size DOUBLE
Size at the bid.
ask_size DOUBLE
Size at the ask.
day_open DECIMAL(38,12)
Day open price; null if unavailable.
day_high DECIMAL(38,12)
Day high price; null if unavailable.
day_low DECIMAL(38,12)
Day low price; null if unavailable.
day_close DECIMAL(38,12)
Day close price; null if unavailable.
prev_close DECIMAL(38,12)
Previous close price; null if unavailable.
volume DOUBLE
Day volume; null if unavailable.
open_interest DOUBLE
Open interest (options/futures); null if n/a.
year_high_price DECIMAL(38,12)
52-week high; null if unavailable.
year_low_price DECIMAL(38,12)
52-week low; null if unavailable.
Examples (2)

Snapshot bid/ask/last and day range for one equity

SELECT symbol, bid, ask, last, day_high, day_low
FROM tastytrade.main.market_snapshot('SPY');

Current mark for every equity position

SELECT p.symbol, p.quantity, s.mark
FROM tastytrade.main.positions() p,
     LATERAL tastytrade.main.market_snapshot(p.symbol, instrument_type => 'equity') s
WHERE p.instrument_type = 'Equity';
Link
nested_future_option_chain (underlying_symbol VARCHAR) 1 example

Compact future-option chain for a future product: one row per (expiration, strike) with call and put

Arguments
underlying_symbol VARCHAR
Future product whose option chain to return, e.g. '/ES'. Pass a literal for one chain, or a column (FROM t, f(t.underlying_symbol) or LATERAL) for one chain per input row.
Returns columns
underlying_symbol VARCHAR
Underlying future contract symbol.
root_symbol VARCHAR
Future root symbol (e.g. /ES).
option_root_symbol VARCHAR
Option root symbol (e.g. EW3).
expiration_date DATE
Expiration date.
expiration_type VARCHAR
Expiration type (Regular, Weekly, …).
settlement_type VARCHAR
Settlement type.
days_to_expiration INTEGER
Calendar days until expiration.
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp (UTC).
strike_price DECIMAL(38,12)
Strike price.
call VARCHAR
Call symbol at this strike.
put VARCHAR
Put symbol at this strike.
call_streamer_symbol VARCHAR
DXLink streamer symbol for the call.
put_streamer_symbol VARCHAR
DXLink streamer symbol for the put.
Example

Strike counts for the nearest /ES option expirations

SELECT option_root_symbol, expiration_date, count(*) AS strikes
FROM tastytrade.main.nested_future_option_chain('/ES')
GROUP BY ALL
ORDER BY expiration_date
LIMIT 10;
Link
nested_option_chain (underlying_symbol VARCHAR) 1 example

Compact option chain for an underlying: one row per (expiration, strike) with call and put

Arguments
underlying_symbol VARCHAR
Underlying symbol whose chain to return. Pass a literal for one chain, or a column (FROM t, f(t.underlying_symbol) or LATERAL) for one chain per input row.
Returns columns
underlying_symbol VARCHAR
Underlying symbol of the chain.
root_symbol VARCHAR
Option root symbol.
expiration_date DATE
Expiration date.
expiration_type VARCHAR
Expiration type (Regular, Weekly, etc.).
days_to_expiration INTEGER
Calendar days until expiration.
strike_price DECIMAL(38,12)
Strike price.
call VARCHAR
Call OCC symbol at this strike.
put VARCHAR
Put OCC symbol at this strike.
call_streamer_symbol VARCHAR
DXLink streamer symbol for the call.
put_streamer_symbol VARCHAR
DXLink streamer symbol for the put.
Example

Calls and puts side by side per strike

SELECT expiration_date, strike_price, call, put
FROM tastytrade.main.nested_option_chain('SPY');
Link
nlv_history (account_number := VARCHAR, lookback := INTERVAL) 2 examples

Net liquidating value OHLC history for an account over a time window

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
lookback := INTERVAL
How far back to look, e.g. lookback => '6 months'; defaults to one year. · default null
Returns columns
account_number VARCHAR
Tastytrade account number.
time TIMESTAMP WITH TIME ZONE
Timestamp of this OHLC bucket (UTC).
open DECIMAL(38,12)
Net liquidating value at the open of the bucket.
high DECIMAL(38,12)
Highest net liquidating value during the bucket.
low DECIMAL(38,12)
Lowest net liquidating value during the bucket.
close DECIMAL(38,12)
Net liquidating value at the close of the bucket.
total_open DECIMAL(38,12)
Total value (incl. pending cash) at open.
total_high DECIMAL(38,12)
Total value high during the bucket.
total_low DECIMAL(38,12)
Total value low during the bucket.
total_close DECIMAL(38,12)
Total value at close.
Examples (2)

Six months of daily net-liq closes

SELECT time, close
FROM tastytrade.main.nlv_history(lookback => INTERVAL '6 months')
ORDER BY time;

Default one-year history for the default account

SELECT time, close FROM tastytrade.main.nlv_history() ORDER BY time;
Link
option_chain (underlying_symbol VARCHAR) 3 examples

Flattened option chain for an underlying (every expiration and strike)

Arguments
underlying_symbol VARCHAR
Underlying symbol whose chain to return. Pass a literal for one chain, or a column (FROM t, f(t.underlying_symbol) or LATERAL) for one chain per input row.
Returns columns
underlying_symbol VARCHAR
Underlying symbol of the chain.
expiration_date DATE
Expiration date of the option.
strike_price DECIMAL(38,12)
Strike price of the option.
option_type VARCHAR
Option type (C for call, P for put).
symbol VARCHAR
OCC option symbol.
root_symbol VARCHAR
Option root symbol.
days_to_expiration INTEGER
Calendar days until expiration.
shares_per_contract INTEGER
Shares deliverable per contract.
settlement_type VARCHAR
Settlement type; null if unknown.
expiration_type VARCHAR
Expiration type (Regular, Weekly, etc.).
exercise_style VARCHAR
Exercise style (American/European).
active BOOLEAN
True if the option is active.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Examples (3)

All listed SPY option contracts

SELECT expiration_date, strike_price, option_type
FROM tastytrade.main.option_chain('SPY');

Streamer symbols for the nearest call contracts (join to greeks())

SELECT expiration_date, streamer_symbol
FROM tastytrade.main.option_chain('SPY')
WHERE option_type = 'C'
ORDER BY expiration_date, strike_price
LIMIT 10;

Listed contract count for several underlyings, one chain per input row

SELECT u.sym, count(*) AS contracts
FROM (VALUES ('SPY'), ('QQQ')) u(sym),
     LATERAL tastytrade.main.option_chain(u.sym) c
GROUP BY u.sym;
Link
option_expiration_iv (symbol VARCHAR) 1 example

Implied volatility per option expiration for a symbol (the IV term structure)

Arguments
symbol VARCHAR
Symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Underlying symbol.
expiration_date DATE
Option expiration date.
option_chain_type VARCHAR
Option chain type (Standard, Non-standard).
settlement_type VARCHAR
Settlement type (AM/PM).
implied_volatility DOUBLE
Implied volatility of the expiration; null if unavailable.
Example

SPY's IV term structure

SELECT expiration_date, implied_volatility
FROM tastytrade.main.option_expiration_iv('SPY')
WHERE option_chain_type = 'Standard'
ORDER BY expiration_date;
Link
options (symbol VARCHAR) 2 examples

Option instrument reference data by OCC symbol (strike, expiration, streamer symbol)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
OCC option symbol.
instrument_type VARCHAR
Instrument type (Equity Option).
underlying_symbol VARCHAR
Underlying equity symbol.
root_symbol VARCHAR
Option root symbol.
option_type VARCHAR
Option type (C for call, P for put).
strike_price DECIMAL(38,12)
Strike price of the option.
expiration_date DATE
Expiration date of the option.
days_to_expiration INTEGER
Calendar days until expiration.
exercise_style VARCHAR
Exercise style (American/European).
shares_per_contract INTEGER
Shares deliverable per contract.
option_chain_type VARCHAR
Option chain type (Standard, etc.).
expiration_type VARCHAR
Expiration type (Regular, Weekly, etc.).
settlement_type VARCHAR
Settlement type; null if unknown.
active BOOLEAN
True if the option is active.
streamer_symbol VARCHAR
DXLink streamer symbol for live market data.
Examples (2)

Look up a listed option contract by its OCC symbol

SELECT o.symbol, o.strike_price, o.expiration_date
FROM (SELECT symbol FROM tastytrade.main.option_chain('SPY') ORDER BY expiration_date, strike_price LIMIT 1) c,
     LATERAL tastytrade.main.options(c.symbol) o;

Strike and expiry for every option position

SELECT p.symbol, o.strike_price, o.expiration_date, o.days_to_expiration
FROM tastytrade.main.positions() p,
     LATERAL tastytrade.main.options(p.symbol) o
WHERE p.instrument_type = 'Equity Option';
Link
order_legs (account_number := VARCHAR, end_date := DATE, live := BOOLEAN, start_date := DATE, status := VARCHAR, underlying_symbol := VARCHAR) 1 example

Legs of each order with their fills aggregated (filled quantity, average fill price), read-only

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
end_date := DATE
Latest order day to include (history only); null for no upper bound. · default null
live := BOOLEAN
true for today's live orders (working and recently completed) instead of the order history. · default false
start_date := DATE
Earliest order day to include (history only); null for no lower bound. · default null
status := VARCHAR
Only orders with this status (history only), e.g. 'Filled' or 'Cancelled'; empty for all. · default ""
underlying_symbol := VARCHAR
Only orders on this underlying symbol (history only); empty for all. · default ""
Returns columns
order_id BIGINT
Order id the leg belongs to.
account_number VARCHAR
Tastytrade account number.
leg_index INTEGER
Position of the leg within its order (0-based).
symbol VARCHAR
Instrument symbol of the leg.
instrument_type VARCHAR
Instrument type of the leg.
action VARCHAR
Leg action (Buy to Open, Sell to Close, Buy, Sell, …).
quantity DOUBLE
Ordered quantity.
remaining_quantity DOUBLE
Quantity not yet filled.
fill_count INTEGER
Number of fills.
filled_quantity DOUBLE
Total filled quantity.
average_fill_price DECIMAL(38,12)
Quantity-weighted average fill price; null if unfilled.
first_filled_at TIMESTAMP WITH TIME ZONE
Time of the first fill (UTC); null if unfilled.
last_filled_at TIMESTAMP WITH TIME ZONE
Time of the last fill (UTC); null if unfilled.
order_status VARCHAR
Status of the parent order.
underlying_symbol VARCHAR
Underlying symbol of the parent order.
Example

The twenty most recently filled legs with their average fill price

SELECT order_id, symbol, action, filled_quantity, average_fill_price
FROM tastytrade.main.order_legs(status => 'Filled')
ORDER BY last_filled_at DESC
LIMIT 20;
Link
orders (account_number := VARCHAR, end_date := DATE, live := BOOLEAN, start_date := DATE, status := VARCHAR, underlying_symbol := VARCHAR) 3 examples

Order history (or today's live orders) for an account, one row per order (read-only)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
end_date := DATE
Latest order day to include (history only); null for no upper bound. · default null
live := BOOLEAN
true for today's live orders (working and recently completed) instead of the order history. · default false
start_date := DATE
Earliest order day to include (history only); null for no lower bound. · default null
status := VARCHAR
Only orders with this status (history only), e.g. 'Filled' or 'Cancelled'; empty for all. · default ""
underlying_symbol := VARCHAR
Only orders on this underlying symbol (history only); empty for all. · default ""
Returns columns
id BIGINT
Order id.
account_number VARCHAR
Tastytrade account number.
underlying_symbol VARCHAR
Underlying symbol of the order.
underlying_instrument_type VARCHAR
Instrument type of the underlying (Equity, Future, …).
order_type VARCHAR
Order type (Limit, Market, Stop, Stop Limit, Notional Market).
time_in_force VARCHAR
Time in force (Day, GTC, GTD, Ext, …).
status VARCHAR
Order status (Received, Live, Filled, Cancelled, Rejected, Expired, …).
size DOUBLE
Order size (quantity of the order as a whole).
price DECIMAL(38,12)
Limit price, signed: negative for a debit; null for market orders.
value DECIMAL(38,12)
Notional value for notional orders, signed; null otherwise.
stop_trigger DECIMAL(38,12)
Stop trigger price; null if none.
gtc_date DATE
Good-till date for GTD orders; null otherwise.
leg_count INTEGER
Number of legs.
legs VARCHAR
Human-readable leg summary, e.g. 'Buy to Open 1 SPY'.
cancellable BOOLEAN
True if the order can still be cancelled.
editable BOOLEAN
True if the order can still be edited.
edited BOOLEAN
True if the order was edited (replaced).
received_at TIMESTAMP WITH TIME ZONE
When tastytrade received the order (UTC).
updated_at TIMESTAMP WITH TIME ZONE
When the order last changed (UTC).
terminal_at TIMESTAMP WITH TIME ZONE
When the order reached a terminal status (UTC); null while working.
cancelled_at TIMESTAMP WITH TIME ZONE
When the order was cancelled (UTC); null if not cancelled.
reject_reason VARCHAR
Rejection reason; null unless rejected.
complex_order_id VARCHAR
Parent complex (OCO/OTOCO) order id; null if standalone.
replaces_order_id BIGINT
Id of the order this one replaced; null if none.
replacing_order_id BIGINT
Id of the order that replaced this one; null if none.
source VARCHAR
Client that placed the order.
Examples (3)

Orders since the start of November, newest first

SELECT received_at, underlying_symbol, order_type, status, price, legs
FROM tastytrade.main.orders(start_date => DATE '2026-11-01')
ORDER BY received_at DESC;

Today's live and recently completed orders

SELECT id, underlying_symbol, status, legs
FROM tastytrade.main.orders(live => true);

How many orders ended in each status

SELECT status, count(*) AS orders
FROM tastytrade.main.orders()
GROUP BY status
ORDER BY orders DESC;
Link
pairs_watchlists () 1 example

Entries in Tastytrade's public pairs watchlists (one row per pair trade)

No arguments
Returns columns
watchlist VARCHAR
Pairs watchlist name.
left_action VARCHAR
Action on the left leg (Buy/Sell).
left_symbol VARCHAR
Left-leg symbol.
left_quantity INTEGER
Left-leg quantity.
right_action VARCHAR
Action on the right leg (Buy/Sell).
right_symbol VARCHAR
Right-leg symbol.
right_quantity INTEGER
Right-leg quantity.
Example

Every published pair trade

SELECT watchlist, left_symbol, right_symbol, left_quantity, right_quantity
FROM tastytrade.main.pairs_watchlists()
ORDER BY watchlist, left_symbol;
Link
positions (account_number := VARCHAR, include_closed := BOOLEAN, include_marks := BOOLEAN, net_positions := BOOLEAN) 3 examples

Open positions for an account (symbol, quantity, mark, P/L)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
include_closed := BOOLEAN
Also return positions closed today (quantity 0). Defaults to false. · default false
include_marks := BOOLEAN
Ask the API to fill mark and mark_price with current quote marks (slower). Defaults to false. · default false
net_positions := BOOLEAN
Net positions in the same symbol across instrument types into one row. Defaults to false. · default false
Returns columns
account_number VARCHAR
Tastytrade account number.
symbol VARCHAR
Instrument symbol of the position.
instrument_type VARCHAR
Instrument type (Equity, Equity Option, Future, etc.).
underlying_symbol VARCHAR
Underlying symbol; null for non-derivatives.
quantity DOUBLE
Position quantity.
quantity_direction VARCHAR
Direction of the quantity (Long, Short, Zero).
average_open_price DECIMAL(38,12)
Average price at which the position was opened.
close_price DECIMAL(38,12)
Reference close price used for valuation.
mark DECIMAL(38,12)
Current mark value of the position; null if unavailable.
mark_price DECIMAL(38,12)
Current mark price per unit; null if unavailable.
multiplier DOUBLE
Contract multiplier.
cost_effect VARCHAR
Cost effect (Credit/Debit) of the position.
realized_day_gain DECIMAL(38,12)
Realized gain/loss for the current day.
realized_today DECIMAL(38,12)
Realized gain/loss booked today.
expires_at TIMESTAMP WITH TIME ZONE
Expiration timestamp for derivatives (UTC); null otherwise.
updated_at TIMESTAMP WITH TIME ZONE
Timestamp the position was last updated (UTC).
Examples (3)

Positions for the default account

SELECT symbol, quantity, quantity_direction
FROM tastytrade.main.positions();

Only option positions

SELECT symbol, quantity, mark
FROM tastytrade.main.positions()
WHERE instrument_type = 'Equity Option';

Positions with current quote marks filled in

SELECT symbol, quantity, mark_price
FROM tastytrade.main.positions(include_marks => true);
Link
profiles (streamer_symbol VARCHAR) 1 example

Live instrument profile per streamer symbol: trading status, halts, 52-week range, shares, dividends (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Streamer symbol.
description VARCHAR
Instrument description.
trading_status VARCHAR
Trading status (Active, Halted, Undefined).
status_reason VARCHAR
Reason for the trading status; null if none.
short_sale_restriction VARCHAR
Short-sale restriction (Active, Inactive, Undefined).
halt_start_time BIGINT
Halt start (epoch ms); 0 if not halted.
halt_end_time BIGINT
Halt end (epoch ms); 0 if not halted.
high_52_week_price DECIMAL(38,12)
52-week high price.
low_52_week_price DECIMAL(38,12)
52-week low price.
beta DOUBLE
Beta.
shares DOUBLE
Shares outstanding.
free_float DOUBLE
Free-float shares.
earnings_per_share DECIMAL(38,12)
Earnings per share.
ex_dividend_amount DECIMAL(38,12)
Most recent ex-dividend amount.
ex_dividend_day_id BIGINT
Most recent ex-dividend day (days since epoch).
dividend_frequency DOUBLE
Dividend payments per year.
high_limit_price DECIMAL(38,12)
Limit-up price; null if none.
low_limit_price DECIMAL(38,12)
Limit-down price; null if none.
Example

Trading status and 52-week range for two symbols

SELECT symbol, trading_status, high_52_week_price, low_52_week_price, shares
FROM (VALUES ('SPY'), ('AAPL')) t(s),
     LATERAL tastytrade.main.profiles(t.s);
Link
public_watchlists () 1 example

Entries in Tastytrade's public watchlists (one row per symbol)

No arguments
Returns columns
watchlist VARCHAR
Watchlist name.
group_name VARCHAR
Watchlist group name.
symbol VARCHAR
Symbol in the watchlist.
instrument_type VARCHAR
Instrument type of the entry; null if unspecified.
Example

Names of the available public watchlists

SELECT DISTINCT watchlist
FROM tastytrade.main.public_watchlists()
ORDER BY watchlist;
Link
quantity_precisions () 1 example

Decimal places allowed in order quantities, per instrument type and symbol

No arguments
Returns columns
instrument_type VARCHAR
Instrument type the precision applies to.
symbol VARCHAR
Symbol the precision applies to; null for the instrument type's default.
value INTEGER
Decimal places allowed in an order quantity.
minimum_increment_precision INTEGER
Decimal places of the minimum quantity increment.
Example

Allowed quantity decimals for each cryptocurrency

SELECT instrument_type, symbol, value
FROM tastytrade.main.quantity_precisions()
WHERE instrument_type = 'Cryptocurrency'
ORDER BY symbol;
Link
quotes (streamer_symbol VARCHAR) 2 examples

One-shot live bid/ask snapshot for streamer symbols (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Streamer symbol the quote is for.
bid_price DECIMAL(38,12)
Best bid price; null if no quote received.
ask_price DECIMAL(38,12)
Best ask price; null if no quote received.
bid_size DOUBLE
Size available at the bid.
ask_size DOUBLE
Size available at the ask.
bid_exchange_code VARCHAR
Exchange code for the bid; null if unknown.
ask_exchange_code VARCHAR
Exchange code for the ask; null if unknown.
event_time BIGINT
DXLink event time (epoch ms); 0 if unknown.
sequence BIGINT
DXLink sequence number.
Examples (2)

Latest bid/ask for one equity

SELECT symbol, bid_price, ask_price FROM tastytrade.main.quotes('SPY');

Latest bid/ask for several equities (one shared capture)

SELECT q.symbol, q.bid_price, q.ask_price
FROM (VALUES ('SPY'), ('QQQ')) t(sym),
     LATERAL tastytrade.main.quotes(t.sym) q;
Link
risk_free_rate () 1 example

The current risk-free interest rate tastytrade uses (public; no credentials needed)

No arguments
Returns columns
risk_free_rate DOUBLE
Current risk-free interest rate used by tastytrade (annualized).
Example

The rate to use when pricing options

SELECT risk_free_rate FROM tastytrade.main.risk_free_rate();
Link
summaries (streamer_symbol VARCHAR) 2 examples

One-shot live daily summary per streamer symbol: day open/high/low/close, previous close, open interest (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Streamer symbol.
day_open_price DECIMAL(38,12)
Day open price; null if not yet traded.
day_high_price DECIMAL(38,12)
Day high price.
day_low_price DECIMAL(38,12)
Day low price.
day_close_price DECIMAL(38,12)
Day close price (or last, intraday).
day_close_price_type VARCHAR
Day close price type (Regular, Indicative, Preliminary, Final).
prev_day_close_price DECIMAL(38,12)
Previous day's close price.
prev_day_close_price_type VARCHAR
Previous day's close price type.
prev_day_volume DOUBLE
Previous day's volume.
open_interest BIGINT
Open interest (options/futures); 0 for equities.
day_id BIGINT
DXLink day identifier (days since epoch).
event_time BIGINT
DXLink event time (epoch ms); 0 if unknown.
Examples (2)

Today's range and the previous close for two ETFs

SELECT symbol, day_open_price, day_high_price, day_low_price,
  prev_day_close_price
FROM (VALUES ('SPY'), ('QQQ')) t(s),
     LATERAL tastytrade.main.summaries(t.s);

Open interest for the five nearest SPY calls

SELECT c.strike_price, s.open_interest
FROM (SELECT * FROM tastytrade.main.option_chain('SPY') WHERE option_type = 'C' ORDER BY expiration_date, strike_price LIMIT 5) c,
     LATERAL tastytrade.main.summaries(c.streamer_symbol) s;
Link
theo_prices (streamer_symbol VARCHAR) 1 example

Live theoretical option price per streamer symbol, with the underlying price, delta and gamma used (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Option streamer symbol.
price DECIMAL(38,12)
Theoretical option price.
underlying_price DECIMAL(38,12)
Underlying price used for the theoretical price.
delta DOUBLE
Delta used by the pricing model.
gamma DOUBLE
Gamma used by the pricing model.
dividend DOUBLE
Implied dividend used by the pricing model.
interest DOUBLE
Implied interest rate used by the pricing model.
time TIMESTAMP WITH TIME ZONE
Event time (UTC).
Example

Theoretical prices of the three nearest SPY calls

SELECT t.symbol, t.price, t.underlying_price, t.delta
FROM (SELECT streamer_symbol FROM tastytrade.main.option_chain('SPY') WHERE option_type = 'C' ORDER BY expiration_date, strike_price LIMIT 3) c,
     LATERAL tastytrade.main.theo_prices(c.streamer_symbol) t;
Link
time_and_sales (streamer_symbol VARCHAR, duration := DOUBLE) 1 example

Live time & sale trade prints for streamer symbols over a capture window (DXLink)

Positional arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Named arguments
duration := DOUBLE
Capture window in seconds (0.5 to 60). Time & sale is a live feed, so this collects trades that print during the window. Defaults to 5. · default 5
Returns columns
symbol VARCHAR
Streamer symbol the trade is for.
time TIMESTAMP WITH TIME ZONE
Timestamp of the trade print (UTC).
price DECIMAL(38,12)
Trade price.
size BIGINT
Trade size.
bid_price DECIMAL(38,12)
Prevailing bid at the time of the trade; null if n/a.
ask_price DECIMAL(38,12)
Prevailing ask at the time of the trade; null if n/a.
exchange_code VARCHAR
Exchange code where the trade printed.
aggressor_side VARCHAR
Aggressor side (Buy/Sell/Undefined).
extended_trading_hours BOOLEAN
True if the trade occurred in extended hours.
Example

Capture 5 seconds of SPY trade prints

SELECT time, price, size, exchange_code
FROM tastytrade.main.time_and_sales('SPY', duration => 5)
ORDER BY time;
Link
total_fees (account_number := VARCHAR, day := DATE) 1 example

Total fees charged to an account on a given day (defaults to today)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
day := DATE
Day to total fees for; defaults to today (New York). · default null
Returns columns
account_number VARCHAR
Tastytrade account number.
day DATE
The date the fees are for.
total_fees DECIMAL(38,12)
Total fees for the day.
Example

Total fees for a specific day

SELECT day, total_fees
FROM tastytrade.main.total_fees(day => DATE '2026-06-30');
Link
trades (streamer_symbol VARCHAR) 1 example

Live last trade per streamer symbol: price, size, change, day volume and turnover (DXLink)

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Streamer symbol.
price DECIMAL(38,12)
Last trade price.
change DECIMAL(38,12)
Change from the previous close.
size BIGINT
Last trade size.
day_volume DOUBLE
Day volume.
day_turnover DOUBLE
Day turnover (traded value).
exchange_code VARCHAR
Exchange of the last trade.
tick_direction VARCHAR
Tick direction (Up, Down, Zero up, Zero down, Undefined).
extended_trading_hours BOOLEAN
True if the last trade was in extended hours.
time TIMESTAMP WITH TIME ZONE
Time of the last trade (UTC).
Example

Last trade and day volume for SPY and an /ES contract

SELECT symbol, price, change, day_volume
FROM (VALUES ('SPY'), ('/ESZ26:XCME')) t(s),
     LATERAL tastytrade.main.trades(t.s);
Link
trading_status (account_number := VARCHAR) 1 example

Trading status and permissions for an account (levels, PDT, margin call, enabled products)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
Returns columns
account_number VARCHAR
Tastytrade account number.
options_level VARCHAR
Approved options trading level.
is_closed BOOLEAN
True if the account is closed.
is_frozen BOOLEAN
True if the account is frozen.
is_closing_only BOOLEAN
True if the account is restricted to closing trades.
is_in_margin_call BOOLEAN
True if the account is in a margin call.
is_pattern_day_trader BOOLEAN
True if flagged as a pattern day trader.
day_trade_count INTEGER
Rolling day-trade count; null if n/a.
is_futures_enabled BOOLEAN
True if futures trading is enabled.
is_cryptocurrency_enabled BOOLEAN
True if cryptocurrency trading is enabled.
is_portfolio_margin_enabled BOOLEAN
True if portfolio margin is enabled; null if n/a.
short_calls_enabled BOOLEAN
True if short calls are enabled.
updated_at TIMESTAMP WITH TIME ZONE
Timestamp the trading status was last updated (UTC).
Example

Permissions for the default account

SELECT options_level, is_pattern_day_trader, is_in_margin_call
FROM tastytrade.main.trading_status();
Link
transactions (account_number := VARCHAR, action := VARCHAR, end_date := DATE, start_date := DATE, symbol := VARCHAR, transaction_type := VARCHAR, underlying_symbol := VARCHAR) 2 examples

Transaction history for an account (trades, fees, money movement)

Named arguments
account_number := VARCHAR
Account number; defaults to the ATTACH account_number option, else all accounts. · default ""
action := VARCHAR
Only this order action, e.g. 'Buy to Open'; empty for all. · default ""
end_date := DATE
Latest transaction day to include; null for no upper bound. · default null
start_date := DATE
Earliest transaction day to include; null for no lower bound. · default null
symbol := VARCHAR
Only transactions in this instrument symbol; empty for all. · default ""
transaction_type := VARCHAR
Only this transaction type, e.g. 'Trade' or 'Money Movement'; empty for all. · default ""
underlying_symbol := VARCHAR
Only transactions on this underlying symbol; empty for all. · default ""
Returns columns
id BIGINT
Unique transaction id.
account_number VARCHAR
Tastytrade account number.
transaction_type VARCHAR
High-level transaction type (Trade, Money Movement, etc.).
transaction_sub_type VARCHAR
Transaction sub-type; null if none.
description VARCHAR
Human-readable description of the transaction.
action VARCHAR
Order action (Buy to Open, Sell to Close, etc.); null if n/a.
symbol VARCHAR
Instrument symbol; null if not instrument-specific.
instrument_type VARCHAR
Instrument type; null if not instrument-specific.
underlying_symbol VARCHAR
Underlying symbol; null if n/a.
quantity DOUBLE
Quantity transacted; null if n/a.
price DECIMAL(38,12)
Per-unit price; null if n/a.
value DECIMAL(38,12)
Gross value of the transaction.
net_value DECIMAL(38,12)
Net value after fees and commission.
commission DECIMAL(38,12)
Commission charged; null if none.
regulatory_fees DECIMAL(38,12)
Regulatory fees; null if none.
clearing_fees DECIMAL(38,12)
Clearing fees; null if none.
order_id BIGINT
Associated order id; null if n/a.
executed_at TIMESTAMP WITH TIME ZONE
Timestamp the transaction executed (UTC); null if n/a.
transaction_date DATE
Calendar date of the transaction.
Examples (2)

Most recent transactions

SELECT executed_at, transaction_type, symbol, net_value
FROM tastytrade.main.transactions()
ORDER BY executed_at DESC
LIMIT 50;

Net cash impact by transaction type since the start of the year

SELECT transaction_type, sum(net_value) AS net
FROM tastytrade.main.transactions(start_date => DATE '2026-01-01')
GROUP BY transaction_type;
Link
underlying_stats (streamer_symbol VARCHAR) 1 example

Live option-market statistics per underlying: implied volatility, call/put volume, put/call ratio (DXLink); NULL where the feed publishes none

Arguments
streamer_symbol VARCHAR
DXLink streamer symbol (the streamer_symbol column of equities/options/option_chain). Pass a literal for one symbol, or a column (FROM t, f(t.streamer_symbol) or LATERAL) for one symbol per input row.
Returns columns
symbol VARCHAR
Underlying streamer symbol.
volatility DOUBLE
30-day implied volatility of the underlying.
front_volatility DOUBLE
Front-month implied volatility.
back_volatility DOUBLE
Back-month implied volatility.
call_volume BIGINT
Day call volume across the underlying's options.
put_volume BIGINT
Day put volume.
option_volume DOUBLE
Total day option volume.
put_call_ratio DOUBLE
Put/call volume ratio.
time TIMESTAMP WITH TIME ZONE
Event time (UTC).
Example

SPY's put/call ratio and option volume

SELECT symbol, volatility, put_call_ratio, option_volume
FROM tastytrade.main.underlying_stats('SPY');
Link
warrants (symbol VARCHAR) 1 example

Warrant instrument reference data (description, listed market, CUSIP)

Arguments
symbol VARCHAR
Instrument symbol to look up. Pass a literal for one symbol, or a column (FROM t, f(t.symbol) or LATERAL) to look up one symbol per input row.
Returns columns
symbol VARCHAR
Warrant symbol.
instrument_type VARCHAR
Instrument type (Warrant).
description VARCHAR
Description of the warrant.
listed_market VARCHAR
Primary listing market.
is_closing_only BOOLEAN
True if only closing trades are allowed.
active BOOLEAN
True if the instrument is active.
cusip VARCHAR
CUSIP identifier; null if unavailable.
Example

Look up a warrant

SELECT symbol, description, listed_market
FROM tastytrade.main.warrants('RXRXW');
Link
watchlists () 1 example

Entries in the user's private watchlists (one row per symbol)

No arguments
Returns columns
watchlist VARCHAR
Watchlist name.
group_name VARCHAR
Watchlist group name.
symbol VARCHAR
Symbol in the watchlist.
instrument_type VARCHAR
Instrument type of the entry; null if unspecified.
Example

All symbols across your private watchlists

SELECT watchlist, symbol, instrument_type FROM tastytrade.main.watchlists();
Link

Credentials

The secret type tastytrade declares, as reported by the worker itself.

tastytrade

How to get these credentials

Tastytrade OAuth credentials (client_secret, refresh_token, optional is_test)

secret.sql
CREATE SECRET tastytrade (
    TYPE tastytrade,
    client_secret '<TASTYTRADE_CLIENT_SECRET>',  -- secret
    refresh_token '<REFRESH_TOKEN>',  -- secret
    is_test       '<is_test>'
);
Key Type Required Description
client_secret secret VARCHAR — OAuth client (provider) secret of your tastytrade API application.
refresh_token secret VARCHAR — Long-lived OAuth refresh token for your tastytrade login.
is_test BOOLEAN — true for the certification (sandbox) environment; defaults to false (production).

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching tastytrade — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

List the accounts available to the session

SELECT account_number, nickname, account_type_name
FROM tastytrade.main.accounts()

Uses accounts

Net liquidating value and buying power for the default account

SELECT net_liquidating_value, equity_buying_power
FROM tastytrade.main.balances()

Uses balances

Open positions for the default account

SELECT symbol, quantity, mark FROM tastytrade.main.positions()

Uses positions

Six months of net-liquidating-value history

SELECT time, close
FROM tastytrade.main.nlv_history(lookback => INTERVAL '6 months')
ORDER BY time

Uses nlv_history

Equity reference data for several symbols, one per input row

SELECT e.symbol, e.is_etf, e.description
FROM (VALUES ('SPY'), ('AAPL')) t(sym),
     LATERAL tastytrade.main.equities(t.sym) e

Uses equities

List all actively traded ETFs

SELECT symbol, description FROM tastytrade.main.all_equities() WHERE is_etf

Uses all_equities

76 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • List the tastytrade accounts available and their nicknames.
  • What open positions are held, and in which account?
  • What is the current implied-volatility rank for SPY?
  • Get today's 5-minute open/high/low/close price bars for QQQ.
  • Find the ticker symbol for Apple.
  • Is the US equities market currently open, and when does it next open?

Tastytrade is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.