小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

分析家各種數(shù)據(jù)格式

 禁忌石 2006-08-23

FinData.FxjData.CS:

using System;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Runtime.InteropServices;


namespace FinData
{
[ProgId("FinData.FxjData"),ComVisible(true)]
public class FxjData
{
public enum DataTypes { dm,hq,hqmb,hq0,hq5,cq,cw0,fp,gb,gd,cw,jjjz,jjzh,bk,pj,hqfq};
private string[,] tableNames = new string[,] {
#region 表名
{"dm","代碼",""},
{"hq","行情",""},
{"hqmb","分筆成交",""},
{"hq0","動(dòng)態(tài)行情",""},
{"hq5","五分鐘行情",""},
{"cq","除權(quán)數(shù)據(jù)",""},
{"cw0","最新財(cái)務(wù)數(shù)據(jù)",""},
{"fp","分紅送配",""},
{"gb","股本結(jié)構(gòu)",""},
{"gd","十大股東",""},
{"cw","財(cái)務(wù)數(shù)據(jù)",""},
{"jjjz","基金凈值",""},
{"jjzh","基金投資組合",""},
{"bk","板塊",""},
{"pj","評(píng)級(jí)",""},
{"hqfq","復(fù)權(quán)行情",""}

};//行順序與Datatype一致,列分別為表名、表中文名、對(duì)應(yīng)文件名(GetTables函數(shù)中賦值)
#endregion
public FxjData()
{
try
{
//從注冊(cè)表中讀取分析家數(shù)據(jù)目錄,如c:\fxj\data
RegistryKey keyFxj;
RegistryKey keySoftware = Registry.LocalMachine.OpenSubKey("Software");
keyFxj = keySoftware.OpenSubKey("FXJ");
if (keyFxj == null)
{
keyFxj = keySoftware.OpenSubKey("Huitianqi");
if (keyFxj == null)
{
fxjPath = "";
fxjDataPath = "";
msg = "沒有找到分析家安裝信息!";
return;
}
}
RegistryKey keySuperstk = keyFxj.OpenSubKey("SUPERSTK");
if (keySuperstk != null)
{
fxjPath = (string)keySuperstk.GetValue("InstPath");
if (fxjPath != "")
{
fxjPath = fxjPath.ToUpper();
if (fxjPath != "" && fxjPath.EndsWith(@"\") == false)
fxjPath = fxjPath + @"\";
fxjDataPath = fxjPath+ @"DATA\";
fxjDataPath = fxjDataPath.ToUpper();
RegistryKey keyMarket = keySuperstk.OpenSubKey("Market");
if (keyMarket != null)
{
string[] marketSubKeyNames = keyMarket.GetSubKeyNames();
if (marketSubKeyNames.Length > 0)
{
RegistryKey[] marketSubKey = new RegistryKey[marketSubKeyNames.Length];
fxjMarket = new string[marketSubKeyNames.Length, 3];
for (int i = 0; i < marketSubKeyNames.Length; i++)
{
marketSubKey[i] = keyMarket.OpenSubKey(marketSubKeyNames[i]);
if (marketSubKey[i] != null)
{
fxjMarket[i, 0] = marketSubKeyNames[i];
fxjMarket[i, 1] = (string)marketSubKey[i].GetValue("name");
fxjMarket[i, 2] = (string)marketSubKey[i].GetValue("shortname");
}
}
for (int i = 0; i < marketSubKeyNames.Length; i++)
{
int lastI=marketSubKeyNames.Length-1;
if (fxjMarket[i, 0].ToUpper() == "SH")
{
string[] temp = new string[3];
temp[0] = fxjMarket[0, 0];
temp[1] = fxjMarket[0, 1];
temp[2] = fxjMarket[0, 2];
fxjMarket[0, 0] = fxjMarket[i, 0];
fxjMarket[0, 1] = fxjMarket[i, 1];
fxjMarket[0, 2] = fxjMarket[i, 2];
fxjMarket[i, 0] = temp[0];
fxjMarket[i, 1] = temp[1];
fxjMarket[i, 2] = temp[2];
}
if (fxjMarket[i, 0].ToUpper() == "SZ")
{
string[] temp = new string[3];
temp[0] = fxjMarket[1, 0];
temp[1] = fxjMarket[1, 1];
temp[2] = fxjMarket[1, 2];
fxjMarket[1, 0] = fxjMarket[i, 0];
fxjMarket[1, 1] = fxjMarket[i, 1];
fxjMarket[1, 2] = fxjMarket[i, 2];
fxjMarket[i, 0] = temp[0];
fxjMarket[i, 1] = temp[1];
fxjMarket[i, 2] = temp[2];
}
if (fxjMarket[i, 0].ToUpper() == "$$")
{
string[] temp = new string[3];
temp[0] = fxjMarket[lastI, 0];
temp[1] = fxjMarket[lastI, 1];
temp[2] = fxjMarket[lastI, 2];
fxjMarket[lastI, 0] = fxjMarket[i, 0];
fxjMarket[lastI, 1] = fxjMarket[i, 1];
fxjMarket[lastI, 2] = fxjMarket[i, 2];
fxjMarket[i, 0] = temp[0];
fxjMarket[i, 1] = temp[1];
fxjMarket[i, 2] = temp[2];
}
}
}
}
return;
}
}
}
catch (Exception ex)
{
msg = ex.Message;
}
}
struct fileStruct
{
public string fileName;//文件名
public int startAddress,blockSize,recordSize;//起始地址,每塊長(zhǎng)度,記錄長(zhǎng)度
public bool codeIsLong, isIndexDataStruct; //codeIsLong索引中的代碼包含有市場(chǎng)代碼SH、SZ等;isIndexDataStruct象Day.Dat那樣的結(jié)構(gòu)即由索引+數(shù)據(jù)組成;
public string[,] fields;//字段
public fileStruct(DataTypes fileType)
{
fileName = "";
startAddress = 0;
blockSize = 0;
recordSize = 0;
codeIsLong = false;
isIndexDataStruct = true;
string fieldString = ""; //字段名,字段標(biāo)簽,類型,長(zhǎng)度字段,存儲(chǔ)順序,偏移量
switch (fileType)
{

#region 代碼表stkinfo51.dat
case DataTypes.dm:
fileName = "STKINFO51.DAT";
startAddress = 0x845898;
blockSize = 0;
recordSize = 248;
codeIsLong = false;
isIndexDataStruct = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"jc,簡(jiǎn)稱,string,32,1,10,;" +
"py,拼音,string,10,2,42,";
break;
#endregion
#region 分紅送配stkinfo51.dat
case DataTypes.cq:
fileName = "STKINFO51.DAT";
startAddress = 0x14;
blockSize = 2116;
recordSize = 20;
codeIsLong = false;
isIndexDataStruct = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,日期,date,4,0,0,;" +
"sgbl,送股比例,single,4,1,4,;" +
"pgbl,配股比例,single,4,2,8,;" +
"pgjg,配股價(jià)格,single,4,3,12,;" +
"fh,分紅,single,4,4,16,";
break;
#endregion
#region 財(cái)務(wù)數(shù)據(jù)(簡(jiǎn)單)stkinfo51.dat
case DataTypes.cw0:
fileName = "STKINFO51.DAT";
startAddress = 0x794;
blockSize = 2116;
recordSize = 196;
codeIsLong = false;
isIndexDataStruct = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,更新日期,date,4,38,192,;" +
"zgb,總股本,single,4,0,0,;" +
"gjg,國(guó)家股,single,4,1,4,;"+
"fqrg,發(fā)起人法人股,single,4,2,8,;"+
"frg,法人股,single,4,3,12,;"+
"b,B股,single,4,4,16,;"+
"h,H股,single,4,5,20,;"+
"a,流通A股,single,4,6,24,;"+
"zgg,職工股,single,4,7,28,;"+
"a2zpg,A2轉(zhuǎn)配股,single,4,8,32,;"+
"bszzc,總資產(chǎn),single,4,9,36,;"+
"bsldzc,流動(dòng)資產(chǎn),single,4,10,40,;"+
"bsgdzc,固定資產(chǎn),single,4,11,44,;"+
"bswxzc,無形資產(chǎn),single,4,12,48,;"+
"bscqtz,長(zhǎng)期投資,single,4,13,52,;"+
"bsldfz,流動(dòng)負(fù)債,single,4,14,56,;"+
"bscqfz,長(zhǎng)期負(fù)債,single,4,15,60,;"+
"bszbgj,資本公積金,single,4,16,64,;"+
"mggjj,每股公積金,single,4,17,68,;"+
"bsgdqy,股東權(quán)益,single,4,18,72,;"+
"iszysl,主營(yíng)收入,single,4,19,76,;"+
"iszylr,主營(yíng)利潤(rùn),single,4,20,80,;"+
"isqtlr,其他利潤(rùn),single,4,21,84,;"+
"isyylr,營(yíng)業(yè)利潤(rùn),single,4,22,88,;"+
"istzsy,投資收益,single,4,23,92,;"+
"isbtsr,補(bǔ)貼收入,single,4,24,96,;"+
"isyywsz,營(yíng)業(yè)外收支,single,4,25,100,;"+
"issytz,上年損益調(diào)整,single,4,26,104,;"+
"islrze,利潤(rùn)總額,single,4,27,108,;"+
"isshlr,稅后利潤(rùn),single,4,28,112,;"+
"isjlr,凈利潤(rùn),single,4,29,116,;"+
"iswfplr,未分配利潤(rùn),single,4,30,120,;"+
"mgwfplr,每股未分配利潤(rùn),single,4,31,124,;"+
"mgsy,每股收益,single,4,32,128,;"+
"mgjzc,每股凈資產(chǎn),single,4,33,132,;"+
"tzmgjzc,調(diào)整每股凈資產(chǎn),single,4,34,136,;"+
"gdqybl,股東權(quán)益比率,single,4,35,140,;"+
"jzcsyl,凈資產(chǎn)收益率,single,4,36,144,";
//"unknown,(未知),string,44,37,148,;"

break;
#endregion
#region 最新行情stkinfo51.dat
case DataTypes.hq0:
fileName = "STKINFO51.DAT";
startAddress = 0x845898;
blockSize = 0;
recordSize = 248;
codeIsLong = false;
isIndexDataStruct = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"jc,簡(jiǎn)稱,string,32,1,10,;" +
"py,拼音,string,10,2,42,;" +
"rq,更新時(shí)間,datetime,4,5,60,;" +
"wrjl,五日均量,single,4,6,64,;" +
"zs,昨收,single,4,7,68,;" +
"jk,今開,single,4,8,72,;" +
"zg,最高,single,4,9,76,;" +
"zd,最低,single,4,10,80,;" +
"zx,最新,single,4,11,84,;" +
"zss,總手?jǐn)?shù),single,4,12,88,;" +
"je,金額,single,4,13,92,;" +
"xss,現(xiàn)手?jǐn)?shù),single,4,14,96,;" +
"sbcj,上筆成交價(jià),single,4,29,156,;" +
"dbcj,當(dāng)筆成交價(jià),single,4,30,160,;" +
"np,內(nèi)盤,single,4,27,148,;" +
"wp,外盤,single,4,28,152,;" +
"mr1jg,買一價(jià),single,4,15,100,;" +
"mr1sl,買一量,single,4,18,112,;" +
"mr2jg,買二價(jià),single,4,16,104,;" +
"mr2sl,買二量,single,4,19,116,;" +
"mr3jg,買三價(jià),single,4,17,108,;" +
"mr3sl,買三量,single,4,20,120,;" +
"mr4jg,買四價(jià),single,4,32,168,;" +
"mr4sl,買四量,single,4,34,176,;" +
"mr5jg,買五價(jià),single,4,33,172,;" +
"mr5sl,買五量,single,4,35,180,;" +
"mc1jg,賣一價(jià),single,4,21,124,;" +
"mc1sl,賣一量,single,4,24,136,;" +
"mc2jg,賣二價(jià),single,4,22,128,;" +
"mc2sl,賣二量,single,4,25,140,;" +
"mc3jg,賣三價(jià),single,4,23,132,;" +
"mc3sl,賣三量,single,4,26,144,;" +
"mc4jg,賣四價(jià),single,4,36,184,;" +
"mc4sl,賣四量,single,4,38,192,;" +
"mc5jg,賣五價(jià),single,4,37,188,;" +
"mc5sl,賣五量,single,4,39,196,";
//"jd,精度,int,4,3,52,;" +
//"scbz,刪除標(biāo)志,int,4,4,56,";
//"unknown,(未知),int,4,31,164,;" +
//",(未知),,48,40,200,;"
break;
#endregion
#region 分筆成交數(shù)據(jù)文件report.dat(結(jié)構(gòu)同day.dat,但其中一些數(shù)據(jù)不是直接保存)
case DataTypes.hqmb:
fileName = "REPORT.DAT";
startAddress = 0x41000;
blockSize = 4068;
recordSize = 36;
codeIsLong = false;
isIndexDataStruct = false;//不完全等同于day.dat結(jié)構(gòu),因此單獨(dú)處理
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,日期,datetime,4,0,0,;" +
"zjcj,最近成交價(jià),single,4,1,4,;" +
"zss,總手?jǐn)?shù),single,4,2,8,calc;" +
"je,金額,single,4,3,12,;" +
"xss,現(xiàn)手?jǐn)?shù),single,4,2,8,;" +
"mm,內(nèi)外盤,string,2,16,35,;" +
"mr1jg,買一價(jià),single,1,10,28,;" +
"mr1sl,買一量,single,2,4,16,;" +
"mr2jg,買二價(jià),single,1,11,29,;" +
"mr2sl,買二量,single,2,5,18,;" +
"mr3jg,買三價(jià),single,1,12,30,;" +
"mr3sl,買三量,single,2,6,20,;" +
"mc1jg,賣一價(jià),single,1,13,31,;" +
"mc1sl,賣一量,single,2,7,22,;" +
"mc2jg,賣二價(jià),single,1,14,32,;" +
"mc2sl,賣二量,single,2,8,24,;" +
"mc3jg,賣三價(jià),single,1,15,33,;" +
"mc3sl,賣三量,single,2,9,26,";
//以類數(shù)據(jù)類型不是存儲(chǔ)類型,程序中不直接用實(shí)際數(shù)據(jù)類型:買/賣X量為short,買/賣X價(jià)為byte
//現(xiàn)手?jǐn)?shù)通過當(dāng)總手?jǐn)?shù)計(jì)算而得,應(yīng)該放在總手?jǐn)?shù)后面
break;
#endregion
#region 日線數(shù)據(jù)文件day.dat
case DataTypes.hq:
fileName = "DAY.DAT";
startAddress = 0x41000;
blockSize = 8192;
recordSize = 32;
codeIsLong = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,日期,date,4,1,0,;" +
"kp,開盤,single,4,2,4,B;" +
"zg,最高,single,4,3,8,B;" +
"zd,最低,single,4,4,12,B;" +
"sp,收盤,single,4,5,16,B;" +
"sl,成交數(shù)量,single,4,6,20,A;"+
"je,成交金額,single,4,7,24,";
break;
#endregion
#region 5分鐘數(shù)據(jù)文件min.dat
case DataTypes.hq5:
fileName = "MIN.DAT";
startAddress = 0x41000;
blockSize = 8192;
recordSize = 32;
codeIsLong = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,日期,datetime,4,1,0,;" +
"kp,開盤,single,4,2,4,B;" +
"zg,最高,single,4,3,8,B;" +
"zd,最低,single,4,4,12,B;" +
"sp,收盤,single,4,5,16,B;" +
"sl,成交數(shù)量,single,4,6,20,A;"+
"je,成交金額,single,4,7,24,";
break;
#endregion
#region 分紅送配數(shù)據(jù)文件exprof.fdt
case DataTypes.fp:
fileName = "EXPROF.FDT";
startAddress = 0x41000;
blockSize = 3776;
recordSize = 236;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0,;"+
"cqrq,除權(quán)日期,date,4,23,176,;" +
"sgbl,送股比例,double,8,1,12,;" +
"sgdjr,送股股權(quán)登記日,date,4,2,20,;"+
"sgcqr,送股除權(quán)日,date,4,3,24,;"+
"sgssr,紅股上市日,date,4,4,28,;"+
"zzbl,轉(zhuǎn)增比例,double,8,5,32,;"+
"zzdjr,轉(zhuǎn)增股權(quán)登記日,date,4,6,40,;"+
"zzcqr,轉(zhuǎn)增除權(quán)日,date,4,7,44,;"+
"zzssr,轉(zhuǎn)增上市日,date,4,8,48,;"+
"fhbl,分紅比例,double,8,9,52,;"+
"fhdjr,分紅股權(quán)登記日,date,4,10,60,;" +
"fhcxr,分紅除息日,date,4,11,64,;" +
"fhpxr,分紅派息日,date,4,12,68,;" +
"pgbl,配股比例,double,8,13,72,;"+
"pgdjr,配股股權(quán)登記日,date,4,14,80,;"+
"pgcqr,配股除權(quán)基準(zhǔn)日,date,4,15,84,;"+
"pgjkqsr,配股繳款起始日,date,4,16,88,;"+
"pgjkzzr,配股繳款終止日,date,4,17,92,;"+
"pgssr,配股可流通上市日,date,4,18,96,;"+
"pgjg,配股價(jià)格,single,4,19,100,;"+
"frgpgbl,公眾股受讓法人股配股比例,double,8,20,104,;"+
"frgmgzrf,認(rèn)購法人股配股每股轉(zhuǎn)讓費(fèi),single,4,21,112,;"+
"pgzcxs,配股主承銷商,string,60,22,116,;"+
"bgrq,報(bào)告日期,date,4,24,180,;"+
"dshrq,董事會(huì)日期,date,4,25,184,;"+
"gdhrq,股東會(huì)日期,date,4,26,188,;"+
"fhggrq,分紅公告日期,date,4,27,192,;"+
"zgbjs,總股本基數(shù),double,8,28,196,;"+
"sgsl,送股數(shù)量,double,8,29,204,;"+
"zzsl,轉(zhuǎn)增數(shù)量,double,8,30,212,;"+
"sjpgs,實(shí)際配股總數(shù),double,8,31,220,;"+
"cqhzgb,除權(quán)后總股本,double,8,32,228";

break;
#endregion
#region 股本結(jié)構(gòu)Capital.fdt
case DataTypes.gb:
fileName = "CAPITAL.FDT";
startAddress = 0x41000;
blockSize = 3488;
recordSize = 218;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0;" +
"rq,日期,date,4,17,214;"+
"zgb,總股本,double,8,1,12;" +
"gjg,國(guó)家股,double,8,2,20;" +
"fqrg,發(fā)起人股,double,8,3,28;" +
"frg,法人股,double,8,4,36;" +
"ybfrps,一般法人配售,double,8,5,44;" +
"zgg,內(nèi)部職工股,double,8,6,52;" +
"a,流通A股,double,8,7,60;" +
"zltzag,戰(zhàn)略投資A股,double,8,8,68;" +
"zpg,轉(zhuǎn)配股,double,8,9,76;" +
"jjps,基金配售,double,8,10,84;" +
"h,H股,double,8,11,92;" +
"b,B股,double,8,12,100;" +
"yxg,優(yōu)先股,double,8,13,108;" +
"ggcg,高級(jí)管理人員持股,double,8,14,116;" +
"gbbdyy,股本變動(dòng)原因,string,56,15,124;" +
"gbbdyylb,股本變動(dòng)原因類別,string,34,16,180";

break;
#endregion
#region 財(cái)務(wù)數(shù)據(jù)Finance.fdt
case DataTypes.cw:
fileName = "FINANCE.FDT";
startAddress = 0x41000;
blockSize = 14848;
recordSize = 464;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0,;"+
"rq,日期,date,4,,460,;"+
"bsdqtzje,短期投資凈額,double,8,1,12,;"+
"bsyszkje,應(yīng)收帳款凈額,double,8,2,20,;"+
"bschje,存貨凈額,double,8,3,28,;"+
"bsldzc,流動(dòng)資產(chǎn),double,8,4,36,;"+
"bscqtzje,長(zhǎng)期投資凈額,double,8,5,44,;"+
"bsgdzc,固定資產(chǎn),double,8,6,52,;"+
"bswxzc,無形及其他資產(chǎn),double,8,7,60,;"+
"bszzc,總資產(chǎn),double,8,8,68,;"+
"bsdqjk,短期借款,double,8,9,76,;"+
"bsyfzk,應(yīng)付帳款,double,8,10,84,;"+
"bsldfz,流動(dòng)負(fù)債,double,8,11,92,;"+
"bscqfz,長(zhǎng)期負(fù)債,double,8,12,100,;"+
"bsfz,負(fù)債合計(jì),double,8,13,108,;"+
"bsgb,股本,double,8,14,116,;"+
"bsssgdqy,少數(shù)股東權(quán)益,double,8,15,124,;"+
"bsgdqy,股東權(quán)益,double,8,16,132,;"+
"bszbgj,資本公積,double,8,17,140,;"+
"bsyygj,盈余公積,double,8,18,148,;"+
"iszysr,主營(yíng)業(yè)務(wù)收入凈額,double,8,1,156,;"+
"iszycb,主營(yíng)業(yè)務(wù)成本,double,8,2,164,;"+
"iszylr,主營(yíng)業(yè)務(wù)利潤(rùn),double,8,3,172,;"+
"isqtlr,其它業(yè)務(wù)利潤(rùn),double,8,4,180,;"+
"isyyfy,營(yíng)業(yè)費(fèi)用,double,8,5,188,;"+
"isglfy,管理費(fèi)用,double,8,6,196,;"+
"iscwfy,財(cái)務(wù)費(fèi)用,double,8,7,204,;"+
"istzsy,投資收益,double,8,8,212,;"+
"islrze,利潤(rùn)總額,double,8,9,220,;"+
"issds,所得稅,double,8,10,228,;"+
"isjlr,凈利潤(rùn),double,8,11,236,;"+
"iskchjlr,扣除經(jīng)常性損益后的凈利潤(rùn),double,8,12,244,;"+
"iswfplr,未分配利潤(rùn),double,8,13,252,;"+
"cfjyhdxjlr,經(jīng)營(yíng)活動(dòng)現(xiàn)金流入,double,8,1,260,;"+
"cfjyhdxjlc,經(jīng)營(yíng)活動(dòng)現(xiàn)金流出,double,8,2,268,;"+
"cfjyhdxjje,經(jīng)營(yíng)活動(dòng)現(xiàn)金凈額,double,8,3,276,;"+
"cftzxjlr,投資現(xiàn)金流入,double,8,4,284,;"+
"cftzxjlc,投資現(xiàn)金流出,double,8,5,292,;"+
"cftzxjje,投資現(xiàn)金凈額,double,8,6,300,;"+
"cfczxjlr,籌措現(xiàn)金流入,double,8,7,308,;"+
"cfczxjlc,籌措現(xiàn)金流出,double,8,8,316,;"+
"cfczxjje,籌措現(xiàn)金凈額,double,8,9,324,;"+
"cfxjjze,現(xiàn)金及現(xiàn)金等價(jià)物凈增額,double,8,10,332,;"+
"cfxsspxj,銷售商品收到的現(xiàn)金,double,8,11,340,;"+
"mgsy,每股收益,single,4,1,348,;"+
"mgjzc,每股凈資產(chǎn),single,4,2,352,;"+
"tzmgjzc,調(diào)整后每股凈資產(chǎn),single,4,3,356,;"+
"mgzbgjj,每股資本公積金,single,4,4,360,;"+
"mgwfplr,每股未分配利潤(rùn),single,4,5,364,;"+
"mgjyxjllje,每股經(jīng)營(yíng)活動(dòng)產(chǎn)生的現(xiàn)金流量?jī)纛~,single,4,6,368,;"+
"mgxjzjje,每股現(xiàn)金及現(xiàn)金等價(jià)物增加凈額,single,4,7,372,;"+
"mll,毛利率,single,4,8,376,;"+
"zyywlrl,主營(yíng)業(yè)務(wù)利潤(rùn)率,single,4,9,380,;"+
"jll,凈利率,single,4,10,384,;"+
"zzcbcl,總資產(chǎn)報(bào)酬率,single,4,11,388,;"+
"jzcsyl,凈資產(chǎn)收益率,single,4,12,392,;"+
"xsxjzb,銷售商品收到的現(xiàn)金占主營(yíng)收入比例,single,4,13,396,;"+
"yszczzl,應(yīng)收帳款周轉(zhuǎn)率,single,4,14,400,;"+
"chzzl,存貨周轉(zhuǎn)率,single,4,15,404,;"+
"gdzczzl,固定資產(chǎn)周轉(zhuǎn)率,single,4,16,408,;"+
"zyywzzl,主營(yíng)業(yè)務(wù)增長(zhǎng)率,single,4,17,412,;"+
"jlrzzl,凈利潤(rùn)增長(zhǎng)率,single,4,18,416,;"+
"zzczzl,總資產(chǎn)增長(zhǎng)率,single,4,19,420,;"+
"jzczzl,凈資產(chǎn)增長(zhǎng)率,single,4,20,424,;"+
"ldbl,流動(dòng)比率,single,4,21,428,;"+
"sdbl,速動(dòng)比率,single,4,22,432,;"+
"zcfzbl,資產(chǎn)負(fù)債比率,single,4,23,436,;"+
"fzbl,負(fù)債比率,single,4,24,440,;"+
"gdqybl,股東權(quán)益比率,single,4,25,444,;"+
"gdzcbl,固定資產(chǎn)比率,single,4,26,448,;"+
"kchmgjlr,扣除經(jīng)常性損益后每股凈利潤(rùn),single,4,27,452,";

break;
#endregion
#region 十大股東stkhold.fdt
case DataTypes.gd:
fileName = "STKHOLD.FDT";
startAddress = 0x41000;
blockSize = 17568;
recordSize = 2196;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0,;"+
"rq,日期,date,4,66,2192,;" +
"gd1mc,股東1名稱,string,160,1,12,;"+
"gd1cgsl,股東1持股數(shù)量,double,8,2,172,;"+
"gd1cgbl,股東1持股比例,single,4,3,180,;"+
"gd1bz,股東1備注,string,20,4,184,;"+
"gd1fr,股東1法人,string,8,5,204,;"+
"gd1jyfw,股東1經(jīng)營(yíng)范圍,string,16,6,212,;"+
"gd2mc,股東2名稱,string,160,7,228,;"+
"gd2cgsl,股東2持股數(shù)量,double,8,8,388,;"+
"gd2cgbl,股東2持股比例,single,4,9,396,;"+
"gd2bz,股東2備注,string,20,10,400,;"+
"gd2fr,股東2法人,string,8,11,420,;"+
"gd2jyfw,股東2經(jīng)營(yíng)范圍,string,16,12,428,;"+
"gd3mc,股東3名稱,string,160,13,444,;"+
"gd3cgsl,股東3持股數(shù)量,double,8,14,604,;"+
"gd3cgbl,股東3持股比例,single,4,15,612,;"+
"gd3bz,股東3備注,string,20,16,616,;"+
"gd3fr,股東3法人,string,8,17,636,;"+
"gd3jyfw,股東3經(jīng)營(yíng)范圍,string,16,18,644,;"+
"gd4mc,股東4名稱,string,160,19,660,;"+
"gd4cgsl,股東4持股數(shù)量,double,8,20,820,;"+
"gd4cgbl,股東4持股比例,single,4,21,828,;"+
"gd4bz,股東4備注,string,20,22,832,;"+
"gd4fr,股東4法人,string,8,23,852,;"+
"gd4jyfw,股東4經(jīng)營(yíng)范圍,string,16,24,860,;"+
"gd5mc,股東5名稱,string,160,25,876,;"+
"gd5cgsl,股東5持股數(shù)量,double,8,26,1036,;"+
"gd5cgbl,股東5持股比例,single,4,27,1044,;"+
"gd5bz,股東5備注,string,20,28,1048,;"+
"gd5fr,股東5法人,string,8,29,1068,;"+
"gd5jyfw,股東5經(jīng)營(yíng)范圍,string,16,30,1076,;"+
"gd6mc,股東6名稱,string,160,31,1092,;"+
"gd6cgsl,股東6持股數(shù)量,double,8,32,1252,;"+
"gd6cgbl,股東6持股比例,single,4,33,1260,;"+
"gd6bz,股東6備注,string,20,34,1264,;"+
"gd6fr,股東6法人,string,8,35,1284,;"+
"gd6jyfw,股東6經(jīng)營(yíng)范圍,string,16,36,1292,;"+
"gd7mc,股東7名稱,string,160,37,1308,;"+
"gd7cgsl,股東7持股數(shù)量,double,8,38,1468,;"+
"gd7cgbl,股東7持股比例,single,4,39,1476,;"+
"gd7bz,股東7備注,string,20,40,1480,;"+
"gd7fr,股東7法人,string,8,41,1500,;"+
"gd7jyfw,股東7經(jīng)營(yíng)范圍,string,16,42,1508,;"+
"gd8mc,股東8名稱,string,160,43,1524,;"+
"gd8cgsl,股東8持股數(shù)量,double,8,44,1684,;"+
"gd8cgbl,股東8持股比例,single,4,45,1692,;"+
"gd8bz,股東8備注,string,20,46,1696,;"+
"gd8fr,股東8法人,string,8,47,1716,;"+
"gd8jyfw,股東8經(jīng)營(yíng)范圍,string,16,48,1724,;"+
"gd9mc,股東9名稱,string,160,49,1740,;"+
"gd9cgsl,股東9持股數(shù)量,double,8,50,1900,;"+
"gd9cgbl,股東9持股比例,single,4,51,1908,;"+
"gd9bz,股東9備注,string,20,52,1912,;"+
"gd9fr,股東9法人,string,8,53,1932,;"+
"gd9jyfw,股東9經(jīng)營(yíng)范圍,string,16,54,1940,;"+
"gd10mc,股東10名稱,string,160,55,1956,;"+
"gd10cgsl,股東10持股數(shù)量,double,8,56,2116,;"+
"gd10cgbl,股東10持股比例,single,4,57,2124,;"+
"gd10bz,股東10備注,string,20,58,2128,;"+
"gd10fr,股東10法人,string,8,59,2148,;"+
"gd10jyfw,股東10經(jīng)營(yíng)范圍,string,16,60,2156,;"+
"gdzs,股東總數(shù),int,4,61,2172,;"+
"gjgfrggds,國(guó)家股法人股股東數(shù),int,4,62,2176,;"+
"aggds,流通股A股股東數(shù),int,4,63,2180,;"+
"bggds,流通股B股股東數(shù),int,4,64,2184,";

break;
#endregion
#region 基金周報(bào)fundweek.fdt
case DataTypes.jjjz:
fileName = "FUNDWEEK.FDT";
startAddress = 0x41000;
blockSize = 12032;
recordSize = 188;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0,;"+
"rq,日期,date,4,13,184,;"+
"dwjz,基金單位凈值,single,4,6,152,;" +
"jjze,基金凈值總額,double,8,5,144,;" +
"gm,基金規(guī)模,double,8,4,136,;" +
"dwcz,基金單位初值,single,4,7,156,;"+
"tzhjz,基金調(diào)整后凈值,single,4,8,160,;"+
"tzhcz,基金調(diào)整后初值,single,4,9,164,;"+
"zzl,基金增長(zhǎng)率(%),double,8,10,168,;"+
"ljjz,基金累計(jì)凈值,single,4,11,176,;"+
"slrq,基金設(shè)立日期,date,4,1,12,;"+
"glr,基金管理人,string,60,2,16,;"+
"tgr,基金托管人,string,60,3,76,"
;//12為保留字段

break;
#endregion
#region 基金投資組合funddiv.fdt
case DataTypes.jjzh:
fileName = "FUNDDIV.FDT";
startAddress = 0x41000;
blockSize = 8320;
recordSize = 260;
codeIsLong = true;
fieldString =
"dm,代碼,code,12,0,0,;" +
"bgrq,報(bào)告日期,date,4,31,252,;" +
"zzrq,截止日期,date,4,32,256,;" +
"dm1,證券1代碼,string,12,1,12,;" +
"sz1,證券1市值,double,8,2,24,;" +
"bl1,證券1占凈值比例(%),single,4,3,32,;" +
"dm2,證券2代碼,string,12,4,36,;" +
"sz2,證券2市值,double,8,5,48,;" +
"bl2,證券2占凈值比例(%),single,4,6,56,;" +
"dm3,證券3代碼,string,12,7,60,;" +
"sz3,證券3市值,double,8,8,72,;" +
"bl3,證券3占凈值比例(%),single,4,9,80,;" +
"dm4,證券4代碼,string,12,10,84,;" +
"sz4,證券4市值,double,8,11,96,;" +
"bl4,證券4占凈值比例(%),single,4,12,104,;" +
"dm5,證券5代碼,string,12,13,108,;" +
"sz5,證券5市值,double,8,14,120,;" +
"bl5,證券5占凈值比例(%),single,4,15,128,;" +
"dm6,證券6代碼,string,12,16,132,;" +
"sz6,證券6市值,double,8,17,144,;" +
"bl6,證券6占凈值比例(%),single,4,18,152,;" +
"dm7,證券7代碼,string,12,19,156,;" +
"sz7,證券7市值,double,8,20,168,;" +
"bl7,證券7占凈值比例(%),single,4,21,176,;" +
"dm8,證券8代碼,string,12,22,180,;" +
"sz8,證券8市值,double,8,23,192,;" +
"bl8,證券8占凈值比例(%),single,4,24,200,;" +
"dm9,證券9代碼,string,12,25,204,;" +
"sz9,證券9市值,double,8,26,216,;" +
"bl9,證券9占凈值比例(%),single,4,27,224,;" +
"dm10,證券10代碼,string,12,28,228,;" +
"sz10,證券10市值,double,8,29,240,;" +
"bl10,證券10占凈值比例(%),single,4,30,248,";


break;
#endregion
#region 板塊userdata\block
case DataTypes.bk:
fileName = "BLOCK.DEF";
startAddress = 0;
blockSize = 0;
recordSize = 248;
codeIsLong = false;
isIndexDataStruct = false;
fieldString =
"lb,類別,string,20,0,0,;" +
"bk,板塊,string,20,1,10,;" +
"dm,證券代碼,string,10,2,42,";
break;
#endregion
#region 評(píng)級(jí)
case DataTypes.pj:
fileName = "評(píng)級(jí).str";
startAddress = 0;
blockSize = 256;
recordSize = 256;
codeIsLong = true;
isIndexDataStruct = false;
fieldString =
"dm,證券代碼,string,12,0,0,;" +
"pj,評(píng)級(jí),string,2,2,0,;" +
"sm,說明,string,244,2,0,";
break;
#endregion
#region 復(fù)權(quán)行情,計(jì)算而得
case DataTypes.hqfq:
fileName = "DAY.DAT";
startAddress = 0x41000;
blockSize = 8192;
recordSize = 32;
codeIsLong = false;
fieldString =
"dm,代碼,code,10,0,0,;" +
"rq,日期,date,4,1,0,;" +
"kp,開盤復(fù)權(quán)價(jià),single,4,2,4,B;" +
"zg,最高復(fù)權(quán)價(jià),single,4,3,8,B;" +
"zd,最低復(fù)權(quán)價(jià),single,4,4,12,B;" +
"sp,收盤復(fù)權(quán)價(jià),single,4,5,16,B;" +
"sl,復(fù)權(quán)成交數(shù)量,single,4,6,20,A;" +
"je,成交金額,single,4,7,24,;"+
"spsyl,收盤收益率,single,4,0,0,";
break;
#endregion
}
string[] fieldLine = fieldString.Split(new char[] { ‘;‘ });
fields = new string[fieldLine.Length, 7];
for (int i = 0; i < fieldLine.Length; i++)
{
string[] field = fieldLine[i].Split(new char[]{‘,‘} ,7 );
for(int j=0;j<field.Length;j++)
{
fields[i,j]=field[j];
}
}
}

}
private string fxjPath = "";
private string fxjDataPath="";
private string[,] fxjMarket;
private string msg = "";
private DateTime date19700101 = new DateTime(1970, 1, 1);
private FileStream fs; private BinaryReader br;
private void checkFileStream(string fxjFileName)
{
if (this.fs == null || (this.fs != null && this.fs.Name.ToUpper() != fxjFileName))
{
if (this.fs != null)
{
fs.Close();
br.Close();
}
fs = new FileStream(fxjFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
br = new BinaryReader(fs);
}
}

public string Version
{
get
{
return ("0.7");
}
}
public int Error
{
get
{
if (msg != "") return 1;
else return 0;
}
}
public string Msg
{
get { return (msg); }
}
public string FxjPath //屬性FxjPath
{
get
{
return (fxjPath);
}
set
{
fxjPath = value;
fxjPath = fxjPath.Trim().ToUpper();
if (fxjPath != "" && !fxjPath.EndsWith(@"\"))
{
fxjPath += @"\";
}
fxjPath = fxjPath.ToUpper();
}
}
public string FxjDataPath //屬性FxjDataPath
{
get
{
return (fxjDataPath);
}
set
{
fxjDataPath = value;
fxjDataPath = fxjDataPath.Trim().ToUpper();
if (fxjDataPath!="" && !fxjDataPath.EndsWith(@"\"))
{
fxjDataPath += @"\";
}
fxjDataPath=fxjDataPath.ToUpper();
}
}

public void ShowAboutBox()
{
FinData.AboutBox ab = new AboutBox();
ab.ShowDialog();
}
public void ShowFxjConverter()
{
FxjConverter fxjConverter = new FxjConverter();
fxjConverter.ShowDialog();
}
public void ShowFxjReader()
{
FxjReader fxjReader = new FxjReader();
fxjReader.ShowDialog();
}

public string[,] GetMarkets()
{
return (fxjMarket);
}
public string[,] GetTables()
{
if (tableNames[0, 2] == "")
{
for (int i = 0; i < tableNames.GetLength(0); i++)
{
DataTypes d = (DataTypes)Enum.Parse(typeof(DataTypes), tableNames[i,0].ToLower());
fileStruct fxjFileStruct = new fileStruct(d);
tableNames[i, 2] = fxjFileStruct.fileName;
}

}

return tableNames;
}
public string GetTableDef(string dataType, string descDataType, bool delOldTable)
{
dataType = dataType.Trim(); descDataType = descDataType.Trim();
string result = "";
fileStruct fxjFileStruct = new fileStruct((DataTypes)Enum.Parse(typeof(DataTypes), dataType.ToLower()));
switch (descDataType.ToUpper())
{
case "SAS":
for (int i = 0; i < fxjFileStruct.fields.GetLength(0); i++)
{
if (result != "") result += ",";
result += fxjFileStruct.fields[i, 0];//字段
if (" ,code,string".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " char(" + fxjFileStruct.fields[i, 3] + ") format=$" + fxjFileStruct.fields[i, 3] + "."; //字符串
}
else if (" ,int,single,double".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " num "; //數(shù)值類型
}
else if (" ,date".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " num format=YYMMDD10."; //date類型
}
else if (" ,datetime".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " num format=datetime."; //datetime類型
}
result += " label=‘" + fxjFileStruct.fields[i, 1] + "‘";//標(biāo)簽

}
result = "create table FinData." + dataType + "(" + result + ");";
if (delOldTable == true)
{
result = "drop table FinData." + dataType + ";" + result;
}
result = "proc sql;" + result + "quit;";
break;
case "SASINPUT"://用于SAS直接讀取數(shù)據(jù)時(shí)所用的INPUT語句,需進(jìn)一步修改
for (int i = 0; i < fxjFileStruct.fields.GetLength(0); i++)
{
if (" ,code,string".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " @(p+" + fxjFileStruct.fields[i, 5] + ") " + fxjFileStruct.fields[i, 0] + " $" + fxjFileStruct.fields[i, 3] + "."; //字符串
}
else if (" ,int,date,datetime".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " @(p+" + fxjFileStruct.fields[i, 5] + ") " + fxjFileStruct.fields[i, 0] + " ib" + fxjFileStruct.fields[i, 3] + "."; //數(shù)值類型
}
else if (" ,single".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " @(p+" + fxjFileStruct.fields[i, 5] + ") " + fxjFileStruct.fields[i, 0] + " float" + fxjFileStruct.fields[i, 3] + "."; //數(shù)值類型
}
else if (" ,double".IndexOf(fxjFileStruct.fields[i, 2]) > 0)
{
result += " @(p+" + fxjFileStruct.fields[i, 5] + ") " + fxjFileStruct.fields[i, 0] + " rb" + fxjFileStruct.fields[i, 3] + "."; //數(shù)值類型
}
}
break;
case "FIELDS"://列出字段名稱
for (int i = 0; i < fxjFileStruct.fields.GetLength(0); i++)
{
result += " " + fxjFileStruct.fields[i, 0] ;
}
break;

default:
result = "";
break;
}
return result;

}
public string GetCodeType(string code)
{
code = code.Trim().ToUpper();
if (Regex.IsMatch(code, @"(SH000300)") == true)
{
return "zs";
}
if (Regex.IsMatch(code, @"(SH60[0-8]\d{3})|(SH90\d{4})|(SZ00[01256789]\d{3})|(SZ20\d{4})|(SZ4[02]\d{4})") == true)
{
return "gp";
}
else if (Regex.IsMatch(code, @"(SH00000\d)|(SH00001[0-6])") == true)
{
return "zs";
}
else if (Regex.IsMatch(code, @"(SH[012]\d{5})|(SZ1[0123]\d{4})") == true && Regex.IsMatch(code, @"(SH181\d{3})") == false && Regex.IsMatch(code, @"(SH190\d{3})") == false)
{
return "zq";
}
else if (Regex.IsMatch(code, @"(SH5[01]\d{4})|(SZ184\d{3})|(SZ1[56]\d{4})") == true)
{
return "jj";
}
else if (Regex.IsMatch(code, @"(SH58\d{4})|(SZ03\d{4})") == true)
{
return "qz";
}
else if (Regex.IsMatch(code, @"(SH000\d{3})|(SZ399\d{3})|(SH8[013]\d{4})") == true)
{
return "zs";
}
return "";
}
private string [] GetCodes(string Market) //讀取Day.dat中的代碼
{
//滬市指數(shù)代碼轉(zhuǎn)換表,分析家同時(shí)保存滬市兩類代碼
string[,] codesRename = new string[,]
{
{"SH1A0001","SH000001"},
{"SH1A0002","SH000002"},
{"SH1A0003","SH000003"},
{"SH1B0001","SH000004"},
{"SH1B0002","SH000005"},
{"SH1B0004","SH000006"},
{"SH1B0005","SH000007"},
{"SH1B0006","SH000008"},
{"SH1B0007","SH000010"},
{"SH1B0008","SH000011"},
{"SH1B0009","SH000012"},
{"SH1B0010","SH000013"},
{"SH1C0003","SH000016"}
};
long len = -1;
long pos = 0;
int flag;
if (FxjDataPath == "")
{
msg = @"無法在注冊(cè)表中到分析家數(shù)據(jù)文件目錄,請(qǐng)自行將屬性 FxjDataPath設(shè)置為有效路徑,如c:\fxj\data\。";
return new string[1] { null };
}
Market = Market.Trim().ToUpper();
if (Market == "")
{
msg = "Market參數(shù)只能是市場(chǎng)簡(jiǎn)稱,如滬市為SH,深市為SZ,香港為HK等。";
return null;
}
string FxjFile = fxjDataPath + Market+@"\DAY.DAT";
msg="";
if (!File.Exists(FxjFile)) //DAY.DAT文件不存在
{
msg = FxjFile + "不存在!";
return new string[1] { null };
}
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code = "";
len = fs.Length;
fs.Position=0;
flag = br.ReadInt32();
if (flag == -65823756) //0xFC139BF4
{
fs.Position = 12;
secCounts=br.ReadInt32();
string[] codes = new string[secCounts];
for (int i = 0; i < secCounts; i++)
{
pos = 24 + 64*i;
if (pos <= len)
{
fs.Position = pos;
code = new string(br.ReadChars(10));//分析家用10個(gè)字節(jié)保存代碼,一般用6個(gè)字節(jié)
code = Market + code.Replace("\0", "");
code = code.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
code = code.ToUpper();
for (int icode = 0; icode < codesRename.GetLength(0); icode++)
{
code = code.Replace(codesRename[icode, 0], codesRename[icode, 1]);
}
codes[i] = code;
}
}
//fs.Close();
msg = "";
return codes;
}
}
catch(Exception e)
{
msg=e.Message;

}
return new string[1] { null };

}
public string[,] GetFields(string dataType)
{
msg = "";
try
{
DataTypes d = (DataTypes)Enum.Parse(typeof(DataTypes), dataType.ToLower());
return GetFields(d);
}
catch
{
msg = @"輸入的參數(shù)有誤。參數(shù)只能是:";
foreach (string s in Enum.GetNames(typeof(DataTypes)))
msg += " \"" + s + "\"";
msg += @" 或者 ";
foreach (int i in Enum.GetValues(typeof(DataTypes)))
msg += " " + i.ToString();

return new string[1, 1] { { null } };
}

}
private string[,] GetFields(DataTypes dataType)
{
msg = "";
try
{
fileStruct fxjFileStruct = new fileStruct(dataType);
string[,] fields = new string[fxjFileStruct.fields.GetLength(0), 3];
//fields[0, 0] = "<字段名>"; fields[0, 1] = "<含義>"; fields[0, 2] = "<類型>";
for (int i = 0; i < fxjFileStruct.fields.GetLength(0); i++)
{
for (int j = 0; j < 3; j++)
{
fields[i, j] = fxjFileStruct.fields[i, j];
}
}

return fields;
}
catch
{
msg = "錯(cuò)誤"; return new string[1, 1] { { null } };
}

}

public string[,] GetData(string dataType, string code)
{
return GetData(dataType, code, "");
}
public string[,] GetData(string dataType, string code, string newFileName)
{
try
{
DataTypes d = (DataTypes)Enum.Parse(typeof(DataTypes), dataType.ToLower());
return GetData(d, code,newFileName);
}
catch
{
msg = @"輸入的參數(shù)有誤。第一個(gè)參數(shù)只能是:";
foreach (string s in Enum.GetNames(typeof(DataTypes)))
msg += " \"" + s + "\"";
msg += @" 或者 ";
foreach (int i in Enum.GetValues(typeof(DataTypes)))
msg += " " + i.ToString() ;

return new string[1, 1] { { null } };
}
}
private string[,] GetData(DataTypes dataType,string code,string newFileName) //讀取數(shù)據(jù),重載
{
if (dataType == DataTypes.bk) return GetBK(code);
if (dataType == DataTypes.pj) return GetPJ(code);
if (dataType == DataTypes.hqfq) return GetHqfq(dataType,code,newFileName);
#region 讀取數(shù)據(jù)前初始化
msg = "";
fileStruct fxjFileStruct = new fileStruct(dataType);
if (newFileName != "") fxjFileStruct.fileName = newFileName; //如果用戶重新指定了文件名
code = code.Trim().ToUpper();
if (code == "")
{
msg = @"CODE參數(shù)不可為空。請(qǐng)?zhí)峁┳C券代碼,如SZ000001。";
return new string[1, 1] { { null } };
}
ArrayList recordList = new ArrayList();
int intField; float floatField; double doubleField; //string stringField;
System.Globalization.CultureInfo cnCultureInfo = new System.Globalization.CultureInfo("zh-CN");
string market = code.Substring(0, 2);
int recordCounts = 0;
short[] blocks = new short[25];
long len = -1;
long pos = 0;
if (this.FxjDataPath == "")
{
msg = @"無法在注冊(cè)表中到分析家數(shù)據(jù)文件目錄,請(qǐng)自行將屬性 FxjDataPath設(shè)置為有效路徑,如c:\fxj\data\。";
return new string[1, 1] { { null } };
}
string FxjFile = fxjDataPath + fxjFileStruct.fileName;
FxjFile = FxjFile.ToUpper();
if (!File.Exists(FxjFile))
{
FxjFile = fxjDataPath + market +@"\" +fxjFileStruct.fileName;
}
msg = "";
if (!File.Exists(FxjFile))
{
msg = fxjFileStruct.fileName + "沒有找到!";
return new string[1, 1] { { null } };
}
#endregion
if (fxjFileStruct.isIndexDataStruct == true)
{
#region 處理DAY.DAT等結(jié)構(gòu)(索引/數(shù)據(jù))的數(shù)據(jù)
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
len = fs.Length;
fs.Position = 12;
secCounts = br.ReadInt32();
bool codeRead = false;
for (int i = 0; i < secCounts && codeRead==false; i++)
{
pos = 24 + 64 * i;
if (pos <= len)
{
fs.Position = pos;
//code0 = new string(br.ReadChars(10));//分析家用10個(gè)字節(jié)保存代碼,一般用8個(gè)字節(jié)
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (fxjFileStruct.codeIsLong == false && code == market + code0 || fxjFileStruct.codeIsLong == true && code == code0)
{
recordCounts = br.ReadInt32();
for (int j = 0; j < 25; j++)
{
blocks[j] = br.ReadInt16();
}
codeRead = true;
}
}
}
int iRecord = 1;//記錄
int iBlock = 0;//第iBlock塊
int fieldCounts = fxjFileStruct.fields.GetLength(0);
while (iBlock < 25 && blocks[iBlock] != -1)
{
int r = 0;
while (iRecord < recordCounts + 1 && r < fxjFileStruct.blockSize / fxjFileStruct.recordSize) //16=3776/236
{
string[] record = new string[fieldCounts];
pos = fxjFileStruct.startAddress + blocks[iBlock] * fxjFileStruct.blockSize + r * fxjFileStruct.recordSize;
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 2].ToLower())
{
case "code":
//code0 = new string(br.ReadChars(8));//有12位,實(shí)際用了8位,第9-12位一般為\0,有時(shí)是錯(cuò)誤字節(jié),因?yàn)橹蛔x8位
//code0 = code0.Replace("\0", "");
record[iField] = code;
break;
case "date":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddDays(intField / 86400)).ToString("yyyy-MM-dd"));
break;
case "datetime":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "int":
intField = br.ReadInt32();
record[iField] = intField.ToString("D", cnCultureInfo);
break;
case "single":
//floatField = br.ReadSingle();
//if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") floatField *= 100;
//record[iField] = floatField.ToString("G", cnCultureInfo);
doubleField =(double) br.ReadSingle();
if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") doubleField *= 100;
record[iField] = doubleField.ToString("_jj_qz".IndexOf(this.GetCodeType(code)) > 0 ? "F3" : "F", cnCultureInfo);
break;
case "double":
doubleField = br.ReadDouble();
record[iField] = doubleField.ToString("F", cnCultureInfo);
break;
case "string":
record[iField] = System.Text.Encoding.Default.GetString(br.ReadBytes(Convert.ToInt32(fxjFileStruct.fields[iField, 3]))).Replace("\0", "");
break;
}
}


recordList.Add(record);

r = r + 1;
iRecord = iRecord + 1;
}
iBlock = iBlock + 1;
}

//fs.Close();
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
}
else
{
switch (dataType)
{
case DataTypes.dm:
#region 代碼表(處理STKINFO51.DAT等結(jié)構(gòu)的數(shù)據(jù))
try
{
this.checkFileStream(FxjFile);
string[,] codesRename = new string[,]
{
{"SH1A0001","SH000001"},
{"SH1A0002","SH000002"},
{"SH1A0003","SH000003"},
{"SH1B0001","SH000004"},
{"SH1B0002","SH000005"},
{"SH1B0004","SH000006"},
{"SH1B0005","SH000007"},
{"SH1B0006","SH000008"},
{"SH1B0007","SH000010"},
{"SH1B0008","SH000011"},
{"SH1B0009","SH000012"},
{"SH1B0010","SH000013"},
{"SH1C0003","SH000016"}
};
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
fs.Position = 8;
secCounts = br.ReadInt32();
int fieldCounts = fxjFileStruct.fields.GetLength(0);
for (int i = 0; i < secCounts; i++)
{
pos = fxjFileStruct.startAddress + i * fxjFileStruct.recordSize;
fs.Position = pos;
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (Regex.IsMatch(code0, @"(1[ABC]00\d\d)") == false)
{
string[] recordFieldName = new string[fieldCounts];
string[] record = new string[fieldCounts];
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 2].ToLower())
{
case "code":
record[iField] = fxjFileStruct.codeIsLong == true ? code0 : market + code0;
record[iField] = record[iField].Replace("HKHK", "HK");
for (int icode = 0; icode < codesRename.GetLength(0); icode++)
{
record[iField] = record[iField].Replace(codesRename[icode, 0], codesRename[icode, 1]);
}
break;
case "date":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddDays(intField / 86400)).ToString("yyyy-MM-dd"));
break;
case "datetime":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "int":
intField = br.ReadInt32();
record[iField] = intField.ToString("D");
break;
case "single":
floatField = br.ReadSingle();
if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") floatField *= 100;
record[iField] = floatField.ToString("F");
break;
case "double":
doubleField = br.ReadDouble();
record[iField] = doubleField.ToString("F");
break;
case "string":
record[iField] = System.Text.Encoding.Default.GetString(br.ReadBytes(Convert.ToInt32(fxjFileStruct.fields[iField, 3]))).Replace("\0", "");
break;
}

}
recordList.Add(record);
}

}

//fs.Close();
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
break;
case DataTypes.hq0:
#region 最新行情(處理STKINFO51.DAT等結(jié)構(gòu)的數(shù)據(jù))
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
fs.Position = 8;
secCounts = br.ReadInt32();
int fieldCounts = fxjFileStruct.fields.GetLength(0);
bool hasCode = false;
for (int i = 0; i < secCounts && hasCode==false; i++)
{
pos = fxjFileStruct.startAddress + i * fxjFileStruct.recordSize;
fs.Position = pos;
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (fxjFileStruct.codeIsLong == false && code == market + code0 || fxjFileStruct.codeIsLong == true && code == code0)
{
hasCode = true;
string[] record = new string[fieldCounts];
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 2].ToLower())
{
case "code":
record[iField] = code;
break;
case "date":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddDays(intField / 86400)).ToString("yyyy-MM-dd"));
break;
case "datetime":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "int":
intField = br.ReadInt32();
record[iField] = intField.ToString("D");
break;
case "single":
//floatField = br.ReadSingle();
//if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") floatField *= 100;
//record[iField] = Math.Round(floatField, 2).ToString("F");
doubleField = (double)br.ReadSingle();
if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") doubleField *= 100;
record[iField] = doubleField.ToString("_jj_qz".IndexOf(this.GetCodeType(code)) > 0 ? "F3" : "F", cnCultureInfo);
break;
case "double":
doubleField = br.ReadDouble();
record[iField] = Math.Round(doubleField, 2).ToString("F");
break;
case "string":
record[iField] = System.Text.Encoding.Default.GetString(br.ReadBytes(Convert.ToInt32(fxjFileStruct.fields[iField, 3]))).Replace("\0", "");
break;
}

}
recordList.Add(record);

}

}

