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/

    IG Store: Store Development.

    General Discussion
    2
    8
    2610
    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.
    • T
      ThatBlokeDave last edited by ThatBlokeDave

      Hello All,
      A long time ago I asked a question about how to integrate our broker of preference. I am personally interested in integrating IG markets for spread betting and CFD's.

      https://community.backtrader.com/topic/459/store-development

      I finally found some time this week to have a crack at it and have made a small milestone with basic data streaming. I thought it might be worth sharing should others be looking at doing a similar thing. The code and a sample script are available on Github.

      https://github.com/Dave-Vallance/bt-ig-store

      Comments and collaboration welcome if anyone else is interested in live trading with IG.

      1 Reply Last reply Reply Quote 0
      • T
        ThatBlokeDave last edited by

        I am moving at a glacial pace on this side project but I have a couple of new miles-stones that I think are worth mentioning here. I see some others are interested in store development so maybe we can help each other out in understanding the inner workings. If you have any questions I am happy to share more (potentially wrong) knowledge. :)

        Current Status

        • Streaming (Integrated the trading_ig streamer into the store and created an IG data feed to load the ticks)
        • New: IG Broker: Performs the open position check when initialized to track existing positions
        • New: Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
        • New: Set IG currency code as a store initialization parameter (Default GBP).

        Still a very dirty development with lots of Oandastore methods that may or may not be needed. My aim is to only keep what is needed but am I not familiar enough with the inner workings yet. Will clean up as I learn more.

        Known Issues

        • On my MAC i get a 'fund mode' attribute error from the broker observer when running cerebro. Oddly enough on my Windows work machine, this does not happen. If you try to run the store and get a similar error, cerebro needs to be initialized with stdstats=false for now until I fix it.
        1 Reply Last reply Reply Quote 0
        • T
          ThatBlokeDave last edited by

          New update today: Slow but steady progress

          Current Status

          • Basic instrument streaming
          • Performs the open position check when initialized to track existing positions
          • Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
          • Set IG currency code as a store initialization parameter (Default GBP).
          • New: Stop order creation and cancellation supported.
          • New: Limit order creation and cancellation supported.
          • New: expiry, guaranteed_stop, time_in_force, and good_till_date parameters
            can now all be passed as key word arguments during order creation and handled
            appropriately. Defaults are used where no kwarg is passed.

          New Issue

          _Value for header {Version: 2} must be of type str or bytes, not <class 'int'>_

          If you see it, you should make sure you have the latest trading_ig module code which this store relies upon.

          1 Reply Last reply Reply Quote 0
          • T
            ThatBlokeDave last edited by

            New Update Today:

            Current Functionality

            • Basic instrument streaming
            • Performs the open position check when initialized to track existing positions
            • Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
            • Set IG currency code as a store initialization parameter (Default GBP).
            • Stop order creation and cancellation supported.
            • Limit order creation and cancellation supported.
            • expiry, guaranteed_stop, time_in_force, and good_till_date parameters
            • New: Improved streamer setup. Can use the same streamer for multiple get_instruments rather than creating multiple streamers
            • New: Manual pull of cash and value
            • New: Account cash and value live streaming
            • FIX: Level Set during order creation caused MARKET Orders to be rejected can now all be passed as key word arguments during order creation and handled appropriately. Defaults are used where no kwarg is passed..
            1 Reply Last reply Reply Quote 0
            • T
              ThatBlokeDave last edited by

              New update today.

              Historical data downloading for backtesting is now supported. However for now it requires users to download my forked version of the trading_ig library until my pull request is accepted (or rejected).

              Current Functionality

              • Basic instrument streaming
              • Performs the open position check when initialized to track existing positions
              • Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
              • Set IG currency code as a store initialization parameter (Default GBP).
              • Stop order creation and cancellation supported.
              • Limit order creation and cancellation supported.
              • expiry, guaranteed_stop, time_in_force, and good_till_date parameters
              • Improved streamer setup. Can use the same streamer for multiple get_instruments rather than creating multiple streamers
              • Manual pull of cash and value
              • Account cash and value live streaming
              • FIX: Level Set during order creation caused MARKET Orders to be rejected can now all be passed as key word * arguments during order creation and handled appropriately. Defaults are used where no kwarg is passed.
              • New: Historical data download for backtesting
              • New: Printing of remaining data download allowance (will later be updated to be a store notification, once notifications are working)
              • New: Sample script for historical data download testing.
              1 Reply Last reply Reply Quote 2
              • T
                ThatBlokeDave last edited by

                New update today... A bit smaller in size this time

                As mentioned last time, if you want to work with historical data, my pull request is still pending. Therefore you should use my forked version of the trading_ig library until then.

                Changes

                • New: Store and Data notifications tested and working
                • New: Samples updated to print Store and Data notifications
                • New: Updated granualarity check to only make the check if Backfilling, Historical or Backfill_Start are required. This allows you to work with any timeframe using tick data for live trading only.

                NOTE: Backfilling and Backfill_Start are not yet supported. The check mentioned above is in preparation for those features being supported. Historical data download is supported.

                Current Functionality

                • Basic instrument streaming
                • Performs the open position check when initialized to track existing positions
                • Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
                • Set IG currency code as a store initialization parameter (Default GBP).
                • Stop order creation and cancellation supported.
                • Limit order creation and cancellation supported.
                • expiry, guaranteed_stop, time_in_force, and good_till_date parameters
                • Improved streamer setup. Can use the same streamer for multiple get_instruments rather than creating multiple streamers
                • Manual pull of cash and value
                • Account cash and value live streaming
                • FIX: Level Set during order creation caused MARKET Orders to be rejected can now all be passed as key word * arguments during order creation and handled appropriately. Defaults are used where no kwarg is passed.
                • Historical data download for backtesting
                • Printing of remaining data download allowance
                • Sample script for historical data download testing.
                1 Reply Last reply Reply Quote 1
                • T
                  ThatBlokeDave last edited by

                  New Update:

                  Not had much time lately, so just another small one.

                  Changes

                  • New: Backfilling from start now supported
                  • New: Parameter backfill_bars allows you to set how many bars to backfill from the start. Since the IG api places restrictions on the number of historical data points a user can download per week, this parameter allows a user to limit the amount of historical data downloaded to only the required amount.

                  Current Functionality

                  • Basic instrument streaming
                  • Performs the open position check when initialized to track existing positions
                  • Opening and closing of simple Market orders using the self.buy() and self.close() is now supported.
                  • Set IG currency code as a store initialization parameter (Default GBP).
                  • Stop order creation and cancellation supported.
                  • Limit order creation and cancellation supported.
                  • expiry, guaranteed_stop, time_in_force, and good_till_date parameters
                  • Improved streamer setup. Can use the same streamer for multiple get_instruments rather than creating multiple streamers
                  • Manual pull of cash and value
                  • Account cash and value live streaming
                  • FIX: Level Set during order creation caused MARKET Orders to be rejected can now all be passed as keyword * arguments during order creation and handled appropriately. Defaults are used where no kwarg is passed.
                  • Historical data download for backtesting
                  • Printing of remaining data download allowance
                  • Sample script for historical data download testing.
                  • Backfilling from start
                  1 Reply Last reply Reply Quote 3
                  • Q
                    QuantTrader last edited by

                    Hello Dave,

                    Well done. Thanks a lot for your codes. May I know if u have a plan to add trading into the development?

                    Thanks,
                    Vincent

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