Difference in performance on a specific day

I have been trying a strategy for a specific period of time (~2 years). To further dig into some of the largest loss-making days, I decided to dig deeper into the specific day. The data from the portfolio's sheet for the specific day differs in the two simulations. (One is the original 2 years one, other is the simulation of the specific day).

Can someone help me explain, why the simulation might behave differently? There seems to be something about EOD selling etc.

Tagged:

Comments

  • Attaching the PDF, so it's easily visible in the comments itself.

  • ptunneyptunney Posts: 246
    edited November 2018

    Very difficult to tell from one small view.
    I would assume you are holding more that one day.. So the multiday will hold off on the PnL and the one day will report PnL based on the end of the day price for any currently open positions, so one has a realized entry and the other does not.
    If I were you I would pull away from the symbol you are having an issue with and write a simple backtest with one symbol held for a week, run it, look at the output, then run it for one day and look at the output. Trying to discern how something works whilst looking at a complicated trade is like trying to read in a dark room with sunglasses on! :smiley:
    The print statement is your friend here. Just output the data that you are interested in into the console.
    (Note, we do have a small bug that on a single multiday backtest, sometimes the console output ends up in the console for the next day, so be aware of that.)

  • Alrighty, let me check over the specific symbol with that weekly experiment.

  • au366129au366129 Posts: 22
    edited November 2018

    Here is some data post some printing and the trade results. These are the two sets of data, I'm getting. I have two trades being made, the second should not be happening as one is already in execution(I have a condition to meet this). I also print "Bingo" whenever a trade is ordered. This print on console only happens once. This second trade is what bugging me, also the reason for the above discrepancy. This second trade doesn't' happen when I get a different result.

    The second version of simulation with all the same code, dates, etc gives the below results which I believe should be the actual results.

  • The second version of simulation with all the same code, dates, etc gives the below results which I believe should be the actual results.

  • ptunneyptunney Posts: 246

    The only way the system can give you a trade that you did not request is if a symbol splits or has some other fundamental action that results in a change in the number of shares you have.

    At a glance it looks like they fill in a different order to how they were placed which suggests limit orders
    I would suspect you are checking position size before sending an order effectively sending another order whilst one is outstanding?

    You can...
    Capture the order data ordercap = order.xxxxxxxx and not send another one

    Or check for pending

    Or make your own state machine…
    in on_start put self.status = 0
    check it is zero before placing an order
    set it to 1 when you place an order
    set it to 2 in on_fill (if you want to)
    check for a 1 (or a 2 if you have that on_fill) before exiting.
    on exiting set it back to zero to trade again or set it to something like 999 to lock it up for the day.

Sign In or Register to comment.