//fs.Close();
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
break;
case DataTypes.cq:
#region 分紅送配(處理STKINFO51.DAT等結(jié)構(gòu)的數(shù)據(jù))
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
fileStruct fxjdmStruct = new fileStruct(DataTypes.dm);// 代碼的結(jié)構(gòu)
int dmpos=0;
fs.Position = 8;
secCounts = br.ReadInt32();
int fieldCounts = fxjFileStruct.fields.GetLength(0);
bool hasCode = false;
for (int i = 0; i < secCounts && hasCode==false; i++)
{
dmpos = fxjdmStruct.startAddress + i * fxjdmStruct.recordSize;
fs.Position = dmpos;
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (fxjdmStruct.codeIsLong == false && code == market + code0 || fxjdmStruct.codeIsLong == true && code == code0)
{
hasCode = true;
int iRecord=0;
pos = fxjFileStruct.startAddress + i * fxjFileStruct.blockSize + iRecord * fxjFileStruct.recordSize;
fs.Position=pos;
while (br.ReadInt32() != 0)
{
string[] record = new string[fieldCounts];
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 2].ToLower())
{
case "code":
record[iField] = code;
break;
case "date":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddDays(intField / 86400)).ToString("yyyy-MM-dd"));
break;
case "datetime":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "int":
intField = br.ReadInt32();
record[iField] = intField.ToString("D");
break;
case "single":
floatField = br.ReadSingle();
if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") floatField *= 100;
record[iField] = Math.Round(floatField, 2).ToString("F");
break;
case "double":
doubleField = br.ReadDouble();
record[iField] = Math.Round(doubleField, 2).ToString("F");
break;
case "string":
record[iField] = System.Text.Encoding.Default.GetString(br.ReadBytes(Convert.ToInt32(fxjFileStruct.fields[iField, 3]))).Replace("\0", "");
break;
}

}
recordList.Add(record);
iRecord = iRecord + 1;
pos = fxjFileStruct.startAddress + i * fxjFileStruct.blockSize + iRecord * fxjFileStruct.recordSize;
fs.Position = pos;

}

}

}

