govortex

package module
v2.0.0-beta.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 20 Imported by: 0

README

Go Reference

Vortex API Golang Client

Official golang client for communicating with Vortex API

Vortex APIs are meant for clients who want to execute orders based on their own strategy programatically and for partners to build their own applications. These apis provide a fast and secure way to place trades, manage positions and access real time market data.

Documentation

Installation

    go get github.com/AsthaTech/govortex

Getting Started with APIs

package main

import (
	"context"

	govortex "github.com/AsthaTech/govortex/v2"
)

const (
	applicationId string = "testApplicationId"
	apiKey        string = "testApiKey"
)

func main() {
	var client govortex.VortexApi
	govortex.InitializeVortexApi(applicationId, apiKey, &client)
	ctx := context.Background()
	client.Login(ctx, "clientCode", "password", "totp")
	// Access token is automatically set upon successful login call

	client.Orders(ctx, 1, 20) //orders need an offset and limit
	client.Positions(ctx)     //positions need an offset and limit

	client.PlaceOrder(ctx, govortex.PlaceOrderRequest{
		Exchange:          govortex.ExchangeTypesNSEEQUITY,
		Token:             22,
		TransactionType:   govortex.TransactionTypesBUY,
		Product:           govortex.ProductTypesDelivery,
		Variety:           govortex.VarietyTypesRegularMarketOrder,
		Quantity:          1,
		Price:             1800,
		TriggerPrice:      0,
		DisclosedQuantity: 0,
		Validity:          govortex.ValidityTypesFullDay,
		ValidityDays:      1,
		IsAMO:             false,
	})

	client.Funds(ctx)

}

Getting started with Feed

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"time"

	"github.com/AsthaTech/govortex/v2"
)

var wire *govortex.Wire

const (
	applicationId string = "testApplicationId"
	apiKey        string = "testApiKey"
)

func main() {
	var client govortex.VortexApi
	govortex.InitializeVortexApi(applicationId, apiKey, &client)
	ctx := context.Background()
	client.Login(ctx, "clientCode", "password", "totp")
	accessToken := client.AccessToken

	// Initialize the wire client
	wire = &govortex.Wire{}
	govortex.InitializeWire(accessToken, wire)

	// Define callbacks
	wire.OnConnect(onConnect)
	wire.OnPriceUpdate(onPriceUpdate)
	wire.OnError(onError)
	wire.OnClose(onClose)
	wire.OnReconnect(onReconnect)
	wire.OnOrderUpdate(onOrderUpdate)

	// Start websocket server
	wire.Serve()
}

func onConnect() {
	fmt.Println("connected")
	wire.Subscribe(govortex.ExchangeTypesNSEEQUITY, 22, govortex.QuoteModesFULL)
}

func onPriceUpdate(q *govortex.FullQuoteData) {
	aa, _ := json.Marshal(q)
	fmt.Println(string(aa))
}

func onError(err error) {
	fmt.Println(err.Error())
}

func onClose(code int, reason string) {
	fmt.Println(code, reason)
}

func onReconnect(attempt int, delay time.Duration) {
	fmt.Println(attempt, delay)
}

func onOrderUpdate(msg govortex.SocketMessage) {
	aa, _ := json.Marshal(msg)
	fmt.Println(string(aa))
}

Run Tests

go test

Generate Docs

go doc -all > doc.txt

Documentation

Index

Constants

View Source
const (
	URILogin               string = "/user/login"
	URISession             string = "/user/session"
	URIInstruments         string = "/data/instruments"
	URIPlaceOrder          string = "/trading/orders/%s"                   //"/trading/orders/regular"
	URIModifyOrder         string = "/trading/orders/%s/%s"                //"/trading/orders/{{order_type}}/{order_id}"
	URIModifyOrderTags     string = "/trading/orders/%s/%s/tags"           //"/trading/orders/{{order_type}}/{order_id}/tags"
	URIDeleteOrder         string = "/trading/orders/%s/%s"                //"/trading/orders/{{order_type}}/{order_id}"
	URIDeleteMultipleOrder string = "/trading/orders/%s/multi_delete"      //"/trading/orders/{{order_type}}/{order_id}"
	URIGttOrderBook        string = "/trading/orders/gtt"                  //"/trading/orders/gtt"
	URIOrderBook           string = "/trading/orders"                      //"/trading/orders"
	URIMultiCancelrders    string = "/trading/orders/regular/multi_delete" //"/trading/orders/regular/multi_delete"
	URIOrderHistory        string = "/trading/orders/%s"                   //"/trading/orders/{order_id}"
	URITrades              string = "/trading/trades"

	URIPositions       string = "/trading/portfolio/positions"
	URIConvertposition string = "/trading/portfolio/positions"
	URIHoldings        string = "/trading/portfolio/holdings"

	URIFunds     string = "/user/funds"
	URIBanks     string = "/user/profile/banks"
	URIBrokerage string = "/user/profile/brokerage"

	URIWithdrawal   string = "/user/funds/withdrawal"
	URIOrderMargin  string = "/margins/order"
	URIBasketMargin string = "/margins/basket"
	URIQuotes       string = "/data/quote"
	URIHistory      string = "/data/history"

	URIOptionChain string = "/strategies/option_chain"

	URIStrategies       string = "/strategies"
	URIBuildStrategies  string = "/strategies/build"
	URIPayoffStrategies string = "/strategies/payoff"

	URITradeReport           string = "/reports/trades/%s?from_date=%s&to_date=%s"
	URITurnoverSummaryReport string = "/reports/turnover/summary/%s?from_date=%s&to_date=%s"
	URITurnoverDetailsReport string = "/reports/turnover/details/%s?from_date=%s&to_date=%s"
	URIPnLReport             string = "/reports/pnl/%s?from_date=%s&to_date=%s"
	URIMTFInterestReport     string = "/reports/mtf_interest/%s?from_date=%s&to_date=%s"

	URITags string = "/reports/tags"
	URITag  string = "/reports/tags/%d"
)

Constants for the API endpoints

View Source
const (
	GeneralError    = "GeneralException"
	TokenError      = "TokenException"
	PermissionError = "PermissionError"
	UserError       = "UserException"
	TwoFAError      = "TwoFAException"
	OrderError      = "OrderException"
	InputError      = "InputException"
	DataError       = "DataException"
	NetworkError    = "NetworkException"
	NotFoundError   = "NotFoundException"
)

Variables

This section is empty.

Functions

func GetErrorName

func GetErrorName(code int) string

GetErrorName returns an error name given an HTTP code.

func InitializeVortexApi

func InitializeVortexApi(applicationId string, apiKey string, apiClient *VortexApi) error

Function to get a new instance of VortexApi Client.

func InitializeWire

func InitializeWire(accessToken string, wire *Wire) error

Default method to create a new instance of Wire which can be used to get price updates and order updates

func NewError

func NewError(etype string, message string, data interface{}) error

NewError creates and returns a new instace of Error with custom error metadata.

Types

type AlertCondition

type AlertCondition string
const (
	AlertConditionLE AlertCondition = "LE"
	AlertConditionGE AlertCondition = "GE"
	AlertConditionEQ AlertCondition = "EQ"
)

type AlertInfo

