Backtesting issue: StrategyRSIRegularOrder

I am getting below error while backtesting my strategy. Can you please help me to resolve thid issue?

[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------Master Cfg Parameters:--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] User: ALGOBULLS VIRTUAL USER
[BT] [2020-09-14 09:15:00] [INFO] [tls] Broker: ABVIRTUALBROKER
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_POSITIONS: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS1: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS2: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_POSITIONS_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS1_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS2_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_INTRADAY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_TPLUS1_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_TPLUS2_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: System Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Trading type: BACKTESTING
[BT] [2020-09-14 09:15:00] [INFO] [tls] User trading start time: 2020-09-14 09:15:00
[BT] [2020-09-14 09:15:00] [INFO] [tls] User trading end time: 2020-09-18 15:15:00
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Funds Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Credit Exposure: 1
[BT] [2020-09-14 09:15:00] [INFO] [tls] Fund Allocator: FundAllocatorLots
[BT] [2020-09-14 09:15:00] [INFO] [tls] Fund Allocator Parameters: {'NUMBER_OF_LOTS': 1}
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Candle Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Candle interval (sec): 900
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Strategy Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Strategy: Undestand working of strategy
[BT] [2020-09-14 09:15:00] [INFO] [tls] Parameters: {'timeperiod1': 5.0, 'timeperiod2': 12.0}
[BT] [2020-09-14 09:15:00] [INFO] [tls] Strategy Mode: INTRADAY
[BT] [2020-09-14 09:15:00] [INFO] [tls] Instruments Bucket: instruments_bucket | [NSE_EQ:TCS]
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Risk Management Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Target Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Stoploss Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Trailing Stoploss Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Desired profit: 1000000.0
[BT] [2020-09-14 09:15:00] [INFO] [tls] Risk Appetite: 10000.0
[BT] [2020-09-14 09:15:00] [INFO] [tls] PNL scan frequency (in sec): 30
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Other Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Allow multiple orders for same script: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] Allow new order when order for script already running: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] Instrument max orders count: 100
[BT] [2020-09-14 09:15:00] [INFO] [tls] Remove Instrument if Order Rejected: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] ------------------------------------------------------------
[BT] [2020-09-14 09:15:00] [INFO] [utils] Instrument (NSE_EQ:TCS) subscribed to historical data successfully
[BT] [2020-09-14 09:15:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-09-14 09:15:00] [INFO] [utils] Prefetching historical data for 1 instruments...
[BT] [2020-09-14 09:15:00] [INFO] [tls] [User: ALGOBULLS VIRTUAL USER] Trading session completed
[BT] [2020-09-14 09:15:00] [INFO] [oms] 

PENDING ORDERS:


COMPLETED ORDERS:


POSITIONS:


HOLDINGS:
[BT] [2020-09-14 09:15:00] [CRITICAL] [tls] Dumping Debug Stack to Python friendly Traceback Format for Python Build Customers: Uncaught exception | Exception Class: <class 'AttributeError'> | Exception Details: 'DataFrame' object has no attribute '_data'
[BT] [2020-09-14 09:15:00] [CRITICAL] [tls] An error has occurred due to which the strategy cannot proceed anymore. Please double check the tweak parameters. If you are a Python Build customer, please double check your strategy code. If everything seems fine, please contact support@algobulls.com for support.

Hi Ganesh,

Kindly share the code snippet where you have used a DataFrame.

Thanks,

