<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid200412291140.iBTBcnek014626@hypatia.math.ethz.ch"
 type="cite">
  <pre wrap="">

Message: 2
Date: Tue, 28 Dec 2004 14:34:03 -0500
From: David Kane <a class="moz-txt-link-rfc2396E" href="mailto:dave@kanecap.com">&lt;dave@kanecap.com&gt;</a>
Subject: Re: [R-sig-finance] bid-ask bouse
To: Joe Cerniglia <a class="moz-txt-link-rfc2396E" href="mailto:cj5815@yahoo.com">&lt;cj5815@yahoo.com&gt;</a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:r-sig-finance@stat.math.ethz.ch">r-sig-finance@stat.math.ethz.ch</a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:16849.46379.161253.806415@gargle.gargle.HOWL">&lt;16849.46379.161253.806415@gargle.gargle.HOWL&gt;</a>
Content-Type: text/plain; charset=us-ascii

I am not sure if this is the appropriate list for your question, but,
since I don't know a better list, here are my thoughts.

1) In order to provide a decent answer, we need to know *much* more
about the strategy. Start by telling us the typical holding period,
the universe of stocks included and the dates for the historical data.

2) Replace "return" in your code with some measure of return adjusted
for bid/ask spread. If you are using daily returns and a daily holding
period (which probably wouldn't be such a great idea, but ignore that
for now), you could just subtract the spread from the return for
puchases while adding it to returns for shorts. Again, that has
nothing to do with R, but seems reasonable enough.

3) More sophisticated answers would involve measuring returns from
offer to bid for buys and bid to offer for shorts. Again, it would be
helpful to know precisely what sort of data you are working with.

Best of luck. Although your question has nothing to do with R, you are
wise to be using R for applied finance. There is no better tool.

Dave Kane

  </pre>
</blockquote>
Some more comments based on my experience:<br>
<ul>
  <li>Accurate estimation of fill prices from observed prices is maybe
the most difficult task when simulating trading systems. <br>
  </li>
  <li>Slippage (&gt;= 0) is a function of market momentum, number of
shares, time of the day, market depth, and more specific properties
such as liquidity of the considered instrument.</li>
  <li>Some of the above measures may not be observed, in particular no
history is available, e.g., for market depth.<br>
  </li>
  <li>Fill price = signal price +/- slippage (+ for buy orders, - for
sell orders)<br>
  </li>
  <li>Signal price = bid/ask price (bid for sell orders, ask for buy
orders) at the time an order is generated by the system or trader</li>
  <li>To get an accurate estimate of the slippage function, a history
of real trades is necessary.</li>
  <li>In cases no bid/ask history is available, the slippage function
may be based on last traded prices.</li>
  <li>Published bid/ask prices may only be advertising quotes and
nobody might be willing to trade on those prices.<br>
  </li>
  <li><big><font size="-1"><big>Some markets close trading of shares
when limit down is reached</big></font>.<br>
    </big></li>
</ul>
For some instruments it is possible to come up with a relatively simple
and accurate slippage function, but this really depends...<br>
<br>
Best<br>
Adrian<br>
<blockquote cite="mid200412291140.iBTBcnek014626@hypatia.math.ethz.ch"
 type="cite">
  <pre wrap="">
Joe Cerniglia writes:
 &gt; 
 &gt; I am trying to test a strategy on small cap stocks in
 &gt; R.  I am concerned that the bid-ask bounce is
 &gt; contributed to the excess return generated by the
 &gt; strategy.  How can I adjust the calculation of the
 &gt; returns on my portfolio to account for the bid-ask
 &gt; spread?
 &gt; 
 &gt; Joe
 &gt; 
 &gt; _______________________________________________
 &gt; <a class="moz-txt-link-abbreviated" href="mailto:R-sig-finance@stat.math.ethz.ch">R-sig-finance@stat.math.ethz.ch</a> mailing list
 &gt; <a class="moz-txt-link-freetext" href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a>



  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">
</pre>
</body>
</html>