type AlertInfo struct {
	Name           string         `json:"name"`
	ClientCode     string         `json:"client_code"`
	Token          int            `json:"token"`
	Exchange       ExchangeTypes  `json:"exchange"`
	TriggerValue   float64        `json:"trigger_value"`
	Property       AlertProperty  `json:"property"`
	Condition      AlertCondition `json:"condition"`
	Status         string         `json:"status" `
	Note           string         `json:"note"`
	Expiry         time.Time      `json:"expiry"`
	LastExecutedAt time.Time      `json:"last_executed_at"`
	IsExecuted     *bool          `json:"is_executed"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
}

type AlertProperty

type AlertProperty string
const (
	AlertPropertyLTP      AlertProperty = "LTP"
	AlertPropertyVOLUME   AlertProperty = "VOLUME"
	AlertPropertyAVGPRICE AlertProperty = "AVGPRICE"
)

type BankDetails

type BankDetails struct {
	AccountNumber string `json:"account_number"`
	Ifsc          string `json:"ifsc"`
	IsPrimary     bool   `json:"is_primary"`
	AccountType   string `json:"account_type"`
	BankName      string `json:"bank_name"`
}

type BanksResponse

type BanksResponse struct {
	Status string              `json:"status"`
	Data   ExchangeBankDetails `json:"data"`
}

type BasketMarginOrder

type BasketMarginOrder struct {
	Exchange        ExchangeTypes    `json:"exchange"`         // Required: Exchange type.
	Token           int              `json:"token"`            // Required: Token of the underlying instrument.
	TransactionType TransactionTypes `json:"transaction_type"` // Required: Type of transaction.
	Product         ProductTypes     `json:"product"`          // Required: Type of product.
	Variety         VarietyTypes     `json:"variety"`          // Required: Type of variety.
	Quantity        int              `json:"quantity"`         // Required: Quantity of the order.
	Price           float64          `json:"price"`            // Required: Price of the order.
}

type BasketMarginRequest

type BasketMarginRequest struct {
	Orders []BasketMarginOrder `json:"orders"`
}

type BasketMarginResponse

type BasketMarginResponse struct {
	Status         string  `json:"status"`
	InitialMargin  float64 `json:"initial_margin"`
	RequiredMargin float64 `json:"required_margin"`
}

type CancelIcebergOrderResponse

type CancelIcebergOrderResponse struct {
	Message string `json:"message"`
	Status  string `json:"status"`
}

type ConvertPositionRequest

type ConvertPositionRequest struct {
	Exchange        ExchangeTypes    `json:"exchange"`         // Required: Exchange type.
	Token           int              `json:"token"`            // Required: Token of the underlying instrument.
	TransactionType TransactionTypes `json:"transaction_type"` // Required: Type of transaction.
	Quantity        int              `json:"quantity"`         // Required: Quantity of the position to convert.
	OldProductType  ProductTypes     `json:"old_product"`      // Required: Old product type of the position.
	NewProductType  ProductTypes     `json:"new_product"`      // Required: New product type to convert the position to.
}

ConvertPositionRequest represents a request to convert a position.

type ConvertPositionResponse

type ConvertPositionResponse struct {
	Status  string `json:"status"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

type DateOptionData

type DateOptionData struct {
	StrikePrice float64        `json:"strike_price"`
	IV          float64        `json:"iv"`
	Theta       float64        `json:"theta"`
	Vega        float64        `json:"vega"`
	Gamma       float64        `json:"gamma"`
	CE          StockWithGreek `json:"CE"`
	PE          StockWithGreek `json:"PE"`
}

type Error

type Error struct {
	Code      int
	ErrorType string
	Message   string
	Data      interface{}
}

Error is the error type used for all API errors.

func (Error) Error

func (e Error) Error() string

This makes Error a valid Go error type.

type ExchangeAuthTokenRequest

type ExchangeAuthTokenRequest struct {
	Checksum      string `json:"checksum"`
	ApplicationId string `json:"applicationId"`
	Token         string `json:"token"`
}

type ExchangeBankDetails

type ExchangeBankDetails struct {
	Nse []BankDetails `json:"nse"`
	Mcx []BankDetails `json:"mcx"`
}

type ExchangeDetail

type ExchangeDetail struct {
	Token    int           `json:"token"`
	Exchange ExchangeTypes `json:"exchange"`
	Symbol   string        `json:"symbol"`
}

type ExchangeDetails

type ExchangeDetails struct {
	Token    int    `json:"token"`
	Exchange string `json:"exchange"`
	Symbol   string `json:"symbol"`
}

type ExchangeFundResponse

type ExchangeFundResponse struct {
	Deposit             float64 `json:"deposit"`
	FundsTransferred    float64 `json:"funds_transferred"`
	Collateral          float64 `json:"collateral"`
	CreditForSale       float64 `json:"credit_for_sale"`
	OptionCreditForSale float64 `json:"option_credit_for_sale"`
	LimitUtilization    float64 `json:"limit_utilization"`
	MtmAndBookedLoss    float64 `json:"mtm_and_booked_loss"`
	BookedProfit        float64 `json:"booked_profit"`
	TotalTradingPower   float64 `json:"total_trading_power"`
	TotalUtilization    float64 `json:"total_utilization"`
	NetAvailable        float64 `json:"net_available"`
	FundsWithdrawal     float64 `json:"funds_withdrawal"`
}

type ExchangeTypes

type ExchangeTypes string
const (
	ExchangeTypesNSEFO       ExchangeTypes = "NSE_FO"
	ExchangeTypesNSEEQUITY   ExchangeTypes = "NSE_EQ"
	ExchangeTypesNSECURRENCY ExchangeTypes = "NSE_CD"
	ExchangeTypesMCX         ExchangeTypes = "MCX_FO"
)

type FullQuoteData

type FullQuoteData struct {
	Exchange          string      `json:"exchange"`
	Token             int         `json:"token"`
	LastTradeTime     int         `json:"last_trade_time"`
	LastUpdateTime    int         `json:"last_update_time"`
	LastTradePrice    float64     `json:"last_trade_price"`
	Volume            int         `json:"volume"`
	AverageTradePrice float64     `json:"average_trade_price"`
	TotalBuyQuantity  int64       `json:"total_buy_quantity"`
	TotalSellQuantity int64       `json:"total_sell_quantity"`
	OpenInterest      int         `json:"open_interest"`
	OpenPrice         float64     `json:"open_price"`
	HighPrice         float64     `json:"high_price"`
	LowPrice          float64     `json:"low_price"`
	ClosePrice        float64     `json:"close_price"`
	LastTradeQuantity int         `json:"last_trade_quantity"`
	Depth             *QuoteDepth `json:"depth"`
	DPRHigh           float64     `json:"dpr_high"`
	DPRLow            float64     `json:"dpr_low"`
}

type FundDetails

type FundDetails struct {
	Deposit             float64 `json:"deposit"`
	FundsTransferred    float64 `json:"funds_transferred"`
	Collateral          float64 `json:"collateral"`
	CreditForSale       float64 `json:"credit_for_sale"`
	OptionCreditForSale float64 `json:"option_credit_for_sale"`
	LimitUtilization    float64 `json:"limit_utilization"`
	FundsWithdrawn      float64 `json:"funds_withdrawn"`
	MtmAndBookedLoss    float64 `json:"mtm_and_booked_loss"`
	BookedProfit        float64 `json:"booked_profit"`
	TotalTradingPower   float64 `json:"total_trading_power"`
	TotalUtilization    float64 `json:"total_utilization"`
	NetAvailable        float64 `json:"net_available"`
}

type FundResponse

type FundResponse struct {
	Nse ExchangeFundResponse `json:"nse"`
	Mcx ExchangeFundResponse `json:"mcx"`
}

type FundWithdrawalCancelRequest

type FundWithdrawalCancelRequest struct {
	TransactionId string        `json:"transaction_id"` // Required: Transaction ID.
	Exchange      ExchangeTypes `json:"exchange"`       // Required: Exchange type.
	Amount        float64       `json:"amount"`         // Required: Amount of the withdrawal.
}

FundWithdrawalCancelRequest represents a request to cancel a fund withdrawal.

type FundWithdrawalItem

type FundWithdrawalItem struct {
	TransactionId string        `json:"transaction_id"`
	Amount        float64       `json:"amount"`
	CreatedAt     time.Time     `json:"created_at"`
	Status        string        `json:"status"`
	Exchange      ExchangeTypes `json:"exchange"`
}

type FundWithdrawalListResponse

type FundWithdrawalListResponse struct {
	Status  string               `json:"status"`
	Message string               `json:"message,omitempty"`
	Data    []FundWithdrawalItem `json:"data"`
}

type FundWithdrawalRequest

type FundWithdrawalRequest struct {
	BankAccountNumber string        `json:"bank_account_number"` // Required: Bank account number.
	Ifsc              string        `json:"ifsc"`                // Required: IFSC code.
	Amount            float64       `json:"amount"`              // Required: Amount to withdraw.
	Exchange          ExchangeTypes `json:"exchange"`            // Required: Exchange type.
}

FundWithdrawalRequest represents a request to withdraw funds.

type FundsResponse

type FundsResponse struct {
	NSE FundDetails `json:"nse"`
	MCX FundDetails `json:"mcx"`
}

type Greeks

type Greeks struct {
	Theta float64 `json:"theta"`
	Delta float64 `json:"delta"`
	Gamma float64 `json:"gamma"`
	Vega  float64 `json:"vega"`
	Iv    float64 `json:"iv"`
}

type GttInfo

type GttInfo struct {
	Id              string           `json:"id"`
	Token           int              `json:"token"`
	Exchange        ExchangeTypes    `json:"exchange"`
	Symbol          string           `json:"symbol"`
	StrikePrice     float64          `json:"strike_price"`
	InstrumentName  string           `json:"instrument_name"`
	ExpiryDate      string           `json:"expiry_date"`
	OptionType      OptionType       `json:"option_type"`
	LotSize         int              `json:"lot_size"`
	TriggerType     GttTriggerType   `json:"trigger_type"`
	TransactionType TransactionTypes `json:"transaction_type"`
	TagIds          pq.Int32Array    `json:"tag_ids"`
	OrderIdentifier string           `json:"order_identifier"`
	Orders          []GttInfoOrder   `json:"orders"`
}

type GttInfoOrder

type GttInfoOrder struct {
	Id           uint           `json:"id"`
	Product      ProductTypes   `json:"product"`
	Variety      VarietyTypes   `json:"variety"`
	Price        *float64       `json:"price"`
	TriggerPrice *float64       `json:"trigger_price"`
	Quantity     int            `json:"quantity"`
	Status       GttOrderStatus `json:"status"`
	CreatedAt    time.Time      `json:"created_at"`
	UpdatedAt    time.Time      `json:"updated_at"`
	TrigerredAt  time.Time      `json:"trigerred_at"`
}

type GttLegs

type GttLegs struct {
	SlTriggerPercent     *float64 `json:"sl_trigger_percent"`     // Optional: Stop loss trigger percentage.
	ProfitTriggerPercent *float64 `json:"profit_trigger_percent"` // Optional: Profit trigger percentage.
}

GttLegs represents legs of a Good 'til Triggered (GTT) order.

type GttOrderResponse

type GttOrderResponse struct {
	Id              string                   `json:"id"`
	Token           int                      `json:"token" binding:"required"`
	Exchange        ExchangeTypes            `json:"exchange" binding:"required"`
	Symbol          string                   `json:"symbol" binding:"required"`
	Series          string                   `json:"series" binding:"required"`
	InstrumentName  InstrumentName           `json:"instrument_name" binding:"required"`
	ExpiryDate      string                   `json:"expiry_date" binding:"required"`
	StrikePrice     float64                  `json:"strike_price" binding:"required"`
	OptionType      OptionType               `json:"option_type" binding:"required"`
	LotSize         int                      `json:"lot_size" binding:"required"`
	TriggerType     GttTriggerType           `json:"trigger_type" binding:"required"`
	TransactionType TransactionTypes         `json:"transaction_type" binding:"required"`
	TagIds          pq.Int32Array            `json:"tag_ids"`
	Orders          []GttOrderResponseOrders `json:"orders" binding:"required"`
}

type GttOrderResponseOrders

type GttOrderResponseOrders struct {
	Id              uint             `json:"id"`
	ProductType     ProductTypes     `json:"product"`
	Variety         VarietyTypes     `json:"variety"`
	TransactionType TransactionTypes `json:"transaction_type"`
	Price           float64          `json:"price"`
	TriggerPrice    float64          `json:"trigger_price"`
	Quantity        int              `json:"quantity"`
	Status          GttOrderStatus   `json:"status"`
	CreatedAt       time.Time        `json:"created_at"`
	UpdatedAt       time.Time        `json:"updated_at"`
	TrigerredAt     time.Time        `json:"trigerred_at"`
}

type GttOrderStatus

type GttOrderStatus string
const (
	GttOrderStatusTriggered GttOrderStatus = "triggered"
	GttOrderStatusActive    GttOrderStatus = "active"
	GttOrderStatusCancelled GttOrderStatus = "cancelled"
	GttOrderStatusExpired   GttOrderStatus = "expired"
	GttOrderStatusCompleted GttOrderStatus = "completed"
)

type GttOrderbookResponse

type GttOrderbookResponse struct {
	Status string              `json:"status"`
	Data   []*GttOrderResponse `json:"data"`
}

type GttTriggerType

type GttTriggerType string

GttTriggerType represents the trigger type for a Good 'til Triggered (GTT) order.

const (
	GttTriggerTypeSingle GttTriggerType = "single" // Single trigger type.
	GttTriggerTypeOCO    GttTriggerType = "oco"    // One Cancels the Other (OCO) trigger type.
)

type HTTPClient

type HTTPClient interface {
	GetClient() *httpClient
	// contains filtered or unexported methods
}

HTTPClient defines the interface for performing HTTP requests.

func NewHTTPClient

func NewHTTPClient(h *http.Client, hLog *log.Logger, debug bool) HTTPClient

NewHTTPClient creates a new instance of the httpClient with the given HTTP client, logger, and debug flag. If the logger is nil, it uses a default logger that writes to os.Stdout. If the HTTP client is nil, it uses a default client with a 5-second timeout and default transport settings.

type HTTPResponse

type HTTPResponse struct {
	Body     []byte
	Response *http.Response
}

HTTPResponse contains the response body and the HTTP response object.

type HistoricalResponse

type HistoricalResponse struct {
	S string    `json:"s"`
	T []int     `json:"t"`
	O []float64 `json:"o"`
	H []float64 `json:"h"`
	L []float64 `json:"l"`
	C []float64 `json:"c"`
	V []float64 `json:"v"`
}

type Holding

type Holding struct {
	ISIN               string          `json:"isin"`
	NSE                *ExchangeDetail `json:"nse,omitempty"`
	BSE                *ExchangeDetail `json:"bse,omitempty"`
	TotalFree          int             `json:"total_free"`
	DPFree             int             `json:"dp_free"`
	PoolFree           int             `json:"pool_free"`
	T1Quantity         int             `json:"t1_quantity"`
	AveragePrice       float64         `json:"average_price"`
	LastPrice          float64         `json:"last_price"`
	Product            string          `json:"product"`
	CollateralQuantity int             `json:"collateral_quantity"`
	CollateralValue    float64         `json:"collateral_value"`
}

type HoldingsResponse

type HoldingsResponse struct {
	Status  string    `json:"status"`
	Message string    `json:"message,omitempty"`
	Data    []Holding `json:"data"`
}

type IcebergOrderData

type IcebergOrderData struct {
	IcebergOrderId string `json:"iceberg_order_id"`
	FirstOrderId   string `json:"first_order_id"`
}

type IcebergOrderResponse

type IcebergOrderResponse struct {
	Message string           `json:"message"`
	Code    string           `json:"code"`
	Status  string           `json:"status"`
	Data    IcebergOrderData `json:"data"`
}

type InstrumentName

type InstrumentName string
const (
	InstrumentNameEqIndex             InstrumentName = "EQIDX"
	InstrumentNameCom                 InstrumentName = "COM"
	InstrumentNameEquities            InstrumentName = "EQUITIES"
	InstrumentNameCommodityFuture     InstrumentName = "FUTCOM"
	InstrumentNameCurrencyFuture      InstrumentName = "FUTCUR"
	InstrumentNameIndexFuture         InstrumentName = "FUTIDX"
	InstrumentNameInterestFuture      InstrumentName = "FUTIRC"
	InstrumentNameInterestFutureT     InstrumentName = "FUTIRT"
	InstrumentNameStockFuture         InstrumentName = "FUTSTK"
	InstrumentNameCurrencyOption      InstrumentName = "OPTCUR"
	InstrumentNameCommodityOption     InstrumentName = "OPTFUT"
	InstrumentNameIndexOption         InstrumentName = "OPTIDX"
	InstrumentNameInterestOption      InstrumentName = "OPTIRC"
	InstrumentNameStockOption         InstrumentName = "OPTSTK"
	InstrumentNameCurrentcyUnderlying InstrumentName = "UNDCUR"
)

type LegStockGreek

type LegStockGreek struct {
	Token       int        `json:"token" binding:"required"`
	StrikePrice float64    `json:"strike_price"`
	OptionType  OptionType `json:"option_type"`
	ExpYYYYMMDD string     `json:"expiry_date"`
	Action      string     `json:"action"`
	LotSize     int        `json:"lot_size"`
	Quantity    int        `json:"quantity"`
	Ltp         float64    `json:"last_trade_price"` // Update
	Iv          float64    `json:"iv"`               // Update *hide
	Greeks      Greeks     `json:"greeks" gorm:"-"`
}

type LoginResponse

type LoginResponse struct {
	Status string   `json:"status"`
	Data   UserData `json:"data"`
}

type LogoutResponse

type LogoutResponse struct {
	Status   string `json:"status"`
	Response string `json:"response"`
}

type LtpQuoteData

type LtpQuoteData struct {
	Exchange       string  `json:"exchange"`
	Token          int     `json:"token"`
	LastTradePrice float64 `json:"last_trade_price"`
}

type MarginModes

type MarginModes string
const (
	MarginModeNew    MarginModes = "NEW"
	MarginModeMODIFY MarginModes = "MODIFY"
)

type MarginResponse

type MarginResponse struct {
	Status    string  `json:"status"`
	Required  float64 `json:"required_margin"`
	Available float64 `json:"available_margin"`
}

type MarketDepthResponse

type MarketDepthResponse struct {
	Status string     `json:"status"`
	Data   QuoteDepth `json:"data"`
}

type Metadata

type Metadata struct {
	TotalRecords int `json:"total_records"`
}

type ModifyGttRequest

type ModifyGttRequest struct {
	Id           uint          `json:"id"`            // Required: Identifier of the GTT order to modify.
	TriggerPrice *float64      `json:"trigger_price"` // Required: New trigger price for the GTT order.
	Price        *float64      `json:"price"`         // Required: New price for the GTT order.
	Quantity     *int          `json:"quantity"`      // Required: New quantity for the GTT order.
	Variety      ValidityTypes `json:"variety"`       // Required: Type of variety. Accepted values: [RL,RL-MKT].
}

ModifyGttRequest represents a request to modify a Good 'til Triggered (GTT) order.

type ModifyIcebergOrderRequest

type ModifyIcebergOrderRequest struct {
	Price          float64 `json:"price"`           // Required: Price of the order.
	TriggerPrice   float64 `json:"trigger_price"`   // Required: Trigger price for the order.
	TradedQuantity int     `json:"traded_quantity"` // Required: Quantity already traded.
}

ModifyIcebergOrderRequest represents a request to modify an Iceberg order.

type ModifyOrderRequest

type ModifyOrderRequest struct {
	Variety           VarietyTypes  `json:"variety" `           // Required: Type of variety.
	Quantity          int           `json:"quantity" `          // Required: Quantity of the order.
	TradedQuantity    *int          `json:"traded_quantity" `   // Required: Quantity which has already been traded according to you. This is important..
	Price             float64       `json:"price" `             // Optional if market order. Price of the order.
	TriggerPrice      float64       `json:"trigger_price"`      // Optional if not stoploss order. Trigger price for the order.
	DisclosedQuantity int           `json:"disclosed_quantity"` // Optional: Disclosed quantity for the order.
	Validity          ValidityTypes `json:"validity" `          // Required: Validity type for the order.
	ValidityDays      int           `json:"validity_days"`      // Optional: Number of validity days.
	TagIds            []int         `json:"tag_ids"`            // Optional: IDs of tags associated with the order.
}

type MultipleOrderCancelRequest

type MultipleOrderCancelRequest struct {
	OrderIds []string `json:"order_ids"`
}

type MultipleOrderResponse

type MultipleOrderResponse struct {
	Status string          `json:"status"`
	Data   []OrderResponse `json:"data"`
}

type NetDayPositions

type NetDayPositions struct {
	Net []PositionItem `json:"net"`
	Day []PositionItem `json:"day"`
}

type OhlcvQuoteData

type OhlcvQuoteData struct {
	Exchange       string  `json:"exchange"`
	Token          int     `json:"token"`
	LastTradePrice float64 `json:"last_trade_price"`
	LastTradeTime  int     `json:"last_trade_time"`
	Volume         int     `json:"volume"`
	OpenPrice      float64 `json:"open_price"`
	HighPrice      float64 `json:"high_price"`
	LowPrice       float64 `json:"low_price"`
	ClosePrice     float64 `json:"close_price"`
}

type OptionChainRequest

type OptionChainRequest struct {
	Token      int           `json:"token"`       // Required: Token of the underlying instrument.
	ExpiryDate string        `json:"expiry_date"` // Optional: Expiry date of options in format YYYYMMDD. If not provided, the result will be of the closest expiry.
	Exchange   ExchangeTypes `json:"exchange"`    // Required: Exchange type.
	AddGreek   bool          `json:"greeks"`      // Optional: Include Greeks in the result. Default is false.
}

OptionChainRequest represents a request to retrieve an option chain.

type OptionChainResponse

type OptionChainResponse struct {
	Status   string            `json:"status"`
	Message  string            `json:"message"`
	Response OptionchainResult `json:"response"`
}

type OptionType

type OptionType string
const (
	OptionTypeCall OptionType = "CE"
	OptionTypePut  OptionType = "PE"
)

type OptionchainResult

type OptionchainResult struct {
	Symbol         string   `json:"symbol"`
	ExpiryDate     string   `json:"expiry_date"`
	HasParentStock bool     `json:"has_parent_stock"`
	ExpiryDates    []string `json:"expiry_dates"`
	Options        struct {
		Exchange ExchangeTypes     `json:"exchange"`
		List     []*DateOptionData `json:"list"`
	} `json:"options"`
	ParentStock struct {
		Symbol   string        `json:"symbol"`
		Exchange ExchangeTypes `json:"exchange"`
		Token    int           `json:"token"`
		ISINCode string        `json:"isin"`
		LTP      float64       `json:"ltp"`
	} `json:"parent"`
}

type Order

type Order struct {
	OrderID                    string                `json:"order_id"`
	Exchange                   ExchangeTypes         `json:"exchange"`
	Token                      int                   `json:"token"`
	OrderNumber                string                `json:"order_number"`
	Status                     string                `json:"status"`
	ErrorReason                string                `json:"error_reason"`
	TransactionType            TransactionTypes      `json:"transaction_type"`
	Product                    ProductTypes          `json:"product"`
	Variety                    VarietyTypes          `json:"variety"`
	TotalQuantity              int                   `json:"total_quantity"`
	PendingQuantity            int                   `json:"pending_quantity"`
	TradedQuantity             int                   `json:"traded_quantity"`
	DisclosedQuantity          int                   `json:"disclosed_quantity"`
	DisclosedQuantityRemaining int                   `json:"disclosed_quantity_remaining"`
	OrderPrice                 float64               `json:"order_price"`
	TriggerPrice               float64               `json:"trigger_price"`
	TradedPrice                float64               `json:"traded_price,omitempty"`
	Validity                   ValidityTypes         `json:"validity"`
	Symbol                     string                `json:"symbol"`
	Series                     string                `json:"series"`
	InstrumentName             InstrumentName        `json:"instrument_name"`
	ExpiryDate                 string                `json:"expiry_date"`
	StrikePrice                float64               `json:"strike_price"`
	OptionType                 OptionType            `json:"option_type"`
	LotSize                    int                   `json:"lot_size"`
	OrderCreatedAt             string                `json:"order_created_at"`
	InitiatedBy                string                `json:"initiated_by"`
	ModifiedBy                 string                `json:"modified_by"`
	IsAMO                      bool                  `json:"is_amo"`
	OrderIdentifier            string                `json:"order_identifier"`
	TagsIds                    pq.Int32Array         `json:"tags_ids"`
	MiddlewareOrderId          uint                  `json:"middleware_order_id"`
	Iceberg                    *OrderBookIcebergInfo `json:"iceberg,omitempty"`
	Gtt                        *OrderBookGttInfo     `json:"gtt,omitempty"`
}

type OrderBookGttInfo

type OrderBookGttInfo struct {
	TriggerType          GttTriggerType `json:"trigger_type"`
	SlTriggerPercent     *float64       `json:"sl_trigger_percent,omitempty"`
	ProfitTriggerPercent *float64       `json:"profit_trigger_percent,omitempty"`
}

type OrderBookIcebergInfo

type OrderBookIcebergInfo struct {
	IcebergOrderId  string `json:"iceberg_order_id"`
	IcebergSequence int    `json:"iceberg_sequence"`
	Legs            int    `json:"legs"`
}

type OrderBookResponse

type OrderBookResponse struct {
	Status   string   `json:"status"`
	Orders   []Order  `json:"orders"`
	Metadata Metadata `json:"metadata"`
}

type OrderHistory

type OrderHistory struct {
	OrderID                string           `json:"order_id"`
	Exchange               ExchangeTypes    `json:"exchange"`
	Token                  int              `json:"token"`
	OrderNumber            string           `json:"order_number"`
	Status                 string           `json:"status"`
	ErrorReason            string           `json:"error_reason"`
	TransactionType        TransactionTypes `json:"transaction_type"`
	Product                ProductTypes     `json:"product"`
	Variety                VarietyTypes     `json:"variety"`
	TotalQuantity          int              `json:"total_quantity"`
	PendingQuantity        int              `json:"pending_quantity"`
	TradedQuantity         int              `json:"traded_quantity"`
	DisclosedQuantity      int              `json:"disclosed_quantity"`
	OrderPrice             float64          `json:"order_price"`
	TriggerPrice           float64          `json:"trigger_price"`
	Validity               ValidityTypes    `json:"validity"`
	ValidityDays           int              `json:"validity_days"`
	Symbol                 string           `json:"symbol"`
	Series                 string           `json:"series"`
	InstrumentName         InstrumentName   `json:"instrument_name"`
	ExpiryDate             string           `json:"expiry_date"`
	StrikePrice            float64          `json:"strike_price"`
	OptionType             OptionType       `json:"option_type"`
	OrderCreatedAt         string           `json:"order_created_at"`
	ExchangeOrderCreatedAt string           `json:"exchange_order_created_at"`
	InitiatedBy            string           `json:"initiated_by"`
	ModifiedBy             string           `json:"modified_by"`
	IsAMO                  bool             `json:"is_amo"`
	OrderIdentifier        string           `json:"order_identifier"`
}

type OrderHistoryResponse

type OrderHistoryResponse struct {
	Status   string         `json:"status"`
	Code     string         `json:"code"`
	Message  string         `json:"message"`
	Data     []OrderHistory `json:"orders"`
	Metadata Metadata       `json:"metadata"`
}

type OrderMarginRequest

type OrderMarginRequest struct {
	Exchange        ExchangeTypes    `json:"exchange"`         // Required: Exchange type.
	Token           int              `json:"token"`            // Required: Token of the underlying instrument.
	TransactionType TransactionTypes `json:"transaction_type"` // Required: Type of transaction.
	Product         ProductTypes     `json:"product"`          // Required: Type of product.
	Variety         VarietyTypes     `json:"variety"`          // Required: Type of variety.
	Quantity        int              `json:"quantity"`         // Required: Quantity of the order.
	Price           float64          `json:"price"`            // Required: Price of the order.
	OldPrice        float64          `json:"old_price"`        // Required: Old price of the order.
	OldQuantity     int              `json:"old_quantity"`     // Required: Old quantity of the order.
	Mode            MarginModes      `json:"mode"`             // Required: Mode of margin calculation.
}

OrderMarginRequest represents a request to calculate margin for an order.

type OrderResponse

type OrderResponse struct {
	Status  string `json:"status"`
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		OrderID string `json:"order_id"`
	} `json:"data"`
}

