Beispiel #1
0
 bool bigInc(StockDayData data1, StockDayData data2)
 {
     //return data1.Open > data1.Close && data2.Open > data2.Close;
     return(data2.Open > data1.Close * 1.08m);
 }
Beispiel #2
0
 bool dayInc(StockDayData data1, StockDayData data2)
 {
     //return data1.Open > data1.Close && data2.Open > data2.Close;
     return(data2.Open < data2.Close && data2.Vol > data1.Vol);
 }
Beispiel #3
0
 bool closeDec(StockDayData data1, StockDayData data2)
 {
     return(data1.Close > data2.Close);
 }
Beispiel #4
0
 bool dayDec(StockDayData data1, StockDayData data2)
 {
     //return data1.Open > data1.Close && data2.Open > data2.Close;
     return(data2.Open > data2.Close && data2.Vol > data1.Vol * 0.8);
 }
Beispiel #5
0
        static public List <StockDayData> getData(string path)
        {
            Stream networkStream = getStockStream(path);

            if (networkStream == null)
            {
                return(null);
            }

            int readSize = 0;

            byte[] buffer = new byte[1024 * 10];


            readSize = networkStream.Read(buffer, 0, buffer.Length);
            string result2  = Encoding.ASCII.GetString(buffer, 0, readSize);
            int    fileSize = 19072;

            if (result2.Equals("NO"))
            {
                networkStream.Close();
                return(null);
            }
            else
            {
                string length = Encoding.ASCII.GetString(buffer, 0, readSize);
                fileSize = int.Parse(length);
            }

            byte[] stockCodeBuf = Encoding.ASCII.GetBytes("READY");
            networkStream.Write(stockCodeBuf, 0, stockCodeBuf.Length);

            //int readCount = 0;
            //byte[] fileBuffer = new byte[fileSize];
            //while (readCount < fileSize)
            //{
            //    readSize = networkStream.Read(fileBuffer, 0, fileBuffer.Length);
            //    readCount += readSize;
            //    //Console.WriteLine("Read part. size = " + readSize + "/ readCount = " + readCount);
            //}
            //networkStream.Close();

            ////////////////////////////////////////////////////////////////////////////////////////////

            //using (MemoryStream ms = new MemoryStream(fileBuffer))
            {
                List <StockDayData> list = new List <StockDayData>();
                BinaryReader        br   = new BinaryReader(networkStream);
                int days = fileSize / 32;
                for (int i = 0; i < days; i++)
                {
                    StockDayData item = new StockDayData();
                    //item.DataDate =DateTime.Parse(new string(br.ReadChars(8)));
                    int date = br.ReadInt32();
                    if (date == 0)
                    {
                        break;
                    }
                    int year  = date / 10000;
                    int month = int.Parse(date.ToString().Substring(4, 2));
                    int day   = int.Parse(date.ToString().Substring(6, 2));
                    //item.DataDate = new DateTime(year, month, day);

                    int    open   = br.ReadInt32();
                    int    high   = br.ReadInt32();
                    int    low    = br.ReadInt32();
                    int    close  = br.ReadInt32();
                    Single amount = br.ReadSingle();
                    //Int32 amount = br.ReadInt32();
                    decimal am       = Convert.ToDecimal(amount);
                    long    amstr    = Convert.ToInt64(amount);
                    int     vol      = br.ReadInt32();
                    int     preclose = 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);
                    //list.Insert(0, item);
                }
                br.Close();
                return(list);
            }
        }