我使用R来处理财务数据,例如cds点差,部分数据的相关性,时间序列......
现在我通过电子邮件定期从bloomberg更新数据,所有数据仅在电子邮件中显示文本(不作为附件),我想编写一个函数来从中读取数据(数百封电子邮件,带有.msg)延伸),并保存到excel。
是否有任何人对如何读取数据有任何暗示?我更喜欢R,但是如果R不能做到,C ++也会起作用。
以下是电子邮件的格式(部分内容):>>>>>
$$ 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%]
答案 0 :(得分:2)
这是一个好的开始:
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%]