tiqs

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

auth.go

client.go

historical.go

market.go

orders.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateChecksum

func GenerateChecksum(appID, appSecret, requestToken string) string

GenerateChecksum creates a SHA256 hash of "appId:appSecret:request-token".

This is used to securely authenticate API requests.

Parameters:

  • appID: The application ID.
  • appSecret: The application secret key.
  • requestToken: The temporary request token obtained from the login process.

Returns:

  • A SHA256 checksum string.

Types

type AuthResponse

type AuthResponse struct {
	Status string `json:"status"` // API response status (e.g., "success" or "error").
	Data   struct {
		Name         string `json:"name"`         // User's name.
		Token        string `json:"token"`        // Authentication token.
		UserID       string `json:"userId"`       // Unique identifier for the user.
		RefreshToken string `json:"refreshToken"` // Token used for refreshing authentication.
	} `json:"data"`
}

AuthResponse represents the structure of the authentication response from the API.

type BasketMarginRequest

type BasketMarginRequest []MarginRequest

BasketMarginRequest represents a collection of margin requests for multiple orders.

type BasketOrderMargin

type BasketOrderMargin struct {
	Data struct {
		MarginUsed           string `json:"marginUsed"`           // Total margin used before placing orders.
		MarginUsedAfterTrade string `json:"marginUsedAfterTrade"` // Total margin used after trade execution.
	} `json:"data"`
	Status string `json:"status"` // API response status (e.g., "success" or "error").
}

BasketOrderMargin represents the API response for multiple order margin requests.

type Client

type Client struct {
	Config     Config           // Configuration settings for the API client.
	HTTPClient *fasthttp.Client // HTTP client for executing requests.
}

Client is the main struct for interacting with the Tiqs API.

It contains the configuration settings and an HTTP client for making API requests.

func NewClient

func NewClient(appID, appSecret string) *Client

NewClient initializes a new SDK client with the provided application credentials.

Parameters:

  • appID: The application ID used for authentication.
  • appSecret: The application secret key used for authentication.

Returns:

  • A pointer to a newly created Client instance.

func (*Client) Authenticate

func (c *Client) Authenticate(requestToken string) (string, error)

Authenticate exchanges the request token for an access token.

This function sends a POST request to authenticate the user and obtain an API token.

Parameters:

  • requestToken: The temporary token received after user login.

Returns:

  • A string containing the authentication token if successful.
  • An error if authentication fails.

func (*Client) AutoLogin

func (c *Client) AutoLogin(username, password, totpSecret string) error

AutoLogin handles the entire authentication flow automatically using credentials.

This function logs in a user programmatically by sending the credentials, performing 2FA verification using TOTP, extracting the request token, and exchanging it for an access token.

Parameters:

  • username: The user's registered ID or email.
  • password: The user's password.
  • totpSecret: The TOTP secret key used to generate 2FA codes.

Returns:

  • An error if authentication fails; otherwise, nil.

func (*Client) CancelOrder

func (c *Client) CancelOrder(orderType, orderID string) error

CancelOrder cancels an existing order.

It sends a DELETE request to the API endpoint "/order/{orderType}/{orderID}".

Parameters:

  • orderType: Type of the order to be canceled (e.g., MARKET, LIMIT).
  • orderID: Unique identifier of the order.

Returns:

  • An error if the cancellation fails; otherwise, nil.

func (*Client) GetBasketMargin

func (c *Client) GetBasketMargin(order BasketMarginRequest) (*BasketOrderMargin, error)

GetBasketMargin fetches the margin details for multiple orders.

This function sends a POST request to the "/margin/basket" endpoint with a collection of orders to calculate the combined margin requirements.

Parameters:

  • order: A BasketMarginRequest struct containing multiple orders.

Returns:

  • A pointer to a BasketOrderMargin struct with total margin details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetHistoricalData

func (c *Client) GetHistoricalData(exchange, token, interval, from, to string, includeOI bool) ([]HistoricalCandle, error)

GetHistoricalData fetches historical OHLCV data for a given instrument.

It sends a GET request to the "/candle/{exchange}/{token}/{interval}?from={from}&to={to}" endpoint to retrieve OHLCV data for the specified time range. If Open Interest (OI) is requested, it is appended as a query parameter.

Parameters:

  • exchange: The exchange where the instrument is listed (e.g., NSE, BSE).
  • token: The unique identifier of the instrument.
  • interval: The timeframe of the candles (e.g., "1m", "5m", "1d").
  • from: The start date/time for historical data (ISO 8601 format).
  • to: The end date/time for historical data (ISO 8601 format).
  • includeOI: Boolean flag to include Open Interest (OI) data if available.

Returns:

  • A slice of HistoricalCandle structs containing OHLCV data if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetHoldings

func (c *Client) GetHoldings() ([]Holding, error)

GetHoldings fetches the holdings for the authenticated user.

