Ejemplo n.º 1
0
 public string LookupDataFile(string Code, CommonDataProvider cdp, ref int Fields)
 {
     if (cdp != null)
     {
         cdp.SetStringData("Code", Code);
     }
     foreach (Master m in Masters)
     {
         if (string.Compare(m.symbol, Code, true) == 0)
         {
             if (cdp != null)
             {
                 cdp.SetStringData("Name", m.issue_name);
             }
             Fields = m.num_fields;
             return(FilePath + "F" + m.file_num + ".DAT");
         }
     }
     if (XMasters != null)
     {
         foreach (XMaster m in XMasters)
         {
             if (string.Compare(m.StockSymbol, Code, true) == 0)
             {
                 if (cdp != null)
                 {
                     cdp.SetStringData("Name", m.StockName);
                 }
                 return(FilePath + "F" + m.Fn + ".MWD");
             }
         }
     }
     return("");
 }
Ejemplo n.º 2
0
 public CommonDataProvider MergeRealtime(CommonDataProvider cdp, string Code)
 {
     if (cdp != null)
     {
         if (DownloadRealTimeQuote && CacheTimeSpan.Days >= 1)
         {
             DataPacket dp = DataPacket.DownloadFromYahoo(Code);
             cdp.Merge(dp);
             cdp.SetStringData("Name", dp.StockName);
         }
         SetStrings(cdp, Code);
     }
     return(cdp);
 }
Ejemplo n.º 3
0
        public override IDataProvider GetData(string Code, int Count)
        {
            string Filename = Root + Code + Ext;

            if (File.Exists(Filename))
            {
                using (StreamReader sr = new StreamReader(Filename))
                {
                    CommonDataProvider cdp = LoadYahooCSV(sr);
                    cdp.SetStringData("Code", Code);
                    return(cdp);
                }
            }
            return(CommonDataProvider.Empty);
        }
Ejemplo n.º 4
0
 public override void SetStrings(CommonDataProvider cdp, string Code)
 {
     cdp.SetStringData("Code", Code);
 }
Ejemplo n.º 5
0
 public virtual void SetStrings(CommonDataProvider cdp, string Code)
 {
     cdp.SetStringData("Code", Code);
 }
Ejemplo n.º 6
0
        public override IDataProvider GetData(string Code, int Count)
        {
            CommonDataProvider cdp = new CommonDataProvider(this);

            if (Code == null)
            {
                Code = "MSFT";
            }
            Random Rnd = new Random(Code.GetHashCode());

            /// ds[0] : OPEN
            /// ds[1] : HIGH
            /// ds[2] : LOW
            /// ds[3] : CLOSE
            /// ds[4] : VOLUME
            /// ds[5] : DATE
            double[][] ds = new double[6][];
            double[]   dd = null;
            if (IntradayInfo != null)
            {
                //ExchangeIntraday ei = ExchangeIntraday.US;
                dd       = IntradayInfo.GetMinuteDate(DateTime.Today.AddDays(-7), DateTime.Today);
                MaxCount = dd.Length;
            }

            for (int i = 0; i < ds.Length; i++)
            {
                ds[i] = new double[MaxCount];
            }

            for (int i = 0; i < MaxCount; i++)
            {
                if (i == 0)
                {
                    ds[0][i] = 20;
                    ds[3][i] = 21;
                    ds[4][i] = 100000;
                }
                else
                {
                    ds[0][i] = ds[0][i - 1] + Rnd.NextDouble() - 0.48;
                    ds[3][i] = ds[0][i - 1] + Rnd.NextDouble() - 0.48;
                    ds[4][i] = Math.Abs(ds[4][i - 1] + Rnd.Next(100000) - 50000);
                }
                ds[1][i] = Math.Max(ds[0][i], ds[3][i]) + Rnd.NextDouble();
                ds[2][i] = Math.Min(ds[0][i], ds[3][i]) - Rnd.NextDouble();
                if (IntradayInfo != null)
                {
                    ds[5][i] = dd[i];
                }
                else
                {
                    ds[5][i] = DateTime.Today.AddDays(i - MaxCount).ToOADate();
                }
            }
            cdp.LoadBinary(ds);
            cdp.SetStringData("Code", Code);
//			if (IntradayInfo!=null)
//				cdp.SetStringData("Code",Code+"@Random Intraday");
//			else cdp.SetStringData("Code",Code+"@Random");
            return(cdp);
        }