Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: How to calculate the bid-ask spread in this case?


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: How to calculate the bid-ask spread in this case?
Date   Thu, 30 Jul 2009 18:31:03 -0400

<>


This code is very specific to your example data, so if your problem is more
general, let the list know...


******
clear*

input  str5 BondID	Date	 Time Bid_Price Ask_Price
AAA     20090729 090540       100.00 .
AAA     20090729 092307       100.05 .
AAA     20090729 093051		    .    101.10 	
AAA     20090729 093523		     .   101.20 
end

compress
//make sure dataset sorted
sort Date Time
list, noobs  

collapse (lastnm) Bid_Price/* 
 */  (firstnm) Ask_Price, by(BondID)
gen spread= Ask_Price- Bid_Price
l
******


HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von stata help
Gesendet: Donnerstag, 30. Juli 2009 16:20
An: statalist@hsphsun2.harvard.edu
Betreff: st: How to calculate the bid-ask spread in this case?

Dear Statalisters,

I have data of foreign bonds with their trading date and time, and the
bid and ask prices.

The data structure is as follows:


Bond ID	Date	 Time(HHMMSS) Bid_Price Ask_Price
AAA     20090729 090540       100.00
AAA     20090729 092307       100.05
AAA     20090729 093051		        101.10 	
AAA     20090729 093523		        101.20 	
.
.
.

I want to calculate the "closest-in-time" bid-ask spread of the
bonds(in this case, 101.10-100.05 = 1.05). Since it is my first time
to deal with this type of data I don't know how to do that. Could any
of you let me know what command I should use or how to program to get
the bid-ask spread?

Thank you very much.

JHS
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index