Python

To install the OpenAlgo Python library, use pip:

pip install openalgo

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

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

from openalgo import api

# Replace 'your_api_key_here' with your actual API key
# Specify the host URL with your hosted domain or ngrok domain. 
# If running locally in windows then use the default host value. 
client = api(api_key='your_api_key_here', host='http://127.0.0.1:5000')

Check OpenAlgo Version

import openalgo 
openalgo.__version__

Examples

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

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 options order (Same Expiry)

Place OptionsMultiOrder Response

To place Diagonal Spread options order (Different Expiry)

Place 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

Quotes 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 strike_count (optional) parameter

Symbols Response

Symbol Example

Symbols 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

TradeBook Example

TradeBook Response

PositionBook Example

PositionBook Response

Holdings Example

Holdings Response

Analyzer Status Example

Analyzer Status Response

Analyzer Toggle Example

Analyzer Toggle Response

LTP Data (Streaming Websocket)

Quotes (Streaming Websocket)

Depth (Streaming Websocket)

Last updated

Was this helpful?