It sends a GET request to the "/user/holdings" endpoint to retrieve all holdings associated with the user's account.

Returns:

  • A slice of Holding structs containing all available holdings if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetHolidays added in v0.0.6

func (c *Client) GetHolidays() (*HolidaysResponse, error)

GetHolidays fetches the list of market holidays and special trading days.

It sends a GET request to the "/info/holidays" endpoint to retrieve market holiday schedules and special trading days.

Returns:

  • A pointer to a HolidaysResponse struct containing holiday details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetIndexList added in v0.0.6

func (c *Client) GetIndexList() (*IndexListResponse, error)

GetIndexList fetches the list of available stock market indices.

It sends a GET request to the "/info/index-list" endpoint to retrieve details of available indices, including their names and unique tokens.

Returns:

  • A pointer to an IndexListResponse struct containing index details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetInstrumentList added in v0.0.8

func (c *Client) GetInstrumentList() ([]Instrument, error)

GetInstrumentList fetches the list of all available instruments.

It sends a GET request to the "/all" endpoint to retrieve a list of all available instruments on the platform.

Returns:

  • A slice of Instrument structs containing all available instruments if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetLimits

func (c *Client) GetLimits() (*Limits, error)

GetLimits fetches the trading limits and margin details for the authenticated user.

This function sends a GET request to the "/user/limits" endpoint to retrieve available margins, blocked funds, collateral, pending orders, and other financial details.

Returns:

  • A pointer to a Limits struct containing the trading limits if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetMargin

func (c *Client) GetMargin(order MarginRequest) (*OrderMargin, error)

GetMargin fetches the margin details for a single order.

It sends a POST request to the "/margin/order" endpoint with the order details to calculate the required margin for the specified transaction.

Parameters:

  • order: A MarginRequest struct containing the order details.

Returns:

  • A pointer to an OrderMargin struct with margin details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetMarketQuote

func (c *Client) GetMarketQuote(token int64, mode string) (*MarketQuote, error)

GetMarketQuote fetches market data for a single instrument.

It sends a POST request to the "/info/quote/{mode}" endpoint to retrieve the latest market details for a given token.

Parameters:

  • token: The unique identifier of the instrument.
  • mode: Market mode (e.g., "full", "ltp", "depth").

Returns:

  • A pointer to MarketQuote struct containing market data if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetMarketQuotes

func (c *Client) GetMarketQuotes(tokens []int64, mode string) ([]MarketQuote, error)

GetMarketQuotes fetches market data for multiple instruments.

It sends a POST request to the "/info/quotes/{mode}" endpoint to retrieve market data for a list of tokens.

Parameters:

  • tokens: A slice of unique identifiers representing instruments.
  • mode: Market mode (e.g., "full", "ltp", "depth").

Returns:

  • A slice of MarketQuote structs containing market data if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetOptionChain added in v0.0.7

func (c *Client) GetOptionChain(token, exchange, count, expiry string) (*OptionChainResponse, error)

GetOptionChain fetches the option chain details for a given symbol.

It sends a POST request to the "/info/option-chain" endpoint to retrieve the option chain details for a specific symbol.

Returns:

  • A pointer to an OptionChainResponse struct containing option chain details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetOptionChainSymbol added in v0.0.6

func (c *Client) GetOptionChainSymbol() (*OptionChainSymbolResponse, error)

GetOptionChainSymbol fetches the available option chain symbols.

It sends a GET request to the "/info/option-chain-symbols" endpoint to retrieve the available option chain symbols categorized by different asset types.

Returns:

  • A pointer to an OptionChainSymbolResponse struct containing option chain symbols if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetOrder

func (c *Client) GetOrder(orderID string) (*OrderDetailsResponse, error)

GetOrder retrieves details of a specific order.

It sends a GET request to the API endpoint "/order/{orderID}".

Parameters:

  • orderID: Unique identifier of the order.

Returns:

  • A pointer to OrderResponse containing order details if successful.
  • An error if the retrieval fails.

func (*Client) GetOrderBook

func (c *Client) GetOrderBook() ([]OrderResponse, error)

GetOrderBook retrieves all orders for the current trading day.

It sends a GET request to the API endpoint "/user/orders" and returns a list of orders.

Returns:

  • A slice of OrderResponse structs containing all orders if successful.
  • An error if the retrieval fails.

func (*Client) GetPositions

func (c *Client) GetPositions() ([]Position, error)

GetPositions fetches the positions for the authenticated user.

It sends a GET request to the "/user/positions" endpoint to retrieve all open and carry-forward positions.

Returns:

  • A slice of Position structs containing all active positions if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) GetRefreshToken added in v0.0.9

func (c *Client) GetRefreshToken() string

GetRefreshToken gets the refresh token of the user.

This function allows to get the refresh token at runtime which can be used to create new Token.

Returns:

  • refreshToken: The refresh token.

func (*Client) GetToken added in v0.0.9

