-
-
Notifications
You must be signed in to change notification settings - Fork 14
Using Market Data methods
Fetch quotes, chains, and historical data. For all the market data related usages, make sure you include the MarketData Model namespace:
using Tradier.Client.Models.MarketData;
Get a list of symbols using a keyword lookup on the symbols description. Results are in descending order by average volume of the security. This can be used for simple search functions.
You can call GetQuotes passing a comma-separated string
with the symbols:
Quotes quotes = await client.MarketData.GetQuotes("AAPL, NFLX");
Or you can call GetQuotes passing a List<string>
with the symbols:
List<string> symbols = new List<string>();
symbols.Add("AAPL");
symbols.Add("NFLX");
Quotes quotes = await client.MarketData.GetQuotes(symbols);
Get a list of symbols using a keyword lookup on the symbols description. Results are in descending order by average volume of the security. This can be used for simple search functions.
You can call PostGetQuotespassing a comma-separated string
with the symbols:
Quotes quotes = await client.MarketData.PostGetQuotes("AAPL, NFLX");
Or you can call PostGetQuotes passing a List<string>
with the symbols:
List<string> symbols = new List<string>();
symbols.Add("AAPL");
symbols.Add("NFLX");
Quotes quotes = await client.MarketData.PostGetQuotes(symbols);
Get all quotes in an option chain. Greek and IV data is included courtesy of ORATS. Please check out their APIs for more in-depth options data.
Options options = await client.MarketData.GetOptionChain("AAPL", "2020-05-27");
Get expiration dates for a particular underlying.
Note that some underlying securities use a different symbol for their weekly options (RUT/RUTW, SPX/SPXW). To make sure you see all expirations, make sure to send the includeAllRoots parameter. This will also ensure any unique options due to corporate actions (AAPL1) are returned.
Expirations expirations = await client.MarketData.GetOptionExpirations("AAPL");
Get an options strike prices for a specified expiration date.
You can call GetStrikes passing the expiration as a string
:
Strikes strikes = await client.MarketData.GetStrikes("UNG", "May 15, 2020");
Or you can call GetStrikes passing the expiration as a DateTime
Strikes strikes = await client.MarketData.GetStrikes("UNG", DateTime.Now);
Get historical pricing for a security. This data will usually cover the entire lifetime of the company if sending reasonable start/end times. You can fetch historical pricing for options by passing the OCC option symbol (ex. AAPL220617C00270000) as the symbol.
You can call GetStrikes passing the start/end dates as a string
:
HistoricalQuotes historicalQuotes =
await client.MarketData.GetHistoricalQuotes("AAPL", "daily", "January 1, 2020", "May 15, 2020");
Or you can call GetStrikes passing the start/end dates as a DateTime
HistoricalQuotes historicalQuotes =
await client.MarketData.GetHistoricalQuotes("AAPL", "daily", DateTime.Today.AddDays(-1), DateTime.Today);
Time and Sales (timesales) is typically used for charting purposes. It captures pricing across a time slice at predefined intervals.
Tick data is also available through this endpoint. This results in a very large data set for high-volume symbols, so the time slice needs to be much smaller to keep downloads time reasonable.
Interval | Data Available (Open) | Data Available (All) |
---|---|---|
tick | 5 days | N/A |
1min | 20 days | 10 days |
5min | 40 days | 18 days |
15min | 40 days | 18 days |
You can call GetStrikes passing the start/end dates as a string
:
Series timeSales =
await client.MarketData.GetTimeSales("AAPL", "1min", "May 1, 2020", "May 15, 2020");
Or you can call GetStrikes passing the start/end dates as a DateTime
Series timeSales =
await client.MarketData.GetTimeSales("AAPL", "1min", DateTime.Today.AddDays(-1), DateTime.Today);
The ETB list contains securities that are able to be sold short with a Tradier Brokerage account. The list is quite comprehensive and can result in a long download response time.
Securities securities = await client.MarketData.GetEtbSecurities();
Get the intraday market status. This call will change and return information pertaining to the current day. If programming logic on whether the market is open/closed – this call should be used to determine the current state.
Clock clock = await client.MarketData.GetClock();
Get the market calendar for the current or given month. This can be used to plan ahead regarding strategies. However, the Get Intraday Status should be used to determine the current status of the market.
Calendar calendar = await client.MarketData.GetCalendar();
Get a list of symbols using a keyword lookup on the symbols description. Results are in descending order by average volume of the security. This can be used for simple search functions.
Securities securitiesFilter = await client.MarketData.SearchCompanies("NY");
Search for a symbol using the ticker symbol or partial symbol. Results are in descending order by average volume of the security. This can be used for simple search functions.
Securities lookup = await client.MarketData.LookupSymbol("goog");
using System;
using System.Linq;
using System.Threading.Tasks;
using Tradier.Client;
using Tradier.Client.Models.MarketData;
namespace MyConsoleApp
{
class Program
{
static async Task Main(string[] args)
{
TradierClient client = new TradierClient("<TOKEN>");
Quotes quotes = await client.MarketData.PostGetQuotes("AAPL, UNG");
foreach (var quote in quotes.Quote)
{
Console.WriteLine($"{quote.Symbol}: High: ${quote.High}");
}
Strikes strikes = await client.MarketData.GetStrikes("UNG", DateTime.Now);
foreach (var strike in strikes.Strike)
{
Console.WriteLine($"Strike: {strike}");
}
Expirations expirations = await client.MarketData.GetOptionExpirations("AAPL");
Console.WriteLine($"Expirations: {String.Join(",", expirations.Date.Select(x => x.ToString("D")))}");
HistoricalQuotes historicalQuotes =
await client.MarketData.GetHistoricalQuotes("AAPL", "daily", "January 1, 2020", "May 15, 2020");
Console.WriteLine($"Highs: {String.Join(",", historicalQuotes.Day.Select(x => x.High))}");
Series timeSales = await client.MarketData.GetTimeSales("AAPL", "1min", "May 1, 2020", "May 15, 2020");
Console.WriteLine($"Prices: {String.Join(",", timeSales.Data.Select(x => x.Price))}");
Securities securities = await client.MarketData.GetEtbSecurities();
Console.WriteLine($"Symbols: {String.Join(",", securities.Security.Select(x => x.Symbol))}");
Clock clock = await client.MarketData.GetClock();
Console.WriteLine($"Next Change: {clock.NextChange}");
Calendar calendar = await client.MarketData.GetCalendar();
Console.WriteLine($"Dates: {calendar.Days.Day.Select(x => x.Date)}");
Securities securitiesFilter = await client.MarketData.SearchCompanies("NY", true);
Console.WriteLine($"Symbols: {String.Join(",", securitiesFilter.Security.Select(x => x.Symbol))}");
}
}
}
Created by Henrique Tedeschi and Vitali Karmanov. See our Disclaimer. Check the API documentation on Tradier API.