### List Customer Accounts Response Source: https://developer.tastytrade.com/api-guides/customer-account-info Example JSON response for the GET /customers/me/accounts endpoint. ```json { "data": { "items": [ { "account": { "account-number": "5WT00001", "external-id": "A0000196557", "opened-at": "2019-03-14T15:39:31.265+00:00", "nickname": "Individual", "account-type-name": "Individual", "day-trader-status": false, "is-closed": false, "is-firm-error": false, "is-firm-proprietary": false, "is-futures-approved": true, "is-test-drive": false, "margin-or-cash": "Margin", "is-foreign": false, "funding-date": "2017-01-02", "investment-objective": "SPECULATION", "futures-account-purpose": "SPECULATING", "suitable-options-level": "No Restrictions", "created-at": "2019-03-14T15:39:31.265+00:00" }, "authority-level": "owner" }, { "account": { "account-number": "5WT00002", "external-id": "A0000196558", "opened-at": "2019-03-14T15:39:31.265+00:00", "nickname": "Individual", "account-type-name": "Individual", "day-trader-status": false, "is-closed": false, "is-firm-error": false, "is-firm-proprietary": false, "is-futures-approved": true, "is-test-drive": false, "margin-or-cash": "Margin", "is-foreign": false, "funding-date": "2017-01-02", "investment-objective": "SPECULATION", "futures-account-purpose": "SPECULATING", "suitable-options-level": "No Restrictions", "created-at": "2019-03-14T15:39:31.265+00:00" }, "authority-level": "owner" } ] }, "context": "/customers/me/accounts" } ``` -------------------------------- ### POST Request Body Example Source: https://developer.tastytrade.com/api-overview Example of a JSON body for a POST request to the /accounts/{account_number}/orders endpoint, demonstrating dasherized parameter names. ```json { "underlying-symbol": "AAPL", "quantity": 1, "time-in-force": "Day" // other params here } ``` -------------------------------- ### Get Single Account Response Source: https://developer.tastytrade.com/api-guides/customer-account-info Example JSON response for the GET /customers/me/accounts/{account_number} endpoint. ```json { "data": { "account-number": "5WT00001", "external-id": "A0000196557", "opened-at": "2019-03-14T15:39:31.265+00:00", "nickname": "Individual", "account-type-name": "Individual", "day-trader-status": false, "is-closed": false, "is-firm-error": false, "is-firm-proprietary": false, "is-futures-approved": true, "is-test-drive": false, "margin-or-cash": "Margin", "is-foreign": false, "funding-date": "2017-01-02", "investment-objective": "SPECULATION", "futures-account-purpose": "SPECULATING", "suitable-options-level": "No Restrictions", "created-at": "2019-03-14T15:39:31.265+00:00" }, "context": "/customers/me/accounts/5WT0001" } ``` -------------------------------- ### Fractional Quantity Order Example Source: https://developer.tastytrade.com/order-submission Example JSON payload for a fractional stock order. Note the use of a decimal quantity for a portion of a share. ```json { "time-in-force": "Day", "order-type": "Market", "legs": [ { "instrument-type": "Equity", "symbol": "AAPL", "quantity": 0.5, "action": "Buy to Open" } ] } ``` -------------------------------- ### Retrieve Active Futures Contracts Source: https://developer.tastytrade.com/api-guides/instruments Example response from the GET /instruments/futures endpoint showing the structure of a futures contract object. ```json { "data": { "items": [ { "symbol": "/ESU3", "product-code": "ES", "contract-size": "50.0", "tick-size": "0.25", "notional-multiplier": "50.0", "main-fraction": "0.0", "sub-fraction": "0.0", "display-factor": "0.01", "last-trade-date": "2023-09-15", "expiration-date": "2023-09-15", "closing-only-date": "2023-09-15", "active": true, "active-month": true, "next-active-month": false, "is-closing-only": false, "stops-trading-at": "2023-09-15T13:30:00.000+00:00", "expires-at": "2023-09-15T13:30:00.000+00:00", "product-group": "CME_ES", "exchange": "CME", "roll-target-symbol": "/ESZ3", "streamer-exchange-code": "XCME", "streamer-symbol": "/ESU23:XCME", "back-month-first-calendar-symbol": true, "is-tradeable": true, "future-etf-equivalent": { "symbol": "SPY", "share-quantity": 506 }, "future-product": { "root-symbol": "/ES", "code": "ES", "description": "E Mini S&P", "clearing-code": "ES", "clearing-exchange-code": "16", "clearport-code": "ES", "legacy-code": "ES", "exchange": "CME", "legacy-exchange-code": "CME", "product-type": "Financial", "listed-months": [ "H", "M", "U", "Z" ], "active-months": [ "H", "M", "U", "Z" ], "notional-multiplier": "50.0", "tick-size": "0.25", "display-factor": "0.01", "streamer-exchange-code": "XCME", "small-notional": false, "back-month-first-calendar-symbol": true, "first-notice": false, "cash-settled": true, "security-group": "ES", "market-sector": "Equity Index", "roll": { "name": "equity_index", "active-count": 3, "cash-settled": true, "business-days-offset": 4, "first-notice": false } }, "tick-sizes": [ { "value": "0.25" } ], "option-tick-sizes": [ { "value": "0.05", "threshold": "5.0" }, { "value": "0.25" } ], "spread-tick-sizes": [ { "value": "0.05", "symbol": "/ESH4" }, { "value": "0.05", "symbol": "/ESZ3" } ] } ] } } ``` -------------------------------- ### List Transactions Response Example Source: https://developer.tastytrade.com/api-guides/account-transactions A sample JSON response structure returned by the GET /accounts/{account_number}/transactions endpoint. ```json { "data": { "items": [ { "id": 252640963, "account-number": "5WT0001", "symbol": "KBWD", "instrument-type": "Equity", "underlying-symbol": "KBWD", "transaction-type": "Receive Deliver", "transaction-sub-type": "Dividend", "description": "Received 1.68074 Long KBWD via Dividend", "action": "Buy to Open", "quantity": "1.68074", "price": "16.46", "executed-at": "2023-07-28T21:00:00.000+00:00", "transaction-date": "2023-07-28", "value": "0.0", "value-effect": "None", "net-value": "0.0", "net-value-effect": "None", "is-estimated-fee": true }, { "id": 252640962, "account-number": "5WT0001", "symbol": "PGX", "instrument-type": "Equity", "underlying-symbol": "PGX", "transaction-type": "Receive Deliver", "transaction-sub-type": "Dividend", "description": "Received 0.55928 Long PGX via Dividend", "action": "Buy to Open", "quantity": "0.55928", "price": "11.28", "executed-at": "2023-07-28T21:00:00.000+00:00", "transaction-date": "2023-07-28", "value": "0.0", "value-effect": "None", "net-value": "0.0", "net-value-effect": "None", "is-estimated-fee": true }, { "id": 252634233, "account-number": "5WT0001", "symbol": "KBWD", "instrument-type": "Equity", "underlying-symbol": "KBWD", "transaction-type": "Money Movement", "transaction-sub-type": "Dividend", "description": "INVESCO EXCHANGE TRADED FD TR", "executed-at": "2023-07-28T21:00:00.000+00:00", "transaction-date": "2023-07-28", "value": "27.74", "value-effect": "Credit", "net-value": "27.74", "net-value-effect": "Credit", "is-estimated-fee": true } ] }, "api-version": "v1", "context": "/accounts/5WT0001/transactions", "pagination": { "per-page": 250, "page-offset": 0, "item-offset": 0, "total-items": 1622, "total-pages": 7, "current-item-count": 250, "previous-link": null, "next-link": null, "paging-link-template": null } } ``` -------------------------------- ### Retrieve Future Options Data Source: https://developer.tastytrade.com/api-guides/instruments Example response structure for a successful GET request to the /instruments/future-options endpoint. ```json { "data": { "items": [ { "symbol": "./ESZ9 EW4U9 190927P2975", "underlying-symbol": "/ESZ9", "product-code": "ES", "expiration-date": "2019-09-27", "root-symbol": "/ES", "option-root-symbol": "EW4", "strike-price": "2975.0", "exchange": "CME", "exchange-symbol": "EW4U9 P2975", "option-type": "P", "exercise-style": "American", "is-vanilla": true, "is-primary-deliverable": true, "future-price-ratio": "1.0", "multiplier": "1.0", "underlying-count": "1.0", "is-confirmed": true, "notional-value": "0.5", "display-factor": "0.01", "security-exchange": "2", "sx-id": "0", "settlement-type": "Future", "strike-factor": "1.0", "maturity-date": "2019-09-27", "is-exercisable-weekly": true, "last-trade-time": "0", "days-to-expiration": -1, "is-closing-only": false, "active": false, "stops-trading-at": "2019-09-27T20:00:00.000+00:00", "expires-at": "2019-09-27T20:00:00.000+00:00", "future-option-product": { "root-symbol": "EW4", "cash-settled": false, "code": "EW4", "legacy-code": "EW4", "clearport-code": "EW4", "clearing-code": "W4", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": true, "market-sector": "Equity Index" } } ] }, "context": "/instruments/future-options" } ``` -------------------------------- ### Notional Amount Order Example Source: https://developer.tastytrade.com/order-submission Example JSON payload for a notional market order. Use this to specify a dollar amount to trade rather than a specific quantity of shares. ```json { "time-in-force": "Day", "order-type": "Notional Market", "value": 10.0, "value-effect": "Debit", "legs": [ { "instrument-type": "Equity", "symbol": "AAPL", "action": "Buy to Open" } ] } ``` -------------------------------- ### Get Customer Information Source: https://developer.tastytrade.com/api-guides/customer-account-info Use 'me' as the customer_id for the GET /customers/me endpoint to retrieve your own customer information. This endpoint returns comprehensive details including personal, address, and suitability data. ```json { "data": { "id": "me", "first-name": "John", "last-name": "Doe", "address": { "street-one": "1234 Fake St.", "city": "Chicago", "state-region": "IL", "postal-code": "12345", "country": "USA", "is-foreign": false, "is-domestic": true }, "mailing-address": { "street-one": "1234 Fake St.", "city": "Chicago", "state-region": "IL", "postal-code": "12345", "country": "USA", "is-foreign": false, "is-domestic": true }, "customer-suitability": { "id": 3, "marital-status": "MARRIED", "number-of-dependents": 4, "employment-status": "EMPLOYED", "occupation": "Technology", "employer-name": "tastytrade", "job-title": "Developer", "annual-net-income": 1000000, "net-worth": 10000000, "liquid-net-worth": 2000000, "stock-trading-experience": "EXTENSIVE", "covered-options-trading-experience": "EXTENSIVE", "uncovered-options-trading-experience": "EXTENSIVE", "futures-trading-experience": "EXTENSIVE" }, "usa-citizenship-type": "Citizen", "is-foreign": false, "mobile-phone-number": "+11231234567", "email": "johndoe@nowhere.com", "tax-number-type": "SSN", "tax-number": "*****1234", "birth-date": "2000-01-01", "external-id": "C0000037211", "citizenship-country": "USA", "subject-to-tax-withholding": false, "agreed-to-margining": true, "agreed-to-terms": true, "has-industry-affiliation": false, "has-political-affiliation": false, "has-listed-affiliation": false, "is-professional": false, "has-delayed-quotes": false, "has-pending-or-approved-application": true, "identifiable-type": "Person", "person": { "external-id": "P0002173211", "first-name": "John", "last-name": "Doe", "birth-date": "2000-01-01", "citizenship-country": "USA", "usa-citizenship-type": "Citizen", "marital-status": "MARRIED", "number-of-dependents": 4, "employment-status": "EMPLOYED", "occupation": "Technology", "employer-name": "tastytrade", "job-title": "Developer" } }, "context": "/customers/me" } ``` -------------------------------- ### AAPL OTOCO Order Example Source: https://developer.tastytrade.com/order-submission Example JSON payload for an OTOCO complex order. The trigger order executes immediately, and subsequent orders are placed upon its fill. ```json { "type": "OTOCO", "trigger-order": { "order-type": "Limit", "price": 157.97, "price-effect": "Debit", "time-in-force": "Day", "legs": [{ "instrument-type": "Equity", "symbol": "AAPL", "action": "Buy to Open", "quantity": 100 }] }, "orders": [ { "order-type": "Limit", "price": 198.68, "price-effect": "Credit", "time-in-force": "GTC", "legs": [{ "symbol": "AAPL", "instrument-type": "Equity", "action": "Sell to Close", "quantity": 100 }] }, { "order-type": "Stop", "time-in-force": "GTC", "stop-trigger": 143.06, "legs": [{ "symbol": "AAPL", "instrument-type": "Equity", "action": "Sell to Close", "quantity": 100 }] } ] } ``` -------------------------------- ### GET /instruments/cryptocurrencies Source: https://developer.tastytrade.com/open-api-spec/instruments Retrieve a list of available cryptocurrency instruments. ```APIDOC ## GET /instruments/cryptocurrencies ### Description Returns a list of all supported cryptocurrency instruments. ### Method GET ### Endpoint /instruments/cryptocurrencies ``` -------------------------------- ### GET /market-time/equities/sessions/current Source: https://developer.tastytrade.com/open-api-spec/market-sessions Retrieve the current market session for equities. ```APIDOC ## GET /market-time/equities/sessions/current ### Description Retrieve the current market session for equities. ### Method GET ### Endpoint /market-time/equities/sessions/current ``` -------------------------------- ### GET /market-time/sessions Source: https://developer.tastytrade.com/open-api-spec/market-sessions Retrieve general market session information. ```APIDOC ## GET /market-time/sessions ### Description Retrieve general market session information. ### Method GET ### Endpoint /market-time/sessions ``` -------------------------------- ### GET /backtests Source: https://developer.tastytrade.com/open-api-spec/backtesting Retrieves a list of all backtests associated with the user. ```APIDOC ## GET /backtests ### Description Get user's backtests. ### Method GET ### Endpoint /backtests ``` -------------------------------- ### Configure Feed Setup Source: https://developer.tastytrade.com/streaming-market-data Use the COMPACT data format when setting up the feed to ensure compatibility and reduce data usage. ```json { "type": "FEED_SETUP", "channel": 1, "acceptAggregationPeriod": 10, "acceptDataFormat": "COMPACT", "acceptEventFields": { "Quote": ["eventType", "eventSymbol", "bidPrice", "askPrice", "bidSize", "askSize"] } } ``` -------------------------------- ### WebSocket API Setup and Subscription Source: https://developer.tastytrade.com/tasty_dxlink.json This section details the sequence of messages required to establish a WebSocket connection, authenticate, open a channel, and subscribe to specific data feeds. ```APIDOC ## WebSocket API Interaction ### Description This sequence demonstrates the initial messages to set up a WebSocket connection, authenticate, request a channel, and subscribe to various data feeds. ### Method WebSocket (WSS) ### Endpoint wss://tasty-openapi-ws.dxfeed.com/realtime ### Messages Sequence 1. **Setup** - **Description**: Establishes the initial connection parameters. - **Message**: `{"type":"SETUP","channel":0,"version":"0.1-DXF-JS/0.3.0","keepaliveTimeout":60,"acceptKeepaliveTimeout":60}` 2. **Authorize** - **Description**: Authenticates the connection using a provided token. - **Message**: `{"type":"AUTH","channel":0,"token":""}` 3. **Open a Channel** - **Description**: Requests a specific service channel, in this case, for the 'FEED' service. - **Message**: `{"type":"CHANNEL_REQUEST","channel":3,"service":"FEED","parameters":{"contract":"AUTO"}}` 4. **Subscribe to Events** - **Description**: Subscribes to specific event types for given symbols. This example includes Trade, Quote, Profile, and Summary for BTC/USD and SPY, as well as a TradeETH type for SPY. - **Message**: `{"type":"FEED_SUBSCRIPTION","channel":3,"reset":true,"add":[{"type":"Trade","symbol":"BTC/USD:CXTALP"},{"type":"Quote","symbol":"BTC/USD:CXTALP"},{"type":"Profile","symbol":"BTC/USD:CXTALP"},{"type":"Summary","symbol":"BTC/USD:CXTALP"},{"type":"Trade","symbol":"SPY"},{"type":"TradeETH","symbol":"SPY"},{"type":"Quote","symbol":"SPY"},{"type":"Profile","symbol":"SPY"},{"type":"Summary","symbol":"SPY"}]}` 5. **Keepalive (Heartbeat)** - **Description**: A periodic message to maintain the connection. - **Message**: `{ "type": "KEEPALIVE", "channel": 0 }` ### Preferences - **preventSavingMessage**: (boolean) - If true, prevents saving messages. - **preventSavingUrl**: (boolean) - If true, prevents saving URLs. - **preventUsingMessage**: (boolean) - If true, prevents using messages. - **preventUsingUrl**: (boolean) - If true, prevents using URLs. ### Request Example (Illustrative - actual messages are sent sequentially) ```json { "type": "SETUP", "channel": 0, "version": "0.1-DXF-JS/0.3.0", "keepaliveTimeout": 60, "acceptKeepaliveTimeout": 60 } ``` ### Response Responses will vary based on the message sent and the data available. Successful operations typically return an acknowledgment or the requested data. Error responses will indicate the nature of the failure. ``` -------------------------------- ### List Future Option Products Source: https://developer.tastytrade.com/api-guides/instruments Use this GET request to retrieve a list of all available future option products. The response includes details for each product and its associated future product. ```json { "data": { "items": [ { "root-symbol": "EW1", "cash-settled": false, "code": "EW1", "legacy-code": "EW1", "clearport-code": "EW1", "clearing-code": "W1", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index", "future-product": { "root-symbol": "/ES", "code": "ES", "description": "E Mini S&P", "clearing-code": "ES", "clearing-exchange-code": "16", "clearport-code": "ES", "legacy-code": "ES", "exchange": "CME", "legacy-exchange-code": "CME", "product-type": "Financial", "listed-months": [ "H", "M", "U", "Z" ], "active-months": [ "H", "M", "U", "Z" ], "notional-multiplier": "50.0", "tick-size": "0.25", "display-factor": "0.01", "streamer-exchange-code": "XCME", "small-notional": false, "back-month-first-calendar-symbol": true, "first-notice": false, "cash-settled": true, "security-group": "ES", "market-sector": "Equity Index", "roll": { "name": "equity_index", "active-count": 3, "cash-settled": true, "business-days-offset": 4, "first-notice": false } } }, { "root-symbol": "EW2", "cash-settled": false, "code": "EW2", "legacy-code": "EW2", "clearport-code": "EW2", "clearing-code": "W2", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index", "future-product": { "root-symbol": "/ES", "code": "ES", "description": "E Mini S&P", "clearing-code": "ES", "clearing-exchange-code": "16", "clearport-code": "ES", "legacy-code": "ES", "exchange": "CME", "legacy-exchange-code": "CME", "product-type": "Financial", "listed-months": [ "H", "M", "U", "Z" ], "active-months": [ "H", "M", "U", "Z" ], "notional-multiplier": "50.0", "tick-size": "0.25", "display-factor": "0.01", "streamer-exchange-code": "XCME", "small-notional": false, "back-month-first-calendar-symbol": true } } ] } } ``` -------------------------------- ### Debit Limit Order with Price Effect Source: https://developer.tastytrade.com/order-submission This example demonstrates a limit order for selling stock, specifying a price and a 'Credit' price effect. Ensure the price effect aligns with the leg action (e.g., 'Debit' for buying, 'Credit' for selling). ```json { "time-in-force": "Day", "order-type": "Limit", "price": 175.25, "price-effect": "Credit", "legs": [ { "instrument-type": "Equity", "quantity": 100, "symbol": "AAPL", "action": "Sell to Open" } ] } ``` -------------------------------- ### GET /instruments/future-option-products/{exchange}/{root_symbol} Source: https://developer.tastytrade.com/api-guides/instruments Fetch a future option product by a given exchange and root symbol. ```APIDOC ## GET /instruments/future-option-products/{exchange}/{root_symbol} ### Description Fetch a future option product by a given exchange and root symbol. ### Method GET ### Endpoint /instruments/future-option-products/{exchange}/{root_symbol} ### Parameters #### Path Parameters - **exchange** (String) - Required - Exchange at which the future option product is traded. Values: CME, SMALLS, CFE, CBOED - **root_symbol** (String) - Required - Future option root symbol, sometimes referred to as the contract symbol ### Response #### Success Response (200) - **data** (Object) - The future option product details #### Response Example { "data": { "root-symbol": "EW1", "cash-settled": false, "code": "EW1", "exchange": "CME", "product-type": "Physical" } } ``` -------------------------------- ### Retrieve Future Products JSON Response Source: https://developer.tastytrade.com/api-guides/instruments Example response body for the /instruments/future-products endpoint showing product attributes and nested option products. ```json { "data": { "items": [ { "root-symbol": "/ES", "code": "ES", "description": "E Mini S&P", "clearing-code": "ES", "clearing-exchange-code": "16", "clearport-code": "ES", "legacy-code": "ES", "exchange": "CME", "legacy-exchange-code": "CME", "product-type": "Financial", "listed-months": [ "H", "M", "U", "Z" ], "active-months": [ "H", "M", "U", "Z" ], "notional-multiplier": "50.0", "tick-size": "0.25", "display-factor": "0.01", "streamer-exchange-code": "XCME", "small-notional": false, "back-month-first-calendar-symbol": true, "first-notice": false, "cash-settled": true, "security-group": "ES", "market-sector": "Equity Index", "option-products": [ { "root-symbol": "E1B", "cash-settled": false, "code": "E1B", "legacy-code": "E1B", "clearport-code": "E1B", "clearing-code": "ER", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index" }, { "root-symbol": "E2B", "cash-settled": false, "code": "E2B", "legacy-code": "E2B", "clearport-code": "E2B", "clearing-code": "ES", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index" }, { "root-symbol": "E3B", "cash-settled": false, "code": "E3B", "legacy-code": "E3B", "clearport-code": "E3B", "clearing-code": "EU", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index" }, { "root-symbol": "E4B", "cash-settled": false, "code": "E4B", "legacy-code": "E4B", "clearport-code": "E4B", "clearing-code": "EV", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index" } ``` -------------------------------- ### AAPL OCO Order Example Source: https://developer.tastytrade.com/order-submission Example JSON payload for an OCO complex order. Both orders are submitted immediately and function as a one-cancels-the-other set. ```json { "type": "OCO", "orders": [ { "order-type": "Limit", "price": 198.68, "price-effect": "Credit", "time-in-force": "GTC", "legs": [{ "symbol": "AAPL", "instrument-type": "Equity", "action": "Sell to Close", "quantity": 100 }] }, { "order-type": "Stop", "time-in-force": "GTC", "stop-trigger": 143.06, "legs": [{ "symbol": "AAPL", "instrument-type": "Equity", "action": "Sell to Close", "quantity": 100 }] } ] } ``` -------------------------------- ### Construct an OTO Order Request Source: https://developer.tastytrade.com/order-management Example request body for an OTO order, where a trigger order initiates two subsequent market orders upon filling. ```json { "type": "OTO", "trigger-order": { "time-in-force": "Day", "order-type": "Limit", "underlying-symbol": "AAPL", "price": 11.50, "price-effect": "Debit", "legs": [ { "instrument-type": "Equity Option", "symbol": "AAPL 250214C00240000", "quantity": 1, "action": "Buy to Close" }, { "instrument-type": "Equity Option", "symbol": "AAPL 250214P00235000", "quantity": 1, "action": "Buy to Close" } ] }, "orders": [ { "time-in-force": "Day", "order-type": "Market", "underlying-symbol": "AAPL", "legs": [ { "instrument-type": "Equity Option", "symbol": "AAPL 250214C00242500", "quantity": 1, "action": "Sell to Close" } ] }, { "time-in-force": "Day", "order-type": "Market", "underlying-symbol": "AAPL", "legs": [ { "instrument-type": "Equity Option", "symbol": "AAPL 250214P00232500", "quantity": 1, "action": "Sell to Close" } ] } ] } ``` -------------------------------- ### Open a Websocket Connection in Node.js Source: https://developer.tastytrade.com/streaming-account-data Establishes a connection to the streamer host using the ws package. ```javascript const WebSocket = require('ws') const host = 'wss://streamer.cert.tastyworks.com' const websocket = new WebSocket(host) websocket.addEventListener('open', () => { // Schedule your heartbeat }) websocket.addEventListener('message', (messageEvent) => { // Parse the message }) ``` -------------------------------- ### OCO Order Example Request Body Source: https://developer.tastytrade.com/order-management This is an example of an OCO order request body. OCO orders are used when one order should cancel the other. Ensure you have an existing position to close. ```json { "type": "OCO", "orders": [{ "order-type": "Limit", "price": 200.50, "price-effect": "Credit", "time-in-force": "GTC", "legs": [ { "symbol": "AAPL", "instrument-type": "Equity", "action": "Sell to Close", "quantity": 100 ``` -------------------------------- ### GET /futures-option-chains/{product_code} Source: https://developer.tastytrade.com/api-guides/instruments Retrieves a list of future option instrument objects for a specific future product code. ```APIDOC ## GET /futures-option-chains/{product_code} ### Description Returns a list of future option instrument objects for the future product code provided in the path. ### Method GET ### Endpoint /futures-option-chains/{product_code} ### Parameters #### Path Parameters - **product_code** (String) - Required - Future product contract symbol ### Response #### Success Response (200) - **data** (Object) - Contains the list of option items. - **context** (String) - The request path context. #### Response Example { "data": { "items": [ { "symbol": "./ESU3 E1DQ3 230803P3860", "underlying-symbol": "/ESU3", "product-code": "ES", "expiration-date": "2023-08-03", "root-symbol": "/ES", "option-root-symbol": "E1D", "strike-price": "3860.0", "exchange": "CME", "exchange-symbol": "E1DQ3 P3860", "streamer-symbol": "./E1DQ23P3860:XCME", "option-type": "P", "exercise-style": "American", "is-vanilla": true, "is-primary-deliverable": true, "future-price-ratio": "1.0", "multiplier": "1.0", "underlying-count": "1.0", "is-confirmed": true, "notional-value": "0.5", "display-factor": "0.01", "security-exchange": "2", "sx-id": "0", "settlement-type": "Future", "strike-factor": "1.0", "maturity-date": "2023-08-03", "is-exercisable-weekly": true, "last-trade-time": "0", "days-to-expiration": 4, "is-closing-only": false, "active": true, "stops-trading-at": "2023-08-03T20:00:00.000+00:00", "expires-at": "2023-08-03T20:00:00.000+00:00", "future-option-product": { "root-symbol": "E1D", "cash-settled": false, "code": "E1D", "legacy-code": "E1D", "clearport-code": "E1D", "clearing-code": "EX", "clearing-exchange-code": "9C", "clearing-price-multiplier": "1.0", "display-factor": "0.01", "exchange": "CME", "product-type": "Physical", "expiration-type": "Weekly", "settlement-delay-days": 0, "is-rollover": false, "market-sector": "Equity Index" } } ] }, "context": "/futures-option-chains/ES" } ``` -------------------------------- ### Connect Message and Response Source: https://developer.tastytrade.com/streaming-account-data Example of a connect message used to subscribe to account updates and the corresponding server response. ```json { "action": "connect", "value": ["5WT00000","5WT00001"], "auth-token": "your access token here", "request-id": 2 } ``` ```json { "status": "ok", "action": "connect", "web-socket-session-id": "5b6e2799", "value": [ "5WT00000", "5WT00001" ], "request-id": 2 } ``` -------------------------------- ### GET /span/rows Source: https://developer.tastytrade.com/open-api-spec/risk-parameters Retrieves SPAN rows data. ```APIDOC ## GET /span/rows ### Description Retrieves SPAN rows data. ### Method GET ### Endpoint /span/rows ``` -------------------------------- ### Get Cryptocurrency Source: https://developer.tastytrade.com/api-guides/instruments Returns a cryptocurrency instrument from a given symbol. ```APIDOC ## GET /instruments/cryptocurrencies/{symbol} ### Description Returns a cryptocurrency instrument from a given symbol. ### Method GET ### Endpoint /instruments/cryptocurrencies/{symbol} ### Parameters #### Path Parameters - **symbol** (String) - required - Cryptocurrency symbol example: BTC/USD ### Request Example ```json { "data": { "id": 1, "symbol": "BTC/USD", "instrument-type": "Cryptocurrency", "short-description": "Bitcoin", "description": "Bitcoin to USD", "is-closing-only": false, "active": true, "tick-size": "0.01", "streamer-symbol": "BTC/USD:CXTALP", "destination-venue-symbols": [ { "id": 1, "symbol": "BTC", "destination-venue": "CITADEL_CRYPTOCURRENCY", "max-quantity-precision": 8, "max-price-precision": 8, "routable": true } ] }, "context": "/instruments/cryptocurrencies/BTC%2FUSD" } ``` ``` -------------------------------- ### Submit Order Request Example Source: https://developer.tastytrade.com/order-management This JSON object represents a sample request payload for submitting an order. It includes details such as account number, order type, size, underlying symbol, and legs of the order. ```json { "data": { "order": { "id": 771043, "account-number": "5WT0001", "time-in-force": "Day", "order-type": "Limit", "size": 1, "underlying-symbol": "SPY", "price": "3.0", "price-effect": "Credit", "status": "Routed", "cancellable": false, "editable": false, "edited": false, "received-at": "2019-10-01T18:26:52.513+00:00", "updated-at": 1569954412572, "legs": [ { "instrument-type": "Equity Option", "symbol": "SPY 191018C00295000", "quantity": 1, "remaining-quantity": 1, "action": "Sell to Open", "fills": [] }, { "instrument-type": "Equity Option", "symbol": "SPY 191018C00298000", "quantity": 1, "remaining-quantity": 1, "action": "Buy to Open", "fills": [] } ] }, "warnings": [], "buying-power-effect": { "change-in-margin-requirement": "300.0", "change-in-margin-requirement-effect": "Debit", "change-in-buying-power": "2.302", "change-in-buying-power-effect": "Debit", "current-buying-power": "8995871.0475", "current-buying-power-effect": "Credit", "new-buying-power": "8995868.7455", "new-buying-power-effect": "Credit", "isolated-order-margin-requirement": "300.0", "isolated-order-margin-requirement-effect": "Debit", "is-spread": true, "impact": "2.302", "effect": "Debit" }, "fee-calculation": { "regulatory-fees": "0.102", "regulatory-fees-effect": "Debit", "clearing-fees": "0.2", "clearing-fees-effect": "Debit", "commission": "2.0", "commission-effect": "Debit", "proprietary-index-option-fees": "0.0", "proprietary-index-option-fees-effect": "Debit", "total-fees": "2.302", "total-fees-effect": "Debit" } }, "api-version": "v1", "context": "/accounts/5WT0001/orders/" } ``` -------------------------------- ### Get Transaction Source: https://developer.tastytrade.com/api-guides/account-transactions Retrieves details for a specific transaction by its ID. ```APIDOC ## GET /accounts/{accountNumber}/transactions/{transactionId} ### Description Retrieves the details of a specific transaction record. ### Method GET ### Endpoint /accounts/{accountNumber}/transactions/{transactionId} ### Parameters #### Path Parameters - **accountNumber** (string) - Required - The unique identifier for the account. - **transactionId** (string) - Required - The unique identifier for the transaction. ```