func (c *Client) GetToken() string

GetToken retrieves the current authentication token.

This function returns the current API token used for authentication.

Returns:

  • The current authentication token.

func (*Client) GetUserDetails

func (c *Client) GetUserDetails() (*User, error)

GetUserDetails fetches user profile details from the Tiqs API.

It makes a GET request to the "/user/details" endpoint and returns a User struct containing all user-related information.

Returns:

  • A pointer to a User struct with the retrieved details if successful.
  • An error if the request fails or the response cannot be parsed.

func (*Client) Login

func (c *Client) Login()

Login prompts the user to log in manually and enter the request token.

This function prints a login URL and asks the user to enter the request token to complete the authentication process.

func (*Client) ModifyOrder

func (c *Client) ModifyOrder(orderType, orderID string, order OrderRequest) (*OrderResponse, error)

ModifyOrder modifies an existing order.

It sends a PATCH request to the API endpoint "/order/{orderType}/{orderID}" with the modified order details.

Parameters:

  • orderType: Type of the order being modified (e.g., MARKET, LIMIT).
  • orderID: Unique identifier of the order to be modified.
  • order: OrderRequest struct containing updated order details.

Returns:

  • A pointer to OrderResponse with the updated order details if successful.
  • An error if the modification fails.

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(orderType string, order OrderRequest) (*OrderResponse, error)

PlaceOrder places a new order in the market.

It sends a POST request to the API endpoint "/order/{orderType}" with the order details.

Parameters:

  • orderType: Type of order (e.g., MARKET, LIMIT).
  • order: OrderRequest struct containing the order details.

Returns:

  • A pointer to OrderResponse with the order confirmation details if successful.
  • An error if the order placement fails.

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken updates the authentication token dynamically.

This function allows updating the API token at runtime without needing to recreate the client.

Parameters:

  • token: The new authentication token.

type Config

type Config struct {
	AppID        string // Application ID for API authentication.
	AppSecret    string // Application secret key for API authentication.
	Token        string // Authentication token for API requests.
	BaseURL      string // Base URL of the Tiqs API.
	RefreshToken string // Token used to refresh authentication when expired.
}

Config holds the SDK configuration settings.

type HistoricalCandle

type HistoricalCandle struct {
	Time   string `json:"time"`         // Timestamp of the candle in ISO 8601 format.
	Open   int64  `json:"open"`         // Open price of the candle.
	High   int64  `json:"high"`         // Highest price during the candle period.
	Low    int64  `json:"low"`          // Lowest price during the candle period.
	Close  int64  `json:"close"`        // Closing price of the candle.
	Volume int64  `json:"volume"`       // Trading volume during the candle period.
	OI     *int64 `json:"oi,omitempty"` // Open Interest (optional, included if requested).
}

HistoricalCandle represents a single OHLCV (Open, High, Low, Close, Volume) data point.

type HistoricalDataResponse

type HistoricalDataResponse struct {
	Status string             `json:"status"` // API response status (e.g., "success" or "error").
	Data   []HistoricalCandle `json:"data"`   // List of historical OHLCV candles.
}

HistoricalDataResponse represents the structure of the historical data API response.

type Holding

type Holding struct {
	AuthorizedQty       string  `json:"authorizedQty"`       // Authorized quantity of the holding.
	AvgPrice            string  `json:"avgPrice"`            // Average price at which the holding was acquired.
	BrokerCollateralQty string  `json:"brokerCollateralQty"` // Quantity pledged as collateral with the broker.
	Close               float64 `json:"close"`               // Closing price of the holding from the previous session.
	CollateralQty       string  `json:"collateralQty"`       // Total collateral quantity.
	DepositoryQty       string  `json:"depositoryQty"`       // Quantity held in the depository.
	EffectiveQty        string  `json:"effectiveQty"`        // Effective quantity available for trading.
	Exchange            string  `json:"exchange"`            // Exchange where the holding is listed (e.g., NSE, BSE).
	Haircut             string  `json:"haircut"`             // Haircut percentage applied to the collateral.
	Ltp                 float64 `json:"ltp"`                 // Last traded price of the holding.
	NonPOAQty           string  `json:"nonPOAQty"`           // Quantity not under Power of Attorney (POA).
	Pnl                 string  `json:"pnl"`                 // Profit and Loss (PnL) on the holding.
	Qty                 string  `json:"qty"`                 // Total quantity held.
	SellableQty         string  `json:"sellableQty"`         // Quantity available for selling.
	Symbol              string  `json:"symbol"`              // Trading symbol of the instrument.
	T1Qty               string  `json:"t1Qty"`               // T+1 quantity, which is yet to be settled.
	Token               string  `json:"token"`               // Unique token identifier for the holding.
	TradingSymbol       string  `json:"tradingSymbol"`       // Full trading symbol of the instrument.
	UnPledgedQty        string  `json:"unPledgedQty"`        // Quantity that is not pledged as collateral.
	UsedQty             string  `json:"usedQty"`             // Quantity already used (e.g., for margin or pledging).
}

