Domanda

I use R a lot to process the financial data, e.g. cds spreads, correlation of tranche data, time series... ...

Now I have periodic data update from bloomberg via email, and all the data are text only in the email (NOT as an attachment file), I wanna write a function to read data from them (hundreds of emails, with .msg extention), and save into excel.

Does any one have any hint on how to read the data? I prefer R, but C++ also works if R cannot do it.

Here is the format of the email (part of):>>>>>

$$ JPM CDX OPTIONS: HY19 AUG Expiry  UPDATE - REF 102⅜[~354bp]
               BOND PUT          BOND CALL
 K [~Sprd]|SEP13>PAY   Dlt |SEP13>RCV   Dlt |MidVol [SprdVol]
108 [313] |  355 365   92% |    5 13     8% |  5.4% [ 40%]
107 [335] | 243½253½ 85% |   23 36    17% |  7.8% [ 33%]
106 [369] |  203 213   77% |  52½62½  28% |  7.1% [ 34%]
105 [387] |  147 167   59% |  99½116½ 41% |  9.3% [ 46%]
È stato utile?

Soluzione

Here is a good start:

email  <- "$$ JPM CDX OPTIONS: HY19 AUG Expiry  UPDATE - REF 102⅜[~354bp]
               BOND PUT          BOND CALL
 K [~Sprd]|SEP13>PAY   Dlt |SEP13>RCV   Dlt |MidVol [SprdVol]
108 [313] |  355 365   92% |    5 13     8% |  5.4% [ 40%]
107 [335] | 243½253½ 85% |   23 36    17% |  7.8% [ 33%]
106 [369] |  203 213   77% |  52½62½  28% |  7.1% [ 34%]
105 [387] |  147 167   59% |  99½116½ 41% |  9.3% [ 46%]"
email
ll <- readLines(textConnection(email))
mm <- read.table(text=ll[-c(1,2)],sep='|',header=TRUE)

  K...Sprd.  SEP13.PAY...Dlt  SEP13.RCV...Dlt MidVol..SprdVol.
1 108 [313]    355 365   92%      5 13     8%       5.4% [ 40%]
2 107 [335]     243½253½ 85%     23 36    17%       7.8% [ 33%]
3 106 [369]    203 213   77%      52½62½  28%       7.1% [ 34%]
4 105 [387]    147 167   59%      99½116½ 41%       9.3% [ 46%]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top