type OrderStatus

type OrderStatus string
const (
	OrderStatusPending            OrderStatus = "PENDING"
	OrderStausMiddlewarePending   OrderStatus = "middleware_pending"
	OrderStatusMiddlewareRejected OrderStatus = "middleware_rejected"
	OrderStatusRejected           OrderStatus = "REJECTED"
	OrderStatusCancelled          OrderStatus = "CANCELLED"
	OrderStatusCompleted          OrderStatus = "COMPLETED"
)

type PayOff

type PayOff struct {
	IPayoff float64 `json:"intraday_pay_off"`
	EPayoff float64 `json:"expiry_pay_off"`
	At      float64 `json:"at"`
}

type PayOffData

type PayOffData struct {
	MaxLoss          float64         `json:"max_loss"`
	MaxProfit        float64         `json:"max_profit"`
	IsInfiniteProfit bool            `json:"infinite_profit"`
	IsInfiniteLoss   bool            `json:"infinite_loss"`
	BreakEvens       []float64       `json:"breakevens"`
	PayOffs          []PayOff        `json:"payoffs"`
	CombinedGreeks   Greeks          `json:"combined_greeks"`
	LivePrice        float64         `json:"last_trade_price"`
	LegStocks        []LegStockGreek `json:"leg_greeks"`
	MinDaysToExpiry  int             `json:"min_days_to_expiry"`
}