Holding represents a user's stock or asset holding details.

type HoldingsResponse

type HoldingsResponse struct {
	Data   []Holding `json:"data"`   // List of user's holdings.
	Status string    `json:"status"` // API response status (e.g., "success" or "error").
}

HoldingsResponse represents the API response containing user holdings.

type HolidaysResponse added in v0.0.6

type HolidaysResponse struct {
	Data struct {
		Holidays           map[string]string          `json:"holidays"`           // A map of holiday dates and their descriptions.
		SpecialTradingDays map[string][][]interface{} `json:"specialTradingDays"` // A map of special trading days with additional details.
	} `json:"data"`
	Status string `json:"status"` // API response status (e.g., "success" or "error").
}

HolidaysResponse represents the API response structure for market holidays.

type IndexListResponse added in v0.0.6

type IndexListResponse struct {
	Data []struct {
		Name  string `json:"name"`  // Name of the index (e.g., NIFTY 50, SENSEX).
		Token string `json:"token"` // Unique identifier (token) for the index.
	} `json:"data"`
	Status string `json:"status"` // API response status (e.g., "success" or "error").
}

IndexListResponse represents the API response structure for retrieving a list of market indices.

type Instrument added in v0.0.8

type Instrument struct {
	ExchSeg            string  `csv:"ExchSeg,omitempty"`
	Token              int64   `csv:"Token,omitempty"`
	LotSize            int64   `csv:"LotSize,omitempty"`
	Symbol             string  `csv:"Symbol,omitempty"`
	CompanyName        string  `csv:"CompanyName,omitempty"`
	Exchange           string  `csv:"Exchange,omitempty"`
	Segment            string  `csv:"Segment,omitempty"`
	TradingSymbol      string  `csv:"TradingSymbol,omitempty"`
	Instrument         string  `csv:"Instrument,omitempty"`
	ExpiryDate         *string `csv:"ExpiryDate,omitempty"` // Nullable field
	Isin               string  `csv:"Isin,omitempty"`
	TickSize           float64 `csv:"TickSize,omitempty"`
	PricePrecision     int     `csv:"PricePrecision,omitempty"`
	Multiplier         int     `csv:"Multiplier,omitempty"`
	PriceMultiplier    float64 `csv:"PriceMultiplier,omitempty"`
	OptionType         *string `csv:"OptionType,omitempty"` // Nullable field
	UnderlyingExchange *string `csv:"UnderlyingExchange,omitempty"`
	UnderlyingToken    *string `csv:"UnderlyingToken,omitempty"`
	StrikePrice        int64   `csv:"StrikePrice,omitempty"`
	ExchExpiryDate     int64   `csv:"ExchExpiryDate,omitempty"`
	UpdateTime         int64   `csv:"UpdateTime,omitempty"`
	MessageFlag        int     `csv:"MessageFlag,omitempty"`
	ExchangeSymbol     string  `csv:"ExchangeSymbol,omitempty"`
}

type Limits

