Navigation

    Backtrader Community

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

    LisaWalters

    @LisaWalters

    A beginner backtrader user.

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

    LisaWalters Unfollow Follow

    Best posts made by LisaWalters

    • Resample together: datafeed and strat params whose units are bars

      Hello community,

      What's the pattern for jointly resampling a datafeed and strat params whose units are bars (e.g. MA period)?

      Example use-case:

      Suppose one has a daily-bar datafeed that's used to run a strategy with a moving average with a period of 30 (MA is a 30-day MA).

      One day, the user decides to try out the same strategy on 3-day bars instead. The datafeed can be resampled or filtered easily to achieve 3-day bars. The MA period should be changed to 10 because a 10-period MA covers the same period as the MA in the previous situation (30 days == 10 periods * 3 days). How should the user go about coding logic that changes the MA period based on the datafeed's resampling?

      posted in General Discussion
      L
      LisaWalters

    Latest posts made by LisaWalters

    • RE: Bug: IB Paper Trading Order Expiry/Valid Time

      I suspected that this could be a timezone mis-match issue so I tried changing IB's timezone to UTC (GMT+0) and setting the expiry time works fine now.

      I think what happens is this:

      Backtrader's does this (pseudocode):

      dt = current date & time in UTC
      expiry_date_time = dt + valid
      place order with expiry_date_time
      

      Order reaches IB. On IB's end, expiry_date_time is interpreted in the user's IB client's timezone (e.g. for someone running IB in australia, expiry_date_time is assumed to be in australia's timezone).

      posted in General Code/Help
      L
      LisaWalters
    • Bug: IB Paper Trading Order Expiry/Valid Time

      Tried out samples/ibtest/ibtest.py. Setting expiry time ("valid" time in Backtrader lingo) leads to orders being rejected by IB system. On the other hand, orders with no expiry time work fine.

      IB records the expiry time correctly though:
      Screenshot 2020-10-31 at 1.03.51 AM.png

      I ran:

      $ python ibtest.py
      --timeframe Days
      --port 7497
      --trade --valid 60
      --usestore --broker
      

      -- valid 60 means 60 seconds to expiry.

      I'm currently running this outside of the US. Tried running with --timezone US/Eastern and this bug still persists.

      Any ideas would be great.

      posted in General Code/Help
      L
      LisaWalters
    • Resample together: datafeed and strat params whose units are bars

      Hello community,

      What's the pattern for jointly resampling a datafeed and strat params whose units are bars (e.g. MA period)?

      Example use-case:

      Suppose one has a daily-bar datafeed that's used to run a strategy with a moving average with a period of 30 (MA is a 30-day MA).

      One day, the user decides to try out the same strategy on 3-day bars instead. The datafeed can be resampled or filtered easily to achieve 3-day bars. The MA period should be changed to 10 because a 10-period MA covers the same period as the MA in the previous situation (30 days == 10 periods * 3 days). How should the user go about coding logic that changes the MA period based on the datafeed's resampling?

      posted in General Discussion
      L
      LisaWalters
    • RE: Threading Error in cerebro.run(maxcpus=...)

      @vladisld Thank you. Yes, the solution proposed resolved the error. I guess those facing this issue will have to manually add the observers they desire.

      posted in General Code/Help
      L
      LisaWalters
    • Threading Error in cerebro.run(maxcpus=...)

      Successfully ran the strategy selection code in https://www.backtrader.com/blog/posts/2016-10-29-strategy-selection/strategy-selection/ (regardless of the value assigned to maxcpus).

      So, I extended the code to my needs.

      In my code, when maxcpus parameter in cerebro.run(maxcpus = ...) is greater than 1, the error shown below would occur (it's a threading error). No errors occur when maxcpus = 1 and the run completes smoothly.

      Any idea as to what I should look at to find the source of the error?

      Changing the value of optreturn in cerebro.run(..) has no effect on this error.

      Should I change to another version of pickling/pickler?

      > python stratsel.py
      
      
      
      Starting Portfolio Value: 1000.00
      Exception in thread Thread-3:
      Traceback (most recent call last):
        File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/threading.py", line 926, in _bootstrap_inner
          self.run()
        File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/threading.py", line 870, in run
          self._target(*self._args, **self._kwargs)
        File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/pool.py", line 470, in _handle_results
          task = get()
        File "/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/multiprocessing/connection.py", line 251, in recv
          return _ForkingPickler.loads(buf.getbuffer())
      AttributeError: Can't get attribute 'Lines_LineSeries_LineIterator_DataAccessor_ObserverBase_Observer_DataTrades_7a5dc4c5b1604837b6655d447e5ae1e0' on <module 'backtrader.lineseries' from '/Users/d/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/backtrader/lineseries.py'>
      
      posted in General Code/Help
      L
      LisaWalters