type PayoffAction

type PayoffAction string
const (
	PayoffActionBUY  PayoffAction = "BUY"
	PayoffActionSELL PayoffAction = "SELL"
)

PayoffAction represents the action for a trading strategy.

type PayoffOption

type PayoffOption struct {
	Token    int          `json:"token"`            // Required: Token of the underlying instrument.
	Action   PayoffAction `json:"action"`           // Required: Action for the option.
	Quantity int          `json:"quantity"`         // Required: Quantity of the option.
	Ltp      float64      `json:"last_trade_price"` // Optional: Last traded price for the option.
}

PayoffOption represents an option within a trading strategy.

type PayoffRequest

type PayoffRequest struct {
	Symbol          string         `json:"symbol" `        // Required: Symbol for the underlying asset.
	Exchange        ExchangeTypes  `json:"exchange" `      // Required: Exchange type.
	Legs            []PayoffOption `json:"legs"`           // Required: Legs of the trading strategy.
	InpDaysToExpiry *int           `json:"days_to_expiry"` // Optional: Number of days to expiry.
	CurrentPnl      float64        `json:"current_pnl"`    // Optional: Current profit or loss.
}

PayoffRequest represents a request to calculate the payoff for a trading strategy.

type PayoffResponse

type PayoffResponse struct {
	Status  string     `json:"status"`
	Message string     `json:"message"`
	Data    PayOffData `json:"data"`
}

