GO
Go SDK for OpenAlgo
To install the OpenAlgo Go library, use go get:
go get github.com/marketcalls/openalgo-goGet 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 package and initialize it with your API key:
package main
import (
"github.com/marketcalls/openalgo-go/openalgo"
"encoding/json"
)
// Replace 'your_api_key_here' with your actual API key
// Specify the host URL with your hosted domain or ngrok domain.
// If running locally then use the default host value.
// Parameters: apiKey, host, version, websocketURL (optional)
client := openalgo.NewClient(
"your_api_key_here",
"http://127.0.0.1:5000",
"v1", // API version
"ws://127.0.0.1:8765", // WebSocket URL (optional)
)
Check OpenAlgo Version
Complete List of Implemented Functions
Order Management
PlaceOrder- Place a new orderPlaceSmartOrder- Place a smart order with position sizingBasketOrder- Place multiple orders at onceSplitOrder- Split large orders into smaller chunksModifyOrder- Modify an existing orderCancelOrder- Cancel a specific orderCancelAllOrder- Cancel all pending ordersClosePosition- Close all open positionsOrderStatus- Get order statusOpenPosition- Get open position for a symbol
Market Data
Quotes- Get real-time quotesDepth- Get market depthHistory- Get historical dataIntervals- Get available time intervalsSymbol- Get symbol informationSearch- Search for symbolsExpiry- Get expiry dates
Account Information
Funds- Get account fundsOrderBook- Get all ordersTradeBook- Get all tradesPositionBook- Get all positionsHoldings- Get holdings
Utility
Ping- Check API connectivityAnalyzerStatus- Get analyzer statusAnalyzerToggle- Toggle analyzer mode (requires boolean: true to enable, false to disable)
WebSocket Streaming
Connect- Connect to WebSocketDisconnect- Disconnect from WebSocketSubscribeLTP- Subscribe to LTP updatesUnsubscribeLTP- Unsubscribe from LTPSubscribeQuote- Subscribe to quote updatesUnsubscribeQuote- Unsubscribe from quotesSubscribeDepth- Subscribe to market depthUnsubscribeDepth- Unsubscribe from depth
Examples
Please refer to the documentation on order constants, and consult the API reference for details on optional parameters
Ping Example
Check API connectivity:
Ping Response
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
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
Depth Example
Depth Response
History Example
History Response
Intervals Example
Intervals response
Symbol Example
Symbols Response
Search Example
Search Response
Expiry Example
Expiry Response
Funds Example
Funds 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?