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/

    Futures Live Trading

    General Code/Help
    3
    8
    587
    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.
    • G
      giakoumis last edited by

      Hello everyone,
      I am trying to use backtrader with Interactive Brokers in order to live trade Futures. I am running into two problems.

      1. Is there a way to get all the contracts related to a symbol ( for example CL ) , in order to add them as feeds to backtrader, get their expiration dates, their multipliers etc?
      2. Can I get historical data from ib for a continuous future? Or I need to request the separate contracts and then use the Rollover class to create the continuous feed?

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        What contract are you looking for for historical data?

        RunBacktest.com

        1 Reply Last reply Reply Quote 0
        • G
          giakoumis last edited by

          Well let's say I want to trade Crude Oil Jul 2020 and I want to get an indicator going back 1 year.

          1 Reply Last reply Reply Quote 0
          • G
            giakoumis last edited by

            I understand that my question seemed rather vague but I am new both at backtrader and algorithmic trading altogether, so I am struggling with the actual implementation details as well as trading concepts at the same time.
            I will try to rephrase my question in hopes that it will be more clear what I am trying to do.

            I want to use backtrader with IB for live trading futures contracts. What I cannot wrap my mind around, is how can I rollover the contract to the next. I understand how I can do this in backtesting using the Rollover class and its functionality but in live trading I can only have the current contract as a live feed.

            My thought at this point is to get the feed for both the front month future as well as the next few months and recreate the rollover logic to decide when I will start trading with the next month's feed. The problem with this logic is that if I want to trade with a large universe of futures the number of feeds will grow. If this is the only way could I possibly add the feeds dynamically so that I only have a small number of contracts per future and load the next one after I rollover?

            Has anyone out there have any sample code I could study for futures live trading?

            Once again thank you for your patience.

            1 Reply Last reply Reply Quote 0
            • A
              ab_trader last edited by

              Intraday or daily bars?

              • If my answer helped, hit reputation up arrow at lower right corner of the post.
              • Python Debugging With Pdb
              • New to python and bt - check this out
              G 1 Reply Last reply Reply Quote 0
              • G
                giakoumis @ab_trader last edited by

                @ab_trader Daily bars

                1 Reply Last reply Reply Quote 0
                • A
                  ab_trader last edited by

                  @giakoumis said in Futures Live Trading:

                  I want to use backtrader with IB for live trading futures contracts. What I cannot wrap my mind around, is how can I rollover the contract to the next. I understand how I can do this in backtesting using the Rollover class and its functionality but in live trading I can only have the current contract as a live feed.

                  You may want to have live data feed for the active contract from ib and than use backfill_from parameter to backfill the data from previously stored continuous contracts. On the first look every time you switch to next contract the bt needs to be restarted with new live data feed and new backfill_from data.

                  @giakoumis said in Futures Live Trading:

                  If this is the only way could I possibly add the feeds dynamically so that I only have a small number of contracts per future and load the next one after I rollover?

                  Data feeds should be added before the cerebro run started, not on the fly. But restarting bt every time you start trading new contract can help.

                  But honestly if you are trading on the daily bars having live trading setup is more hassle than worse.

                  • If my answer helped, hit reputation up arrow at lower right corner of the post.
                  • Python Debugging With Pdb
                  • New to python and bt - check this out
                  G 1 Reply Last reply Reply Quote 0
                  • G
                    giakoumis @ab_trader last edited by

                    @ab_trader Thank you very much for your suggestions. I will look into them in more detail.

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