Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Single strategy and single position on multi data

    Indicators/Strategies/Analyzers
    1
    1
    49
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      partiallycomplex last edited by

      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

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors