????????δ????????????????????????У???????????????????λ??????洢??csv????е?????????????????????????csv????????????????????????Щ?????????????????
????“???????”????????????????????????????????????csv????????????????????????????????????????????????????????Python??????????C++?????????????????????Python????????????????Python????ɡ????????C++???????£?

 

#include <vector>
#include <fstream>
#include <string>
int main(void)
{
//??????????
const int N = 1000;
ifstream fin;
vector<string> file_list??ff;
char  x[N];
string ss;
//?????????????б?
fin.open("fff.txt");
while (!fin.eof())
{
fin.getline(x?? N?? ' ');
ss.assign(x);
if (ss.size() > 0)
{
file_list.push_back(ss);
}
}
fin.close();
//cout<<file_list.size()<<endl;
ofstream fout?? fout0??fout1??fout2??fout3??fout4??fout5;
string obj_file("x.csv")??path1("F:/download/obj/")??path2("F:/download/outh/");
for (int i = 0; i < file_list.size(); ++i)
{
cout<<i+1<<" "<<file_list[i]<<endl;
int f_num = i / 500;
obj_file[0] = '0'+f_num;
fout.open(path2+obj_file??ofstream::out | ofstream::app);
fin.open(path1+file_list[i]);
bool first = true;
while (!fin.eof())
{
fin.getline(x?? N?? ' ');
ss.assign(x);
if (ss.size() > 0 && !first)
{
//1??1004?????
if (i+1<=1004)
{
ss="SH??"+ss;
}
else
{
ss="SS??"+ss;
}
ss.erase(7??1);
ss.erase(9??1);
ss.erase(12??1);
fout<<ss;
}
first = false;
}
fin.close();
fout.close();
}
}

?????????????£??????????????????????????б???????????У??????????У??б?????fff.txt??????????????б??????R?е?dir????????????????????????????????????£?????C++?????????????????鰱??6??????С???????????????????????“?г?”??Σ?SH??????У?SS??????С?????????????????yyyymmdd??C++????????????ss.erase()?????????
?????????????????????????洢?????Oracle?н????????“??”??????SQL Developer???????csv????е????????Oracle?????????????????????????????????
???????????漸????????????????????????????????????????????????????????????潲??????????
????1.????????????????????????????????????????????R????????????????????????????????????????????г????????????????????????????????????????????????
????2.???????°??R???г???????汾????????????????????????????????????????????????治????????????С?
????3.???????????????????????????????????Σ????????????????
?????????RODBC????Oracle??R?????????????????????????????????????????????600000????????000001????????????R???????£?

rm(list=ls())
library(RODBC)
channel <- odbcConnect(dsn="***"??uid="***"??pwd="***")
sql1 <- "SELECT dates?? close?? pre_close FROM idx
where
dates in
(
SELECT dates FROM idx where code='000001'
INTERSECT
SELECT dates FROM security where code='600000'
and
close > 0
and
dates >= to_date('20100101'?? 'yyyymmdd')
)
and
code = '000001'
order by dates asc"
sql2 <- "SELECT dates?? close?? pre_close FROM security
where
dates in
(
SELECT dates FROM idx where code='000001'
INTERSECT
SELECT dates FROM security where code='600000'
and
close > 0
and
dates >= to_date('20100101'?? 'yyyymmdd')
)
and
code = '600000'
order by dates asc"
i000001 <- sqlQuery(channel?? sql1)
head(i000001)
s600000 <- sqlQuery(channel?? sql2)
head(s600000)
t <- s600000$DATES
s <- log(s600000$CLOSE) - log(s600000$PRE_CLOSE)
i <- log(i000001$CLOSE) - log(i000001$PRE_CLOSE)
plot(i?? s?? pch = 20?? xlab="000001"?? ylab="600000")
capm.lm <- lm(s~i)
abline(coef = capm.lm$coe?? co="red"?? lwd=2)