c#读取通达信历史数据的方法

public Bar ReadBarMin(BinaryReader br, int instrumentId, long size)
{

int date = br.ReadUInt16();
int min = br.ReadUInt16();
// 股票2位,国债回购3位,300ETF是4位
double open = Convert.ToDouble(Convert.ToDecimal(br.ReadSingle()));
double high = Convert.ToDouble(Convert.ToDecimal(br.ReadSingle()));
double low = Convert.ToDouble(Convert.ToDecimal(br.ReadSingle()));
double close = Convert.ToDouble(Convert.ToDecimal(br.ReadSingle()));
double amount = Convert.ToDouble(Convert.ToDecimal(br.ReadSingle())); // 成交额不保存
int vol = br.ReadInt32();
int reserve = br.ReadInt32(); // 保留字

int year = date / 2048 + 2004;
int month = date % 2048 / 100;
int day = date % 2048 % 100;

int HH = min / 60;
int mm = min % 60;
if ((HH == 9) && (mm == 1 || mm == 5))
{
dayM = day;
momM = month;

}
if((HH>20)&&(HH<24))
{
day=dayM;
month = momM;
}

DateTime closeDataTime = new DateTime(year, month, day, HH, mm, 0);
DateTime openDateTime = closeDataTime.AddSeconds(-size);

 

你可能感兴趣的:(C#)