### Example GET Request for Market Data Source: https://api.tradestation.com/docs/fundamentals/rate-limiting/rate-limiting-overview A sample HTTP GET request to retrieve market data for a specific stock symbol. This demonstrates the typical structure of an API request including host, authorization, and accept headers. ```http GET https://api.tradestation.com/v3/marketdata/quotes/MSFT HTTP/2 Host: api.tradestation.com Authorization: Bearer Accept: application/json ``` -------------------------------- ### Stream Orders by Order ID (Shell) Source: https://api.tradestation.com/docs/specification This example shows how to stream orders for specified accounts and order IDs using a GET request. Ensure you replace the placeholder TOKEN with your actual authorization token. ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/stream/accounts/61999124,68910124/orders/812767578,812941051' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Brokerage Accounts Response Example Source: https://api.tradestation.com/docs/specification Example JSON response for the Get Accounts endpoint, detailing various account types and their associated properties. Note the different AccountDetail objects for Cash and Margin accounts. ```json { "Accounts": [ { "AccountID": "123456789", "Currency": "USD", "Status": "Active", "AccountType": "Cash", "AccountDetail": { "IsStockLocateEligible": false, "EnrolledInRegTProgram": false, "RequiresBuyingPowerWarning": false, "DayTradingQualified": true, "OptionApprovalLevel": 0, "PatternDayTrader": false } }, { "AccountID": "123456782", "Currency": "USD", "Status": "Active", "AccountType": "Margin", "AccountDetail": { "IsStockLocateEligible": false, "EnrolledInRegTProgram": true, "RequiresBuyingPowerWarning": true, "DayTradingQualified": true, "OptionApprovalLevel": 1, "PatternDayTrader": false } }, { "AccountID": "123456781", "Currency": "USD", "Status": "Active", "AccountType": "Futures" } ] } ``` -------------------------------- ### Example GET Request for Market Data Source: https://api.tradestation.com/docs/fundamentals/http-requests This snippet shows a `curl` command to fetch daily bar data for a specific stock. Ensure you replace 'TOKEN' with your actual API key and adjust parameters as needed. ```bash curl --request GET \ --url 'https://api.tradestation.com/v3/marketdata/barcharts/MSFT?interval=1&unit=Daily&barsback=2&startdate=2020-12-05T21:00:00Z' \ --header 'Authorization: Bearer TOKEN' ``` ```json {"Bars":[{"High":"216.38","Low":"213.65","Open":"214.61","Close":"214.24","TimeStamp":"2020-12-03T21:00:00Z","TotalVolume":"25120922","DownTicks":114646,"DownVolume":14430027,"OpenInterest":"0","IsRealtime":false,"IsEndOfHistory":false,"TotalTicks":226992,"UnchangedTicks":0,"UnchangedVolume":0,"UpTicks":112346,"UpVolume":10690895,"Epoch":1607029200000},{"High":"215.38","Low":"213.18","Open":"214.22","Close":"214.36","TimeStamp":"2020-12-04T21:00:00Z","TotalVolume":"24666039","DownTicks":110196,"DownVolume":13201417,"OpenInterest":"0","IsRealtime":false,"IsEndOfHistory":true,"TotalTicks":218338,"UnchangedTicks":0,"UnchangedVolume":0,"UpTicks":108142,"UpVolume":11464622,"Epoch":1607115600000}]} ``` -------------------------------- ### Get Positions Response Source: https://api.tradestation.com/docs/specification Example JSON response for a successful positions request, including position details and potential errors. ```json { "Positions": [ { "AccountID": "123456782", "AveragePrice": "216.68", "AssetType": "STOCK", "Last": "216.63", "Bid": "216.62", "Ask": "216.64", "ConversionRate": "1", "DayTradeRequirement": "0", "InitialRequirement": "0", "MaintenanceMargin": "0", "PositionID": "64630792", "LongShort": "Long", "Quantity": "10", "Symbol": "MSFT", "Timestamp": "2020-11-16T16:53:37Z", "TodaysProfitLoss": "-0.5", "TotalCost": "2166.8", "MarketValue": "2166.3", "MarkToMarketPrice": "216.68", "UnrealizedProfitLoss": "-0.5", "UnrealizedProfitLossPercent": "-0.023", "UnrealizedProfitLossQty": "-0.05" } ], "Errors": [ { "AccountID": "123456782C", "Error": "Forbidden", "Message": "Request not supported for account type." } ] } ``` -------------------------------- ### Example Authorization URL with PKCE Source: https://api.tradestation.com/docs/fundamentals/authentication/auth-pkce This is an example of the full authorization URL including the required PKCE parameters: `code_challenge` and `code_challenge_method`. Use this URL to redirect users for authentication. ```url https://signin.tradestation.com/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:8080&audience=https://api.tradestation.com&state=STATE&scope=openid offline_access profile MarketData ReadAccount Trade Matrix OptionSpreads&code_challenge=MChCW5vD-3h03HMGFZYskOSTir7II_MMTb8a9rJNhnI&code_challenge_method=S256 ``` -------------------------------- ### Crypto Symbol Names Response Example Source: https://api.tradestation.com/docs/specification Example response containing a list of crypto symbol names. ```json { * "SymbolNames": [ * "BTCUSD", * "ETHUSD", * "LTCUSD", * "BCHUSD" ] } ``` -------------------------------- ### Example Throttled Request for Streaming Accounts Source: https://api.tradestation.com/docs/fundamentals/rate-limiting/rate-limiting-overview This is an example of a GET request to a streaming endpoint that may be throttled if concurrency limits are reached. Ensure your application manages active connections efficiently. ```http GET https://api.tradestation.com/v3/brokerage/stream/accounts//positions HTTP/2 Host: api.tradestation.com Authorization: Bearer Accept: application/json ``` -------------------------------- ### Price Formatting Calculation Example Source: https://api.tradestation.com/docs/specification Illustrates the calculation logic for displaying prices with decimal, fraction, and sub-fractional formatting. ```plaintext x (Price) = 125.92969 y (PriceFormat.Fraction) = 32 z (PriceFormat.SubFraction) = 4 a = trunc(x) b = trunc(frac(x) * y) c = trunc(((frac(x) - (b/y)) * z * y) / (z/10)) ``` -------------------------------- ### Get Historical Orders Request Source: https://api.tradestation.com/docs/specification Example of a GET request to retrieve historical orders using account and order IDs, with a 'since' date filter. Ensure to replace 'TOKEN' with your actual authorization token. ```Shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/historicalorders/123456789,286179863?since=2006-01-13' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Example Response for Access Token Refresh Source: https://api.tradestation.com/docs/fundamentals/authentication/refresh-tokens This is an example of a successful response when obtaining a new access token using a refresh token. It includes the new access token, its expiration time, and other relevant token details. ```json { "access_token": "eGlhc2xv...MHJMaA", "expires_in": 1200, "scope": "openid offline_access", "id_token": "vozT2Ix...wGVFPQ", "token_type": "Bearer" } ``` -------------------------------- ### Example Redirect with Authorization Code Source: https://api.tradestation.com/docs/fundamentals/authentication/auth-code This is an example of the HTTP redirect response a client receives after a user successfully authenticates. The authorization code is included in the query string. ```http HTTP/1.1 302 Found Location: http://localhost:8080?code=AUTHORIZATION_CODE&state=xyzABC123 ``` -------------------------------- ### Market Data Bar Response Example Source: https://api.tradestation.com/docs/specification Example of a successful response for market data bar charts, detailing OHLC, volume, and timestamp information. ```json { * "High": "217.32", * "Low": "216.2", * "Open": "217.32", * "Close": "217", * "TimeStamp": "2020-11-12T17:00:00Z", * "TotalVolume": "807033", * "DownTicks": 2091, * "DownVolume": 396976, * "OpenInterest": "0", * "IsRealtime": false, * "IsEndOfHistory": false, * "TotalTicks": 4296, * "UnchangedTicks": 0, * "UnchangedVolume": 0, * "UpTicks": 2205, * "UpVolume": 410057, * "Epoch": 1605200400000, * "BarStatus": "Open" } ``` -------------------------------- ### Logout Endpoint Request Example Source: https://api.tradestation.com/docs/fundamentals/authentication/logout This example shows how to construct a logout request URL. Include `returnTo` and `client_id` parameters to redirect the user to a specific URL after logout. Ensure the `returnTo` URL is configured in your API Key's Allowed Logout URLs. ```http https://signin.tradestation.com/v2/logout?returnTo=LOGOUT_URL&client_id=YOUR_CLIENT_ID ``` -------------------------------- ### Example JSON Response for Option Strikes Source: https://api.tradestation.com/docs/specification This is an example of a JSON response when requesting option strike data. It shows the 'SpreadType' and a list of 'Strikes'. ```json { * "SpreadType": "Butterfly", * "Strikes": [ * [ * "145", * "150", * "155" ], * [ * "150", * "155", * "160" ] ] } ``` -------------------------------- ### OrderHeartbeatErrorResponseStreamStatusOrder Example Source: https://api.tradestation.com/docs/specification This is an example of the OrderHeartbeatErrorResponseStreamStatusOrder response structure. It details various order properties including account information, legs, and status. ```json [ { "AccountID": "123456782", "CommissionFee": "0", "Currency": "USD", "Duration": "GTC", "GoodTillDate": "2021-05-25T00:00:00Z", "Legs": [ { "AssetType": "STOCK", "BuyOrSell": "Buy", "ExecQuantity": "0", "ExecutionPrice": "112.28", "ExpirationDate": "2021-05-25T00:00:00Z", "OpenOrClose": "Open", "OptionType": "CALL", "QuantityOrdered": "10", "QuantityRemaining": "10", "StrikePrice": "350", "Symbol": "MSFT", "Underlying": "MSFT" } ], "MarketActivationRules": [ { "RuleType": "Price", "Symbol": "EDZ22", "Predicate": "gt", "TriggerKey": "STTN", "Price": "10000.01" } ], "OrderID": "286234131", "OpenedDateTime": "2021-02-24T15:47:45Z", "OrderType": "Market", "PriceUsedForBuyingPower": "230.46", "Routing": "Intelligent", "Status": "OPN", "StatusDescription": "Sent", "AdvancedOptions": "CND=EDZ22>10000.01(STTN);TIM=23:59:59;", "TimeActivationRules": [ { "TimeUtc": "0001-01-01T23:59:59Z" } ], "UnbundledRouteFee": "0" }, { "AccountID": "123456782", "CommissionFee": "0", "ConditionalOrders": [ { "Relationship": "OCO", "OrderID": "286179863" } ], "Currency": "USD", "Duration": "GTC", "GoodTillDate": "2021-02-15T00:00:00Z", "GroupName": "OCO 2706452145", "Legs": [ { "OpenOrClose": "Close", "QuantityOrdered": "10", "ExecQuantity": "0", "QuantityRemaining": "10", "BuyOrSell": "Sell", "Symbol": "MSFT", "AssetType": "STOCK" } ], "OrderID": "286179864", "OpenedDateTime": "2020-11-17T16:34:37Z", "OrderType": "StopMarket", "PriceUsedForBuyingPower": "215.06", "Routing": "Intelligent", "Status": "ACK", "StatusDescription": "Received", "AdvancedOptions": "STPTRG=STT;TRL=5%;", "TrailingStop": { "Percent": "5.0" }, "UnbundledRouteFee": "0" }, { "AccountID": "123456782", "CommissionFee": "0", "ConditionalOrders": [ { "Relationship": "OCO", "OrderID": "286179863" } ], "Currency": "USD", "Duration": "GTC", "GoodTillDate": "2021-02-15T00:00:00Z", "GroupName": "OCO 2706452145", "Legs": [ { "OpenOrClose": "Close", "QuantityOrdered": "10", "ExecQuantity": "0", "QuantityRemaining": "10", "BuyOrSell": "Sell", "Symbol": "MSFT", "AssetType": "STOCK" } ], "OrderID": "286179864", "OpenedDateTime": "2020-11-17T16:34:37Z", "OrderType": "StopMarket", "PriceUsedForBuyingPower": "215.06", "Routing": "Intelligent", "Status": "ACK", "StatusDescription": "Received", "StopPrice": "130", "AdvancedOptions": "STPTRG=STT;OCA=2706452145;", "UnbundledRouteFee": "0" } ] ``` -------------------------------- ### Example Token Exchange Response Source: https://api.tradestation.com/docs/fundamentals/authentication/auth-code This is an example JSON response received after successfully exchanging an authorization code for tokens. It includes the access token, refresh token, ID token, and other relevant details. ```json { "access_token": "eGlhc2xv...MHJMaA", "refresh_token": "eGlhc2xv...wGVFPQ", "id_token": "vozT2Ix...wGVFPQ", "token_type": "Bearer", "scope": "openid profile MarketData ReadAccount Trade offline_access", "expires_in": 1200 } ``` -------------------------------- ### Get Symbol Suggestions Source: https://api.tradestation.com/docs/specification Retrieves a list of symbol suggestions based on the provided text. Requires an authorization token. ```Shell curl --request GET \ --url 'https://api.tradestation.com/v2/data/symbols/suggest/{text}' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Market Depth Aggregate Stream Example Source: https://api.tradestation.com/docs/specification Example structure for a Market Depth Aggregate Stream response, including bids and asks. This format is used for real-time updates. ```json { "Bids": [ { "EarliestTime": "2022-06-28T12:34:56Z", "LatestTime": "2022-06-28T12:34:56Z", "Side": "Bid", "Price": "123.45", "TotalSize": "9000", "BiggestSize": "1500", "SmallestSize": "100", "NumParticipants": 5, "TotalOrderCount": 15 } ], "Asks": [ { "EarliestTime": "2022-06-28T12:34:56Z", "LatestTime": "2022-06-28T12:34:56Z", "Side": "Ask", "Price": "123.45", "TotalSize": "9000", "BiggestSize": "1500", "SmallestSize": "100", "NumParticipants": 5, "TotalOrderCount": 15 } ] } ``` -------------------------------- ### Get Brokerage Accounts Source: https://api.tradestation.com/docs/specification Fetches a list of all brokerage accounts associated with the authenticated user. Requires a valid Authorization token. ```curl curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/accounts' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Get Symbol Details Source: https://api.tradestation.com/docs/specification Retrieves detailed information and formatting for one or more symbols. Up to 50 symbols can be requested per query. ```curl curl --request GET \ --url 'https://api.tradestation.com/v3/marketdata/symbols/MSFT,BTCUSD' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Example Concurrency Limit Failed Response Source: https://api.tradestation.com/docs/fundamentals/rate-limiting/rate-limiting-overview This response indicates that the stream quota has been exceeded. Monitor X-Concurrency-Remaining to manage active streaming connections. ```http HTTP/2 429 date: Fri, 08 Nov 2024 20:03:42 GMT content-type: application/json access-control-allow-origin: * cache-control: no-cache, no-store strict-transport-security: max-age=31536000; includeSubDomains vary: Origin x-concurrency-limit: 40 x-concurrency-remaining: 0 x-concurrency-resource: streaming-positions x-content-type-options: nosniff x-ratelimit-limit: 251 x-ratelimit-period: 300 x-ratelimit-remaining: 25 x-ratelimit-reset: 272 x-ratelimit-resource: streaming-positions {"Error":"TooManyRequests","Message":"Stream quota exceeded"} ``` -------------------------------- ### Example Rate Limit Failed Response Source: https://api.tradestation.com/docs/fundamentals/rate-limiting/rate-limiting-overview This response indicates that the request quota has been exceeded. Check X-Ratelimit-Limit, X-Ratelimit-Period, and X-Ratelimit-Remaining headers for details. ```http HTTP/2 429 date: Fri, 08 Nov 2024 20:04:56 GMT content-type: application/json access-control-allow-origin: * cache-control: no-cache, no-store strict-transport-security: max-age=31536000; includeSubDomains vary: Origin x-content-type-options: nosniff x-ratelimit-limit: 500 x-ratelimit-period: 300 x-ratelimit-remaining: 0 x-ratelimit-reset: 287 x-ratelimit-resource: quotes x-ts-request-id: 30c8b23c2cdedcc39c6ba38339d1818a {"Error":"TooManyRequests","Message":"Rate quota exceeded"} ``` -------------------------------- ### Authorization URL Example Source: https://api.tradestation.com/docs/fundamentals/authentication/auth-code Construct the authorization URL with required query parameters to initiate the OAuth 2.0 flow. Ensure all parameters like client_id, redirect_uri, and scopes are correctly set. ```url https://signin.tradestation.com/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:8080&audience=https://api.tradestation.com&state=STATE&scope=openid offline_access profile MarketData ReadAccount Trade Matrix OptionSpreads ``` -------------------------------- ### Get Market Data - Bar Charts Source: https://api.tradestation.com/docs/fundamentals/http-requests This endpoint retrieves historical bar chart data for a given symbol. You can specify the interval, unit, number of bars, and a start date. ```APIDOC ## GET /v3/marketdata/barcharts/{symbol} ### Description Retrieves historical bar chart data for a specified symbol. Supports filtering by interval, unit, number of bars back, and start date. ### Method GET ### Endpoint `https://api.tradestation.com/v3/marketdata/barcharts/{symbol}` `https://sim-api.tradestation.com/v3/marketdata/barcharts/{symbol}` (sim) ### Parameters #### Query Parameters - **interval** (string) - Required - The interval for the bars (e.g., '1' for 1 minute). - **unit** (string) - Required - The unit for the interval (e.g., 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year'). - **barsback** (integer) - Required - The number of bars to retrieve. - **startdate** (string) - Optional - The start date and time for the data in ISO 8601 format (e.g., '2020-12-05T21:00:00Z'). ### Request Example ```curl curl --request GET \ --url 'https://api.tradestation.com/v3/marketdata/barcharts/MSFT?interval=1&unit=Daily&barsback=2&startdate=2020-12-05T21:00:00Z' \ --header 'Authorization: Bearer TOKEN' ``` ### Response #### Success Response (200) - **Bars** (array) - An array of bar data objects. - **High** (string) - The highest price for the bar. - **Low** (string) - The lowest price for the bar. - **Open** (string) - The opening price for the bar. - **Close** (string) - The closing price for the bar. - **TimeStamp** (string) - The timestamp of the bar in ISO 8601 format. - **TotalVolume** (string) - The total volume for the bar. - **DownTicks** (string) - The number of down ticks. - **DownVolume** (string) - The volume of down ticks. - **OpenInterest** (string) - The open interest. - **IsRealtime** (boolean) - Indicates if the data is real-time. - **IsEndOfHistory** (boolean) - Indicates if this is the end of historical data. - **TotalTicks** (string) - The total number of ticks. - **UnchangedTicks** (string) - The number of unchanged ticks. - **UnchangedVolume** (string) - The volume of unchanged ticks. - **UpTicks** (string) - The number of up ticks. - **UpVolume** (string) - The volume of up ticks. - **Epoch** (integer) - The epoch timestamp for the bar. #### Response Example ```json { "Bars":[ { "High":"216.38", "Low":"213.65", "Open":"214.61", "Close":"214.24", "TimeStamp":"2020-12-03T21:00:00Z", "TotalVolume":"25120922", "DownTicks":"114646", "DownVolume":"14430027", "OpenInterest":"0", "IsRealtime":false, "IsEndOfHistory":false, "TotalTicks":"226992", "UnchangedTicks":"0", "UnchangedVolume":"0", "UpTicks":"112346", "UpVolume":"10690895", "Epoch":1607029200000 }, { "High":"215.38", "Low":"213.18", "Open":"214.22", "Close":"214.36", "TimeStamp":"2020-12-04T21:00:00Z", "TotalVolume":"24666039", "DownTicks":"110196", "DownVolume":"13201417", "OpenInterest":"0", "IsRealtime":false, "IsEndOfHistory":true, "TotalTicks":"218338", "UnchangedTicks":"0", "UnchangedVolume":"0", "UpTicks":"108142", "UpVolume":"11464622", "Epoch":1607115600000 } ] } ``` ``` -------------------------------- ### C# Request for Stream Tick Bars Source: https://api.tradestation.com/docs/specification Example of how to make a GET request to the stream tick bars endpoint using C#. Ensure to replace placeholder values with actual parameters. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class TradestationClient { public static async Task GetTickBarsAsync(string symbol, int interval, int barsBack, string token) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token); var url = $"https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}"; var response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); Console.WriteLine(json); } else { Console.WriteLine($"Error: {response.StatusCode}"); } } } } ``` -------------------------------- ### Python Request for Stream Tick Bars Source: https://api.tradestation.com/docs/specification Example of how to make a GET request to the stream tick bars endpoint using Python. Ensure to replace placeholder values with actual parameters. ```python import requests url = 'https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}' token = 'YOUR_ACCESS_TOKEN' headers = { 'Authorization': f'Bearer {token}' } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f'Error: {response.status_code}') ``` -------------------------------- ### Get Beginning of Day Balances (Shell) Source: https://api.tradestation.com/docs/specification Use this cURL command to fetch the beginning of day balances for specified accounts. Ensure your Authorization header includes a valid Bearer token. ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/bodbalances' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Response Sample for Order Execution Routes Source: https://api.tradestation.com/docs/specification This JSON structure shows a sample response for retrieving order execution routes. It lists available routes with their IDs, associated asset types, and names. ```json { "Routes": [ { "Id": "AMEX", "AssetTypes": [ "STOCK" ], "Name": "AMEX" }, { "Id": "ARCA,", "AssetTypes": [ "STOCK" ], "Name": "ARCX" } ] } ``` -------------------------------- ### Node.js Request for Stream Tick Bars Source: https://api.tradestation.com/docs/specification Example of how to make a GET request to the stream tick bars endpoint using Node.js. Ensure to replace placeholder values with actual parameters. ```javascript const fetch = require('node-fetch'); const url = 'https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}'; const token = 'YOUR_ACCESS_TOKEN'; fetch(url, { method: 'GET', headers: { 'Authorization': `Bearer ${token}` } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Switching to SIM Environment Base URL Source: https://api.tradestation.com/docs/fundamentals/sim-vs-live To access the SIM environment, change your base URL from the live URL to the SIM URL. This is essential for paper trading and testing. ```text https://sim-api.tradestation.com/v3 ``` -------------------------------- ### Shell Request for Stream Tick Bars Source: https://api.tradestation.com/docs/specification Example of how to make a GET request to the stream tick bars endpoint using curl. Ensure to replace placeholder values with actual parameters. ```shell curl --request GET \ --url 'https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Sample JSON Response for Account Balances Source: https://api.tradestation.com/docs/specification This is a sample JSON response illustrating the structure of account balances, including details for Cash, Margin, and Futures accounts. It also shows a potential error structure. ```json { "Balances": [ { "AccountID": "123456789", "AccountType": "Cash", "CashBalance": "987654319787", "BuyingPower": "987654319786.82", "Equity": "987654321539.0976", "MarketValue": "1751.625", "TodaysProfitLoss": "4.9376", "UnclearedDeposit": "0", "BalanceDetail": { "CostOfPositions": "1471.98", "DayTrades": "0", "MaintenanceRate": "67096993251.19", "OptionBuyingPower": "987654319787", "OptionsMarketValue": "0", "OvernightBuyingPower": "987654319786.82", "RequiredMargin": "2371.98", "RealizedProfitLoss": "0", "UnrealizedProfitLoss": "-620.355" }, "Commission": "0" }, { "AccountID": "123456782", "AccountType": "Margin", "CashBalance": "39735538.661", "BuyingPower": "39735498.661", "Equity": "39893233.6211", "MarketValue": "157727.6092", "TodaysProfitLoss": "982.8001", "UnclearedDeposit": "0", "BalanceDetail": { "CostOfPositions": "134589.21", "DayTrades": "0", "MaintenanceRate": "29720.06", "OptionBuyingPower": "39735538.661", "OptionsMarketValue": "0", "OvernightBuyingPower": "39735458.661", "RequiredMargin": "134589.21", "RealizedProfitLoss": "0", "UnrealizedProfitLoss": "23138.3992000534" }, "Commission": "0" }, { "AccountID": "123456781", "AccountType": "Futures", "CashBalance": "123456784.32", "BuyingPower": "123455574.320001", "Equity": "123456184.320001", "MarketValue": "996750", "TodaysProfitLoss": "-549.999999", "UnclearedDeposit": "0", "BalanceDetail": { "DayTradeExcess": "123455574.320001", "RealizedProfitLoss": "0", "UnrealizedProfitLoss": "-599.999999", "DayTradeOpenOrderMargin": "0", "OpenOrderMargin": "0", "DayTradeMargin": "660", "InitialMargin": "660", "MaintenanceMargin": "600", "TradeEquity": "-549.999999", "SecurityOnDeposit": "0", "TodayRealTimeTradeEquity": "-599.999999" }, "CurrencyDetails": [ { "Currency": "USD", "Commission": "0", "CashBalance": "123456784.32", "RealizedProfitLoss": "0", "UnrealizedProfitLoss": "-599.999999", "InitialMargin": "660", "MaintenanceMargin": "600", "AccountConversionRate": "1" } ], "Commission": "0" } ], "Errors": [ { "AccountID": "123456789C", "Error": "Forbidden", "Message": "Request not supported for account type." } ] } ``` -------------------------------- ### Get Today's and Open Orders Source: https://api.tradestation.com/docs/specification Use this cURL command to fetch today's and open orders for specified accounts. Ensure you replace 'TOKEN' with your actual authorization token. ```Shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/orders' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Get Order Execution Routes (Shell) Source: https://api.tradestation.com/docs/specification This cURL command demonstrates how to retrieve a list of valid order execution routes. Ensure you include your authorization token in the header. ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/orderexecution/routes' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Get Historical Orders Request Sample (Shell) Source: https://api.tradestation.com/docs/specification This is a sample cURL command to fetch historical orders for specified accounts. Ensure to replace 'TOKEN' with your actual authorization token. ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/historicalorders?since=2006-01-13' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Response Sample for Activation Triggers Source: https://api.tradestation.com/docs/specification This JSON structure represents a sample response detailing various activation triggers for trading orders. It includes keys, names, and descriptions for each trigger type. ```json { "ActivationTriggers": [ { "Key": "STT", "Name": "Single Trade Tick", "Description": "One trade tick must print within your stop price to trigger your stop." }, { "Key": "STTN", "Name": "Single Trade Tick Within NBBO", "Description": "One trade tick within the National Best Bid or Offer must print within your stop price to trigger your stop." }, { "Key": "SBA", "Name": "Single Bid/Ask Tick", "Description": "Buy/Cover Orders: One Ask tick must print within your stop price to trigger your stop. Sell/Short Orders: One Bid tick must print within your stop price to trigger your stop." }, { "Key": "SAB", "Name": "Single Ask/Bid Tick", "Description": "Buy/Cover Orders: One Bid tick must print within your stop price to trigger your stop. Sell/Short Orders: One Ask tick must print within your stop price to trigger your stop." }, { "Key": "DTT", "Name": "Double Trade Tick", "Description": "Two consecutive trade ticks must print within your stop price to trigger your stop." }, { "Key": "DTTN", "Name": "Double Trade Tick Within NBBO ", "Description": "Two consecutive trade ticks within the National Best Bid or Offer must print within your stop price to trigger your stop." }, { "Key": "DBA", "Name": "Double Bid/Ask Tick", "Description": "Buy/Cover Orders: Two consecutive Ask ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two consecutive Bid ticks must print within your stop price to trigger your stop." }, { "Key": "DAB", "Name": "Double Ask/Bid Tick", "Description": "Buy/Cover Orders: Two consecutive Bid ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two consecutive Ask ticks must print within your stop price to trigger your stop." }, { "Key": "TTT", "Name": "Twice Trade Tick", "Description": "Two trade ticks must print within your stop price to trigger your stop." }, { "Key": "TTTN", "Name": "Twice Trade Tick Within NBBO", "Description": "Two trade ticks within the National Best Bid or Offer must print within your stop price to trigger your stop." }, { "Key": "TBA", "Name": "Twice Bid/Ask Tick", "Description": "Buy/Cover Orders: Two Ask ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two Bid ticks must print within your stop price to trigger your stop." }, { "Key": "TAB", "Name": "Twice Ask/Bid Tick", "Description": "Buy/Cover Orders: Two Bid ticks must print within your stop price to trigger your stop. Sell/Short Orders: Two Ask ticks must print within your stop price to trigger your stop." } ] } ``` -------------------------------- ### Get Symbol Details Source: https://api.tradestation.com/docs/specification Fetches symbol details and formatting information for one or more symbols. ```APIDOC ## GET /v3/marketdata/symbols/{symbols} ### Description Fetches symbol details and formatting information for one or more symbols and relevant errors, if any. Use provided formatting objects to display provided prices and quantities from other API endpoints. ### Method GET ### Endpoint `https://api.tradestation.com/v3/marketdata/symbols/{symbols}` ### Parameters #### Path Parameters - **symbols** (string) - Required - List of valid symbols in comma separated format; for example `"MSFT,BTCUSD"`, no more than 50 symbols per request. ### Response #### Success Response (200) - **SymbolDetailsResponse** (object) - Contains the symbol details and formatting information. #### Error Responses - **400** ErrorResponse - **401** ErrorResponse - **403** ErrorResponse - **404** ErrorResponse - **429** ErrorResponse - **503** ErrorResponse - **504** ErrorResponse ### Request Example ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/marketdata/symbols/MSFT,BTCUSD' \ --header 'Authorization: Bearer TOKEN' ``` ``` -------------------------------- ### Get Crypto Symbol Names Source: https://api.tradestation.com/docs/specification Fetches a list of crypto symbol names for all available cryptocurrency pairs. ```APIDOC ## GET /v3/marketdata/symbollists/cryptopairs/symbolnames ### Description Fetches crypto Symbol Names for all available symbols, i.e., BTCUSD, ETHUSD, LTCUSD and BCHUSD. Note that while data can be obtained for these symbols, they cannot be traded. ### Method GET ### Endpoint `https://api.tradestation.com/v3/marketdata/symbollists/cryptopairs/symbolnames` ### Parameters No parameters are required for this endpoint. ### Response #### Success Response (200) - **SymbolNames** (array of strings) - A list of available crypto symbol names. #### Error Responses - **400** ErrorResponse - **401** ErrorResponse - **403** ErrorResponse - **404** ErrorResponse - **429** ErrorResponse - **503** ErrorResponse - **504** ErrorResponse ### Request Example ```shell curl --request GET \ --url 'https://api.tradestation.com/v3/marketdata/symbollists/cryptopairs/symbolnames' \ --header 'Authorization: Bearer TOKEN' ``` ### Response Example (200) ```json { "SymbolNames": [ "BTCUSD", "ETHUSD", "LTCUSD", "BCHUSD" ] } ``` ``` -------------------------------- ### Place Order Request Sample (Market Order) Source: https://api.tradestation.com/docs/specification This is a sample JSON payload for placing a market order for Microsoft (MSFT) stock. Ensure all required fields like AccountID, Symbol, Quantity, OrderType, and TradeAction are correctly populated. ```json { "AccountID": "123456782", "Symbol": "MSFT", "Quantity": "10", "OrderType": "Market", "TradeAction": "BUY", "TimeInForce": { "Duration": "DAY" }, "Route": "Intelligent" } ``` -------------------------------- ### Get Stream Positions Request Sample Source: https://api.tradestation.com/docs/specification This cURL command demonstrates how to request streaming positions for specified accounts. Ensure you replace 'TOKEN' with your actual authorization token and provide valid Account IDs. ```Shell curl --request GET \ --url 'https://api.tradestation.com/v3/brokerage/stream/accounts/61999124,68910124/positions' \ --header 'Authorization: Bearer TOKEN' ``` -------------------------------- ### Get Activation Triggers Source: https://api.tradestation.com/docs/specification Retrieves available trigger methods and their corresponding keys, which are necessary for placing orders with activation triggers. ```APIDOC ## GET /v3/orderexecution/activationtriggers ### Description To place orders with activation triggers, a valid TriggerKey must be sent with the order. This resource provides the available trigger methods with their corresponding key. ### Method GET ### Endpoint /v3/orderexecution/activationtriggers ### Request Example ```bash curl --request GET \ --url 'https://api.tradestation.com/v3/orderexecution/activationtriggers' \ --header 'Authorization: Bearer TOKEN' ``` ``` -------------------------------- ### Get Positions Source: https://api.tradestation.com/docs/specification Fetches positions for the given Accounts. This endpoint supports Cash, Margin, Futures, and DVP account types. ```APIDOC ## GET /v3/brokerage/accounts/{accounts}/positions ### Description Fetches positions for the given Accounts. Request valid for `Cash`, `Margin`, `Futures`, and `DVP` account types. ### Method GET ### Endpoint `https://api.tradestation.com/v3/brokerage/accounts/{accounts}/positions` ### Parameters #### Path Parameters - **accounts** (string) - Required - List of valid Account IDs for the authenticated user in comma separated format; for example `"61999124,68910124"`. 1 to 25 Account IDs can be specified, comma separated. Recommended batch size is 10. #### Query Parameters - **symbol** (string) - Optional - List of valid symbols in comma separated format; for example `MSFT,MSFT *,AAPL`. You can use an * as wildcard to make more complex filters. ### Responses #### Success Response (200) - **Positions** (array) - Positions data. - **Errors** (array) - Error details if any. #### Response Example ```json { "Positions": [ { "AccountID": "123456782", "AveragePrice": "216.68", "AssetType": "STOCK", "Last": "216.63", "Bid": "216.62", "Ask": "216.64", "ConversionRate": "1", "DayTradeRequirement": "0", "InitialRequirement": "0", "MaintenanceMargin": "0", "PositionID": "64630792", "LongShort": "Long", "Quantity": "10", "Symbol": "MSFT", "Timestamp": "2020-11-16T16:53:37Z", "TodaysProfitLoss": "-0.5", "TotalCost": "2166.8", "MarketValue": "2166.3", "MarkToMarketPrice": "216.68", "UnrealizedProfitLoss": "-0.5", "UnrealizedProfitLossPercent": "-0.023", "UnrealizedProfitLossQty": "-0.05" } ], "Errors": [ { "AccountID": "123456782C", "Error": "Forbidden", "Message": "Request not supported for account type." } ] } ``` ```