Navigation

    Backtrader Community

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

    BorutF

    @BorutF

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

    BorutF Unfollow Follow

    Best posts made by BorutF

    • RE: How to get the index of the current iteration in next?

      @run-out said in How to get the index of the current iteration in next?:

      @borutf You can get the current bar but using len(self)

      Thanks.

      posted in General Code/Help
      B
      BorutF
    • RE: 5min data from yahoo

      @anders_lind

      2022-05-17 23:59:59.999989

      This happens to every datetime??

      I always use bt.feeds.PandasData , it can work on yfinance downloads as well.

      posted in General Code/Help
      B
      BorutF

    Latest posts made by BorutF

    • RE: Can we write Celebro engine data in the excel ?

      @varsha-shingade with the help of analyzers:

      cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
      strat = cerebro.run(tradehistory=True)
      
      pyfoliozer = strat[0].analyzers.getbyname('pyfolio')
      returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()
      transactions.to_csv("transactions.csv")
      

      There are other options with analyzers, because there is so much data you can save.

      posted in General Discussion
      B
      BorutF
    • RE: sell_bracket() order: sell() got an unexpected keyword argument 'size'

      Seems unusual to me.

      May I ask why do you even call super().sell_bracket ?

      Why not just self.sell_bracket ? Did you change sell_bracket somehow?

      posted in General Code/Help
      B
      BorutF
    • Define which specific method you want to inherit from strategy.

      I want to inherit some functions in my strategy from a parent class (BaseStrategy).

      Let's use this example:

      def notify_cashvalue(self, cash, value):
              if value < starting_cash * self.terminate_threshold:
                  self.log(f'Stopping strategy at due drop below {self.terminate_threshold * 100}% of initial cash.')
                  self.cerebro.runstop()
      

      This would be the function inside BaseStrategy and my actual strategy would inherit. This function requires that the terminate_threshold is defined in the child strategy. This could be a nuisance if I want to inherit the BaseStrategy, but I don't want that particular method. I know I could rewrite notify_cashvalue, however I would prefer to add the methods I want inherit instead of removing them. I want to customly compose the strategy instead of inheriting everything.

      posted in General Code/Help
      B
      BorutF
    • RE: No such file or directory: orcl....txt

      @aeroandy1

      I have seen this before. I don't know how to make it work.

      On the other hand I know

      data = bt.feeds.PandasData(dataname=yf.download('ORCL', '2011-01-01', '2021-12-01'))
      

      this works.

      posted in General Code/Help
      B
      BorutF
    • RE: 5min data from yahoo

      @anders_lind

      2022-05-17 23:59:59.999989

      This happens to every datetime??

      I always use bt.feeds.PandasData , it can work on yfinance downloads as well.

      posted in General Code/Help
      B
      BorutF
    • Do analyzers have a common output function?

      Let's say I want the most readable output for each analyzer that I add to the strategy. Namely, I don't want to go in detail for each specific analyzer.

      I know you can call get_analysis() but that prints some orderedDicts.

      Right now the output varries between analyzers a lot.

      posted in General Code/Help
      B
      BorutF
    • RE: Anyone use backtrader to do live trading on Bitcoin exchange?

      I am using ccxtbt from: https://github.com/Dave-Vallance/bt-ccxt-store

      Where do you specify the frequency of fetching the data?

      posted in General Discussion
      B
      BorutF
    • Setting only the fromdate parameter in Yahoo Data Feed

      It seems as if the data feed does not work if you only set the fromdate.

      Possibly because the lines 309 and 313 backtrader/feeds/yahoo.py only compare if todate is not None. They do this two times, perhaps the second one should compare the fromdate.

      posted in General Code/Help
      B
      BorutF
    • What library to use for OANDA trading?

      OANDA Store , the store uses oandapy which is like a six year old library that uses the defunct version of the API(v1). I have not manage to get it to work, so I am starting to wonder whether it would be better to use some other library such as btoandav20.

      What have your experiences been?

      posted in General Code/Help
      B
      BorutF
    • How do you set a pending order for a short order?

      If I understand correctly you execute a short order by first executing sell().

      I do that and it seems to work correctly based on the sum aggregated from trades.

      However I noticed pending order gets executed when the price exceeds the entry price. I want it the other way around, so that it gets executed when the price is lower.

      posted in General Code/Help
      B
      BorutF