type PlaceGttLegRequest

type PlaceGttLegRequest struct {
	Quantity     int          `json:"quantity"`      // Required: Quantity of the leg.
	Price        float64      `json:"price"`         // Required: Price of the leg.
	TriggerPrice float64      `json:"trigger_price"` // Required: Trigger price for the leg.
	ProductType  ProductTypes `json:"product"`       // Required: Type of product for the leg.
}

PlaceGttLegRequest represents a leg of a Good 'til Triggered (GTT) order.

type PlaceGttRequest

type PlaceGttRequest struct {
	Exchange        ExchangeTypes       `json:"exchange"`         // Required: Exchange type.
	Token           int                 `json:"token"`            // Required: Token of the underlying instrument.
	TransactionType TransactionTypes    `json:"transaction_type"` // Required: Type of transaction.
	Variety         ValidityTypes       `json:"variety"`          // Optional: Type of variety. By default RL is considered. Accepted values: [RL,RL-MKT].
	Quantity        *int                `json:"quantity"`         // Required: Quantity of the order.
	TriggerPrice    *float64            `json:"trigger_price"`    // Required: Trigger price for the order.
	Price           *float64            `json:"price"`            // Required: Price of the order.
	OrderIdentifier string              `json:"order_identifier"` // Required: Identifier for the order.
	GttTriggerType  GttTriggerType      `json:"gtt_trigger_type"` // Required: Type of GTT trigger.
	Product         ProductTypes        `json:"product"`          // Required: Type of product.
	Stoploss        *PlaceGttLegRequest `json:"stoploss"`         // Optional: Stop loss leg of the GTT order.
	Profit          *PlaceGttLegRequest `json:"profit"`           // Optional: Profit leg of the GTT order.
	TagIds          []int               `json:"tag_ids"`          // Required: IDs of tags associated with the order.
}

PlaceGttRequest represents a request to place a Good 'til Triggered (GTT) order.

type PlaceIcebergOrderRequest

type PlaceIcebergOrderRequest struct {
	Exchange        ExchangeTypes    `json:"exchange"`         // Required: Exchange type.
	Token           int              `json:"token"`            // Required: Token of the underlying instrument.
	TransactionType TransactionTypes `json:"transaction_type"` // Required: Type of transaction.
	Product         ProductTypes     `json:"product"`          // Required: Type of product.
	Variety         VarietyTypes     `json:"variety"`          // Required: Type of variety.
	Quantity        int              `json:"quantity"`         // Required: Quantity of the order.
	Price           *float64         `json:"price"`            // Optional if market order. Price of the order.
	TriggerPrice    float64          `json:"trigger_price"`    // Optional if not stoploss order. Trigger price for the order.
	OrderIdentifier string           `json:"order_identifier"` // Optional: Your identifier for the order.
	Validity        ValidityTypes    `json:"validity"`         // Required: Validity type for the order.
	Legs            int              `json:"legs"`             // Required: Number of legs for the order.
	TagIds          pq.Int32Array    `json:"tag_ids"`          // IDs of tags associated with the order.
}

PlaceIcebergOrderRequest represents a request to place an Iceberg order.

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Exchange          ExchangeTypes    `json:"exchange"`           // Required: Exchange type.
	Token             int              `json:"token"`              // Required: Token of the underlying instrument.
	TransactionType   TransactionTypes `json:"transaction_type"`   // Required: Type of transaction.
	Product           ProductTypes     `json:"product"`            // Required: Type of product.
	Variety           VarietyTypes     `json:"variety"`            // Required: Type of variety.
	Quantity          int              `json:"quantity"`           // Required: Quantity of the order.
	Price             float64          `json:"price"`              // Optional if market order. Price of the order.
	TriggerPrice      float64          `json:"trigger_price"`      // Optional if not stoploss order. Trigger price for the order.
	OrderIdentifier   string           `json:"order_identifier"`   // Optional: Your identifier for the order.
	DisclosedQuantity int              `json:"disclosed_quantity"` // Optional: Disclosed quantity for the order.
	Validity          ValidityTypes    `json:"validity"`           // Required: Validity type for the order.
	ValidityDays      int              `json:"validity_days"`      // Optional: Number of validity days.
	IsAMO             bool             `json:"is_amo"`             // Optional: Flag indicating if the order is an after-market order.
	Gtt               *GttLegs         `json:"gtt"`                // Optional: Good 'til Triggered (GTT) legs.
	TagIds            []int            `json:"tag_ids"`            // Optional: IDs of tags associated with the order.
}

PlaceOrderRequest represents a request to place an order.

type PositionItem

type PositionItem struct {
	Exchange              ExchangeTypes `json:"exchange"`
	Symbol                string        `json:"symbol"`
	ExpiryDate            string        `json:"expiry_date"`
	OptionType            OptionType    `json:"option_type"`
	StrikePrice           float64       `json:"strike_price"`
	Token                 int           `json:"token"`
	Product               ProductTypes  `json:"product"`
	Quantity              int           `json:"quantity"`
	OvernightBuyValue     float64       `json:"overnight_buy_value"`
	OvernightSellValue    float64       `json:"overnight_sell_value"`
	OvernightAveragePrice float64       `json:"overnight_average_price"`
	LotSize               int           `json:"lot_size"`
	Multiplier            float64       `json:"multiplier"`
	AveragePrice          float64       `json:"average_price"`
	Value                 float64       `json:"value"`
	BuyValue              float64       `json:"buy_value"`
	SellValue             float64       `json:"sell_value"`
	BuyQuantity           int           `json:"buy_quantity"`
	SellQuantity          int           `json:"sell_quantity"`
	BuyPrice              float64       `json:"buy_price"`
	SellPrice             float64       `json:"sell_price"`
}

type PositionResponse

