NodeJS
NodeJS
To install the OpenAlgo Node.js library, use npm:
npm install openalgoGet 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 OpenAlgo class from the library and initialize it with your API key:
import OpenAlgo from 'openalgo';
// 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.
const client = new OpenAlgo('your_api_key_here', 'http://127.0.0.1:5000');Check OpenAlgo Version
import { version } from 'openalgo';
console.log(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 Condor 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
MultiQuotes response
Depth Example
Depth Response
History Example
History Response
Intervals Example
Intervals response
OptionChain Example
Note: To fetch entire option chain for an expiry, remove the strikeCount (optional) parameter
OptionChain 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
Holidays Example
Holidays Response
Timings Example
Timings Response
Analyzer Status Example
Analyzer Status Response
Analyzer Toggle Example
Analyzer Toggle Response
LTP Data (Streaming Websocket)
Quotes (Streaming Websocket)
Depth (Streaming Websocket)
Please refer to the documentation and consult the API reference for details on optional parameters:
Last updated
Was this helpful?