tradestation-api-ts
Version:
A comprehensive TypeScript wrapper for TradeStation WebAPI v3
1,189 lines • 534 kB
JSON
{
"openapi": "3.0.3",
"info": {
"title": "",
"description": "# Authentication\nFor more information on authorization and gaining an access/refresh token, please visit: [Authentication](/docs/fundamentals/authentication/auth-overview).\n<SecurityDefinitions />\n",
"version": "",
"contact": {
"name": "TradeStation API Team",
"email": "ClientExperience@tradestation.com",
"url": "https://developer.tradestation.com/webapi"
}
},
"servers": [
{
"url": "https://api.tradestation.com"
}
],
"security": [
{
"Bearer-Token": []
}
],
"tags": [
{
"name": "marketdata",
"description": "Snapshots and live streams of market data from supported exchanges.\n"
}
],
"paths": {
"/v2/data/symbols/suggest/{text}": {
"get": {
"summary": "Suggest Symbols\n",
"description": "Suggests symbols semantically based upon partial input of symbol name,\ncompany name, or description. Does not return Options symbols.\n",
"operationId": "suggestsymbols",
"tags": [
"marketdata"
],
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v2/data/symbols/suggest/{text}' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v2/data/symbols/suggest/{text}',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v2/data/symbols/suggest/{text}\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers)\n\nprint(response.text)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v2/data/symbols/suggest/{text}\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request))\n{\n response.EnsureSuccessStatusCode();\n var body = await response.Content.ReadAsStringAsync();\n Console.WriteLine(body);\n}"
}
],
"parameters": [
{
"name": "$top",
"in": "query",
"description": "The top number of results to return.",
"required": false,
"schema": {
"type": "integer"
}
},
{
"name": "$filter",
"in": "query",
"description": "An OData filter to apply to the results. Supports the `eq` and `neq` filter opeators. E.g. `AAP?$filter=Category%20neq%20%27Stock%27`.\nValid values are: `Category` (`Stock`, `Index`, `Future`, `Forex`), `Country` (E.g. `United States`, `GB`) `Currency` (E.g. `USD`, `AUD`),\nand `Exchange` (E.g. `NYSE`).",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "text",
"in": "path",
"description": "Symbol text for suggestion. Partial input of a symbol name, company name, or description.",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Symbol Suggest",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/SymbolSuggestDefinition"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Unexpected Error",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"502": {
"description": "Bad Gateway",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"504": {
"description": "Gateway Timeout",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v2/data/symbols/search/{criteria}": {
"get": {
"summary": "Search for Symbols\n",
"description": "Searches symbols based upon input criteria including Name, Category and\nCountry.\n",
"operationId": "searchSymbols",
"tags": [
"marketdata"
],
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v2/data/symbols/search/{criteria}' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v2/data/symbols/search/{criteria}',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v2/data/symbols/search/{criteria}\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers)\n\nprint(response.text)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v2/data/symbols/search/{criteria}\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request))\n{\n response.EnsureSuccessStatusCode();\n var body = await response.Content.ReadAsStringAsync();\n Console.WriteLine(body);\n}"
}
],
"parameters": [
{
"name": "criteria",
"in": "path",
"description": "Criteria are represented as Key/value pairs (`&` separated):\n\n`N`: Name of Symbol. (Optional)\n\n`C`: Asset categories. (Optional) Possible values:\n - `Future` or `FU`\n - `FutureOption` or `FO`\n - `Stock` or `S` (Default)\n - `StockOption` or `SO` (If root is specified, default category)\n - `Index` or `IDX`\n - `CurrencyOption` or `CO`\n - `MutualFund` or `MF`\n - `MoneyMarketFund` or `MMF`\n - `IndexOption` or `IO`\n - `Bond` or `B`\n - `Forex` or `FX`\n\n`Cnt`: Country where the symbol is traded in. (Optional) Possible values:\n - `ALL` if not specified (Default)\n - `US`\n - `DE`\n - `CA`\n\n#### For Equities Lookups:\n\n`N`: partial/full symbol name, will return all symbols that contain the provided name value\n\n`Desc`: Name of the company\n\n`Flg`: indicates whether symbols no longer trading should be included in the results returned. (Optional) This criteria is not returned in the symbol data. Possible values:\n - `true`\n - `false` (Default)\n\n`Cnt`: Country where the symbol is traded in. (Optional) Possible values:\n - `ALL` if not specified (Default)\n - `US`\n - `DE`\n - `CA`\n\n#### For Options Lookups:\n(Category=StockOption, IndexOption, FutureOption or CurrencyOption)\n\n`R`: Symbol root. Required field, the symbol the option is a derivative of, this search will not return options based on a partial root.\n\n`Stk`: Number of strikes prices above and below the underlying price\n - Default value 3\n\n`Spl`: Strike price low\n\n`Sph`: Strike price high\n\n`Exd`: Number of expiration dates.\n - Default value 3\n\n`Edl`: Expiration date low, ex: 01-05-2011\n\n`Edh`: Expiration date high, ex: 01-20-2011\n\n`OT`: Option type. Possible values:\n - `Both` (Default)\n - `Call`\n - `Put`\n\n`FT`: Future type for FutureOptions. Possible values:\n - `Electronic` (Default)\n - `Pit`\n\n`ST`: Symbol type: Possible values:\n - `Both`\n - `Composite` (Default)\n - `Regional`\n\n#### For Futures Lookups:\n(Category = Future)\n\n`Desc`: Description of symbol traded\n\n`R`: Symbol root future trades\n\n`FT`: Futures type. Possible values:\n - `None`\n - `PIT`\n - `Electronic` (Default)\n - `Combined`\n\n`Cur`: Currency. Possible values:\n - `All`\n - `USD` (Default)\n - `AUD`\n - `CAD`\n - `CHF`\n - `DKK`\n - `EUR`\n - `DBP`\n - `HKD`\n - `JPY`\n - `NOK`\n - `NZD`\n - `SEK`\n - `SGD`\n\n`Exp`: whether to include expired contracts\n - `false` (Default)\n - `true`\n\n`Cnt`: Country where the symbol is traded in. (Optional) Possible values:\n - `ALL` if not specified (Default)\n - `US`\n - `DE`\n - `CA`\n\n#### For Forex Lookups:\n\n`N`: partial/full symbol name. Use all or null for a list of all forex symbols\n\n`Desc`: Description\n\nNote:\n - The exchange returned for all forex searches will be `FX`\n - The country returned for all forex searches will be `FOREX`\n",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Symbol Search Response",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/SymbolSearchDefinition"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Symbol Not Found",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Unexpected Error",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"502": {
"description": "Bad Gateway",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"504": {
"description": "Gateway Timeout",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v2/stream/tickbars/{symbol}/{interval}/{barsBack}": {
"get": {
"summary": "Stream Tick Bars\n",
"description": "Streams tick bars data for the regular session from a number of bars back, each bar returned separated by interval number of ticks.\n",
"operationId": "streamTickBars",
"tags": [
"marketdata"
],
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options).on('data', function (data) {\n console.log(data.toString());\n}).on('error', function(err) {\n console.error(err)\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers, stream=True)\n\nfor line in response.iter_lines():\n if line:\n print(line)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v2/stream/tickbars/{symbol}/{interval}/{barsBack}\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))\n{\n response.EnsureSuccessStatusCode();\n using (var stream = await response.Content.ReadAsStreamAsync())\n {\n using (StreamReader reader = new StreamReader(stream))\n {\n while (!reader.EndOfStream)\n {\n var line = await reader.ReadLineAsync();\n if (line == null) break;\n Console.WriteLine(line);\n }\n }\n }\n}"
}
],
"parameters": [
{
"name": "symbol",
"in": "path",
"description": "A Symbol Name",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "interval",
"in": "path",
"description": "Interval for each bar returned (in ticks).",
"required": true,
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 64999
}
},
{
"name": "barsBack",
"in": "path",
"description": "The number of bars to stream, going back from current time.",
"required": true,
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 10
}
}
],
"responses": {
"200": {
"description": "Tickbar Response",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/TickbarDefinition"
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Symbol Not Found",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Unexpected Error",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"502": {
"description": "Bad Gateway",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"504": {
"description": "Gateway Timeout",
"content": {
"application/vnd.tradestation.streams+json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/v3/brokerage/accounts": {
"get": {
"tags": [
"Brokerage"
],
"description": "Fetches the list of Brokerage Accounts available for the current user.",
"operationId": "GetAccounts",
"summary": "Get Accounts",
"responses": {
"200": {
"description": "Accounts",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Accounts"
},
"example": {
"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"
}
]
}
}
}
},
"400": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"401": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"403": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"429": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"503": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"504": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v3/brokerage/accounts' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v3/brokerage/accounts',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v3/brokerage/accounts\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers)\n\nprint(response.text)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v3/brokerage/accounts\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request))\n{\n response.EnsureSuccessStatusCode();\n var body = await response.Content.ReadAsStringAsync();\n Console.WriteLine(body);\n}"
}
]
}
},
"/v3/brokerage/accounts/{accounts}/balances": {
"get": {
"tags": [
"Brokerage"
],
"description": "Fetches the brokerage account `Balances` for one or more given accounts. Request valid for `Cash`, `Margin`, `Futures`, and `DVP` account types.",
"operationId": "GetBalances",
"summary": "Get Balances",
"parameters": [
{
"name": "accounts",
"in": "path",
"description": "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.",
"required": true,
"schema": {
"type": "string",
"example": "61999124,68910124"
}
}
],
"responses": {
"200": {
"description": "Balances",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Balances"
},
"example": {
"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."
}
]
}
}
}
},
"400": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"401": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"403": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"429": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"503": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"504": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/balances' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/balances',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/balances\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers)\n\nprint(response.text)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/balances\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request))\n{\n response.EnsureSuccessStatusCode();\n var body = await response.Content.ReadAsStringAsync();\n Console.WriteLine(body);\n}"
}
]
}
},
"/v3/brokerage/accounts/{accounts}/bodbalances": {
"get": {
"tags": [
"Brokerage"
],
"description": "Fetches the Beginning of Day Balances for the given Accounts. Request valid for `Cash`, `Margin`, `Futures`, and `DVP` account types.",
"operationId": "GetBalancesBOD",
"summary": "Get Balances BOD",
"parameters": [
{
"name": "accounts",
"in": "path",
"description": "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.",
"required": true,
"schema": {
"type": "string",
"example": "61999124,68910124"
}
}
],
"responses": {
"200": {
"description": "BalancesBOD",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BalancesBOD"
},
"example": {
"BODBalances": [
{
"AccountID": "123456789",
"AccountType": "Cash",
"BalanceDetail": {
"AccountBalance": "987654321258.98",
"CashAvailableToWithdraw": "987654321258.98",
"DayTradingMarginableBuyingPower": "987654321258.98",
"DayTrades": "0",
"Equity": "987654321258.98",
"NetCash": "987654321258.98",
"OptionBuyingPower": "987654321258.98",
"OptionValue": "0",
"OvernightBuyingPower": "987654321258.98"
}
},
{
"AccountID": "123456782",
"AccountType": "Margin",
"BalanceDetail": {
"AccountBalance": "40000000",
"CashAvailableToWithdraw": "40000000",
"DayTradingMarginableBuyingPower": "40000000",
"DayTrades": "0",
"Equity": "40000000",
"NetCash": "40000000",
"OptionBuyingPower": "40000000",
"OptionValue": "0",
"OvernightBuyingPower": "80000000"
}
},
{
"AccountID": "123456781",
"AccountType": "Futures",
"BalanceDetail": {
"Equity": "123456784.32",
"CashAvailableToWithdraw": "123456784.32",
"NetCash": "123456784.32",
"OpenTradeEquity": "0",
"SecurityOnDeposit": "0"
},
"CurrencyDetails": [
{
"Currency": "USD",
"CashBalance": "123456784.32",
"AccountOpenTradeEquity": "0",
"AccountSecurities": "0",
"OpenTradeEquity": "0",
"Securities": "0"
}
]
}
],
"Errors": [
{
"AccountID": "123456789C",
"Error": "Forbidden",
"Message": "Request not supported for account type."
}
]
}
}
}
},
"400": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"401": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"403": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"429": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"503": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"504": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"x-codeSamples": [
{
"lang": "Shell",
"source": "curl --request GET \\\n --url 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/bodbalances' \\\n --header 'Authorization: Bearer TOKEN'"
},
{
"lang": "Node",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/bodbalances',\n headers: {Authorization: 'Bearer TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python",
"source": "import requests\n\nurl = \"https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/bodbalances\"\n\nheaders = {\"Authorization\": \"Bearer TOKEN\"}\n\nresponse = requests.request(\"GET\", url, headers=headers)\n\nprint(response.text)"
},
{
"lang": "C#",
"source": "var client = new HttpClient();\nvar request = new HttpRequestMessage\n{\n Method = HttpMethod.Get,\n RequestUri = new Uri(\"https://api.tradestation.com/v3/brokerage/accounts/61999124,68910124/bodbalances\"),\n Headers =\n {\n { \"Authorization\", \"Bearer TOKEN\" },\n },\n};\nusing (var response = await client.SendAsync(request))\n{\n response.EnsureSuccessStatusCode();\n var body = await response.Content.ReadAsStringAsync();\n Console.WriteLine(body);\n}"
}
]
}
},
"/v3/brokerage/accounts/{accounts}/historicalorders": {
"get": {
"tags": [
"Brokerage"
],
"description": "Fetches Historical Orders for the given Accounts except open orders, sorted in descending order of time closed. Request valid for all account types.",
"operationId": "GetHistoricalOrders",
"summary": "Get Historical Orders",
"parameters": [
{
"name": "accounts",
"in": "path",
"description": "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.",
"required": true,
"schema": {
"type": "string",
"example": "61999124,68910124"
}
},
{
"name": "since",
"in": "query",
"description": "Historical orders since date. For example `\"2006-01-13\",\"01-13-2006\",\"2006/01/13\",\"01/13/2006\"`. Limited to 90 days prior to the current date.",
"required": true,
"schema": {
"type": "string",
"example": "2006-01-13"
}
},
{
"name": "pageSize",
"in": "query",
"description": "The number of requests returned per page when paginating responses. If not provided, results will not be paginated and a maximum of 600 orders is returned.",
"required": false,
"schema": {
"type": "integer",
"example": 600,
"minimum": 1,
"default": 600,
"maximum": 600
}
},
{
"name": "nextToken",
"in": "query",
"description": "An encrypted token with a lifetime of 1 hour for use with paginated order responses. This is returned with paginated results, and used in only the subsequent request which will return a new nextToken until there are fewer returned orders than the requested pageSize. If the number of returned orders equals the pageSize, and there are no additional orders, the nextToken will not be generated.",
"required": false,
"schema": {
"type": "string",
"example": "eyJ0aW1lc3RhbXAiOjE2NT...NTMwMDB9"
}
}
],
"responses": {
"200": {
"description": "Orders",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HistoricalOrders"
},
"example": {
"Orders": [
{
"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",
"ClosedDateTime": "2020-11-16T16:53:37Z",
"Currency": "USD",
"Duration": "GTC",
"FilledPrice": "216.68",
"GoodTillDate": "2021-02-14T00:00:00Z",
"Legs": [
{
"OpenOrClose": "Open",
"QuantityOrdered": "10",
"ExecQuantity": "10",
"QuantityRemaining": "0",
"BuyOrSell": "Buy",
"Symbol": "MSFT",
"AssetType": "STOCK"
}
],
"OrderID": "123456789",
"OpenedDateTime": "2020-11-16T16:53:37Z",
"OrderType": "Market",
"PriceUsedForBuyingPower": "216.66",
"Routing": "Intelligent",
"Status": "FLL",
"StatusDescription": "Filled",
"UnbundledRouteFee": "0"
},
{
"AccountID": "123456782",
"CommissionFee": "0",
"ConditionalOrders": [
{
"Relationship": "OCO",
"OrderID": "286179864"
}
],
"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"
}
],
"LimitPrice": "230",
"OrderID": "286179863",
"OpenedDateTime": "2020-11-17T16:34:37Z",
"OrderType": "Limit",
"PriceUsedForBuyingPower": "230",
"Routing": "Intelligent",
"Status": "ACK",
"StatusDescription": "Received",
"AdvancedOptions": "OCA=2706452145;",
"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"
}
],
"Errors": [],
"NextToken": "eyJ0aW1lc3RhbXAiOjE2NTY1NjI2MDQwMDEs>LTM3QzAtNEIxOS04OTU4LUExQ0YwQjYwRDM3NSIsImV4cGlyYXRpb25UaW1lc3RhbXAiOjE2NTY2OTM3NTMwMDB9"
}
}
}
},
"400": {
"description": "ErrorResponse",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}