Skip to content

Getting Started

Welcome to go-arrow, the official Go SDK for the Arrow Trading Platform. The package covers REST APIs for orders, portfolio, margins, and market data, plus WebSocket helpers for live quotes and order updates.

Current release: v1.8.0. Import the arrow package from github.com/arrow-trade/go-arrow.

Key Features

  • Market Data & Analytics


    Real-time quotes, OHLC, LTP, market depth, historical candles, option chains, Greeks, and more.

  • Order Management


    Place, modify, and cancel orders across NSE, BSE, NFO, BFO, and MCXFO with limit, stop, and mpp market-style orders.

  • Real-time Streaming


    WebSocket feeds for order updates, token market data (ltp / ltpc / quote / full + CAS), and HFT (zstd) ticks.

  • Secure Authentication


    Request-token OAuth (Authenticate) and fully automated login with TOTP (AutoLogin).

Installation

go get github.com/arrow-trade/go-arrow@v1.8.0

Pin a release tag in production. go get github.com/arrow-trade/go-arrow@latest tracks the newest tagged version.

The module path is github.com/arrow-trade/go-arrow. Import the public package as:

import "github.com/arrow-trade/go-arrow/arrow"

Requirements

Package Version
Go 1.24+
github.com/valyala/fasthttp Latest
github.com/gorilla/websocket Latest
github.com/pquerna/otp Latest
github.com/klauspost/compress Latest
github.com/rs/zerolog Latest

Dependencies are pulled automatically by go get.

Quick Start

1. Initialize the Client

NewClient takes both the application ID and the application secret. REST calls use a 10s timeout by default (same as the Python SDK).

package main

import (
    "time"

    "github.com/arrow-trade/go-arrow/arrow"
)

func main() {
    client := arrow.NewClient("YOUR_APP_ID", "YOUR_APP_SECRET")

    // Optional: verbose request lifecycle logs
    client.SetDebug(true)

    // Optional: override the 10s REST timeout
    // client := arrow.NewClientWithTimeout("YOUR_APP_ID", "YOUR_APP_SECRET", 30*time.Second)
    // client.SetHTTPTimeout(30 * time.Second)
}

App secret at construction

Unlike the Python client (ArrowClient(app_id=...) then secret at login), Go stores AppSecret on Client.Config and uses it for Authenticate checksums. Do not hard-code it — load from the environment.

2. Authenticate

if err := client.AutoLogin("YOUR_USER_ID", "YOUR_PASSWORD", "YOUR_TOTP_SECRET"); err != nil {
    log.Fatal(err)
}
// Interactive: prints https://app.arrow.trade/app/login?appId=... and reads the request token from stdin
client.Login()

// Or exchange a token you already captured from the callback URL:
token, err := client.Authenticate("request_token_from_callback")
if err != nil {
    log.Fatal(err)
}
fmt.Println("Access token:", token)

3. Place Your First Order

order, err := client.PlaceOrder("regular", arrow.OrderRequest{
    Exchange:        string(arrow.ExchangeNSE),
    Symbol:          "RELIANCE-EQ",
    Quantity:        "1",
    DisclosedQty:    "0",
    Product:         string(arrow.ProductCNC),
    OrderType:       string(arrow.OrderTypeLimit),
    TransactionType: string(arrow.TransactionTypeBuy),
    Price:           "1450.0",
    Validity:        string(arrow.ValidityDAY),
})
if err != nil {
    log.Fatal(err)
}
fmt.Println("Order placed:", order.Data.OrderNo)

Numeric fields on OrderRequest are strings (the REST body uses string quantities and prices).

4. Get Market Data

quote, err := client.GetQuote(arrow.ExchangeNSE, "RELIANCE-EQ", arrow.InfoQuoteLTP)
if err != nil {
    log.Fatal(err)
}
// REST prices are integers in paise (×100)
ltp := quote["ltp"].(float64) / 100
fmt.Printf("Last traded price: ₹%.2f\n", ltp)

Argument order

GetQuote(exchange, symbol, mode) — exchange first. The Python SDK is get_quote(mode, symbol, exchange).

5. Stream Live Data

import (
    "context"
    "fmt"
    "log"

    "github.com/arrow-trade/go-arrow/arrow"
)

streams, err := client.NewStreams() // order updates + token data stream
if err != nil {
    log.Fatal(err)
}
defer streams.Close()

if err := streams.DataStream.Subscribe(arrow.StreamModeQuote, []int32{3045, 1594}); err != nil {
    log.Fatal(err)
}

ctx := context.Background()
go streams.DataStream.ReadTicks(ctx, func(tick arrow.MarketTick) {
    fmt.Printf("Token: %d | LTP: %d | IsCAS: %v\n", tick.Token, tick.LTP, tick.IsCAS)
}, func(err error) {
    log.Println("tick error:", err)
})

select {} // keep the process alive

What's Next?

Topic Description
Authentication Request-token and AutoLogin flows, session helpers
Orders Place, modify, cancel, margin, order book
Portfolio Positions, holdings, limits, user profile
Market Data Quotes, candles, instruments, option chain, Greeks
WebSocket Streaming Order stream, token stream, HFT, CAS
API Reference Complete method and constant catalog

Support

Resource Link
Documentation https://docs.arrow.trade
Source github.com/arrow-trade/go-arrow
Package docs pkg.go.dev/github.com/arrow-trade/go-arrow
Support Email support@arrow.trade

Pro Tip

Start with the Authentication guide before wiring live orders. Tokens expire after 24 hours.