Applying slippage to historical equity curves.

Discussion in 'Automated Trading' started by walterjennings, Feb 3, 2011.

  1. Hey guys, I'm trying to apply seen slippage to historical equity curves using live trade slippage values and I'm not sure if I'm doing it correctly. I was hoping someone with experience doing this could help me out.

    My simulated automated system usually deviates from my live system because it is impossible to perfectly simulate order fills on a unknown book in historical data. The deviation I've accepted is that there are some trades my simulated system gets and my live system misses, this happens due to Fill On Touch simulation, and the difference seen in simulated equity vs live equity is just the value of being first in the order queue vs wherever I am.

    So I've been running my system live on the market, at the end of each trading day I record Simu_Profit, Simu_Volume, Live_Profit, Live_Volume. Generally speaking Simul_Volume is always more than Live_Volume, and Simu_Profit is almost always more than Live_Profit (Missing trades rarely adds value).

    In trying to figure out what my average slippage per share traded to expect. I figure out the average profit per share on the Simu, which is Simu_Profit/Simu_Volume, and I figure out the profit per share on the Live, Live_Profit/Live_Volume.

    I then figure out what the difference between Simu_PPS (profit per share traded) and Live_PPS, equaling (Simu_PPS-Live_PPS). So this should give the expected deviation in profit per share traded. So if my Simu trades 10000 shares daily, and makes $10000, and live trades 8000 daily, making $8000 profit, you would say there is 'no per share traded slippage'. Which means I could run my Live system at 1.25*Simu_TradeSize and obtain the Simu's equity curve.

    So to find my universal average for projecting on historical data, I take Simu_TotalProfit/Simu_TotalVolume, and find the difference with Live_TotalProfit/Live_TotalVolume.

    It seems with 3 months of live testing, I get an average slippage per share traded of about 0.005, trading about 92% of the simu volume. So the way I project this onto historical simulated equity curves to try to get the 'best guess' of the type of performance I will see going forward, is for each day in the historical equity curve, I scale the daily volume by 92%, then multiply the volume traded by the profit per share traded minus 0.005.

    So on a day that made 0.02 cents per share, trading 100 shares total, my 'expected live' performance would be 92*0.015.

    Is this a correct way to get an 'expected' equity curve taking into account seen slippage? I worry that by factoring in the amount of shares traded, I might be fooling myself into thinking this is profitable while it isn't in the long term.

    Thanks for any help.
     
  2. To establish whether I have understood what you are trying to do...

    You want to adjust historical simulated equity curves for factors that you believe will make them look more like the real curves you might have obtained if you had really traded them?

    If the foregoing is not correct, then ignore what I put next, as I have misunderstood you!
    = = = = = = =

    Different traders will define “slippage” in different ways, and I don’t want to get into an argument about whether what you have described is “slippage” or not ... I don’t think this fact is important in answering the question you pose at the end of your post:

    You seem to be doing (using your notation) the following:
    Real_Equity_Curve = Simu_Volume X my_volume_discount_factor X { my_Estimated_Live_PPS - my_slippage }

    IMO, the way you calculate my_Estimated_Live_PPS already captures some of the effects you are trying to calculate with your slippage term, as your measurement compares pre- and post- "slippage" measurements (i.e. Live_PPS and Simu_PPS) . Therefore you are double-counting the "slippage" effects you are trying to capture.

    IMHO, the following would be better, and adequate:

    Real_Equity_Curve = Simu_Volume X my_volume_discount_factor X my_Estimated_Live_PPS
     
  3. Thanks for the reply, sorry if I wasnt clear in my description. I should only be counting slippage once.

    Best_Guess_Curve(day) = Simu_Volume(day) * Volume_discount_factor * (Simu_PPS(day) - Expected_Simu_Vs_Live_PPS_Diff)

    Where Expected_Simu_Vs_Live_PPS_Diff = Average_Simu_PPS - Average_Live_PPS.
    Where Average_Simu_PPS = Simu_Total_Profit/Simu_Total_Volume
    Note that Simu_Total_Volume/Profit is the sum of all volume or profit over the live testing period, Average_Live_PPS is calculated the same way over the same span of time. Which should give me a reasonable average deviation from Simu_PPS
     
  4. Thanks. Yes, that’s clearer (to me at least!), and it looks fine.
     
  5. drp7804

    drp7804

    You may have already thought of this and maybe this is down in the "splitting hairs" level of detail, and also not sure what granularity of historical data you're dealing with... but...

    One idea would be to start tracking (in your live trading) the number of shares hit at your price before your trade fills. This would effectively tell you how far back in the queue you tend to be. Over however many observations (hours, days, weeks, etc), you begin to see a distribution of this number, which you could then use to simulate fill probability in your backtesting.

    For example, just to throw out numbers, say in your live trading for a given day, you observe the following:

    (left number range is # shares executed at your price between that price becomming NBBO and you getting filled, middle number is the number of times you get filled in that share range over the course of the day, right number is % of total observations)

    000-100 : 10 : 12.8%
    100-200 : 13 : 16.7%
    200-300 : 20 : 25.6%
    300-400 : 18 : 23.1%
    400-500 : 17 : 21.8%

    You could then modify your backtest to generate a random number between 0 and 100. If you then lay the above distribution out contguously from 0 to 100, you could use the random number you got to tell you where you are in the queue for the next prospective trade. Does that make sense?

    This assumes that the queues for a given price point are, in fact, FIFO queues... as in the time you got in line is the only deciding factor, not order size, etc.

    I have no idea whether this would improve the accuracy of your backtest. Or how accurately the distribution shape for one time period predicts the shape in some future time period. But in the best case scenario, this might remove the need to do the volume scaling you described. Anyway, just some thoughts...
     
  6. drp7804

    drp7804

    Not sure if this was clear, but I meant to say that you should regenerate that random number with every trade in your backtest. Over many trades, that process should begin to approximate the distribution you observed in live trading. Hope that makes sense.