type Limits struct {
	Data []struct {
		Cash                          string `json:"cash"`
		DayCash                       string `json:"dayCash"`
		BlockedAmount                 string `json:"blockedAmount"`
		UnClearedCash                 string `json:"unClearedCash"`
		BrokerCollateralAmount        string `json:"brokerCollateralAmount"`
		LiquidCollateralAmount        string `json:"liquidCollateralAmount"`
		EquityCollateralAmount        string `json:"equityCollateralAmount"`
		PayIn                         string `json:"payIn"`
		PayOut                        string `json:"payOut"`
		MarginUsed                    string `json:"marginUsed"`
		CashNCarryBuyUsed             string `json:"cashNCarryBuyUsed"`
		CashNCarrySellCredits         string `json:"cashNCarrySellCredits"`
		Turnover                      string `json:"turnover"`
		PendingOrderValue             string `json:"pendingOrderValue"`
		Span                          string `json:"span"`
		Exposure                      string `json:"exposure"`
		DeliveryMargin                string `json:"deliveryMargin"`
		MtomCurrentPct                string `json:"mtomCurrentPct"`
		RealisedPnL                   string `json:"realisedPnL"`
		UnRealisedMtoM                string `json:"unRealisedMtoM"`
		ProductMargin                 string `json:"productMargin"`
		Premium                       string `json:"premium"`
		VarELMMargin                  string `json:"varELMMargin"`
		GrossExposure                 string `json:"grossExposure"`
		GrossExposureDerivate         string `json:"grossExposureDerivate"`
		ScripBasketMargin             string `json:"scripBasketMargin"`
		AdditionalScriptBasketMargin  string `json:"additionalScriptBasketMargin"`
		Brokerage                     string `json:"brokerage"`
		Collateral                    string `json:"collateral"`
		GrossCollateral               string `json:"grossCollateral"`
		TurnOverLimit                 string `json:"turnOverLimit"`
		PendingOrderValueAmount       string `json:"pendingOrderValueAmount"`
		CurrentRealizedPnLei          string `json:"currentRealizedPnLei"`
		CurrentRealizedPnLem          string `json:"currentRealizedPnLem"`
		CurrentRealizedPnLc           string `json:"currentRealizedPnLc"`
		CurrentRealizedPnLdi          string `json:"currentRealizedPnLdi"`
		CurrentRealizedPnLdm          string `json:"currentRealizedPnLdm"`
		CurrentRealizedPnLfi          string `json:"currentRealizedPnLfi"`
		CurrentRealizedPnLfm          string `json:"currentRealizedPnLfm"`
		CurrentRealizedPnLci          string `json:"currentRealizedPnLci"`
		CurrentRealizedPnLcm          string `json:"currentRealizedPnLcm"`
		CurrentUnRealizedPnLei        string `json:"currentUnRealizedPnLei"`
		CurrentUnRealizedPnLem        string `json:"currentUnRealizedPnLem"`
		CurrentUnRealizedPnLc         string `json:"currentUnRealizedPnLc"`
		CurrentUnRealizedPnLdi        string `json:"currentUnRealizedPnLdi"`
		CurrentUnRealizedPnLdm        string `json:"currentUnRealizedPnLdm"`
		CurrentUnRealizedPnLfi        string `json:"currentUnRealizedPnLfi"`
		CurrentUnRealizedPnLfm        string `json:"currentUnRealizedPnLfm"`
		CurrentUnRealizedPnLci        string `json:"currentUnRealizedPnLci"`
		CurrentUnRealizedPnLcm        string `json:"currentUnRealizedPnLcm"`
		SpanDi                        string `json:"spanDi"`
		SpanDm                        string `json:"spanDm"`
		SpanFi                        string `json:"spanFi"`
		SpanFm                        string `json:"spanFm"`
		SpanCi                        string `json:"spanCi"`
		SpanCm                        string `json:"spanCm"`
		ExposureMarginDi              string `json:"exposureMarginDi"`
		ExposureMarginDm              string `json:"exposureMarginDm"`
		ExposureMarginFi              string `json:"exposureMarginFi"`
		ExposureMarginFm              string `json:"exposureMarginFm"`
		ExposureMarginCi              string `json:"exposureMarginCi"`
		ExposureMarginCm              string `json:"exposureMarginCm"`
		PremiumDi                     string `json:"premiumDi"`
		PremiumDm                     string `json:"premiumDm"`
		PremiumFi                     string `json:"premiumFi"`
		PremiumFm                     string `json:"premiumFm"`
		PremiumCi                     string `json:"premiumCi"`
		PremiumCm                     string `json:"premiumCm"`
		VarELMei                      string `json:"varELMei"`
		VarELMem                      string `json:"varELMem"`
		VarELMc                       string `json:"varELMc"`
		CoveredProductMarginEh        string `json:"coveredProductMarginEh"`
		CoveredProductMarginEb        string `json:"coveredProductMarginEb"`
		CoveredProductMarginDh        string `json:"coveredProductMarginDh"`
		CoveredProductMarginDb        string `json:"coveredProductMarginDb"`
		CoveredProductMarginFh        string `json:"coveredProductMarginFh"`
		CoveredProductMarginFb        string `json:"coveredProductMarginFb"`
		CoveredProductMarginCh        string `json:"coveredProductMarginCh"`
		CoveredProductMarginCb        string `json:"coveredProductMarginCb"`
		ScripBasketMarginEi           string `json:"scripBasketMarginEi"`
		ScripBasketMarginEm           string `json:"scripBasketMarginEm"`
		ScripBasketMarginEc           string `json:"scripBasketMarginEc"`
		AdditionalScripBasketMarginDi string `json:"additionalScripBasketMarginDi"`
		AdditionalScripBasketMarginDm string `json:"additionalScripBasketMarginDm"`
		AdditionalScripBasketMarginFi string `json:"additionalScripBasketMarginFi"`
		AdditionalScripBasketMarginFm string `json:"additionalScripBasketMarginFm"`
		AdditionalScripBasketMarginCi string `json:"additionalScripBasketMarginCi"`
		AdditionalScripBasketMarginCm string `json:"additionalScripBasketMarginCm"`
		BrokerageEi                   string `json:"brokerageEi"`
		BrokerageEm                   string `json:"brokerageEm"`
		BrokerageEc                   string `json:"brokerageEc"`
		BrokerageEh                   string `json:"brokerageEh"`
		BrokerageEb                   string `json:"brokerageEb"`
		BrokerageDi                   string `json:"brokerageDi"`
		BrokerageDm                   string `json:"brokerageDm"`
		BrokerageDh                   string `json:"brokerageDh"`
		BrokerageDb                   string `json:"brokerageDb"`
		BrokerageFi                   string `json:"brokerageFi"`
		BrokerageFm                   string `json:"brokerageFm"`
		BrokerageFh                   string `json:"brokerageFh"`
		BrokerageFb                   string `json:"brokerageFb"`
		BrokerageCi                   string `json:"brokerageCi"`
		BrokerageCm                   string `json:"brokerageCm"`
		BrokerageCh                   string `json:"brokerageCh"`
		BrokerageCb                   string `json:"brokerageCb"`
		PeakMargin                    string `json:"peakMargin"`
		RequestTime                   string `json:"requestTime"`
	} `json:"data"`
	Status string `json:"status"`
}

