Navigation

    Backtrader Community

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

    nooby_mcnoob

    @nooby_mcnoob

    6
    Reputation
    700
    Profile views
    27
    Posts
    1
    Followers
    0
    Following
    Joined Last Online

    nooby_mcnoob Unfollow Follow

    Best posts made by nooby_mcnoob

    • RE: Live data does not match historical data for ibtest.py #359

      @dasch @backtrader

      Thanks for your help. The PEBKAC is resolved :-)

      I guess it is obvious to you, but perhaps a default mode of "backtest bars should match live bars" would follow the principle of least surprise? In any case, here are some live resampled bars, followed by the corresponding historical resampled bars with a timeframe of 5 minutes with rightedge=False. This shows that live bars match historical bars. Now the question I have to answer myself is: "why did righedge=False not work in my system when I tried it live?"

      Live

      Data0, 0196,                    736793.5625, 2018-04-09T09:30:00.000000, 1.27725, 1.27794, 1.27709, 1.27773, -1.0, 0, 1.277366
      Data0, 0197,              736793.5659722222, 2018-04-09T09:35:00.000000, 1.27773, 1.27882, 1.27745, 1.27874, -1.0, 0, 1.277632
      Data0, 0198,              736793.5694444445, 2018-04-09T09:40:00.000000, 1.27874, 1.27876, 1.27756, 1.27769, -1.0, 0, 1.27775
      Data0, 0199,              736793.5729166666, 2018-04-09T09:45:00.000000, 1.27769, 1.27791, 1.27729, 1.27751, -1.0, 0, 1.277784
      Data0, 0200,              736793.5763888889, 2018-04-09T09:50:00.000000, 1.27751, 1.27751, 1.2765, 1.27675, -1.0, 0, 1.277684
      Data0, 0201,              736793.5798611111, 2018-04-09T09:55:00.000000, 1.27675, 1.27726, 1.27634, 1.27681, -1.0, 0, 1.2775
      Data0, 0202,              736793.5833333334, 2018-04-09T10:00:00.000000, 1.27681, 1.27716, 1.27641, 1.27712, -1.0, 0, 1.277176
      Data0, 0203,              736793.5868055555, 2018-04-09T10:05:00.000000, 1.27712, 1.27748, 1.27683, 1.27736, -1.0, 0, 1.27711
      Data0, 0204,              736793.5902777778, 2018-04-09T10:10:00.000000, 1.27736, 1.27757, 1.27725, 1.27736, -1.0, 0, 1.2770800000000002
      Data0, 0205,                   736793.59375, 2018-04-09T10:15:00.000000, 1.27736, 1.2774, 1.27652, 1.27652, -1.0, 0, 1.277034
      

      Historical

      Data0, 0196,                    736793.5625, 2018-04-09T09:30:00.000000, 1.27725, 1.27794, 1.27709, 1.27773, -1.0, 0, 1.277366
      Data0, 0197,              736793.5659722222, 2018-04-09T09:35:00.000000, 1.27773, 1.27882, 1.27745, 1.27874, -1.0, 0, 1.277632
      Data0, 0198,              736793.5694444445, 2018-04-09T09:40:00.000000, 1.27874, 1.27876, 1.27756, 1.27769, -1.0, 0, 1.27775
      Data0, 0199,              736793.5729166666, 2018-04-09T09:45:00.000000, 1.27769, 1.27791, 1.27729, 1.27751, -1.0, 0, 1.277784
      Data0, 0200,              736793.5763888889, 2018-04-09T09:50:00.000000, 1.27751, 1.27751, 1.2765, 1.27675, -1.0, 0, 1.277684
      Data0, 0201,              736793.5798611111, 2018-04-09T09:55:00.000000, 1.27675, 1.27726, 1.27634, 1.27681, -1.0, 0, 1.2775
      Data0, 0202,              736793.5833333334, 2018-04-09T10:00:00.000000, 1.27681, 1.27716, 1.27641, 1.27712, -1.0, 0, 1.277176
      Data0, 0203,              736793.5868055555, 2018-04-09T10:05:00.000000, 1.27712, 1.27748, 1.27683, 1.27736, -1.0, 0, 1.27711
      Data0, 0204,              736793.5902777778, 2018-04-09T10:10:00.000000, 1.27736, 1.27757, 1.27725, 1.27736, -1.0, 0, 1.2770800000000002
      Data0, 0205,                   736793.59375, 2018-04-09T10:15:00.000000, 1.27736, 1.2774, 1.27652, 1.27652, -1.0, 0, 1.277034
      
      
      posted in General Discussion
      N
      nooby_mcnoob
    • RE: passing data to strategy via an *args

      @blonc

      Try:

      def__init__(self):
         self.d0 = self.params.d0
         self.d1 = self.params.d1
      
      posted in General Code/Help
      N
      nooby_mcnoob
    • RE: Is it possible to backtest minute data with a lunch break?

      You'd do something like this:

      class MyStrategy(...):
        def next(self):
          now = self.data0.datetime.datetime(0)
          if now.time() >= datetime.time(11,31) and now.time() <= datetime.time(12,59):
             ... your logic here ...
      
      posted in General Discussion
      N
      nooby_mcnoob

    Latest posts made by nooby_mcnoob

    • RE: IBController + Backtrader, no bars being produced after connection has resumed

      I've had this problem as well, the only reliable solution I've found is to restart the backtrader process and manually manage any open orders. Kinda sucks to have to do this.

      posted in General Code/Help
      N
      nooby_mcnoob
    • RE: Is it possible to backtest minute data with a lunch break?

      You'd do something like this:

      class MyStrategy(...):
        def next(self):
          now = self.data0.datetime.datetime(0)
          if now.time() >= datetime.time(11,31) and now.time() <= datetime.time(12,59):
             ... your logic here ...
      
      posted in General Discussion
      N
      nooby_mcnoob
    • RE: Trailing take profit

      @tw00000 said in Trailing take profit:

      It does seem in times of volatility the StopTrailLimit would be very disadvantageous - are there any advantages?

      It can be problematic. I've had markets go right over my limit. The only thing I do is have a OCO stop market order further than the trail in case markets go crazy and I'm not there to do something.

      posted in General Code/Help
      N
      nooby_mcnoob
    • RE: Is there way to track open orders with IB broker?

      Here is how I debug live trades:

      1. Use notify_trade and notify_order functions and print out the status as it comes in
      2. Don't use GTC orders unless your strategy cancels orders. I use time-limited orders

      Additionally, when I place an order, I assign the current order to a member: self._order = ... and unset it when notify_trade marks it as closed. Then, I don't do any of the strategy logic unless self._order is None.

      posted in General Discussion
      N
      nooby_mcnoob
    • RE: Weekly resampling, set cutoff to a different weekday?

      Looks like I should use a trading calendar

      posted in General Discussion
      N
      nooby_mcnoob
    • Weekly resampling, set cutoff to a different weekday?

      See summary. Is there any way to set the specific day of the week used to mean the beginning/end of the week? Currently it appears to default to Sunday/Monday which is OK but I'd like more control.

      posted in General Discussion
      N
      nooby_mcnoob
    • RE: Brain limitations: position sizing for forex

      @backtrader Actually, I'm unable to see how to apply this.

      If we have

      self.buy_bracket(price=100,...)
      

      But the actual price is $.75, the order will go to the broker at $100... I'm very confused. Maybe the right thing to do is to manually create the bracket orders.

      posted in General Discussion
      N
      nooby_mcnoob
    • RE: Brain limitations: position sizing for forex

      @backtrader oh that's very interesting and makes perfect sense, thank you!

      posted in General Discussion
      N
      nooby_mcnoob
    • Brain limitations: position sizing for forex

      This is tough, I think because the "size" has to be different if you want to convert 100% of the amount back to your base currency.

      So say my base currency is USD and I am trading USD/GBP (I know this isn't a real pair). If I convert $100 to £75, the order could look like this:

      self.buy_bracket(price=.75,limitprice=.78,stopprice=0.74)

      The sizer is called once, and lets say the idea is to always trade a size of $100, so we configured bt.sizers.FixedSizer,stake=100

      Now say the profit limit is hit, that means we will convert £100 into $133. But we only had £75 which means we will be taking some sort of a position instead of closing it out.

      I'm trying to figure out how we would size this properly, but it seems to be a limitation in my brain.

      posted in General Discussion
      N
      nooby_mcnoob
    • RE: Optimizing Strategy with IBStore data returns pickle error

      I tried to resolve this issue by walking recursively down the object tree rooted at cerebro and setting all lock types to None. Didn't work, still found a lock somewhere.

      posted in Indicators/Strategies/Analyzers
      N
      nooby_mcnoob