` aki

from pyalgotrading.strategy.strategy_base import StrategyBase
from pyalgotrading.constants import *
import talib

class StrategyRSIRegularOrder(StrategyBase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args,**kwargs)
        self.timeperiod1 = self.strategy_parameters['timeperiod1']
        self.main_order = None  # empty dict

    def initialize(self):
        self.main_order = {}

    @staticmethod
    def name():
        return 'RSI Regular Order Strategy'

    @staticmethod
    def versions_supported():
        return AlgoBullsEngineVersion.VERSION_3_2_0

    def get_rsi_value(self, instrument):
        hist_data = self.get_historical_data(instrument)
        rsi_value = talib.RSI(hist_data['close'], timeperiod=timeperiod1)
        return rsi_value

    def strategy_select_instruments_for_entry(self, candle, instruments_bucket):
        selected_instruments_bucket = []
        sideband_info_bucket = []

        for instrument in instruments_bucket:
            rsi_value = self.get_rsi_value(instrument)

            if rsi_value < 25:
                selected_instruments_bucket.append(instrument)
                sideband_info_bucket.append({'action': 'BUY'})
            elif rsi_value > 75:
                if self.strategy_mode is StrategyMode.INTRADAY:
                    selected_instruments_bucket.append(instrument)
                    sideband_info_bucket.append({'action': 'SELL'})
        return selected_instruments_bucket, sideband_info_bucket


    def strategy_enter_position(self, candle, instrument, sideband_info):
        if sideband_info['action'] == 'BUY':
            qty = self.number_of_lots * instrument.lot_size
            self.main_order[instrument] = \
            self.BuyOrderRegular(instrument=instrument,order_code=BrokerOrderCodeConstants.INTRADAY,
                                 order_variety=BrokerOrderVarietyConstants.MARKET, quantity=qty)
        if sideband_info['action'] == 'SELL':
            qty = self.number_of_lots * instrument.lot_size
            self.main_order[instrument] = \
                self.SellOrderRegular(instrument=instrument,
                                      order_code=BrokerOrderCodeConstants.INTRADAY,
                                      order_variety=BrokerOrderVarietyConstants.MARKET,
                                      quantity=qty)
        else:
            raise SystemExit(f'Got invalid sideband_info value:{sideband_info}')
            return self.main_order[instrument]

    def strategy_select_instruments_for_exit(self, candle, instruments_bucket):
        selected_instruments_bucket = []
        sideband_info_bucket = []

        for instrument in instruments_bucket:
            if self.main_order.get(instrument) is not None:
                selected_instruments_bucket.append(instrument)
                sideband_info_bucket.append({'action': 'EXIT'})
        return selected_instruments_bucket, sideband_info_bucket

    def strategy_exit_position(self, candle, instrument, sideband_info):
        if sideband_info['action'] == 'EXIT':
            self.main_order[instrument].exit_position()
            self.main_order[instrument] = None
            return True
        return False

Hi Ganesh,

The team is looking into this.

I will get back to you soon.

Thanks,

` aki

Hi Ganesh,

Could you change

To

and try ?

