https://github.com/vslee/iexsharp
IEX Cloud API for C# and other .net languages. Supports SSE streaming
https://github.com/vslee/iexsharp
api csharp dotnet finance finance-api finance-data finance-derivatives iex iex-api iex-cloud-api iex-stock iex-trading iex-trading-api iexcloud iexfinance-api iextrading market-data marketdata sdk sse-streaming
Last synced: 6 months ago
JSON representation
IEX Cloud API for C# and other .net languages. Supports SSE streaming
- Host: GitHub
- URL: https://github.com/vslee/iexsharp
- Owner: vslee
- License: mit
- Created: 2019-11-23T21:51:22.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T04:34:51.000Z (about 3 years ago)
- Last Synced: 2024-04-27T08:23:18.085Z (over 1 year ago)
- Topics: api, csharp, dotnet, finance, finance-api, finance-data, finance-derivatives, iex, iex-api, iex-cloud-api, iex-stock, iex-trading, iex-trading-api, iexcloud, iexfinance-api, iextrading, market-data, marketdata, sdk, sse-streaming
- Language: C#
- Homepage:
- Size: 994 KB
- Stars: 90
- Watchers: 16
- Forks: 37
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# IEXSharp
IEX Cloud API for C# and other .net languages. Supports SSE streaming.
## Prerequisites
This library currently targets `netstandard20`. Thus, it can be used with `.net framework 4.6.1`+ or `.net core 2.0`+
## Usage
 Prereleases are on [GH Packages](https://github.com/vslee/IEXSharp/packages). A new prerelease is built automatically after every commit.[](https://www.nuget.org/packages/VSLee.IEXSharp/) Releases are on [NuGet](https://www.nuget.org/packages/VSLee.IEXSharp/)
### IEX Cloud
```c#
public IEXCloudClient(string publishableToken, string secretToken, bool signRequest, bool useSandBox,
APIVersion version = APIVersion.stable, RetryPolicy retryPolicy = RetryPolicy.Exponential)
```
First, create an instance of `IEXCloudClient`
```c#
// For FREE and LAUNCH users
IEXCloudClient iexCloudClient =
new IEXCloudClient("publishableToken", "secretToken", signRequest: false, useSandBox: false);// For SCALE and GROW users
IEXCloudClient iexCloudClient =
new IEXCloudClient("publishableToken", "secretToken", signRequest: true, useSandBox: false);// Sandbox
IEXCloudClient iexCloudClient =
new IEXCloudClient("publishableToken", "secretToken", signRequest: false, useSandBox: true);
```
To display historical prices. Read more about [DateTime in the wiki](https://github.com/vslee/IEXSharp/wiki/DateTime).
```c#
using (var iexCloudClient =
new IEXCloudClient("publishableToken", "secretToken", signRequest: false, useSandBox: false))
{
var response = await iexCloudClient.StockPrices.HistoricalPriceAsync("AAPL", ChartRange.OneMonth);
if (response.ErrorMessage != null)
{
Console.WriteLine(response.ErrorMessage);
}
else
{
foreach (var ohlc in response.Data)
{
var dt = ohlc.GetTimestampInEST(); // note use of the extension method instead of ohlc.date
Console.WriteLine(
$"{dt} Open: {ohlc.open}, High: {ohlc.high}, Low: {ohlc.low}, Close: {ohlc.close}, Vol: {ohlc.volume}");
}
}
}```
To use SSE streaming (only included with paid IEX subscription plans). Extended [example in the wiki](https://github.com/vslee/IEXSharp/wiki/SSE-Streaming-Example).
```c#
using (var sseClient = iexCloudClient.StockPrices.QuoteStream(symbols: new string[] { "spy", "aapl" },
UTP: false, interval: StockQuoteSSEInterval.OneSecond))
{
sseClient.Error += (s, e) =>
{
Console.WriteLine("Error Occurred. Details: {0}", e.Exception.Message);
};
sseClient.MessageReceived += m =>
{
Console.WriteLine(m.ToString());
};
await sseClient.StartAsync(); // this will block until Stop() is called
}```
Additional usage examples are illustrated in the test project: [`IEXSharpTest`](https://github.com/vslee/IEXSharp/tree/master/IEXSharpTest/Cloud)### Legacy
IEX has deprecated most of their [legacy API](https://iextrading.com/developers/docs/). However, some functions are still active and you can access them via:
```c#
IEXLegacyClient iexLegacyClient = new IEXLegacyClient();
```## Contributing
We welcome pull requests! See [CONTRIBUTING.md](CONTRIBUTING.md).
## License
[](LICENSE.md)
## Disclaimers
Data provided for free by [IEX](https://iextrading.com/) via their [IEX Cloud API](https://iexcloud.io/docs/api/)
Per their [guidelines](https://iexcloud.io/docs/api/#disclaimers):
- Required: If you display any delayed price data, you must display “15 minute delayed price” as a disclaimer.
- Required: If you display latestVolume you must display “Consolidated Volume in Real-time” as a disclaimer.
- Required: If you use cash flow, income statement, balance sheet, financials, or fundamentals endpoints, use must display “Data provided by New Constructs, LLC © All rights reserved.”
- Note on pricing data: All CTA and UTP pricing data is delayed at least 15 minutes.This project is not related to the similarly named [IEX-Sharp](https://iexsharp.com/)
## Acknowledgments
* Thanks to [Zhirong Huang (ZHCode)](https://zh-code.com/) for his great foundational work on this library