.NET

OpenAlgo.NET

OpenAlgo.NET SDK for algorithmic trading - C# client for OpenAlgo API

Installation

To install the OpenAlgo.NET library, use NuGet:

dotnet add package OpenAlgo.NET

Or via Package Manager:

Install-Package OpenAlgo.NET

Compatibility

Framework
Version
Support

.NET

6.0

LTS (Long Term Support)

.NET

7.0

STS (Standard Term Support)

.NET

8.0

LTS (Long Term Support) - Recommended

The SDK is built using only built-in .NET libraries with no external dependencies.

Get the OpenAlgo apikey

Make Sure that your OpenAlgo Application is running. Login to OpenAlgo Application with valid credentials and get the OpenAlgo apikey

For detailed function parameters refer to the API Documentation

Getting Started with OpenAlgo.NET

First, import the Api class from the OpenAlgo.NET library and initialize it with your API key:

Examples

Please refer to the documentation on order constants, and consult the API reference for details on optional parameters


Sync API Reference

PlaceOrder example

To place a new market order:

Place Market Order Response

To place a new limit order:

Place Limit Order Response

PlaceSmartOrder Example

To place a smart order considering the current position size:

Place Smart Market Order Response

OptionsOrder Example

To place ATM options order

Place Options Order Response

To place ITM options order

Place Options Order Response

To place OTM options order

Place Options Order Response

OptionsMultiOrder Example

To place Iron Condor options order (Same Expiry)

OptionsMultiOrder Response

To place Diagonal Spread options order (Different Expiry)

OptionsMultiOrder Response

BasketOrder example

To place a new basket order:

Basket Order Response

SplitOrder example

To place a new split order:

SplitOrder Response

ModifyOrder Example

To modify an existing order:

Modify Order Response

CancelOrder Example

To cancel an existing order:

CancelOrder Response

CancelAllOrder Example

To cancel all open orders and trigger pending orders

CancelAllOrder Response

ClosePosition Example

To close all open positions across various exchanges

ClosePosition Response

OrderStatus Example

To Get the Current OrderStatus

OrderStatus Response

OpenPosition Example

To Get the Current OpenPosition

OpenPosition Response

Quotes Example

Quotes response

MultiQuotes Example

MultiQuotes Response

Depth Example

Depth Response

History Example

History Response

Intervals Example

Intervals Response

OptionChain Example

Note : To fetch entire option chain for a expiry remove the strikeCount (optional) parameter

OptionChain Response

Symbol Example

Symbol Response

Search Example

Search Response

OptionSymbol Example

ATM Option

OptionSymbol Response

ITM Option

OptionSymbol Response

OTM Option

OptionSymbol Response

SyntheticFuture Example

SyntheticFuture Response

OptionGreeks Example

OptionGreeks Response

Expiry Example

Expiry Response

Instruments Example

Instruments Response

Telegram Alert Example

Telegram Alert Response

Funds Example

Funds Response

Margin Example

Margin Response

OrderBook Example

OrderBook Response

TradeBook Example

TradeBook Response

PositionBook Example

PositionBook Response

Holdings Example

Holdings Response

Holidays Example

Holidays Response

Timings Example

Timings Response

Analyzer Status Example

Analyzer Status Response

Analyzer Toggle Example

Analyzer Toggle Response


Async API Reference

All methods have async versions with the Async suffix. For example:

Available Async Methods

Sync Method
Async Method

PlaceOrder()

PlaceOrderAsync()

PlaceSmartOrder()

PlaceSmartOrderAsync()

OptionsOrder()

OptionsOrderAsync()

OptionsMultiOrder()

OptionsMultiOrderAsync()

BasketOrder()

BasketOrderAsync()

SplitOrder()

SplitOrderAsync()

ModifyOrder()

ModifyOrderAsync()

CancelOrder()

CancelOrderAsync()

CancelAllOrder()

CancelAllOrderAsync()

ClosePosition()

ClosePositionAsync()

OrderStatus()

OrderStatusAsync()

OpenPosition()

OpenPositionAsync()

Quotes()

QuotesAsync()

MultiQuotes()

MultiQuotesAsync()

Depth()

DepthAsync()

History()

HistoryAsync()

Intervals()

IntervalsAsync()

OptionChain()

OptionChainAsync()

Symbol()

SymbolAsync()

Search()

SearchAsync()

OptionSymbol()

OptionSymbolAsync()

SyntheticFuture()

SyntheticFutureAsync()

OptionGreeks()

OptionGreeksAsync()

Expiry()

ExpiryAsync()

Instruments()

InstrumentsAsync()

Telegram()

TelegramAsync()

Funds()

FundsAsync()

Margin()

MarginAsync()

OrderBook()

OrderBookAsync()

TradeBook()

TradeBookAsync()

PositionBook()

PositionBookAsync()

Holdings()

HoldingsAsync()

Holidays()

HolidaysAsync()

Timings()

TimingsAsync()

AnalyzerStatus()

AnalyzerStatusAsync()

