sreenivasdoosa / sdoosa-algo-trade-python

Algo trade project in python
513 stars 318 forks source link

dynamically passing stocklist to samplestrategy: Not picking updated list #26

Open viks555 opened 3 years ago

viks555 commented 3 years ago

Hi srini,

I am trying to pass cash stock list through a function in the samplestrategy.py but it picks up only the list which is available at start after that it does not update the list. i believe the strategy loops every 30 secs and therefore should update the stocks when its get updated during later executions ..

def init(self): if SampleStrategy.instance != None: raise Exception("This class is a singleton!") else: SampleStrategy.instance = self

Call Base class constructor

super().__init__("SAMPLE")
# Initialize all the properties specific to this strategy
self.productType = ProductType.MIS

/**here i have replaced the earlier hard coded list with a class function stocks.scripname thats picks up stocks and keeps on changing during the day***/

****self.symbols = stocks.scripname()

self.slPercentage = 2
self.targetPercentage = 4
self.startTimestamp = Utils.getTimeOfToDay(9, 45, 0) # When to start the strategy. Default is Market start time
self.stopTimestamp = Utils.getTimeOfToDay(14, 0, 0) # This is not square off timestamp. This is the timestamp after which no new trades will be placed under this strategy but existing trades continue to be active.
self.squareOffTimestamp = Utils.getTimeOfToDay(14, 50, 0) # Square off time
self.capital = 5000 # Capital to trade (This is the margin you allocate from your broker account for this strategy)
self.leverage = 2 # 2x, 3x Etc
self.maxTradesPerDay = 6 # Max number of trades per day under this strategy
self.isFnO = False # Does this strategy trade in FnO or not
self.capitalPerSet = 0 # Applicable if isFnO is True (1 set means 1CE/1PE or 2CE/2PE etc based on your strategy logic)