//fs.Close();
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
break;
case DataTypes.cw0:
#region 財(cái)務(wù)數(shù)據(jù)--簡(jiǎn)單(處理STKINFO51.DAT等結(jié)構(gòu)的數(shù)據(jù))
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
fileStruct fxjdmStruct = new fileStruct(DataTypes.dm);// 代碼的結(jié)構(gòu)
int dmpos = 0;
fs.Position = 8;
secCounts = br.ReadInt32();
int fieldCounts = fxjFileStruct.fields.GetLength(0);
bool hasCode = false;
for (int i = 0; i < secCounts && hasCode == false; i++)
{
dmpos = fxjdmStruct.startAddress + i * fxjdmStruct.recordSize;
fs.Position = dmpos;
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (fxjdmStruct.codeIsLong == false && code == market + code0 || fxjdmStruct.codeIsLong == true && code == code0)
{
hasCode = true;
int iRecord = 0;
pos = fxjFileStruct.startAddress + i * fxjFileStruct.blockSize + iRecord * fxjFileStruct.recordSize;
fs.Position = pos;
string[] record = new string[fieldCounts];
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 2].ToLower())
{
case "code":
record[iField] = code;
break;
case "date":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddDays(intField / 86400)).ToString("yyyy-MM-dd"));
break;
case "datetime":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "int":
intField = br.ReadInt32();
record[iField] = intField.ToString("D");
break;
case "single":
floatField = br.ReadSingle();
if (fxjFileStruct.fields[iField, 6].ToUpper() == "A") floatField *= 100;
record[iField] = Math.Round(floatField, 2).ToString("F");
break;
case "double":
doubleField = br.ReadDouble();
record[iField] = Math.Round(doubleField, 2).ToString("F");
break;
case "string":
record[iField] = System.Text.Encoding.Default.GetString(br.ReadBytes(Convert.ToInt32(fxjFileStruct.fields[iField, 3]))).Replace("\0", "");
break;
}

}
recordList.Add(record);
}

}

