当前位置:   article > 正文

java读取通达信day_读取通达信的股票日线数据例子

java读取通达信.day文件

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; }

}

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/171177
推荐阅读
相关标签
  

闽ICP备14008679号