Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. hans
    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 2
    • Posts 7
    • Best 0
    • Groups 0

    hans

    @hans

    1
    Reputation
    724
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Location The Netherlands

    hans Unfollow Follow

    Latest posts made by hans

    • Suggestion: caching

      Hi,

      I'd like to make a suggestion to create an option to cache results.

      When searching for a profitable strategy backtrader is (in my case, presumably also for others) frequently used to add an indicator or two, rerun, examine the results etc. This involves many iterations, in which many of the same indicators need to be recalculated. By caching the calculated series, lots of computing time can be saved when rerunning. In my opinion it would be a valuable addition to add caching as an option to backtrader.

      There are multiple ways caching could be a achieved. One of them would be to create a cache file (that would be (re)written at the end of a run and examined for data already available at the beginning of a run). Maybe the Writer functionality could be used to implement this.

      Having a cache, once could avoid calculating the same time and again.

      What do you think about this suggestion? Consider it useful?

      posted in General Discussion
      hans
      hans
    • RE: Plot - maximize windows

      An alternate, very simple, approach is to handle the window outside of backtrader. Personally I wrote a (tiny) script (in keyboard maestro, mac only) to just resize the window with a F2 keypress, exactly to the dimensions I prefer. This keeps your code clean and works simple and effective. Just run, and press a key if you want to see a bigger window with the graphical results.

      posted in General Code/Help
      hans
      hans
    • RE: Change BuySell to "trade arrows" in charts #213

      I created a simple csv with: datetime, price and volume (from a csv with bid/sell info). High, low, open and close point to the same price field:

      data = bt.feeds.GenericCSVData(
              dataname='datafile.csv',
              fromdate=datetime.datetime(2010, 1, 1),
              todate=datetime.datetime(2010, 12, 31),
              nullvalue=0.0,
              dtformat=('%Y-%m-%d %H:%M:%S.%f'),
              datetime=0, 
              high=1, low=1, open=1, close=1, 
              volume=2,
              openinterest=-1
          )
      
      posted in General Code/Help
      hans
      hans
    • RE: Short selling - Strategy versus Signals

      Thanks a lot for this detailed and helpful explanation!

      posted in General Discussion
      hans
      hans
    • RE: Plot - maximize windows

      Just for people working on a mac: the solution described above does not seem to work on macOS (at least not in my environment).

      posted in General Code/Help
      hans
      hans
    • Short selling - Strategy versus Signals

      (firstly: I am new to backtrader, so forgive me if I overread smth in the documentation)

      background:
      I am interested in forex trading (working primarily with tick data). I installed backtrader and ran some of its examples successfully, so I started with the basic example (from tutrial) which I am modifying to play around with backtrader.

      short
      When the strategy indicates a sell, I'd like to turn the long position into a short position. For example: when my indicator signals a reversal, I want to close a current (long) position, and switch to a short position (and vice versa). I could not figure out how to do this with a Strategy (hints/solutions welcome!), so I dug into the documentation and read about the section "strategy with signals". That seems approprate. As a matter of fact: it seems to be working quite well. However...

      Everything concerning buying and selling appears "in the dark", so I attempted to intercept buy/sell signals and trade position, much like the logging in the tutorial. I am yet to find out how to get notified when a signal appears. In the first place, I'd like to just log a line to the console for each buy and sell, just like the logging in the tuturial.

      Can anyone point me in the right position to get this done (either by means of a Strategy or using plain signals)? Thanks in advance!

      posted in General Discussion
      hans
      hans
    • RE: Change BuySell to "trade arrows" in charts #213

      As far as I can see the arrows do not appear when working with tick data (at least not in my figures). Is that intended behaviour or possibly a bug?

      posted in General Code/Help
      hans
      hans