` aki

Yeah, it’s typo. But it didn’t resolve issue.

This time, I have copied code from “Python-Algorithmic-Trading-Cookbook” for StrategyEMARegularOrder class.

Still, I am facing problem.

Code Snippet:

from pyalgotrading.strategy.strategy_base import StrategyBase
from pyalgotrading.constants import *

class StrategyEMARegularOrder(StrategyBase):

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    self.timeperiod1 = self.strategy_parameters['timeperiod1']
    self.timeperiod2 = self.strategy_parameters['timeperiod2']

    self.main_order = None

def initialize(self):
    self.main_order = {}

@staticmethod
def name():
    return 'EMA Regular Order Strategy'

@staticmethod
def versions_supported():
    return AlgoBullsEngineVersion.VERSION_3_2_0

def get_crossover_value(self, instrument):
    hist_data = self.get_historical_data(instrument)
    ema_x = talib.EMA(hist_data['close'], timeperiod=self.timeperiod1)
    ema_y = talib.EMA(hist_data['close'], timeperiod=self.timeperiod2)
    crossover_value = self.utils.crossover(ema_x, ema_y)
    return crossover_value

def strategy_select_instruments_for_entry(self, candle, instruments_bucket):

    selected_instruments_bucket = []
    sideband_info_bucket = []

    for instrument in instruments_bucket:
        crossover_value = self.get_crossover_value(instrument)
        if crossover_value == 1:
            selected_instruments_bucket.append(instrument)
            sideband_info_bucket.append({'action': 'BUY'})
        elif crossover_value == -1:
            if self.strategy_mode is StrategyMode.INTRADAY:
                selected_instruments_bucket.append(instrument)
                sideband_info_bucket.append({'action': 'SELL'})

    return selected_instruments_bucket, sideband_info_bucket

def strategy_enter_position(self, candle, instrument, sideband_info):
    if sideband_info['action'] == 'BUY':
        qty = self.number_of_lots * instrument.lot_size
        self.main_order[instrument] = \
            self.broker.BuyOrderRegular(instrument=instrument,
                                        order_code=BrokerOrderCodeConstants.INTRADAY,
                                        order_variety=BrokerOrderVarietyConstants.MARKET,
                                        quantity=qty)
    elif sideband_info['action'] == 'SELL':
        qty = self.number_of_lots * instrument.lot_size
        self.main_order[instrument] = \
            self.broker.SellOrderRegular(instrument=instrument,
                                         order_code=BrokerOrderCodeConstants.INTRADAY,
                                         order_variety=BrokerOrderVarietyConstants.MARKET,
                                         quantity=qty)
    else:
        raise SystemExit(f'Got invalid sideband_info value: {sideband_info}')

    return self.main_order[instrument]

def strategy_select_instruments_for_exit(self, candle, instruments_bucket):
    selected_instruments_bucket = []
    sideband_info_bucket = []

    for instrument in instruments_bucket:
        if self.main_order.get(instrument) is not None:
            crossover_value = self.get_crossover_value(instrument)
            if crossover_value in [1, -1]:
                selected_instruments_bucket.append(instrument)
                sideband_info_bucket.append({'action': 'EXIT'})
    return selected_instruments_bucket, sideband_info_bucket

def strategy_exit_position(self, candle, instrument, sideband_info):
    if sideband_info['action'] == 'EXIT':
        self.main_order[instrument].exit_position()
        self.main_order[instrument] = None
        return True

    return False

Log

[2020-09-21 21:22:36] Performing sanity checks on cfg strategy_parameters, setting up broker connection and required data structures...
[2020-09-21 21:22:38] ABBroker connection has been setup successfully.
[2020-09-21 21:22:38] Sanity checks on cfg successful.
[2020-09-21 21:22:38] Setting up broker connection...
[2020-09-21 21:22:38] Broker connection has been setup successfully.
[2020-09-21 21:22:38] (NSE_EQ) Funds available in client's ABVirtualBroker account is : Rs. '1000000000.00'
[2020-09-21 21:22:38] 
########################################
 INITIALIZING ALGOBULLS CORE (v3.2.0)... 
########################################
[2020-09-21 21:22:38] Welcome ALGOBULLS VIRTUAL USER!
[2020-09-21 21:22:38] Reading strategy...
[2020-09-21 21:22:40] Entering Backtesting mode. Henceforth, all timestamps will be Backtesting timestamps...
[BT] [2020-08-03 09:30:00] [INFO] [tls] STARTING ALGOBULLS CORE...
[BT] [2020-08-03 09:30:00] [INFO] [tls] 
            
  #####  #######    #    ######  ####### ### #     #  #####     
 #     #    #      # #   #     #    #     #  ##    # #     #    
 #          #     #   #  #     #    #     #  # #   # #          
  #####     #    #     # ######     #     #  #  #  # #  ####    
       #    #    ####### #   #      #     #  #   # # #     #    
 #     #    #    #     # #    #     #     #  #    ## #     #    
  #####     #    #     # #     #    #    ### #     #  #####     

    #    #        #####  ####### ######  #     # #       #        #####    
   # #   #       #     # #     # #     # #     # #       #       #     #   
  #   #  #       #       #     # #     # #     # #       #       #         
 #     # #       #  #### #     # ######  #     # #       #        #####    
 ####### #       #     # #     # #     # #     # #       #             #   
 #     # #       #     # #     # #     # #     # #       #       #     #   
 #     # #######  #####  ####### ######   #####  ####### #######  #####    

  #####  ####### ######  #######
 #     # #     # #     # #
 #       #     # #     # #
 #       #     # ######  #####
 #       #     # #   #   #
 #     # #     # #    #  #
  #####  ####### #     # #######
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------Master Cfg Parameters:--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] User: ALGOBULLS VIRTUAL USER
[BT] [2020-08-03 09:30:00] [INFO] [tls] Broker: ABVIRTUALBROKER
[BT] [2020-08-03 09:30:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_POSITIONS: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS1: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS2: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] RESUME_POSITIONS_ON_START: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS1_ON_START: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS2_ON_START: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] EXIT_INTRADAY_ORDERS_ON_STOP: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] EXIT_TPLUS1_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] EXIT_TPLUS2_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: System Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Trading type: BACKTESTING
[BT] [2020-08-03 09:30:00] [INFO] [tls] User trading start time: 2020-08-03 09:30:00
[BT] [2020-08-03 09:30:00] [INFO] [tls] User trading end time: 2020-09-21 15:15:00
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: Funds Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Credit Exposure: 1
[BT] [2020-08-03 09:30:00] [INFO] [tls] Fund Allocator: FundAllocatorLots
[BT] [2020-08-03 09:30:00] [INFO] [tls] Fund Allocator Parameters: {'NUMBER_OF_LOTS': 1}
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: Candle Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Candle interval (sec): 900
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: Strategy Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Strategy: EMA Regular Order Strategy
[BT] [2020-08-03 09:30:00] [INFO] [tls] Parameters: {'timeperiod1': 4.0, 'timeperiod2': 9.0}
[BT] [2020-08-03 09:30:00] [INFO] [tls] Strategy Mode: INTRADAY
[BT] [2020-08-03 09:30:00] [INFO] [tls] Instruments Bucket: instruments_bucket | [NSE_EQ:SBIN]
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: Risk Management Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Target Trigger: 0.1000
[BT] [2020-08-03 09:30:00] [INFO] [tls] Stoploss Trigger: 0.1000
[BT] [2020-08-03 09:30:00] [INFO] [tls] Trailing Stoploss Trigger: 0.1000
[BT] [2020-08-03 09:30:00] [INFO] [tls] Desired profit: 1000000.0
[BT] [2020-08-03 09:30:00] [INFO] [tls] Risk Appetite: 10000.0
[BT] [2020-08-03 09:30:00] [INFO] [tls] PNL scan frequency (in sec): 30
[BT] [2020-08-03 09:30:00] [INFO] [tls] --------------------User Cfg Parameters: Other Parameters--------------------
[BT] [2020-08-03 09:30:00] [INFO] [tls] Allow multiple orders for same script: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] Allow new order when order for script already running: True
[BT] [2020-08-03 09:30:00] [INFO] [tls] Instrument max orders count: 100
[BT] [2020-08-03 09:30:00] [INFO] [tls] Remove Instrument if Order Rejected: False
[BT] [2020-08-03 09:30:00] [INFO] [tls] ------------------------------------------------------------
[BT] [2020-08-03 09:30:00] [INFO] [utils] Instrument (NSE_EQ:SBIN) subscribed to historical data successfully
[BT] [2020-08-03 09:30:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-08-03 09:30:00] [INFO] [utils] Prefetching historical data for 1 instruments...
[BT] [2020-08-03 09:30:00] [INFO] [tls] [User: ALGOBULLS VIRTUAL USER] Trading session completed
[BT] [2020-08-03 09:30:00] [INFO] [oms] 

PENDING ORDERS:


COMPLETED ORDERS:


POSITIONS:


HOLDINGS:
[BT] [2020-08-03 09:30:00] [CRITICAL] [tls] Dumping Debug Stack to Python friendly Traceback Format for Python Build Customers: Uncaught exception | Exception Class: <class 'TypeError'> | Exception Details: 'IndexError' object is not subscriptable
[BT] [2020-08-03 09:30:00] [CRITICAL] [tls] An error has occurred due to which the strategy cannot proceed anymore. Please double check the tweak parameters. If everything seems fine, please contact support@algobulls.com for support.

Copyright 2020 AlgoBulls Technologies Private Limited

Hi Ganesh,

I would like to address your concerns point wise.

  1. For

Could you solve the typo issue and let us know if it worked for you?

  1. For

Could you create a separate thread for this? Because the error you have encountered is different from what you have in StrategyRSIRegularOrder. Both these errors are unrelated.

Thanks,
` aki

