Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. partiallycomplex
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    P
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    partiallycomplex

    @partiallycomplex

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    partiallycomplex Unfollow Follow

    Latest posts made by partiallycomplex

    • Single strategy and single position on multi data

      Hi,
      I cant properly set a strategy that has multi data feed (ie the components of sp500) and inside of next() method i ahve put a function call to my personal model .
      in next method I am trying

       def my_f(self, x):
               y = randn() #ie my strategy called on data x
         return y
      
      
        def next(self):
      
          if self.order:
                  return
      
          ret={}
         for d in self.datas:
                ret[d]=self.my_f(d)
         best_stock = min(ret, key=ret.get)
          ......
          if  not self.position:
                 self.buy(data=d,.....)
      

      It doesnt work and it use just a small part of the dataset (ie I have data from 2019-2022, but i see only trades on the last 30 days)
      If i run the strategy for each single data feed it works

      best

      posted in Indicators/Strategies/Analyzers
      P
      partiallycomplex