OptionEdge.API.AliceBlue.Smart
1.0.0.15-beta
This is a prerelease version of OptionEdge.API.AliceBlue.Smart.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package OptionEdge.API.AliceBlue.Smart --version 1.0.0.15-beta
NuGet\Install-Package OptionEdge.API.AliceBlue.Smart -Version 1.0.0.15-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OptionEdge.API.AliceBlue.Smart" Version="1.0.0.15-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OptionEdge.API.AliceBlue.Smart --version 1.0.0.15-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OptionEdge.API.AliceBlue.Smart, 1.0.0.15-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OptionEdge.API.AliceBlue.Smart as a Cake Addin #addin nuget:?package=OptionEdge.API.AliceBlue.Smart&version=1.0.0.15-beta&prerelease // Install OptionEdge.API.AliceBlue.Smart as a Cake Tool #tool nuget:?package=OptionEdge.API.AliceBlue.Smart&version=1.0.0.15-beta&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Smart Extensions for AliceBlue .Net Client Library
This is an extension library to AliceBlue .Net Client library. This smart extension adds following useful features:
- Auto login (through PlayWright)
- Search contracts/instruments by instrument symbol or instrument token.
- Expiry calculator: get weekly/monthly expiry dates
- Symbol Generator: generate trading symbol based on expiry, strike and option type
- Get Last Traded Price by trading symbol or instrument token
- Many more features coming soon
Refer to this Youtube video for AliceBlue .Net Client library usage & integration guide ProfTheta - Your Guide to Options
Requirements
- Targets
netstandard2.0
and can be used with.Net Core 2.0 and above
&.Net Framework 4.6 and above
. - Auto login feature is provided using PlayWright through the Chromium browser. You may need to download the Chromium broswer to the application folder through the following command:
.\playwright.ps1 install chromium
Install Nuget Packages
Install-Package OptionEdge.API.AliceBlue.Smart -Version 1.0.0.13-beta
Sample project
Refer the sample file DevTest.cs
within OptionEdge.API.AliceBlue.Smart.Samples
project which demonstrate the capabilities of this library.
Getting Started
Import namespaces
using OptionEdge.API.AliceBlue.Smart;
using OptionEdge.API.AliceBlue.Records;
Sample Class File
public class DevTest
{
string? _userId = Environment.GetEnvironmentVariable("ALICE_BLUE_USER_ID");
string? _apiKey = Environment.GetEnvironmentVariable("ALICE_BLUE_API_KEY");
string? _password = Environment.GetEnvironmentVariable("ALICE_BLUE_PASSWORD");
string? _yob = Environment.GetEnvironmentVariable("ALICE_BLUE_YOB");
string? _mpin = Environment.GetEnvironmentVariable("ALICE_BLUE_MPIN");
string _tokenFileName = "token.txt";
AliceBlueSmart? _aliceBlueSmart;
public void Run()
{
_aliceBlueSmart = new AliceBlueSmart(_userId, _apiKey, enableLogging: true,
onAccessTokenGenerated: (token) =>
{
File.WriteAllText(_tokenFileName, token);
}, cachedAccessTokenProvider: () =>
{
return File.Exists(_tokenFileName) ? File.ReadAllText(_tokenFileName) : "";
}
);
// YOUR CODE HERE
// SEE BELOW FOR SAMPLE CODE
}
}
Auto login
// Login to ANT Web
// set showBrowser as true to see the browser UI else false. No browser UI will be created
// Chromium browser needs to be installed at the binary location
// .\playwright.ps1 install chromium
var isLoginSuccess = _aliceBlueSmart.Login(
userName: _userId,
password: _password,
yob: _yob,
mpin: _mpin,
showBrowser: true).Result;
if (isLoginSuccess)
Console.WriteLine("Logged in to ANT Web successfully.");
else
{
Console.WriteLine("login to ANT Web failed.");
}
Create Ticker and subscribe for live feeds
// Create Ticker for live feeds
var ticker = _aliceBlueSmart.CreateTicker();
ticker.OnClose += ticker_OnClose;
ticker.OnConnect += ticker_OnConnect;
ticker.OnTick += ticker_OnTick;
ticker.OnReady += ticker_OnReady;
// Subscribe for live feeds by instrument token
ticker.Subscribe(Constants.EXCHANGE_NFO, Constants.TICK_MODE_QUOTE, new int[] { 2222 });
// UnSubscribe from live feeds
ticker.UnSubscribe(Constants.EXCHANGE_NFO, new int[] { 2222 });
Search Contracts by Symbol or Token
// Load all contracts for NFO in memory
_aliceBlueSmart.LoadContracts(Constants.EXCHANGE_NFO);
// get contract by instrument token.
var contract1 = _aliceBlueSmart.GetInstrument(Constants.EXCHANGE_NFO, 51942);
// get contract by trading symbol
var contract2 = _aliceBlueSmart.GetInstrument(Constants.EXCHANGE_NFO, "symbol");
Get LTP (Last Traded Price)
// Get Last Traded Price by Trading Symbol or Instrument Token
var ltp = _aliceBlueSmart.GetLTP(Constants.EXCHANGE_NFO, "BANKNIFTY22SEP40800CE");
Expiry Calculator
var expiryCalculator = _aliceBlueSmart.CreateExpiryCalculator(DateTime.Now);
var allExpiries = expiryCalculator.GetExpiries();
var monthlies = expiryCalculator.GetMonthlies();
Expiry Calculator Output
15-09-2022
22-09-2022
29-09-2022
27-10-2022
24-11-2022
Symbol Generator
// Get NIFTY current week's PUT ATM strike symbol
var niftyCurrentWeekATMPut = symbolGenerator.GetSymbol(
"NIFTY",
allExpiries[0],
ALICE_BLUE_API_OPTION_TYPE.PE,
symbolGenerator.GetATMStrike(17343, 50));
// Get BANKNIFTY next week's Call ATM strike symbol
var bankniftyNextWeekATMCall = symbolGenerator.GetSymbol(
"BANKNIFTY",
allExpiries[1],
ALICE_BLUE_API_OPTION_TYPE.CE,
symbolGenerator.GetATMStrike(39856, 100));
Console.WriteLine(niftyCurrentWeekATMPut);
Console.WriteLine(bankniftyNextWeekATMCall);
Above code generates NIFTY2291517350PE
& BANKNIFTY2292239900CE
symbols.
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Playwright (>= 1.25.0)
- OptionEdge.API.AliceBlue (>= 1.0.0.15-beta)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 94 | 7/17/2024 |
1.0.7 | 102 | 5/5/2024 |
1.0.6 | 121 | 4/23/2024 |
1.0.5 | 113 | 4/23/2024 |
1.0.4 | 275 | 3/27/2023 |
1.0.3 | 414 | 10/13/2022 |
1.0.2 | 475 | 9/30/2022 |
1.0.1 | 471 | 9/23/2022 |
1.0.0.15-beta | 172 | 9/16/2022 |
1.0.0.14-beta | 169 | 9/16/2022 |
1.0.0.13-beta | 172 | 9/15/2022 |
1.0.0.12-beta | 181 | 9/15/2022 |
1.0.0.11-beta | 154 | 9/15/2022 |
1.0.0.10-beta | 187 | 9/14/2022 |
1.0.0.5-beta | 151 | 9/11/2022 |