Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Resampling Data - IBBroker - several data feed with different compression values

    General Code/Help
    1
    3
    165
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alexandre Durand
      Alexandre Durand last edited by

      Hi,

      There is something I don't understand in the behavior of my script when I resample data.
      I'm resampling the same data in another time-frame with different compression values.

      See below :

      Server Version: 76
      TWS Time at connection:20200723 14:22:55 AWST
      ***** DATA NOTIF: DELAYED
      EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=16
      EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=8
      EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=4
      EUR.USD, 10, 2020-07-23 00:53:04, 1.16, compression=1
      EUR.USD, 11, 2020-07-23 00:53:04, 1.16, compression=8
      EUR.USD, 11, 2020-07-23 00:53:04, 1.16, compression=4
      EUR.USD, 11, 2020-07-23 00:53:05, 1.16, compression=1
      EUR.USD, 12, 2020-07-23 00:53:04, 1.16, compression=4
      EUR.USD, 12, 2020-07-23 00:53:06, 1.16, compression=1
      EUR.USD, 13, 2020-07-23 00:53:07, 1.16, compression=1
      EUR.USD, 14, 2020-07-23 00:53:08, 1.16, compression=1
      EUR.USD, 15, 2020-07-23 00:53:09, 1.16, compression=1
      

      My understanding is the following :
      in the strategy data0 will be updated every 1 second
      in the strategy data1 will be updated every 2 seconds
      in the strategy data2 will be updated every 4 seconds
      in the strategy data3 will be updated every 8 seconds
      in the strategy data4 will be updated every 16 seconds

      When I log the output of the data in the next(self) of my strategy it doesn't seem to be the case :

      WS Time at connection:20200723 12:11:49 AWST
      ***** DATA NOTIF: DELAYED
      EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=16
      EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=8
      EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -4.00, compression=4
      EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
      EUR.USD, 4, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      EUR.USD, 5, 2020-07-22 22:41:52, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
      EUR.USD, 5, 2020-07-22 22:41:53, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      EUR.USD, 6, 2020-07-22 22:41:54, 1.16, 1.16, 1.16, 1.16, -2.00, compression=2
      EUR.USD, 6, 2020-07-22 22:41:54, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      EUR.USD, 7, 2020-07-22 22:41:55, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      EUR.USD, 8, 2020-07-22 22:41:56, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      EUR.USD, 9, 2020-07-22 22:41:57, 1.16, 1.16, 1.16, 1.16, -1.00, compression=1
      

      At the beginning I receive updates from the 4 compressed data.

      In Live my strategy only receive data0 updates :

      ***** DATA NOTIF: LIVE
      EUR.USD, 1801, 2020-07-23 01:22:56, 1.16, compression=1
      EUR.USD, 1802, 2020-07-23 01:22:59, 1.16, compression=1
      EUR.USD, 1803, 2020-07-23 01:22:59, 1.16, compression=1
      EUR.USD, 1804, 2020-07-23 01:23:01, 1.16, compression=1
      EUR.USD, 1805, 2020-07-23 01:23:02, 1.16, compression=1
      

      Am I missing something ?
      How can I have, on the same original data set, several data feeds with different compression values ?

      Thanks for your help,


      Alex

      1 Reply Last reply Reply Quote 0
      • Alexandre Durand
        Alexandre Durand last edited by

        The resampling code :

        stockkwargs = dict(
                dataname='EUR.USD',
                sectype='CASH',
                exchange='IDEALPRO',
                # timeframe=bt.TimeFrame.Seconds,
                # compression=1
            )
            data = ibstore.getdata( **stockkwargs)
            cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=1)
            cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=2)
            cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=4)
            cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=8)
            cerebro.resampledata(data, name=stockkwargs['dataname'], timeframe=bt.TimeFrame.Seconds, compression=16)
        

        Alex

        1 Reply Last reply Reply Quote 0
        • Alexandre Durand
          Alexandre Durand last edited by

          I found the Error, It was in my code ==> []

          Thanks for this great platform.

          Chears,


          Alex

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors