GO

Go

To install the OpenAlgo Go library, use go get:

go get github.com/marketcalls/openalgo-go

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 openalgo package and initialize the client with your API key:

package main

import (
    "fmt"
    "github.com/marketcalls/openalgo-go/openalgo"
)

func main() {
    // Replace 'your_api_key_here' with your actual API key
    // Default host is http://127.0.0.1:5000
    client := openalgo.NewClient("your_api_key_here", "http://127.0.0.1:5000")

    // Or with custom WebSocket URL
    client := openalgo.NewClient("your_api_key_here", "http://127.0.0.1:5000", "v1", "ws://127.0.0.1:8765")
}

Check 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

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, omit the strikeCount 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

With priority:

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

LTP Data (Streaming WebSocket)

Quotes (Streaming WebSocket)

Depth (Streaming WebSocket)

Last updated

Was this helpful?