Navigation

    Backtrader Community

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

    joeyy

    @joeyy

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

    joeyy Unfollow Follow

    Best posts made by joeyy

    • RE: notify_order shows wrong calculations

      Perfect! so the BUY/SELL show the underlying single unit asset price whereas the PROFIT is the delta times the stake size (minus commission). It adds up. Thank you Rajanprabu!

      posted in General Code/Help
      J
      joeyy
    • cerebro.optstrategy slow AF on mac and really fast on Windows ?

      Hi All!

      This is such an esoteric problem and I don't suppose others have encountered it, but I figured it might be worth a shot.
      I have a strategy which I want to test across thousands and thousands of permutations via cerebro.optstrategy.
      When I run it on my macbook pro it's ridiculously slow and is able to compute about 5-6 results per minute, which basically makes it unusable.
      Then if I run the same code on a mediocre windows machine it generates hundreds of results per minute.
      Has anyone experienced anything similar ? Is there a config somewhere where I can make it more CPU intensive / add threads ?

      Thanks in advance!

      posted in General Code/Help
      J
      joeyy

    Latest posts made by joeyy

    • cerebro.optstrategy slow AF on mac and really fast on Windows ?

      Hi All!

      This is such an esoteric problem and I don't suppose others have encountered it, but I figured it might be worth a shot.
      I have a strategy which I want to test across thousands and thousands of permutations via cerebro.optstrategy.
      When I run it on my macbook pro it's ridiculously slow and is able to compute about 5-6 results per minute, which basically makes it unusable.
      Then if I run the same code on a mediocre windows machine it generates hundreds of results per minute.
      Has anyone experienced anything similar ? Is there a config somewhere where I can make it more CPU intensive / add threads ?

      Thanks in advance!

      posted in General Code/Help
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      this is def. better, thanks!

      posted in General Discussion
      J
      joeyy
    • RE: indicator always runs on the shorter candle timeframe

      I figured it out. It was as simple as adding the timeframe to the indicator init as such

      self.ema = bt.ind.EMA(self.data1, period=self.p.period)
      
      posted in General Code/Help
      J
      joeyy
    • indicator always runs on the shorter candle timeframe

      hi everyone and happy holidays,

      I have a strategy that combines 2 timeframes, 1 every 5 minutes to make snappy decisions such as a stop loss and another 4 hours timeframe that runs the strategy.

      If I add an indicator, such as EMA

      self.ema = bt.ind.EMA(period=self.p.period)
              self.ema = btind.ExponentialMovingAverage(period=self.p.period)
      

      And instantiate 2 timeframes

       data_ticks_long = bt.feeds.CCXT(
              exchange='binance',
              symbol=symbol,
              timeframe=bt.TimeFrame.Minutes,
              config={'rateLimit': 1000, 'enableRateLimit': True},
              fromdate=from_date,
              compression=STRATEGY_CANDLE_SIZE_IN_MINUTES
          )
      
          data_ticks_short = bt.feeds.CCXT(
              exchange='binance',
              symbol=symbol,
              timeframe=bt.TimeFrame.Minutes,
              config={'rateLimit': 1000, 'enableRateLimit': True},
              fromdate=from_date,
              compression=STOPLOSS_CANDLE_SIZE_IN_MINUTES
          )
      

      it would build the EMA line based on the ticks in the next function. Since the shorter timeframe happens every 5 minutes my EMA will be built entirely from that timeframe.
      How do I get my indicator to be based on the longer, 4 hours, timeframe ?

      thanks!

      posted in General Code/Help
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      That makes sense, I do wish to replace my hack with something more sustainable. Perhaps the link you were looking for was this one -
      https://community.backtrader.com/topic/1329/how-to-determine-if-the-data-is-being-replayed-in-strategy

      posted in General Discussion
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      thank you ab_trader!
      your answer got me most of the way. I can split the logic in my next function based on the index of the self.datas object.
      There is one caveat though. If I want to compare the indicator's value to one of the timeframe, it will get evaluated for every tick, and might satisfy a greater than / less than condition in the wrong tick. In other words, if I have an SMA, and 2 candles: one is 5min, the other 60min, and I want to buy based on the SMA cross with the 60min candle, it will still get checked every 5min and the SMA will change in every iteration. Therefore I might be making trades without waiting for the 60min tick.

      I solved it by adding a flag that checks if the slow indicator value has changed, which stays the same for every fast tick, i.e -

      if(self.last_candle_ref_price != self.data1.lines.close[0]):
         if self.sma.lines.sma[0] < self.data1.lines.close[0]:
            <do something>
      
      self.last_candle_ref_price = self.data1.lines.close[0]
      
      posted in General Discussion
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      this doesn't work, won't tell you anything about the current tick compression

      posted in General Discussion
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      correction: the longer timeframe

      posted in General Discussion
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      thanks for the reply! unfortunately self.data.p.compression always returns the shorter timeframe

      2017-08-18 00:00:00, EMA PRICE 4357.05,  CLOSE PRICE 4286.53, TIME FRAME : 60
      2017-08-18 01:00:00, EMA PRICE 4346.73,  CLOSE PRICE 4243.59, TIME FRAME : 60
      2017-08-18 02:00:00, EMA PRICE 4339.54,  CLOSE PRICE 4267.59, TIME FRAME : 60
      2017-08-18 03:00:00, EMA PRICE 4335.25,  CLOSE PRICE 4292.39, TIME FRAME : 60
      2017-08-18 04:00:00, EMA PRICE 4330.95,  CLOSE PRICE 4287.92, TIME FRAME : 60
      2017-08-18 05:00:00, EMA PRICE 4329.37,  CLOSE PRICE 4313.56, TIME FRAME : 60
      2017-08-18 06:00:00, EMA PRICE 4324.83,  CLOSE PRICE 4279.46, TIME FRAME : 60
      2017-08-18 07:00:00, EMA PRICE 4322.60,  CLOSE PRICE 4300.25, TIME FRAME : 60
      2017-08-18 08:00:00, EMA PRICE 4318.97,  CLOSE PRICE 4282.73, TIME FRAME : 60
      2017-08-18 09:00:00, EMA PRICE 4317.62,  CLOSE PRICE 4304.15, TIME FRAME : 60
      2017-08-18 10:00:00, EMA PRICE 4321.14,  CLOSE PRICE 4356.31, TIME FRAME : 60
      2017-08-18 11:00:00, EMA PRICE 4322.88,  CLOSE PRICE 4340.31, TIME FRAME : 60
      2017-08-18 12:00:00, EMA PRICE 4323.69,  CLOSE PRICE 4331.71, TIME FRAME : 60
      2017-08-18 13:00:00, EMA PRICE 4320.90,  CLOSE PRICE 4293.09, TIME FRAME : 60
      2017-08-18 14:00:00, EMA PRICE 4315.31,  CLOSE PRICE 4259.40, TIME FRAME : 60
      2017-08-18 15:00:00, EMA PRICE 4308.18,  CLOSE PRICE 4236.89, TIME FRAME : 60
      2017-08-18 16:00:00, EMA PRICE 4302.93,  CLOSE PRICE 4250.34, TIME FRAME : 60
      2017-08-18 17:00:00, EMA PRICE 4292.96,  CLOSE PRICE 4193.35, TIME FRAME : 60
      2017-08-18 18:00:00, EMA PRICE 4277.00,  CLOSE PRICE 4117.41, TIME FRAME : 60
      2017-08-18 19:00:00, EMA PRICE 4264.21,  CLOSE PRICE 4136.28, TIME FRAME : 60
      2017-08-18 20:00:00, EMA PRICE 4242.11,  CLOSE PRICE 4021.11, TIME FRAME : 60
      2017-08-18 21:00:00, EMA PRICE 4217.89,  CLOSE PRICE 3975.69, TIME FRAME : 60
      2017-08-18 22:00:00, EMA PRICE 4208.42,  CLOSE PRICE 4113.75, TIME FRAME : 60
      2017-08-18 23:00:00, EMA PRICE 4199.33,  CLOSE PRICE 4108.37, TIME FRAME : 60
      2017-08-19 00:00:00, EMA PRICE 4196.07,  CLOSE PRICE 4163.49, TIME FRAME : 60
      2017-08-19 01:00:00, EMA PRICE 4191.75,  CLOSE PRICE 4148.53, TIME FRAME : 60
      2017-08-19 02:00:00, EMA PRICE 4188.53,  CLOSE PRICE 4156.39, TIME FRAME : 60
      
      posted in General Discussion
      J
      joeyy
    • RE: Is there a way to differentiate 2 streams of sampled data in the next function ?

      A more concrete example is having 1 SMA and needing to write logic that's different based on the compression you're viewing

      posted in General Discussion
      J
      joeyy