type PositionResponse struct {
	Status string          `json:"status"`
	Data   NetDayPositions `json:"data"`
}

type PredictionType

type PredictionType string

PredictionType represents the type of prediction for a trading strategy.

const (
	PredictionTypeABOVE   PredictionType = "ABOVE"   // Predict that the asset price will be above a certain level.
	PredictionTypeBELOW   PredictionType = "BELOW"   // Predict that the asset price will be below a certain level.
	PredictionTypeBETWEEN PredictionType = "BETWEEN" // Predict that the asset price will be within a certain range.
)

type ProductTypes

type ProductTypes string
const (
	ProductTypesIntraday ProductTypes = "INTRADAY"
	ProductTypesDelivery ProductTypes = "DELIVERY"
	ProductTypesMTF      ProductTypes = "MTF"
)

type QuoteDepth

type QuoteDepth struct {
	Buy  []QuoteEntry `json:"buy"`
	Sell []QuoteEntry `json:"sell"`
}

type QuoteEntry

type QuoteEntry struct {
	Quantity int     `json:"quantity"`
	Price    float64 `json:"price"`
	Orders   int     `json:"orders"`
}

type QuoteModes

type QuoteModes string
const (
	QuoteModesLTP   QuoteModes = "ltp"
	QuoteModesFULL  QuoteModes = "full"
	QuoteModesOHLCV QuoteModes = "ohlcv"
)

type QuoteResponse

type QuoteResponse struct {
	Status string                 `json:"status"`
	Data   map[string]interface{} `json:"data"`
}

type Resolutions

type Resolutions string
const (
	ResolutionsMin1   Resolutions = "1"
	ResolutionsMin2   Resolutions = "2"
	ResolutionsMin3   Resolutions = "3"
	ResolutionsMin4   Resolutions = "4"
	ResolutionsMin5   Resolutions = "5"
	ResolutionsMin10  Resolutions = "10"
	ResolutionsMin15  Resolutions = "15"
	ResolutionsMin30  Resolutions = "30"
	ResolutionsMin45  Resolutions = "45"
	ResolutionsMin60  Resolutions = "60"
	ResolutionsMin120 Resolutions = "120"
	ResolutionsMin180 Resolutions = "180"
	ResolutionsMin240 Resolutions = "240"
	ResolutionsDay    Resolutions = "1D"
	ResolutionsWeek   Resolutions = "1W"
	ResolutionsMonth  Resolutions = "1M"
)
const (
	Min1   Resolutions = "1"
	Min2   Resolutions = "2"
	Min3   Resolutions = "3"
	Min4   Resolutions = "4"
	Min5   Resolutions = "5"
	Min10  Resolutions = "10"
	Min15  Resolutions = "15"
	Min30  Resolutions = "30"
	Min45  Resolutions = "45"
	Min60  Resolutions = "60"
	Min120 Resolutions = "120"
	Min180 Resolutions = "180"
	Min240 Resolutions = "240"
	Day1   Resolutions = "day"
	Week1  Resolutions = "week"
	Month1 Resolutions = "month"
)

type SocketMessage

type SocketMessage struct {
	Type       string             `json:"type"`
	Data       *SocketMessageData `json:"data,omitempty"`
	AlertInfo  *AlertInfo         `json:"alert_info,omitempty"`
	Gtt        *GttInfo           `json:"gtt,omitempty"`
	ClientCode string             `json:"client_code,omitempty"`
}

type SocketMessageData

type SocketMessageData struct {
	OrderId                    string           `json:"order_id"`
	MiddlewareOrderId          uint             `json:"middleware_order_id"`
	TriggersGtt                bool             `json:"triggers_gtt"`
	OrderNumber                string           `json:"order_number"`
	AmoOrderId                 string           `json:"amo_order_id"`
	PlacedBy                   string           `json:"placed_by"`
	ModifiedBy                 string           `json:"modified_by"`
	Status                     OrderStatus      `json:"status"`
	StatusMessage              string           `json:"status_message"`
	Symbol                     string           `json:"symbol"`
	Series                     string           `json:"series"`
	InstrumentName             string           `json:"instrument_name"`
	Token                      int              `json:"token"`
	Exchange                   ExchangeTypes    `json:"exchange"`
	ExpiryDate                 string           `json:"expiry_date"`
	StrikePrice                float32          `json:"strike_price"`
	OptionType                 string           `json:"option_type"`
	TransactionType            TransactionTypes `json:"transaction_type"`
	Validity                   ValidityTypes    `json:"validity"`
	ValidityDays               int              `json:"validity_days"`
	Product                    ProductTypes     `json:"product"` //Intraday, Delivery or MTF
	Variety                    VarietyTypes     `json:"variety"` //regular , SL , SL-MKT,amo etc
	DisclosedQuantity          int              `json:"disclosed_quantity"`
	DisclosedQuantityRemaining int              `json:"disclosed_quantity_remaining"`
	TotalQuantity              int              `json:"total_quantity"`
	PendingQuantity            int              `json:"pending_quantity"`
	TradedQuantity             int              `json:"traded_quantity"`
	ThisTradeQuantity          int              `json:"this_trade_quantity,omitempty"`
	MarketType                 string           `json:"market_type"`
	OrderPrice                 float32          `json:"order_price"`
	TriggerPrice               float32          `json:"trigger_price"`
	CoverTriggerPrice          float32          `json:"cover_trigger_price"`
	TradedPrice                float32          `json:"traded_price"`
	IsAmo                      bool             `json:"is_amo"`
	OrderIdentifier            string           `json:"order_identifier"`
	InternalRemarks            string           `json:"internal_remarks"`
	OrderCreatedAt             string           `json:"order_created_at"`
	OrderUpdatedAt             string           `json:"order_updated_at"`
	TradeNumber                string           `json:"trade_number,omitempty"`
	TradeTime                  string           `json:"trade_time,omitempty"`
	MarketSegmentId            int              `json:"market_segment_id"`
	GtdOrderStatus             OrderStatus      `json:"gtd_order_status"`
	SequenceNumber             int              `json:"sequence_number"`
}

type StockWithGreek

type StockWithGreek struct {
	Token          int     `json:"token"`
	InstrumentName string  `json:"instrument_name"`
	LotSize        int     `json:"lot_size"`
	SecurityDesc   string  `json:"security_description"`
	Eligibility    int     `json:"eligibility"`
	Ltp            float64 `json:"ltp"`
	OpenInterest   int     `json:"open_interest"`
	DayFirstTickOI int     `json:"day_first_tick_oi" `
	Volume         int     `json:"volume"`
	Delta          float64 `json:"delta"`
}

type StrategiesRequest

type StrategiesRequest struct {
	Token       int    `json:"token"`       // Required: Token for authentication.
	Symbol      string `json:"symbol"`      // Required: Symbol for the underlying asset.
	ExpYYYYMMDD string `json:"expiry_date"` // Required: Expiry date of the strategy in format YYYYMMDD.
}

StrategiesRequest represents a request to retrieve strategies.

type StrategiesResponse

type StrategiesResponse struct {
	Status  string           `json:"status"`
	Message string           `json:"message"`
	Data    StrategiesResult `json:"data"`
}

type StrategiesResult

type StrategiesResult struct {
	Symbol     string     `json:"symbol"`
	Token      int        `json:"token"`
	Ltp        float64    `json:"ltp"`
	Strategies []Strategy `json:"strategies"`
}

type Strategy

type Strategy struct {
	Name                 string               `json:"strategy_name"`
	TradingOpportunities []TradingOpportunity `json:"trading_opportunities"`
}

type StrategyBuilderRequest

type StrategyBuilderRequest struct {
	Token      int            `json:"token"`       // Required: Token of the underlying instrument.
	Symbol     string         `json:"symbol"`      // Required: Symbol of the underlying instrument.
	MarketView PredictionType `json:"prediction"`  // Required: Prediction type. Should be one of ["ABOVE", "BELOW", "BETWEEN"]
	ExpiryDate string         `json:"expiry_date"` // Required: Expiry date of options in format: YYYYMMDD
	PriceRange []float64      `json:"price_range"` // Price range for the strategy.
}

type StrategyLeg

type StrategyLeg struct {
	Option   StrategyStock `json:"option"`
	Action   string        `json:"action"`
	Quantity int           `json:"quantity"`
}

type StrategyStock

type StrategyStock struct {
	Token          int           `json:"token"`
	InstrumentName string        `json:"instrument_name"`
	Symbol         string        `json:"symbol"`
	StrikePrice    float64       `json:"strike_price"`
	OptionType     OptionType    `json:"option_type"`
	LotSize        int           `json:"lot_size"`
	SecurityDesc   string        `json:"security_description"`
	Exchange       ExchangeTypes `json:"exchange"`
	ExpYyyymmdd    string        `json:"expiry_date"`
	Ltp            float64       `json:"ltp"`
	Greeks         struct {
		Theta float64 `json:"theta"`
		Delta float64 `json:"delta"`
		Gamma float64 `json:"gamma"`
		Vega  float64 `json:"vega"`
		Iv    float64 `json:"iv"`
	} `json:"greeks"`
}