Hi Ganesh,

To clarify further for Point 1 mentioned in my reply above, Kindly fix the typo and paste the error logs again. So that we can track the issue to closure.

To clarify further for Point 2 mentioned in my reply above, Kindly create a separate thread for the same and let’s track it to closure too.

Thanks,
` aki

Hi Team,

I apologized for the confusion created. I was just testing backtesting with clean code.

Point 1:

class StrategyRSIRegularOrder(StrategyBase):

I am still getting error but this time it is different. Pleas have a look at the below backtesting log:

[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------Master Cfg Parameters:--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] User: ALGOBULLS VIRTUAL USER
[BT] [2020-08-10 09:15:00] [INFO] [tls] Broker: ABVIRTUALBROKER
[BT] [2020-08-10 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_POSITIONS: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS1: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS2: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] RESUME_POSITIONS_ON_START: True
[BT] [2020-08-10 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS1_ON_START: True
[BT] [2020-08-10 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS2_ON_START: True
[BT] [2020-08-10 09:15:00] [INFO] [tls] EXIT_INTRADAY_ORDERS_ON_STOP: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] EXIT_TPLUS1_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] EXIT_TPLUS2_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: System Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Trading type: BACKTESTING
[BT] [2020-08-10 09:15:00] [INFO] [tls] User trading start time: 2020-08-10 09:15:00
[BT] [2020-08-10 09:15:00] [INFO] [tls] User trading end time: 2020-09-21 15:15:00
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Funds Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Credit Exposure: 1
[BT] [2020-08-10 09:15:00] [INFO] [tls] Fund Allocator: FundAllocatorLots
[BT] [2020-08-10 09:15:00] [INFO] [tls] Fund Allocator Parameters: {‘NUMBER_OF_LOTS’: 1}
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Candle Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Candle interval (sec): 900
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Strategy Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Strategy: RSI Regular Order Strategy
[BT] [2020-08-10 09:15:00] [INFO] [tls] Parameters: {‘timeperiod1’: 14.0}
[BT] [2020-08-10 09:15:00] [INFO] [tls] Strategy Mode: INTRADAY
[BT] [2020-08-10 09:15:00] [INFO] [tls] Instruments Bucket: instruments_bucket | [NSE_EQ:SBIN]
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Risk Management Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Target Trigger: 0.1000
[BT] [2020-08-10 09:15:00] [INFO] [tls] Stoploss Trigger: 0.1000
[BT] [2020-08-10 09:15:00] [INFO] [tls] Trailing Stoploss Trigger: 0.1000
[BT] [2020-08-10 09:15:00] [INFO] [tls] Desired profit: 1000000.0
[BT] [2020-08-10 09:15:00] [INFO] [tls] Risk Appetite: 10000.0
[BT] [2020-08-10 09:15:00] [INFO] [tls] PNL scan frequency (in sec): 30
[BT] [2020-08-10 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Other Parameters--------------------
[BT] [2020-08-10 09:15:00] [INFO] [tls] Allow multiple orders for same script: True
[BT] [2020-08-10 09:15:00] [INFO] [tls] Allow new order when order for script already running: True
[BT] [2020-08-10 09:15:00] [INFO] [tls] Instrument max orders count: 100
[BT] [2020-08-10 09:15:00] [INFO] [tls] Remove Instrument if Order Rejected: False
[BT] [2020-08-10 09:15:00] [INFO] [tls] ------------------------------------------------------------
[BT] [2020-08-10 09:15:00] [INFO] [utils] Instrument (NSE_EQ:SBIN) subscribed to historical data successfully
[BT] [2020-08-10 09:15:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-08-10 09:15:00] [INFO] [utils] Prefetching historical data for 1 instruments…
[BT] [2020-08-10 09:15:00] [INFO] [strategy]
####################
Strategy Parameters:
StrategyParameters([(‘timeperiod1’, 14)])
####################
[BT] [2020-08-10 09:15:00] [INFO] [tls] Opening current intraday positions, if any…
[BT] [2020-08-10 09:15:00] [INFO] [tls] Not processing holdings as STRATEGY_MODE is INTRADAY
[BT] [2020-08-10 09:15:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-08-10 09:15:00] [INFO] [tls] [User: ALGOBULLS VIRTUAL USER] Trading session completed
[BT] [2020-08-10 09:15:00] [INFO] [oms]

PENDING ORDERS:

COMPLETED ORDERS:

POSITIONS:

HOLDINGS:
[BT] [2020-08-10 09:15:00] [CRITICAL] [tls] Dumping Debug Stack to Python friendly Traceback Format for Python Build Customers: Uncaught exception | Exception Class: <class ‘AttributeError’> | Exception Details: ‘NoneType’ object has no attribute ‘filters’
[BT] [2020-08-10 09:15:00] [CRITICAL] [tls] An error has occurred due to which the strategy cannot proceed anymore. Please double check the tweak parameters. If everything seems fine, please contact support@algobulls.com for support.

Hi Ganesh,

The team is looking into this.

I will get back to you soon.

Thanks,

` aki

