Backtrader Community

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

    Suraj Thorat 0

    @Suraj Thorat 0

    0
    Reputation
    6
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Suraj Thorat 0 Unfollow Follow

    Latest posts made by Suraj Thorat 0

    • Cheat on close takes the next bar's execution date and the current bar's execution price

      Is there a way to make cheat on close execute the orders on the same bar as well as give the date of the same bar. Right now the notify_trade takes current bar's execution price but next bar's date as an execution date.

      2005-03-07, ------------BUY order placed------------
      2005-03-07, EOD Close: 112.98   mOnthlY close 102.74  Current ATR 11.81   Stop Loss at 101.17
      2005-03-08, BUY EXECUTED: test, Price: 112.98,status: 4.00, Cost: 112.98, Comm 0.00
      2005-03-08 test Opened: PnL Gross 0.0, Net 0.0
      112.98
      -sell stop trail--sell stop trail-
      2007-10-17, SELL EXECUTED: test, Price: 565.42, Cost: 112.98, Comm 0.00
      2007-10-17 test Closed: PnL Gross 452.44, Net 452.44
      112.98
      2007-10-17, ------------BUY order placed------------
      2007-10-17, EOD Close: 671.89   mOnthlY close 317.54  Current ATR 172.47   Stop Loss at 499.42
      2007-10-18, BUY EXECUTED: test, Price: 671.89,status: 4.00, Cost: 671.89, Comm 0.00
      2007-10-18 test Opened: PnL Gross 0.0, Net 0.0
      671.89
      -sell stop trail--sell stop trail-
      2008-10-23, SELL EXECUTED: test, Price: 305.79, Cost: 671.89, Comm 0.00
      2008-10-23 test Closed: PnL Gross -366.1, Net -366.1
      671.89
      2014-05-19, ------------BUY order placed------------
      2014-05-19, EOD Close: 560.03   mOnthlY close 447.60  Current ATR 74.87   Stop Loss at 485.16
      2014-05-20, BUY EXECUTED: test, Price: 560.03,status: 4.00, Cost: 560.03, Comm 0.00
      2014-05-20 test Opened: PnL Gross 0.0, Net 0.0
      560.03
      -sell stop trail--sell stop trail-
      2020-03-09, SELL EXECUTED: test, Price: 1124.79, Cost: 560.03, Comm 0.00
      2020-03-09 test Closed: PnL Gross 564.76, Net 564.76
      560.03
      2020-05-08, ------------BUY order placed------------
      2020-05-08, EOD Close: 1561.80   mOnthlY close 1514.05  Current ATR 328.55   Stop Loss at 1233.25
      2020-05-11, BUY EXECUTED: test, Price: 1561.80,status: 4.00, Cost: 1561.80, Comm 0.00
      2020-05-11 test Opened: PnL Gross 0.0, Net 0.0
      

      Any suggestion to change in the source code or any extra module I don't know of would be really appreciated.

      posted in General Code/Help
      Suraj Thorat 0
      Suraj Thorat 0
    • RE: Executing the placed orders on the same bar close price, cheat on close executes order on next bar

      @ab_trader said in Executing the placed orders on the same bar close price, cheat on close executes order on next bar:

      price

      Also one more thing I would like to add is
      7th September the order is created in next()
      8th September the order is shown as executed from notify_trade.

      posted in General Discussion
      Suraj Thorat 0
      Suraj Thorat 0
    • RE: Executing the placed orders on the same bar close price, cheat on close executes order on next bar

      @ab_trader thank you for the quick reply. I have the logs in office actually and I am on a timeline where in I have to solve the problem quickly, I will post them once I reach office tomorrow, about 9 hours from now.

      I added coc True in cerebro.broker, I also did the same in adding coc True to order to itself.
      I failed at it, don't know what mistake I am doing.

      If the signal comes on 7th september for example, the execution is shown on 8th September (from notify trade)

      At last I thought maybe I can just get two types of data adjusting ones date (shift function of pandas and deleting the top most row) above the others using dataframe so that I can get signals from one data and place an order on another and avoid cheat on close altogether, but for some reason/mistake backtrader is adjusting the data to the same date while importing the CSV using backtradercustomcsv function (interestingly the last date is repeated twice when this is done).

      I understand it is really hard to give me a solution without the logs and codes and maybe I am making some mistake I gotta figure this out somehow.
      Thank you.

      posted in General Discussion
      Suraj Thorat 0
      Suraj Thorat 0
    • Executing the placed orders on the same bar close price, cheat on close executes order on next bar

      My orders get executed on next bar if I use cheat on close. The logic is clear why I want to execute on same bar. I just need a way to do execute the placed orders on the same bars close price. The buy gets created on the current bar but still it gets executed on next bar. I used cheat on close.
      Please tell me a way to do so or change the code in the backtrader library to help me do it.

      posted in General Discussion
      Suraj Thorat 0
      Suraj Thorat 0
    • RE: Same bar order execution

      @valentin can you tell me how you did it? My orders get executed on next bar if I use cheat on close. The logic is clear why I want to execute on same bar. I just need a way to do execute the placed orders on the same bars close price.

      posted in General Discussion
      Suraj Thorat 0
      Suraj Thorat 0