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/

    How to do intraday trading in backtrader ?

    General Discussion
    4
    4
    3320
    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.
    • R
      RY 93 last edited by RY 93

      Suppose I just want to do intraday trading then how can I do it using timers or filters.I can do it any way by handling the datetime object and check if current time falls within the intraday timing then only i will execute the buy or sell signals but I want some smart way or inbuilt functionality to do it.
      And how to forcefully execute or close all the open orders if these signals(buy,sell) crossed the intraday time limit ?

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @RY 93 last edited by

        @ry-93 said in How to do intraday trading in backtrader ?:

        Suppose I just want to do intraday trading then how can I do it using timers or filters

        By using intraday data (i.e.: sub-day timeframe)

        @ry-93 said in How to do intraday trading in backtrader ?:

        I can do it any way by handling the datetime object and check if current time falls within the intraday timing then only i will execute the buy or sell signals but I want some smart way or inbuilt functionality to do it.

        Each data feed carries a timestamp which can be converted to a datetime.datetime and/or datetime.time instance to let you know what the current time is in Python format. For example

        cur_dt = self.data.datetime.datetime(0)  # get current datetime
        cur_tm = self.data.datetime.time(0)  # get current time
        

        You may of course get the time component from the datetime object if you prefer.

        @ry-93 said in How to do intraday trading in backtrader ?:

        And how to forcefully execute or close all the open orders if these signals(buy,sell) crossed the intraday time limit ?

        Keep a reference to the orders you have issued, check the time and when your deadline is met, issue a cancel on the orders which have not been executed yet (i.e.: not remove from your list, because they have been notified as Completed)

        1 Reply Last reply Reply Quote 1
        • Onder Oz
          Onder Oz last edited by

          Hello,
          does backtrader have access to preMarket data too in smaller timeframes?

          1 Reply Last reply Reply Quote 0
          • vladisld
            vladisld last edited by

            @Onder-Oz said in How to do intraday trading in backtrader ?:

            does backtrader have access to preMarket data too in smaller timeframes

            Backtrader accepts any data, pre/post market included. Just be sure your data provider supplies such data.

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