赞
踩
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingStockAnalysisApplication.Entity;namespaceStockAnalysisApplication
{publicpartialclassTdxDataReaderSample : Form
{publicTdxDataReaderSample()
{
InitializeComponent();
}privatevoidtoolStripButton1_Click(objectsender, EventArgs e)
{//char[] aa={'1','2'};//this.Text =aa.ToString();//MessageBox.Show(new string(aa));if(openFileDialog1.ShowDialog()==DialogResult.OK)
{stringfilename=openFileDialog1.FileName;
FileStream fs=File.OpenRead(filename);
BinaryReader br=newBinaryReader(fs);intdays=(int)fs.Length/32;
Listlist=newList();for(inti=0; i
{
StockDayData item=newStockDayData();//item.DataDate =DateTime.Parse(new string(br.ReadChars(8)));intdate=br.ReadInt32();intyear=date/10000;intmonth=int.Parse(date.ToString().Substring(4,2));intday=int.Parse(date.ToString().Substring(6,2));//item.DataDate = new DateTime(year, month, day);intopen=br.ReadInt32();inthigh=br.ReadInt32();intlow=br.ReadInt32();intclose=br.ReadInt32();
Single amount=br.ReadSingle();//Int32 amount = br.ReadInt32();decimalam=Convert.ToDecimal(amount);longamstr=Convert.ToInt64(amount);intvol=br.ReadInt32();intpreclose=br.ReadInt32();//Decimal open = Convert.ToDecimal(br.ReadSingle());item.Date=date;
item.Open=Convert.ToDecimal (open/100m);
item.High=Convert.ToDecimal(high/100m);
item.Low=Convert.ToDecimal(low/100m);
item.Close=Convert.ToDecimal(close/100m);
item.Amount=amstr;
item.Vol=vol;
item.PreClose=Convert.ToDecimal(preclose/100m);
list.Add(item);
}
br.Close();
fs.Close();this.dataGridView1.DataSource=list;
}
}
}publicclassStockDayData
{privateintmDate;publicintDate
{get{returnmDate; }set{ mDate=value; }
}privatedecimalmOpen;publicdecimalOpen
{get{returnmOpen; }set{ mOpen=value; }
}privatedecimalmHigh;publicdecimalHigh
{get{returnmHigh; }set{ mHigh=value; }
}privatedecimalmLow;publicdecimalLow
{get{returnmLow; }set{ mLow=value; }
}privatedecimalmClose;publicdecimalClose
{get{returnmClose; }set{ mClose=value; }
}privatelongmAmount;publiclongAmount
{get{returnmAmount; }set{ mAmount=value; }
}privateintmVol;publicintVol
{get{returnmVol; }set{ mVol=value; }
}privatedecimalmPreClose;publicdecimalPreClose
{get{returnmPreClose; }set{ mPreClose=value; }
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。