Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Start Equity
100000
End Equity
100000
Net Profit
0%
Sharpe Ratio
0
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
₹0.00
Estimated Strategy Capacity
₹0
Lowest Capacity Asset
Portfolio Turnover
0%
# region imports
from AlgorithmImports import *
# endregion

class SamcoBrokerageExampleAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2021, 1, 1)
        self.set_account_currency("INR")
        self.set_cash(100000)
        
        self.set_brokerage_model(BrokerageName.SAMCO, AccountType.MARGIN)
        
        self._symbol = self.add_equity("YESBANK", Resolution.MINUTE, Market.INDIA).symbol
        
        # Set default order properites
        self.default_order_properties = IndiaOrderProperties(Exchange.NSE, IndiaOrderProperties.IndiaProductType.NRML)
        self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED
        

    def on_data(self, data):
        if self.portfolio.invested:
            return
        
        # Place an order with the default order properties
        self.limit_order(self._symbol, 1, round(data[self._symbol].price + 100, 1))
        
        # Place an order and with new order properties
        order_properties = IndiaOrderProperties(Exchange.BSE, IndiaOrderProperties.IndiaProductType.MIS)
        ticket = self.limit_order(self._symbol, 1, round(data[self._symbol].price * .9, 1), order_properties = order_properties)
        
        # Update the order
        update_settings = UpdateOrderFields()
        update_settings.limit_price = round(data[self._symbol].price * .95, 1)
        ticket.update(update_settings)