LewisFam.Stocks is a fast, free and simple stock and option prices API written in C#. This API can easily be intergrated into any .NET project.
- Fast and Free!
- Free real-time stock quotes from Cnbc & Webull
- Free real-time stock option prices from Webull
- .NET Cross-Platform
LewisFam.Stocks is free and open source comman class libary using.
Install-Package LewisFam.Stocks
dotnet add package LewisFam.Stocks
using LewisFam.Stocks;
var stock = await StocksUtil.FindStockAsync("MSFT"); //find
//Multiple quotes.
var stockList = new List<Stock>();
stockList.Add(stock);
//stockList.Add(someOtherStock);
var quotes = await StocksUtil.GetRealTimeMarketQuotesAsync(stockList);
////or extension method.
//quotes = await stockList.GetGetRealTimeMarketQuotesAsync();
var quote = await StocksUtil.GetRealTimeMarketQuoteAsync(stock);
////or extension method.
//quote = await stock.GetRealTimeMarketQuoteAsync();
var options = await StocksUtil.GetAllStockOptionsAsync(stock.TickerId);
////or extension method.
//options = await stock.GetAllStockOptionsAsync();
using LewisFam.Stocks.ThirdParty.Cnbc;
using LewisFam.Stocks.ThirdParty.Services;
using LewisFam.Stocks.ThirdParty.Webull;
public class Startup {
public void ConfigureServices(IServiceCollection services)
{
//..
services.AddTransient<IWebullDataService, WebullDataService>();
services.AddTransient<ICnbcDataService, CnbcDataService>();
//services.AddControllersWithViews();
//services.AddRazorPages();
//..
}
}
using LewisFam.Stocks.ThirdParty.Services;
using LewisFam.Stocks.ThirdParty.Webull;
public class SampleStockController : Controller
{
private readonly IWebullDataService _webull;
public SampleStockController(IWebullDataService webull)
{
_webull = webull;
}
public async Task<IActionResult> GetAllOptions(long tickerId)
{
var data = await _webulll.GetAllStockOptionsAsync(tickerId);
if (data == null) return BadRequest(tickerId);
return View(data);
}
}
The LewisFam library uses a number of open source projects to work properly:
- .NET
- Web access
- LewisFam.Common - a free and open source common library.
- Cnbc - Real-Time stock quotes.
- Webull - Real-Time stock quotes and option prices.
And of course LewisFam.Stocks itself is open source with a public repository on GitHub.
MIT
Free Software, Yay!
v1.0.6