Backtrader Community

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

    FaiqS

    @FaiqS

    2
    Reputation
    37
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    FaiqS Unfollow Follow

    Best posts made by FaiqS

    • Multiple Datafeeds and multiple Timeframes

      Hi all,
      I am running backtests with multiple feeds (multiple stocks all USA market). So am following recommended approach: sudo code

      for stock in stockiist:
          data = load corresponding csv file into Pandas dataframe
         cerebro.adddata(data)
      

      Then in next func of strategy:

      for stock in self.datas:
            do whatever 
      

      And that is working well for me. However, now I need to use Fibonnaci pivot point indicator which requires monthly data. According to this documentation
      https://www.backtrader.com/docu/data-multitimeframe/data-multitimeframe/
      I will need to add resampled line after adding the data, something like this

      for stock in stockiist:
         data = load corresponding csv file into Pandas dataframe
         cerebro.adddata(data) #Daily sampled data
         cerebro.resampledata(data,bt.TimeFrame.Months)
      

      My understanding is that now self.datas will have the following:
      "stock1 daily line, stock1 monthly line, stock2 daily line, stock2 monthly line, ..etc
      Which is not convenient to iterate through in next function of strategy.
      I wonder if there is a way to have monthly data added to another feed (other than self.datas) so in next function will have daily data fetched from self.datas and monthly data fetched from this additional feed.
      The documentation here
      https://www.backtrader.com/docu/data-resampling/data-resampling/
      States that
      "backtrader has built-in support for resampling by passing the original data through a filter object. Although there are several ways to achieve this, a straightforward interface exists to achieve this"
      The straightforward it is referring to is to add "cerebro.adddata(data)" but nothing is said about other approaches. Would appreciate if anybody has done this and can provide help
      Thanks

      posted in General Discussion
      FaiqS
      FaiqS
    • RE: Multiple Datafeeds and multiple Timeframes

      Thanks @backtrader. Yes that is an option to do it but I just wish it was more flexible.
      I guess I will have to live with it.

      posted in General Discussion
      FaiqS
      FaiqS

    Latest posts made by FaiqS

    • RE: Multiple Datafeeds and multiple Timeframes

      Thanks @backtrader. Yes that is an option to do it but I just wish it was more flexible.
      I guess I will have to live with it.

      posted in General Discussion
      FaiqS
      FaiqS
    • Multiple Datafeeds and multiple Timeframes

      Hi all,
      I am running backtests with multiple feeds (multiple stocks all USA market). So am following recommended approach: sudo code

      for stock in stockiist:
          data = load corresponding csv file into Pandas dataframe
         cerebro.adddata(data)
      

      Then in next func of strategy:

      for stock in self.datas:
            do whatever 
      

      And that is working well for me. However, now I need to use Fibonnaci pivot point indicator which requires monthly data. According to this documentation
      https://www.backtrader.com/docu/data-multitimeframe/data-multitimeframe/
      I will need to add resampled line after adding the data, something like this

      for stock in stockiist:
         data = load corresponding csv file into Pandas dataframe
         cerebro.adddata(data) #Daily sampled data
         cerebro.resampledata(data,bt.TimeFrame.Months)
      

      My understanding is that now self.datas will have the following:
      "stock1 daily line, stock1 monthly line, stock2 daily line, stock2 monthly line, ..etc
      Which is not convenient to iterate through in next function of strategy.
      I wonder if there is a way to have monthly data added to another feed (other than self.datas) so in next function will have daily data fetched from self.datas and monthly data fetched from this additional feed.
      The documentation here
      https://www.backtrader.com/docu/data-resampling/data-resampling/
      States that
      "backtrader has built-in support for resampling by passing the original data through a filter object. Although there are several ways to achieve this, a straightforward interface exists to achieve this"
      The straightforward it is referring to is to add "cerebro.adddata(data)" but nothing is said about other approaches. Would appreciate if anybody has done this and can provide help
      Thanks

      posted in General Discussion
      FaiqS
      FaiqS
    • RE: Clarification about bracket orders

      Is anybody using buy limit feature?

      posted in General Discussion
      FaiqS
      FaiqS
    • Clarification about bracket orders

      Looking at the bracket order implementation in backtrader, I think something is missing.
      When I do bracket order with broker (long for example), I have the option to specify buy limit. For example, if close price is $50, I want to buy at $51 but not to exceed $52 and then stop loss is $45 and Take Profit is $60.
      I see that stop loss is implemented as sell stop and take a profit is implemented as sell limit which is exactly what broker offer. However, I don't see the limit for buy entry. The reason behind this limit is, I want to catch momentum when equity is going up but if it gaps or goes to high, it is not worth buying it anymore.
      Can somebody help me explain how to do this in backtrader if possible?
      Thanks

      posted in General Discussion
      FaiqS
      FaiqS
    • Indicator for multiple data feeds

      I have read documentation and went over the issues that people had regarding this but still can't find an answer to my question so I am hoping someone can help me out here.
      Basically I have strategy that uses multiple data feeds (each feed is for specific equity) and I am creating own indicator.
      My understanding is, the output lines of the indicator will be array of lines (Line for each feed or equity). Is my understanding correct?
      If so, how do I define lines array inside the indicator? all I am seeing is
      lines = ('metric1','metric'2)
      If I have multiple feeds then I should have an array of metric1 and metric 2 for each feed, correct?
      Size of the array will be the number of the equities I am feeding to my strategy. That number will be known in my strategy and should be passed to indicator at instantiation. ?
      Can you somebody help?
      Thanks

      posted in Indicators/Strategies/Analyzers
      FaiqS
      FaiqS