Limits represents the trading limits and margin details for a user.

type MarginRequest

type MarginRequest struct {
	Exchange        string `json:"exchange"`        // Exchange where the order is placed (e.g., NSE, BSE).
	Token           string `json:"token"`           // Unique identifier for the instrument.
	Quantity        string `json:"quantity"`        // Order quantity.
	Product         string `json:"product"`         // Product type (e.g., MIS, CNC, NRML).
	Price           string `json:"price"`           // Order price (applicable for LIMIT orders).
	TransactionType string `json:"transactionType"` // Order transaction type (BUY/SELL).
	OrderType       string `json:"order"`           // Type of order (e.g., MARKET, LIMIT).
	Symbol          string `json:"symbol"`          // Trading symbol of the instrument.
}

MarginRequest represents the structure for a single order margin request.

type MarginResponse

type MarginResponse struct {
	Cash   string `json:"cash"` // Available cash balance.
	Charge struct {
		Brokerage      int     `json:"brokerage"`      // Brokerage fees.
		SebiCharges    float64 `json:"sebiCharges"`    // SEBI charges.
		ExchangeTxnFee float64 `json:"exchangeTxnFee"` // Exchange transaction fees.
		StampDuty      float64 `json:"stampDuty"`      // Stamp duty applicable.
		Ipft           float64 `json:"ipft"`           // Investor Protection Fund Trust (IPFT) fees.
		TransactionTax int     `json:"transactionTax"` // Transaction tax applied.

		Gst struct {
			Cgst  int     `json:"cgst"`  // Central GST amount.
			Sgst  int     `json:"sgst"`  // State GST amount.
			Igst  float64 `json:"igst"`  // Integrated GST amount.
			Total float64 `json:"total"` // Total GST amount.
		} `json:"gst"`

		Total float64 `json:"total"` // Total charge applied.
	} `json:"charge"`

	Margin     string `json:"margin"`     // Required margin for the order.
	MarginUsed string `json:"marginUsed"` // Margin already used.
}

MarginResponse represents the response structure for margin calculations.

type MarketQuote

type MarketQuote struct {
	Token        int64  `json:"token"`        // Unique identifier for the instrument.
	LTP          int64  `json:"ltp"`          // Last traded price of the instrument.
	Open         int64  `json:"open"`         // Opening price of the instrument for the trading session.
	High         int64  `json:"high"`         // Highest price of the instrument in the current session.
	Low          int64  `json:"low"`          // Lowest price of the instrument in the current session.
	Close        int64  `json:"close"`        // Closing price of the instrument from the previous session.
	Volume       int64  `json:"volume"`       // Total traded volume of the instrument.
	TotalBuyQty  int64  `json:"totalBuyQty"`  // Total quantity of buy orders in the market.
	TotalSellQty int64  `json:"totalSellQty"` // Total quantity of sell orders in the market.
	LTT          int64  `json:"ltt"`          // Last trade time of the instrument (epoch timestamp).
	Status       string `json:"status"`       // API response status (e.g., "success" or "error").
}

MarketQuote represents the response structure for market quotes.

type OptionChainResponse added in v0.0.7

type OptionChainResponse struct {
	Data []struct {
		Exchange       string `json:"exchange"`
		Symbol         string `json:"symbol"`
		Token          string `json:"token"`
		OptionType     string `json:"optionType"`
		StrikePrice    string `json:"strikePrice"`
		PricePrecision string `json:"pricePrecision"`
		TickSize       string `json:"tickSize"`
		LotSize        string `json:"lotSize"`
	} `json:"data"`
	Status string `json:"status"`
}

OptionChainResponse represents the API response structure for fetching option chain details.

type OptionChainSymbolResponse added in v0.0.6

type OptionChainSymbolResponse struct {
	Data   map[string][]string `json:"data"`   // A map containing option chain symbols grouped by category.
	Status string              `json:"status"` // API response status (e.g., "success" or "error").
}

OptionChainSymbolResponse represents the API response structure for retrieving option chain symbols.

type OrderDetailsResponse added in v0.0.10