Hi Ganesh,

For this line of code:

Please print the data type of the variable rsi_value.

If this variable is a pandas dataframe or a series data type, then it cannot be compared to an integer literal directly.

For the line of code above, the returned type may be a series.

To get a single value out of a series, you can try:
rsi_value.iloc[-1]
to get the last value in the series or
rsi_value.iloc[0]
to get the first value in the series.

For TA-Lib documentation, go here:


For Pandas documentation, go here:

Thanks,
` aki

Hi,

I got below message in log and backtesting halted.
[BT] [2020-09-14 09:30:00] [CRITICAL] [tls] Strategy breached code of conduct. Please adjust your strategy to follow guidelines and run again. Halting strategy...

Complete Log:

[2020-09-22 15:06:00] Performing sanity checks on cfg strategy_parameters, setting up broker connection and required data structures...
[2020-09-22 15:06:01] ABBroker connection has been setup successfully.
[2020-09-22 15:06:01] Sanity checks on cfg successful.
[2020-09-22 15:06:01] Setting up broker connection...
[2020-09-22 15:06:01] Broker connection has been setup successfully.
[2020-09-22 15:06:01] (NSE_EQ) Funds available in client's ABVirtualBroker account is : Rs. '1000000000.00'
[2020-09-22 15:06:01] 
########################################
 INITIALIZING ALGOBULLS CORE (v3.2.0)... 
########################################
[2020-09-22 15:06:01] Welcome ALGOBULLS VIRTUAL USER!
[2020-09-22 15:06:01] Reading strategy...
[2020-09-22 15:06:02] Entering Backtesting mode. Henceforth, all timestamps will be Backtesting timestamps...
[BT] [2020-09-14 09:15:00] [INFO] [tls] STARTING ALGOBULLS CORE...
[BT] [2020-09-14 09:15:00] [INFO] [tls] 
            
  #####  #######    #    ######  ####### ### #     #  #####     
 #     #    #      # #   #     #    #     #  ##    # #     #    
 #          #     #   #  #     #    #     #  # #   # #          
  #####     #    #     # ######     #     #  #  #  # #  ####    
       #    #    ####### #   #      #     #  #   # # #     #    
 #     #    #    #     # #    #     #     #  #    ## #     #    
  #####     #    #     # #     #    #    ### #     #  #####     

    #    #        #####  ####### ######  #     # #       #        #####    
   # #   #       #     # #     # #     # #     # #       #       #     #   
  #   #  #       #       #     # #     # #     # #       #       #         
 #     # #       #  #### #     # ######  #     # #       #        #####    
 ####### #       #     # #     # #     # #     # #       #             #   
 #     # #       #     # #     # #     # #     # #       #       #     #   
 #     # #######  #####  ####### ######   #####  ####### #######  #####    

  #####  ####### ######  #######
 #     # #     # #     # #
 #       #     # #     # #
 #       #     # ######  #####
 #       #     # #   #   #
 #     # #     # #    #  #
  #####  ####### #     # #######
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------Master Cfg Parameters:--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] User: ALGOBULLS VIRTUAL USER
[BT] [2020-09-14 09:15:00] [INFO] [tls] Broker: ABVIRTUALBROKER
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_POSITIONS: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS1: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] AUTO_ADD_INSTRUMENTS_BUCKET_FROM_HOLDINGS_TPLUS2: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_POSITIONS_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS1_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] RESUME_HOLDINGS_TPLUS2_ON_START: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_INTRADAY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_TPLUS1_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] EXIT_TPLUS2_DELIVERY_ORDERS_ON_STOP: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: System Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Trading type: BACKTESTING
[BT] [2020-09-14 09:15:00] [INFO] [tls] User trading start time: 2020-09-14 09:15:00
[BT] [2020-09-14 09:15:00] [INFO] [tls] User trading end time: 2020-09-18 15:15:00
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Funds Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Credit Exposure: 1
[BT] [2020-09-14 09:15:00] [INFO] [tls] Fund Allocator: FundAllocatorLots
[BT] [2020-09-14 09:15:00] [INFO] [tls] Fund Allocator Parameters: {'NUMBER_OF_LOTS': 1}
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Candle Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Candle interval (sec): 900
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Strategy Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Strategy: RSI Regular Order Strategy
[BT] [2020-09-14 09:15:00] [INFO] [tls] Parameters: {'timeperiod1': 14.0}
[BT] [2020-09-14 09:15:00] [INFO] [tls] Strategy Mode: INTRADAY
[BT] [2020-09-14 09:15:00] [INFO] [tls] Instruments Bucket: instruments_bucket | [NSE_EQ:SBIN]
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Risk Management Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Target Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Stoploss Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Trailing Stoploss Trigger: 0.1000
[BT] [2020-09-14 09:15:00] [INFO] [tls] Desired profit: 1000000.0
[BT] [2020-09-14 09:15:00] [INFO] [tls] Risk Appetite: 10000.0
[BT] [2020-09-14 09:15:00] [INFO] [tls] PNL scan frequency (in sec): 30
[BT] [2020-09-14 09:15:00] [INFO] [tls] --------------------User Cfg Parameters: Other Parameters--------------------
[BT] [2020-09-14 09:15:00] [INFO] [tls] Allow multiple orders for same script: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] Allow new order when order for script already running: True
[BT] [2020-09-14 09:15:00] [INFO] [tls] Instrument max orders count: 100
[BT] [2020-09-14 09:15:00] [INFO] [tls] Remove Instrument if Order Rejected: False
[BT] [2020-09-14 09:15:00] [INFO] [tls] ------------------------------------------------------------
[BT] [2020-09-14 09:15:00] [INFO] [utils] Instrument (NSE_EQ:SBIN) subscribed to historical data successfully
[BT] [2020-09-14 09:15:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-09-14 09:15:00] [INFO] [utils] Prefetching historical data for 1 instruments...
[BT] [2020-09-14 09:15:00] [INFO] [strategy] 
####################
Strategy Parameters:
StrategyParameters([('timeperiod1', 14)])
####################
[BT] [2020-09-14 09:15:00] [INFO] [tls] Opening current intraday positions, if any...
[BT] [2020-09-14 09:15:00] [INFO] [tls] Not processing holdings as STRATEGY_MODE is INTRADAY
[BT] [2020-09-14 09:15:00] [INFO] [utils] 1 Instrument(s) (re)subscribed to historical data successfully
[BT] [2020-09-14 09:15:00] [INFO] [clock] Waiting for 900.00 seconds until end of current candle (2020-09-14 09:30:00)...
[BT] [2020-09-14 09:30:00] [CRITICAL] [tls] Strategy breached code of conduct. Please adjust your strategy to follow guidelines and run again. Halting strategy...
[BT] [2020-09-14 09:30:00] [INFO] [tls] Received event EXCEPTION. Stopping AlgoBulls Trading Core Engine...
[BT] [2020-09-14 09:30:00] [INFO] [tls] Stopping without exiting any positions...
[BT] [2020-09-14 09:30:00] [INFO] [tls] [User: ALGOBULLS VIRTUAL USER] Trading session completed
[BT] [2020-09-14 09:30:00] [INFO] [oms] 

PENDING ORDERS:


COMPLETED ORDERS:


POSITIONS:


HOLDINGS:

Hi Ganesh,

I am covering some points here:

  1. Issues related to “Strategy breached code of conduct”:
    This is related to the platform, which ensures that the strategy code adheres to certain guidelines. We have made some updates at our end. So, kindly run the strategy code again to see if you can proceed forward.

  2. Issues related to “Pythonic errors”:
    This is related to some errors encountered in your strategy code. We have updated the logs feature to give you a more detailed report of the particular error you are encountering. This should help you to google the particular Python code error and proceed forward.

To summarize, run your strategy code again to see whether the security feature is letting you proceed forward. And then kindly see if the detailed (logs) report is helping you to isolate specific code errors better now.

Thanks,
` aki