AnalyzerToggle()

AnalyzerToggleAsync()


WebSocket Streaming

LTP Data (Streaming Websocket)

LTP Response

Quotes (Streaming Websocket)

Quote Response

Depth (Streaming Websocket)

Depth Response

WebSocket Methods Summary

Method
Description

Connect() / ConnectAsync()

Connect to WebSocket server

Disconnect() / DisconnectAsync()

Disconnect from WebSocket server

SubscribeLtp(instruments, callback)

Subscribe to LTP updates

UnsubscribeLtp(instruments)

Unsubscribe from LTP updates

SubscribeQuote(instruments, callback)

Subscribe to Quote updates

UnsubscribeQuote(instruments)

Unsubscribe from Quote updates

SubscribeDepth(instruments, callback)

Subscribe to Market Depth updates

UnsubscribeDepth(instruments)

Unsubscribe from Market Depth updates

GetLtp(exchange, symbol)

Get cached LTP data

GetQuotes(exchange, symbol)

Get cached Quote data

GetDepth(exchange, symbol)

Get cached Depth data


Error Handling


Complete API Reference

Order Management

Sync Method
Async Method
Description

PlaceOrder()

PlaceOrderAsync()

Place a new order

PlaceSmartOrder()

PlaceSmartOrderAsync()

Place a smart order with position sizing

ModifyOrder()

ModifyOrderAsync()

Modify an existing order

CancelOrder()

CancelOrderAsync()

Cancel a specific order

CancelAllOrder()

CancelAllOrderAsync()

Cancel all open orders

ClosePosition()

ClosePositionAsync()

Close all open positions

OrderStatus()

OrderStatusAsync()

Get status of a specific order

OpenPosition()

OpenPositionAsync()

Get current open position quantity

Basket & Split Orders

Sync Method
Async Method
Description

BasketOrder()

BasketOrderAsync()

Place multiple orders in a single request

SplitOrder()

SplitOrderAsync()

Split large order into smaller chunks

Options Trading

Sync Method
Async Method
Description

OptionsOrder()

OptionsOrderAsync()

Place ATM/ITM/OTM option order

OptionsMultiOrder()

OptionsMultiOrderAsync()

Place multi-leg option strategy

OptionSymbol()

OptionSymbolAsync()

Get option symbol by offset

OptionChain()

OptionChainAsync()

Get full option chain data

OptionGreeks()

OptionGreeksAsync()

Calculate option Greeks

SyntheticFuture()

SyntheticFutureAsync()

Calculate synthetic future price

Expiry()

ExpiryAsync()

Get expiry dates for symbol

Market Data

Sync Method
Async Method
Description

Quotes()

QuotesAsync()

Get real-time quotes for a symbol

MultiQuotes()

MultiQuotesAsync()

Get quotes for multiple symbols

Depth()

DepthAsync()

Get market depth (order book)

History()

HistoryAsync()

Get historical OHLCV data

Intervals()

IntervalsAsync()

Get supported time intervals

Sync Method
Async Method
Description

Symbol()

SymbolAsync()

Get symbol details

Search()

SearchAsync()

Search for symbols

Instruments()

InstrumentsAsync()

Download all instruments

Account & Portfolio

Sync Method
Async Method
Description

Funds()

FundsAsync()

Get funds and margin details

Margin()

MarginAsync()

Calculate margin requirements

OrderBook()

OrderBookAsync()

Get order book

TradeBook()

TradeBookAsync()

Get trade book

PositionBook()

PositionBookAsync()

Get position book

Holdings()

HoldingsAsync()

Get stock holdings

Utilities

Sync Method
Async Method
Description

Holidays()

HolidaysAsync()

Get trading holidays for a year

Timings()

TimingsAsync()

Get exchange timings for a date

Telegram()

TelegramAsync()

Send Telegram alert message

AnalyzerStatus()

AnalyzerStatusAsync()

Get analyzer mode status

AnalyzerToggle()

AnalyzerToggleAsync()

Toggle analyze/live mode

WebSocket Streaming

Sync Method
Async Method
Description

Connect()

ConnectAsync()

Connect to WebSocket server

Disconnect()

DisconnectAsync()

Disconnect from WebSocket

SubscribeLtp()

SubscribeLtpAsync()

Subscribe to LTP updates

UnsubscribeLtp()

UnsubscribeLtpAsync()

Unsubscribe from LTP

SubscribeQuote()

SubscribeQuoteAsync()

Subscribe to Quote updates

UnsubscribeQuote()

UnsubscribeQuoteAsync()

Unsubscribe from Quote

SubscribeDepth()

SubscribeDepthAsync()

Subscribe to Depth updates

UnsubscribeDepth()

UnsubscribeDepthAsync()

Unsubscribe from Depth

GetLtp()

-

Get cached LTP data

GetQuotes()

-

Get cached Quote data

GetDepth()

-

Get cached Depth data


License

This project is licensed under the MIT License - see the LICENSE file for details.

Last updated

Was this helpful?