type OrderDetailsResponse struct {
	Data []struct {
		Status             string `json:"status"`
		Exchange           string `json:"exchange"`
		Symbol             string `json:"symbol"`
		ID                 string `json:"id"`
		Price              string `json:"price"`
		Quantity           string `json:"quantity"`
		Product            string `json:"product"`
		OrderStatus        string `json:"orderStatus"`
		ReportType         string `json:"reportType"`
		TransactionType    string `json:"transactionType"`
		Order              string `json:"order"`
		FillShares         string `json:"fillShares"`
		AveragePrice       string `json:"averagePrice"`
		RejectReason       string `json:"rejectReason"`
		ExchangeOrderID    string `json:"exchangeOrderID"`
		CancelQuantity     string `json:"cancelQuantity"`
		Remarks            string `json:"remarks"`
		DisclosedQuantity  string `json:"disclosedQuantity"`
		OrderTriggerPrice  string `json:"orderTriggerPrice"`
		Retention          string `json:"retention"`
		BookProfitPrice    string `json:"bookProfitPrice"`
		BookLossPrice      string `json:"bookLossPrice"`
		TrailingPrice      string `json:"trailingPrice"`
		Amo                string `json:"amo"`
		PricePrecision     string `json:"pricePrecision"`
		TickSize           string `json:"tickSize"`
		LotSize            string `json:"lotSize"`
		Token              string `json:"token"`
		TimeStamp          string `json:"timeStamp"`
		OrderTime          string `json:"orderTime"`
		ExchangeUpdateTime string `json:"exchangeUpdateTime"`
		RequestTime        string `json:"requestTime"`
		ErrorMessage       string `json:"errorMessage"`
	} `json:"data"`
	Status string `json:"status"`
}

type OrderMargin

type OrderMargin struct {
	Data   MarginResponse `json:"data"`   // Margin calculation details.
	Status string         `json:"status"` // API response status (e.g., "success" or "error").
}

OrderMargin represents the API response for a single order margin request.

type OrderRequest

type OrderRequest struct {
	Exchange        string `json:"exchange"`                // Exchange where the order is placed (e.g., NSE, BSE).
	Token           string `json:"token"`                   // Unique identifier for the instrument.
	Quantity        string `json:"quantity"`                // Order quantity.
	DisclosedQty    string `json:"disclosedQty,omitempty"`  // Disclosed quantity (optional).
	Product         string `json:"product"`                 // Product type (e.g., MIS, CNC, NRML).
	Symbol          string `json:"symbol"`                  // Trading symbol of the instrument.
	TransactionType string `json:"transactionType"`         // Order transaction type (BUY/SELL).
	OrderType       string `json:"order"`                   // Type of order (e.g., MARKET, LIMIT).
	Price           string `json:"price"`                   // Order price (applicable for LIMIT orders).
	Validity        string `json:"validity"`                // Order validity (e.g., DAY, IOC).
	Tags            string `json:"tags,omitempty"`          // Custom tags for order tracking (optional).
	AMO             bool   `json:"amo,omitempty"`           // Indicates if the order is an After Market Order (AMO).
	TriggerPrice    string `json:"triggerPrice,omitempty"`  // Trigger price for stop-loss or conditional orders.
	BookLossPrice   string `json:"bookLossPrice,omitempty"` // Book loss price for risk management.
}

OrderRequest represents the structure for placing an order.

type OrderResponse

type OrderResponse struct {
	Status    string `json:"status"`              // API response status (e.g., "success", "error").
	Message   string `json:"message,omitempty"`   // Message from the API (if any).
	ErrorCode string `json:"errorCode,omitempty"` // Error code in case of failure.
	Data      struct {
		OrderNo     string `json:"orderNo,omitempty"`     // Order number assigned by the exchange.
		RequestTime string `json:"requestTime,omitempty"` // Timestamp of the order request.
	} `json:"data,omitempty"`
}

OrderResponse represents the API response after placing an order.

type Position