//fs.Close();
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
break;
case DataTypes.hqmb:
#region 處理Report.DAT數(shù)據(jù)(結(jié)構(gòu)類似DAY.DAT,但有些數(shù)值需要進(jìn)一步計(jì)算而來)
try
{
this.checkFileStream(FxjFile);
int secCounts = 0;//文件中證券總數(shù)
string code0 = "";
len = fs.Length;
fs.Position = 12;
secCounts = br.ReadInt32();
bool codeRead = false;
for (int i = 0; i < secCounts && codeRead==false; i++)
{
pos = 24 + 64 * i;
if (pos <= len)
{
fs.Position = pos;
//code0 = new string(br.ReadChars(10));//分析家用10個(gè)字節(jié)保存代碼,一般用8個(gè)字節(jié)
code0 = System.Text.Encoding.Default.GetString(br.ReadBytes(10));
code0 = code0.Replace("\0", "");
code0 = code0.Replace("HKHK", "HK"); //香港證券代碼本身保存為HKxxxx
if (fxjFileStruct.codeIsLong == false && code == market + code0 || fxjFileStruct.codeIsLong == true && code == code0)
{
recordCounts = br.ReadInt32();
for (int j = 0; j < 25; j++)
{
blocks[j] = br.ReadInt16();
}
codeRead = true;
}
}
}
int iRecord = 1;//記錄
int iBlock = 0;//第iBlock塊
int fieldCounts = fxjFileStruct.fields.GetLength(0);
while (iBlock < 25 && blocks[iBlock] != -1)
{
int r = 0;
while (iRecord < recordCounts + 1 && r < fxjFileStruct.blockSize / fxjFileStruct.recordSize) //16=3776/236
{
string[] record = new string[fieldCounts];
pos = fxjFileStruct.startAddress + blocks[iBlock] * fxjFileStruct.blockSize + r * fxjFileStruct.recordSize;
for (int iField = 0; iField < fieldCounts; iField++)
{
fs.Position = pos + Convert.ToInt64(fxjFileStruct.fields[iField, 5]);
switch (fxjFileStruct.fields[iField, 0].ToLower()) //這里與讀取DAY.DAT用法不同,判斷的是代碼而不是類型
{
case "dm":
record[iField] = code;
break;
case "rq":
intField = br.ReadInt32();
record[iField] = (intField == 0 ? "" : (date19700101.AddSeconds(intField)).ToString("yyyy-MM-dd HH:mm:ss"));
break;
case "zjcj":
case "zss":
case "je":
floatField = br.ReadSingle();
record[iField] = floatField.ToString("_jj_qz".IndexOf(this.GetCodeType(code)) > 0 ? "F3" : "F");
break;
case "mr1sl":
case "mr2sl":
case "mr3sl":
case "mc1sl":
case "mc2sl":
case "mc3sl":
record[iField] = br.ReadUInt16().ToString("D");
break;
case "mr1jg":
case "mr2jg":
case "mr3jg":
case "mc1jg":
case "mc2jg":
case "mc3jg":
float jg=br.ReadSByte();
if ("_jj_qz".IndexOf(this.GetCodeType(code)) > 0)
{
jg = Convert.ToSingle(record[2]) + jg / 1000;
record[iField] = jg.ToString("F3");
}
else
{
jg = Convert.ToSingle(record[2]) + jg / 100;
record[iField] = jg.ToString("F");
}
break;
case "xss":
record[iField] = "";//現(xiàn)手?jǐn)?shù)在下面計(jì)算
break;
case "mm":
int mm = br.ReadSByte();
record[iField] = "";
if (mm == -128) record[iField] = "內(nèi)盤"; //-128 = 0x80
if (mm == -64) record[iField] = "外盤"; //-64 = 0xC0
break;
}

}


recordList.Add(record);

r = r + 1;
iRecord = iRecord + 1;
}
iBlock = iBlock + 1;
}

//fs.Close();
float zssSaved = 0;
string[,] records = new string[recordList.Count, fieldCounts];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
for (int j = 0; j < fieldCounts; j++)
{
if (j == 5) //現(xiàn)手?jǐn)?shù)
{
record0[j]= (Convert.ToSingle(record0[3]) - zssSaved).ToString();
zssSaved = Convert.ToSingle(record0[3]);
}
records[i, j] = record0[j];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
catch (Exception e)
{
msg = e.Message;
}
#endregion
break;
}

}
msg = "返回空數(shù)組。";
return new string[1, 1] { { null } };

}
private string[,] GetBK(string code)//板塊定義數(shù)據(jù)
{
msg = "";
fileStruct fxjFileStruct = new fileStruct(DataTypes.bk);
if (code == null) code = "";
code = code.Trim().ToUpper();
ArrayList recordList = new ArrayList();
if (this.FxjDataPath == "")
{
msg = @"無法在注冊(cè)表中到分析家數(shù)據(jù)文件目錄,請(qǐng)自行將屬性 FxjDataPath設(shè)置為有效路徑,如c:\fxj\data\。";
return new string[1, 1] { { null } };
}
string FxjBlockPath = fxjDataPath;
FxjBlockPath = FxjBlockPath.ToUpper().Replace("\\DATA\\", "\\USERDATA\\BLOCK\\") ; //假設(shè)目錄中含有data文字
string FxjFile = FxjBlockPath + fxjFileStruct.fileName;

msg = "";
if (!File.Exists(FxjFile))
{
msg = "板塊文件無法找到。";
return new string[1, 1] { { null } };
}
try
{
this.checkFileStream(FxjFile);
string bklines="";string lb="";string bk="";
string bkFile = ""; string dmLines = ""; int n = -1;
bklines=System.Text.Encoding.Default.GetString(br.ReadBytes((int)fs.Length));
string[] bks = bklines.Replace("\r\n","\n").Split(new Char[] { ‘\n‘ });
for(int i =0 ; i<bks.Length;i++)
{
if (bks[i] != "")
{
bks[i] = bks[i].Trim();
if (bks[i].StartsWith("[") && bks[i].EndsWith("]"))
{
lb = bks[i].Replace("[","").Replace("]","");
}
else
{
bk = bks[i];
if (bk != "")
{
if (code == "" || (code!="" && bk.ToUpper()==code) )
{
bkFile = FxjBlockPath + bk + ".blk";
if (File.Exists(bkFile))
{
StreamReader bkReader = new StreamReader(bkFile);
bkReader.Read(); bkReader.Read();
dmLines = bkReader.ReadToEnd();
dmLines = dmLines.Replace("\x05", "\0").Replace("\0Z00", "\0\0\0\0").Replace("\0\0\0\0", ",");
string[] dms = dmLines.Split(‘,‘);
string[,] record = new string[dms.Length, 3];
for (int r = 0; r < dms.Length; r++)
{
if (dms[r] != "")
{
n = n + 1;
record[r, 0] = lb;
record[r, 1] = bk;
record[r, 2] = dms[r];
}
}
recordList.Add(record);
}
}
}
}
}
}
//fs.Close();
if (n > 0)
{
string[,] records = new string[n+1, 3];
int rr = 0;
for (int i = 0; i < recordList.Count; i++)
{
string[,] record0 = (string[,])recordList[i];
for (int j = 0; j < record0.GetLength(0); j++)
{
if (record0[j, 0] != null && record0[j, 1] != null && record0[j,2]!=null)
{
records[rr, 0] = record0[j, 0];
records[rr, 1] = record0[j, 1];
records[rr, 2] = record0[j, 2];
rr = rr + 1;
}
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
}
catch (Exception e)
{
msg = e.Message;
}
return new string[1, 1] { { null } };

}
private string[,] GetPJ(string code)//評(píng)級(jí)數(shù)據(jù)
{
msg = "";
fileStruct fxjFileStruct = new fileStruct(DataTypes.pj);
code = code.Trim().ToUpper();
ArrayList recordList = new ArrayList();
if (this.FxjDataPath == "")
{
msg = @"無法在注冊(cè)表中到分析家數(shù)據(jù)文件目錄,請(qǐng)自行將屬性 FxjDataPath設(shè)置為有效路徑,如c:\fxj\data\。";
return new string[1, 1] { { null } };
}
string fxjSubPath = fxjDataPath;
fxjSubPath = fxjSubPath.ToUpper().Replace("\\DATA\\", "\\USERDATA\\SelfData\\"); //假設(shè)目錄中含有data文字
string FxjFile = fxjSubPath + fxjFileStruct.fileName;

msg = "";
if (!File.Exists(FxjFile))
{
msg = fxjFileStruct.fileName +"無法找到。";
return new string[1, 1] { { null } };
}
try
{
this.checkFileStream(FxjFile);
int n = 0;
int pos =fxjFileStruct.startAddress + n * fxjFileStruct.recordSize;
fs.Position = pos;
while (br.PeekChar()!=-1)
{
string[] record = new string[3];
pos = fxjFileStruct.startAddress + n * fxjFileStruct.recordSize;
fs.Position = pos;
record[0]=System.Text.Encoding.Default.GetString(br.ReadBytes(8));//dm
if (code==""||(code!="" && code==record[0]))
{
fs.Position = pos+12;
record[2] = System.Text.Encoding.Default.GetString(br.ReadBytes(244));
record[1] = record[2].Substring(0,2).Trim();
record[2] = record[2].Replace("\0","").Trim();
if(record[0]!="") recordList.Add(record);
}
n = n + 1;
}
//fs.Close();
if (n > 0)
{
string[,] records = new string[recordList.Count, 3];
for (int i = 0; i < recordList.Count; i++)
{
string[] record0 = (string[])recordList[i];
if (record0[0] != null)
{
records[i, 0] = record0[0];
records[i, 1] = record0[1];
records[i, 2] = record0[2];
}
}
if (records.GetLength(0) == 0) msg = "沒有讀到數(shù)據(jù)!";
return records;
}
}
catch (Exception e)
{
msg = e.Message;
}
return new string[1, 1] { { null } };

}
private string[,] GetHqfq(DataTypes dataType, string code, string newFileName)//復(fù)權(quán)價(jià)格,分紅再投資,向前復(fù)權(quán)法
{
FxjData fxj = new FxjData();
string[,] hq=fxj.GetData("hq", code, newFileName);
if (fxj.Error != 0 || hq.GetLength(1)<4 ) return new string[1, 1] { { null } };
string[,] x = new string[hq.GetLength(0),9];
string[,] cq = fxj.GetData("cq", code, newFileName);
string fmt = "_jj_qz".IndexOf(this.GetCodeType(code)) > 0 ? "F3" : "F";
if (fxj.Error != 0 || cq.GetLength(1) < 4 || cq.GetLength(0)==0) //沒有除權(quán)信息
{
for (int i = 0; i < hq.GetLength(0); i++)
{
for (int j = 0; j < hq.GetLength(1); j++)
{
x[i, j] = hq[i, j];
}
if (i == 0)
{
x[i, hq.GetLength(1)] = "0.00000";
}
else
{
x[i, hq.GetLength(1)] = (Single.Parse(hq[i, 5]) / Single.Parse(hq[i - 1, 5]) - 1).ToString("0.00000");
}
}
}
else //有除權(quán)信息
{
DateTime[] cqdt = new DateTime[cq.GetLength(0)];
for (int j = 0; j < cq.GetLength(0); j++) cqdt[j] = new DateTime(int.Parse(cq[j, 1].Split(‘-‘)[0]), int.Parse(cq[j, 1].Split(‘-‘)[1]), int.Parse(cq[j, 1].Split(‘-‘)[2]));
int i0 = hq.GetLength(0) - 1;
DateTime hqdt_1,hqdt;
double kp_1,zg_1,zd_1,sp_1,kp,zg,zd,sp,kpx,zgx,zdx,spx,sgbl,kpsyl,zgsyl,zdsyl,spsyl, pgbl, pgjg, fh;
for (int k = 0; k < 8; k++) x[i0, k] = hq[i0, k]; //最后一條記錄
x[0, 8] = "0.00000";
kpx = double.Parse(x[i0, 2]);
zgx = double.Parse(x[i0, 3]);
zdx = double.Parse(x[i0, 4]);
spx = double.Parse(x[i0, 5]);
for (int i = i0; i > 0; i--)
{
sgbl = 0; pgbl = 0; pgjg = 0; fh = 0;
hqdt_1 = new DateTime(int.Parse(hq[i - 1, 1].Split(‘-‘)[0]), int.Parse(hq[i - 1, 1].Split(‘-‘)[1]), int.Parse(hq[i - 1, 1].Split(‘-‘)[2]));
hqdt = new DateTime(int.Parse(hq[i, 1].Split(‘-‘)[0]), int.Parse(hq[i, 1].Split(‘-‘)[1]), int.Parse(hq[i, 1].Split(‘-‘)[2]));
for (int j = 0; j < cq.GetLength(0); j++)
{
if (hqdt_1 < cqdt[j] && cqdt[j] <= hqdt)
{
sgbl = double.Parse(cq[j, 2]);
pgbl = double.Parse(cq[j, 3]);
pgjg = double.Parse(cq[j, 4]);
fh = double.Parse(cq[j, 5]);
}
}
x[i-1, 0] = hq[i-1, 0];//dm
x[i-1, 1] = hq[i-1, 1];//rq
//syl=1+第t日收益率 =( t日收盤價(jià)*(1+送股比例+配股比例)+分紅金額-配股價(jià)格*配股比例)/(t-1日收盤價(jià))
kp = double.Parse(hq[i, 2]);
zg = double.Parse(hq[i, 3]);
zd = double.Parse(hq[i, 4]);
sp = double.Parse(hq[i, 5]);
kp_1 = double.Parse(hq[i-1, 2]);
zg_1 = double.Parse(hq[i-1, 3]);
zd_1 = double.Parse(hq[i-1, 4]);
sp_1 = double.Parse(hq[i-1, 5]);
kpsyl = (kp * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / kp_1;
zgsyl = (zg * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / zg_1;
zdsyl = (zd * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / zd_1;
spsyl = (sp * (1 + sgbl + pgbl) + fh - pgjg * pgbl) / sp_1;
kpx = kpx / kpsyl;
zgx = zgx / zgsyl;
zdx = zdx / zdsyl;
spx = spx / spsyl;
x[i - 1, 2] = kpx.ToString(fmt);
x[i - 1, 3] = zgx.ToString(fmt);
x[i - 1, 4] = zdx.ToString(fmt);
x[i - 1, 5] = spx.ToString(fmt);
x[i - 1, 6] = hq[i - 1, 6];//sl 成交量未復(fù)權(quán)
x[i - 1, 7] = hq[i - 1, 7];//je
x[i, 8] = (spsyl - 1).ToString("0.00000");//spsyl 收盤價(jià)收益率

}

}

return x;

}
}
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多