type TagInfo

type TagInfo struct {
	Id          int       `json:"id"`
	ClientCode  string    `json:"client_code"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type TagRequest

type TagRequest struct {
	Name        string `json:"name"`        // Name of the tag.
	Description string `json:"description"` // Description of the tag.
}

TagRequest represents a request to create a tag.

type TagResponse

type TagResponse struct {
	Status  string  `json:"status"`
	Message string  `json:"message"`
	Data    TagInfo `json:"data"`
}

type TagsResponse

type TagsResponse struct {
	Status  string    `json:"status"`
	Message string    `json:"message"`
	Data    []TagInfo `json:"data"`
}

type Trade

type Trade struct {
	OrderID         string           `json:"order_id"`
	Exchange        ExchangeTypes    `json:"exchange"`
	Token           int              `json:"token"`
	TradeNo         string           `json:"trade_no"`
	ExchangeOrderNo string           `json:"exchange_order_no"`
	TransactionType TransactionTypes `json:"transaction_type"`
	Product         ProductTypes     `json:"product"`
	Variety         VarietyTypes     `json:"variety"`
	TradeQuantity   int              `json:"trade_quantity"`
	TradePrice      float64          `json:"trade_price"`
	Symbol          string           `json:"symbol"`
	Series          string           `json:"series"`
	InstrumentName  string           `json:"instrument_name"`
	ExpiryDate      string           `json:"expiry_date"`
	StrikePrice     float64          `json:"strike_price"`
	OptionType      OptionType       `json:"option_type"`
	TradedAt        string           `json:"traded_at"`
	InitiatedBy     string           `json:"initiated_by"`
	ModifiedBy      string           `json:"modified_by"`
	OrderIdentifier string           `json:"order_identifier"`
}

type TradeBookResponse

type TradeBookResponse struct {
	Status   string  `json:"status"`
	Trades   []Trade `json:"trades"`
	Metadata struct {
		TotalRecords int `json:"total_records"`
	} `json:"metadata"`
}

type TradingOpportunity

type TradingOpportunity struct {
	Legs             []StrategyLeg `json:"legs"`
	MaxLoss          float64       `json:"max_loss"`
	MaxProfit        float64       `json:"max_profit"`
	IsInfiniteProfit bool          `json:"is_infinite_profit"`
	IsInfiniteLoss   bool          `json:"is_infinite_loss"`
	BreakEven        []float64     `json:"breakeven"`
}

type TransactionTypes

type TransactionTypes string
const (
	TransactionTypesBUY  TransactionTypes = "BUY"
	TransactionTypesSELL TransactionTypes = "SELL"
)

type UserData

type UserData struct {
	AccessToken  string   `json:"access_token"`
	UserName     string   `json:"user_name"`
	LoginTime    string   `json:"login_time"`
	Email        string   `json:"email"`
	Mobile       string   `json:"mobile"`
	Exchanges    []string `json:"exchanges"`
	ProductTypes []string `json:"product_types"`
	Others       struct {
		UserCode string `json:"userCode"`
		POA      int    `json:"POA"`
	} `json:"others"`
	UserID        string `json:"user_id"`
	TradingActive bool   `json:"tradingActive"`
}

type ValidityTypes

type ValidityTypes string
const (
	ValidityTypesFullDay           ValidityTypes = "DAY"
	ValidityTypesImmediateOrCancel ValidityTypes = "IOC"
	ValidityTypesAfterMarket       ValidityTypes = "AMO"
)

type VarietyTypes

type VarietyTypes string
const (
	VarietyTypesRegularLimitOrder  VarietyTypes = "RL"
	VarietyTypesRegularMarketOrder VarietyTypes = "RL-MKT"
	VarietyTypesStopLimitOrder     VarietyTypes = "SL"
	VarietyTypesStopMarketOrder    VarietyTypes = "SL-MKT"
)

type VortexApi

type VortexApi struct {
	AccessToken string
	// contains filtered or unexported fields
}

VortexApi is a struct representing the Vortex API client

func (*VortexApi) Banks

func (v *VortexApi) Banks(ctx context.Context) (*BanksResponse, error)

Banks retrieves a list of banks from the Vortex API. It returns a BanksResponse containing the list of banks and an error if any.

func (*VortexApi) BasketMargin

func (v *VortexApi) BasketMargin(ctx context.Context, request *BasketMarginRequest) (*BasketMarginResponse, error)

BasketMargin gets the required margin to place a collection of new orders in the Vortex API. It takes a context and an BasketMarginRequest as input. It returns a BasketMarginResponse and an error.

func (*VortexApi) BuildStrategy

BuildStrategy initiates the strategy building process with the Vortex API based on the provided StrategyBuilderRequest. It takes a context and a StrategyBuilderRequest as input. It returns a StrategiesResponse and an error.

func (*VortexApi) CancelGttOrder

func (v *VortexApi) CancelGttOrder(ctx context.Context, gtt_order_id string) (*OrderResponse, error)

CancelGttOrder cancels an existing Good Till Trigger (GTT) order with the Vortex API. It takes a context and a GTT order ID as input. It returns an OrderResponse and an error.

func (*VortexApi) CancelIcebergOrder

func (v *VortexApi) CancelIcebergOrder(ctx context.Context, iceberg_order_id string) (*CancelIcebergOrderResponse, error)

CancelIcebergOrder cancels an existing iceberg order with the Vortex API. It takes a context and an iceberg order ID as input. It returns a CancelIcebergOrderResponse and an error.

func (*VortexApi) CancelMultipleRegularOrders

func (v *VortexApi) CancelMultipleRegularOrders(ctx context.Context, req MultipleOrderCancelRequest) (*MultipleOrderResponse, error)

func (*VortexApi) CancelOrder

func (v *VortexApi) CancelOrder(ctx context.Context, orderID string) (*OrderResponse, error)

CancelOrder cancels an existing order with the Vortex API. It takes a context, an ExchangeTypes value, and an order ID as input. It returns an OrderResponse and an error.

func (*VortexApi) ConvertPosition

func (*VortexApi) CreateTag

func (v *VortexApi) CreateTag(ctx context.Context, request TagRequest) (*TagResponse, error)

CreateTag creates a new tag with the Vortex API. It takes a context and a TagRequest as input. It returns a TagResponse and an error.

func (*VortexApi) DeleteTag

func (v *VortexApi) DeleteTag(ctx context.Context, tag_id int) (*TagResponse, error)

DeleteTag deletes an existing tag with the Vortex API. It takes a context and a tag ID as input. It returns a TagResponse and an error.

func (*VortexApi) DownloadMaster

func (v *VortexApi) DownloadMaster(ctx context.Context) ([]map[string]string, error)

DownloadMaster retrieves the master data from the Vortex API. It returns a slice of maps representing the CSV records and an error if any.

func (*VortexApi) ExchangeToken

func (v *VortexApi) ExchangeToken(ctx context.Context, auth_token string) (*LoginResponse, error)

ExchangeToken exchanges auth token received for the access_token from the Vortex API. It takes a context and auth_token as input. If the login is successful, the method updates the accessToken field of the VortexApi instance. It returns the LoginResponse and an error.

func (*VortexApi) Funds

func (v *VortexApi) Funds(ctx context.Context) (*FundsResponse, error)

Funds retrieves the funds information from the Vortex API. It returns a FundsResponse containing the funds information and an error if any.

func (*VortexApi) GetLoginUrl

func (v *VortexApi) GetLoginUrl() string

GetLoginUrl returns the login URL for the Vortex API

func (*VortexApi) GetOptionChain

func (v *VortexApi) GetOptionChain(ctx context.Context, req OptionChainRequest) (*OptionChainResponse, error)

GetOptionChain retrieves the option chain from the Vortex API based on the provided OptionChainRequest. It takes a context and an OptionChainRequest as input. It returns an OptionChainResponse and an error.

func (*VortexApi) GetPayoff

func (v *VortexApi) GetPayoff(ctx context.Context, req PayoffRequest) (*PayoffResponse, error)

GetPayoff calculates the payoff for strategies with the Vortex API based on the provided PayoffRequest. It takes a context and a PayoffRequest as input. It returns a PayoffResponse and an error.

func (*VortexApi) GetStrategies

func (v *VortexApi) GetStrategies(ctx context.Context, req StrategiesRequest) (*StrategiesResponse, error)

GetStrategies retrieves strategies from the Vortex API based on the provided StrategiesRequest. It takes a context and a StrategiesRequest as input. It returns a StrategiesResponse and an error.

func (*VortexApi) GttOrders

func (v *VortexApi) GttOrders(ctx context.Context) (*GttOrderbookResponse, error)

GttOrders retrieves the Good Till Trigger (GTT) orderbook from the Vortex API. It takes a context as input. It returns a GttOrderbookResponse and an error.

func (*VortexApi) HistoricalCandles

func (v *VortexApi) HistoricalCandles(ctx context.Context, exchange ExchangeTypes, token int, from time.Time, to time.Time, resolution Resolutions) (*HistoricalResponse, error)

HistoricalCandles retrieves historical candlestick data from the Vortex API. It takes a context, an ExchangeTypes value, a token, a start time, an end time, and a resolution as input. It returns a HistoricalResponse and an error.

func (*VortexApi) Holdings

func (v *VortexApi) Holdings(ctx context.Context) (*HoldingsResponse, error)

Holdings retrieves the holdings information from the Vortex API. It returns a HoldingsResponse and an error.

func (*VortexApi) Login

func (v *VortexApi) Login(ctx context.Context, clientCode string, password string, totp string) (*LoginResponse, error)

Login performs the login operation in the Vortex API. It takes a context, client code, password, and TOTP (Time-Based One-Time Password) as input. If the login is successful, the method updates the accessToken field of the VortexApi instance. It returns the LoginResponse and an error.

func (*VortexApi) Logout

func (v *VortexApi) Logout(ctx context.Context) (*LogoutResponse, error)

Logout logs the user out from the Vortex API and the access token is then no longer useful. It takes a context as input. It returns the LogoutResponse and an error.

func (*VortexApi) ModifyGttOrder

func (v *VortexApi) ModifyGttOrder(ctx context.Context, gtt_order_id string, request ModifyGttRequest) (*OrderResponse, error)

ModifyGttOrder modifies an existing Good Till Trigger (GTT) order with the Vortex API. It takes a context, a GTT order ID, and a ModifyGttRequest as input. It returns an OrderResponse and an error.

func (*VortexApi) ModifyIcebergOrder

func (v *VortexApi) ModifyIcebergOrder(ctx context.Context, iceberg_order_id string, request ModifyIcebergOrderRequest) (*IcebergOrderResponse, error)

ModifyIcebergOrder modifies an existing iceberg order with the Vortex API. It takes a context, an iceberg order ID, and a ModifyIcebergOrderRequest as input. It returns an IcebergOrderResponse and an error.

func (*VortexApi) ModifyOrder

func (v *VortexApi) ModifyOrder(ctx context.Context, request ModifyOrderRequest, exchange ExchangeTypes, orderID string) (*OrderResponse, error)

ModifyOrder modifies an existing order with the Vortex API. It takes a context, a ModifyOrderRequest, an ExchangeTypes value, and an order ID as input. The request's Validity field is used to determine the ValidityDays value. It returns an OrderResponse and an error.

func (*VortexApi) OrderHistory

func (v *VortexApi) OrderHistory(ctx context.Context, orderId string) (*OrderHistoryResponse, error)

func (*VortexApi) OrderMargin

func (v *VortexApi) OrderMargin(ctx context.Context, request *OrderMarginRequest) (*MarginResponse, error)

OrderMargin gets the required margin to place or modify an order in the Vortex API. It takes a context and an OrderMarginRequest as input. It returns a MarginResponse and an error.

func (*VortexApi) Orders

func (v *VortexApi) Orders(ctx context.Context) (*OrderBookResponse, error)

Orders retrieves the order book information from the Vortex API. It takes a context, an offset, and a limit as input. It returns an OrderBookResponse and an error.

func (*VortexApi) PlaceGttOrder

func (v *VortexApi) PlaceGttOrder(ctx context.Context, request PlaceGttRequest) (*OrderResponse, error)

PlaceGttOrder places a Good Till Trigger (GTT) order with the Vortex API. It takes a context and a PlaceGttRequest as input. It returns an OrderResponse and an error.

func (*VortexApi) PlaceIcebergOrder

func (v *VortexApi) PlaceIcebergOrder(ctx context.Context, request PlaceIcebergOrderRequest) (*IcebergOrderResponse, error)

PlaceIcebergOrder places an iceberg order with the Vortex API. It takes a context and a PlaceIcebergOrderRequest as input. It returns an IcebergOrderResponse and an error.

func (*VortexApi) PlaceOrder

func (v *VortexApi) PlaceOrder(ctx context.Context, request PlaceOrderRequest) (*OrderResponse, error)

PlaceOrder places an order with the Vortex API. It takes a context and a PlaceOrderRequest as input. The request's Validity field is used to determine the ValidityDays and IsAMO values. It returns an OrderResponse and an error.

func (*VortexApi) Positions

func (v *VortexApi) Positions(ctx context.Context) (*PositionResponse, error)

Positions retrieves the positions information from the Vortex API. It returns a PositionsResponse and an error.

func (*VortexApi) Quotes

func (v *VortexApi) Quotes(ctx context.Context, instruments []string, mode QuoteModes) (*QuoteResponse, error)

Quotes retrieves real-time quote information for the specified instruments from the Vortex API. It takes a context, a slice of instrument names, and a quote mode as input. It returns a QuoteResponse and an error.

func (*VortexApi) SetAccessToken

func (v *VortexApi) SetAccessToken(accessToken string)

func (*VortexApi) SetHTTPClient

func (v *VortexApi) SetHTTPClient(h *http.Client)

SetHTTPClient sets the HTTP client for the Vortex API client

func (*VortexApi) SetLogging

func (v *VortexApi) SetLogging(flag bool)

SetLogging sets the HTTP client with logging enabled

func (*VortexApi) Tags

func (v *VortexApi) Tags(ctx context.Context) (*TagsResponse, error)

Tags retrieves the list of tags from the Vortex API. It takes a context as input. It returns a TagsResponse and an error.

func (*VortexApi) Trades

func (v *VortexApi) Trades(ctx context.Context, offset int, limit int) (*TradeBookResponse, error)

Trades retrieves the trade book information from the Vortex API. It returns a TradeBookResponse and an error.

func (*VortexApi) UpdateTag

func (v *VortexApi) UpdateTag(ctx context.Context, tag_id int, request TagRequest) (*TagResponse, error)

UpdateTag updates an existing tag with the Vortex API. It takes a context, a tag ID, and a TagRequest as input. It returns a TagResponse and an error.

type Wire

type Wire struct {
	Conn *websocket.Conn
	// contains filtered or unexported fields
}

func (*Wire) Close

func (t *Wire) Close() error

func (*Wire) OnClose

func (t *Wire) OnClose(f func(code int, reason string))

Set a function to receive update whenever the socket closes

func (*Wire) OnConnect

func (t *Wire) OnConnect(f func())

Set a function to receive update whenever the socket is connected

func (*Wire) OnError

func (t *Wire) OnError(f func(err error))

Set a function to receive update whenever there is an error

func (*Wire) OnMessage

func (t *Wire) OnMessage(f func(messageType int, message []byte))

Set a function to receive raw message

func (*Wire) OnNoReconnect

func (t *Wire) OnNoReconnect(f func(attempt int))

func (*Wire) OnOrderUpdate

func (t *Wire) OnOrderUpdate(f func(order SocketMessage))

Set a function to receive Order Updates

func (*Wire) OnPriceUpdate

func (t *Wire) OnPriceUpdate(f func(*FullQuoteData))

Set a function to receive Price Updates

func (*Wire) OnReconnect

func (t *Wire) OnReconnect(f func(attempt int, delay time.Duration))

Set a function to receive update whenever the socket reconnects

func (*Wire) Resubscribe

func (t *Wire) Resubscribe()

func (*Wire) Serve

func (t *Wire) Serve()

Call this function to start the websocket server

func (*Wire) ServeWithContext

func (t *Wire) ServeWithContext(ctx context.Context)

Call this function to start the websocket server with a context

func (*Wire) SetAccessToken

func (t *Wire) SetAccessToken(accessToken string)

Use this function to change access token

func (*Wire) SetAutoReconnect

func (t *Wire) SetAutoReconnect(val bool)

Use this function to change auto reconnection setting. Default: true

func (*Wire) SetConnectTimeout

func (t *Wire) SetConnectTimeout(val time.Duration)

Use this function to change connection timeout value. Dafault: 7 seconds

func (*Wire) SetReconnectMaxDelay

func (t *Wire) SetReconnectMaxDelay(val time.Duration) error

Use this function to change max reconnection delay. Default: 60 seconds

func (*Wire) SetReconnectMaxRetries

func (t *Wire) SetReconnectMaxRetries(val int)

Use this function to change max connection retries. Default: 300

func (*Wire) SetRootURL

func (t *Wire) SetRootURL(u url.URL)

Use this function to set new url for websocket connection

func (*Wire) Stop

func (t *Wire) Stop()

Stop the wire instance and all the goroutines it has spawned.

func (*Wire) Subscribe

func (t *Wire) Subscribe(exchange ExchangeTypes, token int, mode QuoteModes)

Call this function to subscribe to an instrument

func (*Wire) Unsubscribe

func (t *Wire) Unsubscribe(exchange ExchangeTypes, token int, mode QuoteModes)

Call this function to unsubscribe an instrument

Directories

Path Synopsis
examples
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL