book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

Drafts

ZerodhaBrokerageModel

Introduction

This page explains the ZerodhaBrokerageModel, including the asset classes it supports, its default security-level models, and its default markets.

SetBrokerageModel(BrokerageName.Zerodha, AccountType.Cash);
SetBrokerageModel(BrokerageName.Zerodha, AccountType.Margin);
self.set_brokerage_model(BrokerageName.ZERODHA, AccountType.CASH)
self.set_brokerage_model(BrokerageName.ZERODHA, AccountType.MARGIN)

To view the implementation of this model, see the LEAN GitHub repository.

Asset Classes

Our Zerodha integration supports trading Indian Equities.

Orders

We model the Zerodha API by supporting several order types, order properties, and order updates.

Order Types

The following table describes the available order types for each asset class that the ZerodhaBrokerageModel supports:

Order TypeIndia Equity
Marketgreen check
Limitgreen check
Stop marketgreen check
Stop limitgreen check

Order Properties

We model custom order properties from the Zerodha API. The following table describes the members of the IndiaOrderProperties object that you can set to customize order execution:

PropertyData TypeDescriptionDefault Value
ExchangeexchangeExchangeSelect the exchange for sending the order to. The following instructions are available:
  • Exchange.NSE
  • Exchange.BSE
ProductTypeproduct_typestringstr A ProductTypeproduct_type instruction to apply to the order. The IndiaOrderProperties.IndiaProductType enumeration has the following members:
TimeInForcetime_in_forceTimeInForceA TimeInForce instruction to apply to the order. The following instructions are available:
  • DayDAY
  • GoodTilCanceledGOOD_TIL_CANCELED
  • GoodTilDategood_til_date
TimeInForce.GoodTilCanceledTimeInForce.GOOD_TIL_CANCELED

Updates

We model the Samco Zerodha by supporting order updates.

Handling Splits

If you're using raw data normalization and you have active orders with a limit, stop, or trigger price in the market for a US Equity when a stock split occurs, the following properties of your orders automatically adjust to reflect the stock split:

  • Quantity
  • Limit price
  • Stop price
  • Trigger price

Fills

The ZerodhaBrokerageModel uses the EquityFillModel.

Slippage

The ZerodhaBrokerageModel uses the NullSlippageModel.

Fees

The ZerodhaBrokerageModel uses the ZerodhaFeeModel.

Buying Power

The ZerodhaBrokerageModel uses the SecurityMarginModel. If you have a margin account, the ZerodhaBrokerageModel allows up to 5x leverage.

Settlement

The ZerodhaBrokerageModel uses the ImmediateSettlementModel for margin accounts and the DelayedSettlementModel with the default settlement rules for cash accounts.

// For cash accounts:
security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime));

// For margin accounts:
security.SetSettlementModel(new ImmediateSettlementModel());
# For cash accounts:
security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME))

# For margin accounts:
security.set_settlement_model(ImmediateSettlementModel())

Margin Interest Rate

The ZerodhaBrokerageModel uses the NullMarginInterestRateModel.

Default Markets

The default market of the ZerodhaBrokerageModel is Market.IndiaMarket.INDIA.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: