Just trying to understand the real application on statistical arbitrage. In theory we assume the cost is zero and also the prices are the same ie: there is only one price. However in practice we have transactions costs and there are 2 prices the bid and ask price.
So how do we account for the transaction costs and what do we do about the bid and ask price? which price do we use? do we just take the mid price of the sum of the bid and ask?
Anyone have example code snippets to demonstrate how this concept is applied in a real market example?
What I'm doing regarding mean reversion:
- Load Bid and Ask quotes for all of my spread constituents
- Then I calculate spread, hedge ratio, and zscore using (Bid+Ask)/2 (I also tried using just Bid and it works similarly)
- Then I apply hedge ratios on in-sample and out-of-sample data and generate Enter/Exits signals
- Then perform a full backtest using real quotes (Bid and Ask) for every position and add commission to the trade costs.
- When required I also replicate slippage, but it's questionable hot to do it correctly, I've been usually using some arbitrary "constant" -> here I see the only problem of my approach, but honestly I do not now how to handle it better
- Calculate and evaluate portfolio statistics
Regards
T.
I agree slippage can only be estimated and we cannot be very accurate with it.
Since you already have the bid & ask data, you can use the bid & ask price and volume to get the actual fill price. As a method of caution only hit less than 1% of the bid or ask volume as per the side you are at a time. This will ensure that the impact of your order on the order book is minimal.
Regards
Ishan
Hello Viseth,
You can account for transaction charges on Blueshift. An example can be seen here.
Hope this helps!