type Position struct {
	AvgPrice                 string `json:"avgPrice"`                 // Average price of the position.
	BreakEvenPrice           string `json:"breakEvenPrice"`           // Break-even price of the position.
	CarryForwarAvgPrice      string `json:"carryForwarAvgPrice"`      // Carry-forward average price of the position.
	CarryForwardBuyAmount    string `json:"carryForwardBuyAmount"`    // Carry-forward buy amount.
	CarryForwardBuyAvgPrice  string `json:"carryForwardBuyAvgPrice"`  // Carry-forward buy average price.
	CarryForwardBuyQty       string `json:"carryForwardBuyQty"`       //	Carry-forward buy quantity.
	CarryForwardSellAmount   string `json:"carryForwardSellAmount"`   // Carry-forward sell amount.
	CarryForwardSellAvgPrice string `json:"carryForwardSellAvgPrice"` // Carry-forward sell average price.
	CarryForwardSellQty      string `json:"carryForwardSellQty"`      // Carry-forward sell quantity.
	DayBuyAmount             string `json:"dayBuyAmount"`             // Day buy amount.
	DayBuyAvgPrice           string `json:"dayBuyAvgPrice"`           // Day buy average price.
	DayBuyQty                string `json:"dayBuyQty"`                //	Day buy quantity.
	DaySellAmount            string `json:"daySellAmount"`            // Day sell amount.
	DaySellAvgPrice          string `json:"daySellAvgPrice"`          // Day sell average price.
	DaySellQty               string `json:"daySellQty"`               // Day sell quantity.
	Exchange                 string `json:"exchange"`                 // Exchange where the position is held.
	LotSize                  string `json:"lotSize"`                  // Lot size of the position.
	Ltp                      string `json:"ltp"`                      // Last traded price of the position.
	Multiplier               string `json:"multiplier"`               // Multiplier of the position.
	NetBuyQty                string `json:"netBuyQty"`                // Net buy quantity.
	NetSellQty               string `json:"netSellQty"`               // Net sell quantity.
	NetUploadPrice           string `json:"netUploadPrice"`           // Net upload price.
	OpenBuyAmount            string `json:"openBuyAmount"`            // Open buy amount.
	OpenBuyAvgPrice          string `json:"openBuyAvgPrice"`          // Open buy average price.
	OpenBuyQty               string `json:"openBuyQty"`               // Open buy quantity.
	OpenSellAmount           string `json:"openSellAmount"`           // Open sell amount.
	OpenSellAvgPrice         string `json:"openSellAvgPrice"`         // Open sell average price.
	OpenSellQty              string `json:"openSellQty"`              // Open sell quantity.
	Pnl                      string `json:"pnl"`                      // Profit and loss of the position.
	PriceFactor              string `json:"priceFactor"`              // Price factor of the position.
	PricePrecision           string `json:"pricePrecision"`           // Price precision of the position.
	Product                  string `json:"product"`                  // Product type of the position.
	Qty                      string `json:"qty"`                      // Quantity of the position.
	RealisedPnL              string `json:"realisedPnL"`              // Realised profit and loss of the position.
	Symbol                   string `json:"symbol"`                   // Trading symbol of the position.
	TickSize                 string `json:"tickSize"`                 // Tick size of the position.
	Token                    string `json:"token"`                    // Token of the position.
	UnRealisedPnl            string `json:"unRealisedPnl"`            // Unrealised profit and loss of the position.
	UnrealisedMarkToMarket   string `json:"unrealisedMarkToMarket"`   // Unrealised mark-to-market of the position.
	UploadPrice              string `json:"uploadPrice"`              // Upload price of the position.
}

type PositionsResponse

type PositionsResponse struct {
	Data   []Position `json:"data"`   // List of positions held by the user.
	Status string     `json:"status"` // API response status (e.g., "success" or "error").
}

PositionsResponse represents the API response for user positions.

type User

type User struct {
	Data struct {
		AccountID   string `json:"accountID"` // Unique identifier for the user's account.
		Address     string `json:"address"`   // Residential address of the user.
		BankDetails []struct {
			Vpa           string `json:"vpa"`           // Virtual Payment Address (UPI).
			BankName      string `json:"bankName"`      // Name of the bank associated with the account.
			AccountType   string `json:"accountType"`   // Type of bank account (e.g., Savings, Current).
			AccountNumber string `json:"accountNumber"` // Account number linked to the user.
		} `json:"bankDetails"` // List of bank accounts associated with the user.

		Blocked       bool   `json:"blocked"` // Indicates if the user's account is blocked.
		City          string `json:"city"`    // City of residence.
		DepositoryIDs struct {
			String string `json:"String"` // Depository participant ID as a string.
			Valid  bool   `json:"Valid"`  // Boolean indicating if the depository ID is valid.
		} `json:"depositoryIDs"` // User's depository information.

		Email       string   `json:"email"`       // User's registered email address.
		Exchanges   []string `json:"exchanges"`   // List of exchanges the user has access to.
		ID          string   `json:"id"`          // Unique identifier for the user.
		Image       string   `json:"image"`       // Profile image URL of the user.
		Name        string   `json:"name"`        // Full name of the user.
		OrdersTypes []string `json:"ordersTypes"` // Types of orders the user can place.
		Pan         string   `json:"pan"`         // Permanent Account Number (PAN) of the user.
		Phone       string   `json:"phone"`       // User's registered phone number.
		Products    []string `json:"products"`    // List of financial products the user has access to.
		State       string   `json:"state"`       // State of residence.
		TotpEnabled bool     `json:"totpEnabled"` // Indicates whether TOTP-based 2FA is enabled.
		UserType    string   `json:"userType"`    // Type of user (e.g., Retail, Institutional).
	} `json:"data"` // Data field containing user details.

	Status string `json:"status"` // Status of the API response (e.g., "success" or "error").
}

User represents the structure of user details received from the Tiqs API.

Jump to

Keyboard shortcuts

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