示例#1
0
 /// <summary>
 /// Merge streaming data
 /// </summary>
 /// <param name="sd">Streaming Data</param>
 /// <returns>true if merged, false if this is a new data</returns>
 public bool Merge(DataPacket dp, DataCycle dc)
 {
     if (!dc.SameSequence(dp.Date, Date))
     //if (dp.Date>=Date.AddMinutes(1))
     {
         Open     = dp.Close;
         High     = dp.Close;
         Low      = dp.Close;
         Close    = dp.Close;
         AdjClose = dp.Close;
         Volume   = dp.Volume;
         Date     = dp.Date;
         return(false);
     }
     else
     {
         Close    = dp.Close;
         AdjClose = Close;
         High     = Math.Max(High, Close);
         Low      = Math.Min(Low, Close);
         Volume   = dp.Volume;
         Date     = dp.Date;
         return(true);
     }
 }
示例#2
0
        static public FormulaChart ShowObjectOnChart(FormulaChart fc, TextReader reader, DataManagerBase dmb,
                                                     bool ObjectLayout)
        {
            ObjectManager om = FromChart(fc);

            om.ReadXml(reader, false);
            if (om.startTime != 0.0)
            {
                fc.StartTime = DateTime.FromOADate(om.startTime);
            }
            if (om.endTime != 0.0)
            {
                fc.EndTime = DateTime.FromOADate(om.endTime);
            }

            if (ObjectLayout && om.indicators != null)
            {
                fc.Areas.Clear();
                if (om.indicators != null)
                {
                    fc.StringsToArea(om.indicators.Split(';'));
                }
                fc.SetAreaPercent(om.areaPercent);
                fc.Rect = new Rectangle(0, 0, om.width, om.height);
            }
            om.SetCanvas(om.Canvas);
            if (om.skin != null)
            {
                fc.SetSkin(om.skin);
            }

            fc.StickRenderType = om.stickRenderType;
            if (om.symbol != null && om.symbol != "")
            {
                //if (om.latestTime!=0.0)
                //	dmb.EndTime = DateTime.FromOADate(om.latestTime);
                CommonDataProvider cdp = (CommonDataProvider)dmb[om.symbol];
                cdp.DataCycle   = DataCycle.Parse(om.currentDataCycle);
                fc.DataProvider = cdp;
            }
            FormulaArea fa = fc.MainArea;

            if (fa != null)
            {
                fa.StockRenderType = om.stockRenderType;
            }

            if (om.minPrice != 0)
            {
                if (fa != null)
                {
                    fa.AxisY.MinY      = om.minPrice;
                    fa.AxisY.MaxY      = om.maxPrice;
                    fa.AxisY.AutoScale = false;
                }
            }
            return(fc);
        }
示例#3
0
 /// <summary>
 /// Get CommonDataProvider for symbols, override one of the GetData and GetDatas is ok.
 /// </summary>
 /// <param name="symbols">stock symbols</param>
 /// <param name="dataCycle">data cycle</param>
 /// <param name="startTime">start time</param>
 /// <param name="endTime">end time</param>
 /// <returns>Array of CommonDataProvider</returns>
 public virtual CommonDataProvider[] GetDatas(string[] symbols, DataCycle dataCycle, DateTime startTime, DateTime endTime)
 {
     if (symbols.Length > 0)
     {
         return new CommonDataProvider[] { GetData(symbols[0], dataCycle, startTime, endTime) }
     }
     ;
     return(null);
 }
 public override CommonDataProvider GetData(string symbols, DataCycle dataCycle, DateTime startTime, DateTime endTime)
 {
     byte[] bs = DownloadBinary(symbols, "http://subscribe.easychart.net/member/datafeed.aspx?f=BinaryHistory&AddWhenNoSymbol=1&Symbol=" + symbols);
     if (bs != null)
     {
         CommonDataProvider cdp = new CommonDataProvider(null);
         cdp.LoadByteBinary(bs);
         cdp.SetStringData("Code", symbols.ToUpper());
         return(cdp);
     }
     return(null);
 }
示例#5
0
//		private void miOverlayVolume_Click(object sender, System.EventArgs e)
//		{
//			ChartControl.DefaultFormulas = "MAIN#OverlayV!#MA(14)#MA(60);RSI(14)#RSI(28);MACD";
//		}

        /// <summary>
        /// Assign data manager to current chart control
        /// </summary>
        /// <param name="dmb">Data manager to assign</param>
        /// <param name="DefaultSymbol"></param>
        /// <param name="DefaultCycle"></param>
        /// <param name="DefaultBars"></param>
        /// <returns></returns>
        private string LoadDataManager(DataManagerBase dmb, string DefaultSymbol, DataCycle DefaultCycle, int DefaultBars)
        {
            string s = InputBox.ShowInputBox("Quote:", DefaultSymbol);

            if (s != "")
            {
                ChartControl.DataManager      = dmb;
                ChartControl.Symbol           = s;
                ChartControl.StockBars        = DefaultBars;
                ChartControl.CurrentDataCycle = DefaultCycle;
            }
            return(s);
        }
示例#6
0
        private void miForexText_Click(object sender, System.EventArgs e)
        {
            MemoryDataManager mdm = new MemoryDataManager(new ForexTextDataManager());
            string            s   = LoadDataManager(mdm, "EURUSD", DataCycle.Parse("Minute15"), 150) + "=X";

//			if (dcbForex==null)
//			{
//				dcbForex = new YahooDataClient();
//				dcbForex.OnStreamingData+=new StreamingDataChanged(dcb_OnStreamingData);
//				dcbForex.UtcStreamingTime = false;
//				dcbForex.StartStreaming(s);
//			}
//			else dcbForex.SetStreamingSymbol(s);
        }
        static public DataPacket MergeFile(string Filename, DataPacket dp, DataCycle dc)
        {
            using (FileStream fs = new FileStream(Filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                byte[] bs = new byte[DataPacket.PacketByteSize];
                if (fs.Length >= bs.Length)
                {
                    fs.Seek(-bs.Length, SeekOrigin.End);
                }
                int i = fs.Read(bs, 0, bs.Length);

                DataPacket dpExist = DataPacket.FromBytes(bs);
                dpExist.Symbol = dp.Symbol;
                if (dpExist.Merge(dp, dc))
                {
                    fs.Seek(-bs.Length, SeekOrigin.End);
                }
                bs = dpExist.ToByte();
                fs.Write(bs, 0, bs.Length);
                return(dpExist);
            }
        }
示例#8
0
        /// <summary>
        /// Get stock data of certain data cycle
        /// </summary>
        /// <param name="dc">The data cycle</param>
        /// <returns></returns>
        public Hashtable GetCycleData(DataCycle dc)
        {
            if (dc.CycleBase == DataCycleBase.DAY && dc.Repeat == 1 && !Adjusted)
            {
                return(htData);
            }
            else
            {
                Hashtable htCycle = (Hashtable)htAllCycle[dc.ToString()];
                if (htCycle == null)
                {
                    Hashtable ht;
                    if (DataCycle.CycleBase < DataCycleBase.DAY)
                    {
                        ht = htRealtime;
                    }
                    else
                    {
                        ht = htData;
                    }
                    if (ht == null)
                    {
                        return(ht);
                    }

                    double[] ODATE = (double[])ht["DATE"];
                    if (ODATE == null)
                    {
                        return(null);
                    }

                    int[] NEWDATE = new int[ODATE.Length];

                    int Last = int.MinValue;
                    int j    = -1;
                    int Num;
                    for (int i = 0; i < ODATE.Length; i++)
                    {
                        Num = DataCycle.GetSequence(ODATE[i]);
                        if (Num > Last)
                        {
                            j++;
                        }
                        NEWDATE[i] = j;
                        Last       = Num;
                    }

                    if (ht["CLOSE"] != null)
                    {
                        if (ht["OPEN"] == null)
                        {
                            ht["OPEN"] = ht["CLOSE"];
                        }
                        if (ht["HIGH"] == null)
                        {
                            ht["HIGH"] = ht["CLOSE"];
                        }
                        if (ht["LOW"] == null)
                        {
                            ht["LOW"] = ht["CLOSE"];
                        }
                    }

                    htCycle = new Hashtable();
                    foreach (string s in ht.Keys)
                    {
                        htCycle[s] = new double[j + 1];
                    }

                    bool     NeedAdjust = (Adjusted && ht["ADJCLOSE"] != null && ht["CLOSE"] != null);
                    double[] CLOSE      = (double[])ht["CLOSE"];
                    double[] ADJCLOSE   = (double[])ht["ADJCLOSE"];

                    foreach (string s in ht.Keys)
                    {
                        bool           DoAdjust = NeedAdjust;
                        MergeCycleType mct;
                        try
                        {
                            mct = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), s);
                        }
                        catch
                        {
                            DoAdjust = false;
                            if (s == "VOLUME" || s == "AMOUNT")
                            {
                                mct = MergeCycleType.SUM;
                            }
                            else
                            {
                                mct = MergeCycleType.CLOSE;
                            }
                        }
                        MergeCycle(ODATE, NEWDATE, CLOSE, ADJCLOSE, (double[])ht[s], (double[])htCycle[s], mct, DoAdjust);
                    }
                    htAllCycle[dc.ToString()] = htCycle;
                }
                return(htCycle);
            }
        }
示例#9
0
 public string GetUnique()
 {
     return(DataCycle.ToString());
 }
示例#10
0
 /// <summary>
 /// Get CommonDataProvider for symbol, override one of the GetData and GetDatas is ok.
 /// </summary>
 /// <param name="symbol">stock symbol</param>
 /// <param name="dataCycle">data cycle</param>
 /// <param name="startTime">start time</param>
 /// <param name="endTime">end time</param>
 /// <returns>CommonDataProvider</returns>
 public virtual CommonDataProvider GetData(string symbol, DataCycle dataCycle, DateTime startTime, DateTime endTime)
 {
     return(GetDatas(new string[] { symbol }, dataCycle, startTime, endTime)[0]);
 }
示例#11
0
 private void miLoadBond_Click(object sender, System.EventArgs e)
 {
     LoadDataManager(new BondTextDataManager(), "ZT1", DataCycle.Parse("Minute10"), 200);
 }
示例#12
0
 public DataManager(InstrumentInfo instrumentInfo, DataCycle dataCycle)
 {
 }
示例#13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int    Height = 800;
            int    Width  = 600;
            Bitmap B;

            try
            {
                long Start = DateTime.Now.Ticks;

                ExchangeIntraday ei        = null;
                DateTime         StartTime = DateTime.Today.AddMonths(-6);
                DateTime         EndTime   = DateTime.Today;

                string Param = Request.QueryString["Span"];
                if (Param != null && Param != "")
                {
                    DataCycle dc;
                    if (Param.Length > 2)
                    {
                        dc = DataCycle.Parse(Param);
                    }
                    else
                    {
                        dc = new DataCycle(DataCycleBase.MONTH, Tools.ToIntDef(Param, 6));
                    }
                    StartTime = EndTime - dc;
                    //StartTime = EndTime.AddMonths(-Tools.ToIntDef(Param,6));
                }

                //Create financial chart instance
                FormulaChart fc = new FormulaChart();

                string Main = Request.QueryString["Main"];
                if (Main == null || Main == "")
                {
                    fc.AddArea("MAIN", 3);
                }
                else
                {
                    fc.AddArea(Main, 3);
                }

                string QuoteCode = Request.QueryString["Code"];
                if (QuoteCode == null)
                {
                    QuoteCode = "";
                }

                DataManagerBase dmb;
                Param = Request.QueryString["Provider"];
                if (Param == null)
                {
                    Param = "";
                }
                if (string.Compare(Param, "DB", true) == 0)
                {
                    //Create DBDataManager , Get stock data from sql server.
                    dmb = new DBDataManager();
                    ((DBDataManager)dmb).AutoYahooToDB =
                        Request.QueryString["His"] != "0" && Config.AutoYahooToDB == 1;
                    if (Request.QueryString["RT"] == "1")
                    {
                        ((DataManagerBase)dmb).DownloadRealTimeQuote = true;
                    }
                }
                else if (Param == "" || string.Compare(Param, "Yahoo", true) == 0)
                {
                    //Create YahooDataManager , Get stock data from yahoo.
                    dmb = new YahooDataManager();
                    ((YahooDataManager)dmb).CacheRoot = HttpRuntime.AppDomainAppPath + "Cache\\";
                    if (Config.IncludeTodayQuote == 1)
                    {
                        ((DataManagerBase)dmb).DownloadRealTimeQuote = true;
                    }
                }
                else
                {
                    string ManagerName = "WebDemos." + Param + "DataManager";
                    Type   t           = Type.GetType(ManagerName);
                    if (t == null)
                    {
                        throw new Exception(ManagerName + " not found!");
                    }
                    dmb = (DataManagerBase)Activator.CreateInstance(t);
                    if (dmb is IntraDataManagerBase)
                    {
                        ei = ExchangeIntraday.GetExchangeIntraday(Utils.GetExchange(QuoteCode));
                        ((CacheDataManagerBase)dmb).CacheTimeSpan = TimeSpan.FromMilliseconds(Config.IntradayCacheTime * 1000);
                        //((CacheDataManagerBase)dmb).EnableFileCache = false;

                        StartTime = ei.GetCurrentTradingDay();
                        EndTime   = StartTime.AddSeconds(3600 * 24 - 1);
                        QuoteCode = Utils.GetPart1(QuoteCode);
                    }
                    dmb.EndTime   = Utils.ToDateDef(Request.QueryString["End"], EndTime);
                    dmb.StartTime = Utils.ToDateDef(Request.QueryString["Start"], StartTime);
                }

                int MainIndex = 0;

                if (Config.SymbolCase == "Upper")
                {
                    QuoteCode = QuoteCode.ToUpper();
                }
                else if (Config.SymbolCase == "Lower")
                {
                    QuoteCode = QuoteCode.ToLower();
                }

                string[] QuoteCodes = QuoteCode.Split(',');
                string   Over       = "";
                QuoteCode = QuoteCodes[0];
                for (int i = 1; i < QuoteCodes.Length; i++)
                {
                    if (Over != "")
                    {
                        Over += ";";
                    }
                    Over += "Compare(" + QuoteCodes[i] + ")";
                }

                Param = Request.QueryString["IND"];
                string[] Inds = null;
                if (Param != null && Param != "")
                {
                    Inds = Param.Split(';');
                }

                //Set stock chart size
                Param = Request.QueryString["Size"];
                try
                {
                    if (Param != null && Param != "")
                    {
                        int i = Param.IndexOf('*');
                        if (i > 0)
                        {
                            Width  = int.Parse(Param.Substring(0, i));
                            Height = int.Parse(Param.Substring(i + 1));
                        }
                        else
                        {
                            Width  = int.Parse(Param);
                            Height = Width * 3 / 4;
                            if (Inds != null && Inds.Length > 1)
                            {
                                Height += Height / 5 * (Inds.Length - 2);
                            }
                            Height += 36;
                        }
                    }
                }
                catch
                {
                }

                CommonDataProvider DataProvider = (CommonDataProvider)dmb[QuoteCode];
                if (DataProvider == null)
                {
                    throw new Exception(QuoteCode + " not found!");
                }
                if (dmb is IntraDataManagerBase)
                {
                    fc.FixedTime = object.Equals(Request.QueryString["Fix"], "1");
                    if (fc.FixedTime)
                    {
                        DataProvider.IntradayInfo = ei;
                    }
                }

                if (DataProvider.Count == 0)
                {
                    throw new Exception("No data found!");
                }
                fc[MainIndex].Formulas[0].Name = QuoteCode;

                //Add MA lines to main stock view
                Param = Request.QueryString["MA"];
                if (Param != null && Param != "")
                {
                    foreach (string s in Param.Split(';'))
                    {
                        if (s != "")
                        {
                            fc[MainIndex].AddFormula("FML.MA(" + s + ")");
                        }
                    }
                }

                //Add EMA lines to main stock view
                Param = Request.QueryString["EMA"];
                if (Param != null && Param != "")
                {
                    foreach (string s in Param.Split(';'))
                    {
                        if (s != "")
                        {
                            fc[MainIndex].AddFormula("FML.EMA(" + s + ")");
                        }
                    }
                }

                //Add override lines to main stock view
                Param = Request.QueryString["OVER"];
                if (Param != null && Param != "")
                {
                    if (Over != "")
                    {
                        Param = Param + ";" + Over;
                    }
                }
                else
                {
                    Param = Over;
                }

                if (dmb is IntraDataManagerBase)
                {
                    string s = DataProvider.GetStringData("LastPrice");
                    if (s != null && s != "")
                    {
                        double d = double.Parse(s);
                        s = "DotLine(" + d.ToString("f2") + ")";
                        if (Param != null && Param != "")
                        {
                            Param += ";" + s;
                        }
                        else
                        {
                            Param = s;
                        }
                    }
                }

                if (Param != null && Param != "")
                {
                    //foreach(string s in Param.Split(';'))
                    string[] ss = Param.Split(';');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        string s = ss[i].ToUpper();
                        if (s != "")
                        {
                            if (s == "AreaBB")
                            {
                                fc[MainIndex].InsertFormula(0, "FML." + s);
                            }
                            else
                            {
                                fc[MainIndex].AddFormula("FML." + s);
                            }
                        }
                    }
                }

                //Add indicators to stock chart
                if (Inds != null)
                {
                    foreach (string s in Inds)
                    {
                        if (s != "")
                        {
                            int k = s.IndexOf("{U}");
                            if (k > 0)
                            {
                                fc.InsertArea(MainIndex, "FML." + s.Substring(0, k));
                                MainIndex++;
                            }
                            else
                            {
                                fc.AddArea("FML." + s);
                            }
                        }
                    }
                }

                //Apply build-in stock chart skin
                Param = Request.QueryString["Skin"];
                if (Param == null || Param == "")
                {
                    Param = Config.DefaultSkin;
                }
                FormulaSkin fs = FormulaSkin.GetSkinByName(Param);
                if (fs != null)
                {
                    if (Config.YAxisFormat != "")
                    {
                        fs.AxisY.Format = Config.YAxisFormat;
                    }

                    if (Config.ShowXAxisInLastArea)
                    {
                        fs.ShowXAxisInLastArea = true;
                    }

                    fc.SetSkin(fs);
                }

                try
                {
                    fc.LatestValueType = (LatestValueType)Enum.Parse(typeof(LatestValueType), Config.LatestValueType, true);
                }
                catch
                {
                }

                //Add compare line to other stocks
                Param = Request.QueryString["COMP"];
                if (Param != null && Param != "")
                {
                    foreach (string s in Param.Split(';', ','))
                    {
                        if (s != "")
                        {
                            fc[MainIndex].AddFormula("COMPARE(" + s + ")");
                        }
                    }
                    fc[MainIndex].AxisY.ShowAsPercent = true;
                    fc[MainIndex].AxisY.Format        = "p1";
                    fc.LatestValueType = LatestValueType.None;
                }

                //Set stock chart time period
                fc.EndTime             = Utils.ToDateDef(Request.QueryString["End"], EndTime);
                fc.StartTime           = Utils.ToDateDef(Request.QueryString["Start"], StartTime);
                DataProvider.DataCycle = DataCycle.Parse(Request.QueryString["Cycle"]);

                //Set X-Axis format
                string XFormat = Request.QueryString["XFormat"];
                if (XFormat != null && XFormat != "")
                {
                    fc.AxisXFormat = XFormat;
                    fc.AllXFormats = null;
                }

                //Set Y-Axis format
                string YFormat = Request.QueryString["YFormat"];
                if (YFormat != null && YFormat != "")
                {
                    fc.AxisYFormat = YFormat;
                }

                //Set X-Axis cycle
                string XCycle = Request.QueryString["XCycle"];
                if (XCycle != null && XCycle != "")
                {
                    fc.DataCycle = DataCycle.Parse(XCycle);
                }

                //Set render type : Bar , Candle or Line
                Param = Request.QueryString["Type"];
                if (Param != null && Param != "")
                {
                    StockRenderType srt;
                    if (Param.Length == 1)
                    {
                        srt = (StockRenderType)int.Parse(Param);
                    }
                    else
                    {
                        srt = (StockRenderType)Enum.Parse(typeof(StockRenderType), Param, true);
                    }
                    fc[MainIndex].StockRenderType = srt;
                }

                //Set Scale type : Normal or Log
                Param = Request.QueryString["Scale"];
                if (Param != null && Param != "")
                {
                    ScaleType st;
                    if (Param.Length == 1)
                    {
                        st = (ScaleType)int.Parse(Param);
                    }
                    else
                    {
                        st = (ScaleType)Enum.Parse(typeof(ScaleType), Param, true);
                    }
                    fc[MainIndex].AxisY.Scale = st;
                }

                //Bottom margin
                Param = Request.QueryString["BMargin"];
                if (Param != null && Param != "")
                {
                    fc[MainIndex].BottomMargin = Tools.ToDoubleDef(Param, 0);
                }

                //Bind stock data
                fc.DataProvider = DataProvider;

                for (int i = 1; i < fc[MainIndex].FormulaDataArray.Count; i++)
                {
                    if (fc[MainIndex][i].ParentFormula.FormulaName.StartsWith("COMPARE"))
                    {
                        FormulaAxisY fay = fc[MainIndex].AddNewAxisY(AxisPos.Left);
                        FormulaData  fd  = fc[MainIndex][i];
                        fd.Transform  = Transform.Normal;
                        fd.AxisYIndex = 1;
                        break;
                    }
                }

                fc[MainIndex].AxisY.MajorTick.ShowLine = Config.ShowMainAreaLineY;
                fc[MainIndex].AxisX.MajorTick.ShowLine = Config.ShowMainAreaLineX;

                //Set indicator line width
                Param = Request.QueryString["Width"];
                if (Param != null && Param != "")
                {
                    float LineWidth = float.Parse(Param);
                    for (int i = 0; i < fc.Areas.Count; i++)
                    {
                        fc[i].LinePen.Width = LineWidth;
                    }
                }
                fc[MainIndex].AxisY.AutoMultiply = false;

                if (Request.QueryString["SV"] == "0")
                {
                    fc.ShowValueLabel = false;
                }
                fc.StickRenderType = Config.StickRenderType;

                Rectangle Rect = new Rectangle(0, 0, Width, Height);
                Param = Request.QueryString["Layout"];
                if (Param == null || Param == "")
                {
                    Param = "Default";
                }
                string[] Layouts = Param.Split(';', ',');
                Layout   L       = Layout.ParseString(Config.Read(Layouts[0] + "Layout", "ChartRect=(0,0,0,0)"), Rect);    //,DataProvider);
                for (int j = 1; j < Layouts.Length; j++)
                {
                    L.Merge(Layout.ParseString(Config.Read(Layouts[j] + "Layout", "ChartRect=(0,0,0,0)"), Rect));                //,DataProvider));
                }
                L.CompanyName = Config.CompanyName;
                L.URL         = Config.URL;
                L.StartTick   = Start;
                fc.Rect       = L.ChartRect;
                B             = fc.GetBitmap(Width, Height, fc.Rect);
                Graphics g = Graphics.FromImage(B);
                L.Render(g, Rect, fc);


                int X = Tools.ToIntDef(Request.QueryString["X"], 0);
                int Y = Tools.ToIntDef(Request.QueryString["Y"], 0);
                if (X > 0 && Y > 0)
                {
                    fc.Rect            = new Rectangle(0, 0, Width, Height);
                    fc.ShowCursorLabel = true;
                    fc.DrawCursor(g, X, Y);
                }
            }
            catch (Exception ex)
            {
                B = new Bitmap(Width, Height);
                Graphics g = Graphics.FromImage(B);

                g.Clear(Color.White);

                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(ex.Message, new Font("Verdana", 12),
                             new SolidBrush(Color.FromArgb(196, Color.Black)), new Rectangle(0, 0, Width, Height), sf);
            }

            //Create stock image to Bitmap
            Response.ContentType = "Image/" + Config.ImageFormat;

            //Create chart stream
            MemoryStream ms = new MemoryStream();

            if (Config.ImageFormat == "Gif")
            {
                Type tQuantization = (Type)Application["Quantization"];
                if (tQuantization == null)
                {
                    Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly a in ass)
                    {
                        if (a.FullName.StartsWith("ImageQuantization"))
                        {
                            tQuantization = a.GetType("ImageQuantization.OctreeQuantizer");
                        }
                    }
                    Application["Quantization"] = tQuantization;
                }

                if (tQuantization != null)
                {
                    object[] os;
                    if (Config.TransparentColor.IsEmpty)
                    {
                        os = new object[] { B, ms, Config.GifColors }
                    }
                    ;
                    else
                    {
                        os = new object[] { B, ms, Config.GifColors, Config.TransparentColor }
                    };

                    tQuantization.InvokeMember("Save",
                                               BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, os);
                }

                if (ms.Length == 0)
                {
                    B.Save(ms, ImageFormat.Png);
                }
            }
            else if (Config.ImageFormat == "Png")
            {
                B.Save(ms, ImageFormat.Png);
            }
            else if (Config.ImageFormat == "Jpeg")
            {
                B.Save(ms, ImageFormat.Jpeg);
            }

            //Output the chart stream to web browser
            ms.WriteTo(Response.OutputStream);
        }
示例#14
0
        /// <summary>
        /// Get stock data of certain data cycle
        /// </summary>
        /// <param name="dc">The data cycle</param>
        /// <returns></returns>
        public Hashtable GetCycleData(DataCycle dc)
        {
            if (dc.CycleBase == DataCycleBase.DAY && dc.Repeat == 1 && !Adjusted)
            {
                return(htData);
            }
            else
            {
                dc.WeekAdjust = weekAdjust;
                Hashtable htCycle = (Hashtable)htAllCycle[dc.ToString()];
                if (htCycle == null)
                {
                    if (htData == null)
                    {
                        return(htData);
                    }

                    Hashtable ht = htData;
                    if (intradayInfo != null)
                    {
                        ht = DoExpandMinute(ht);
                    }

                    if (futureBars != 0)
                    {
                        ht = ExpandFutureBars(ht);
                    }

                    if (ht["CLOSE"] != null)
                    {
                        if (ht["OPEN"] == null)
                        {
                            ht["OPEN"] = ht["CLOSE"];
                        }
                        if (ht["HIGH"] == null)
                        {
                            ht["HIGH"] = ht["CLOSE"];
                        }
                        if (ht["LOW"] == null)
                        {
                            ht["LOW"] = ht["CLOSE"];
                        }
                    }

                    double[] ODATE = (double[])ht["DATE"];
                    if (ODATE == null)
                    {
                        return(null);
                    }

                    int[] NEWDATE = new int[ODATE.Length];

                    int Last = int.MinValue;
                    int j    = -1;
                    int Num;
                    for (int i = 0; i < ODATE.Length; i++)
                    {
                        if (DataCycle.CycleBase == DataCycleBase.TICK)
                        {
                            Num = i / DataCycle.Repeat;
                        }
                        else
                        {
                            Num = DataCycle.GetSequence(ODATE[i]);
                        }
                        if (Num > Last)
                        {
                            j++;
                        }
                        NEWDATE[i] = j;
                        Last       = Num;
                    }

                    htCycle = new Hashtable();
                    foreach (string s in ht.Keys)
                    {
                        htCycle[s] = new double[j + 1];
                    }

                    bool     NeedAdjust = (Adjusted && ht["ADJCLOSE"] != null && ht["CLOSE"] != null);
                    double[] CLOSE      = (double[])ht["CLOSE"];
                    double[] ADJCLOSE   = (double[])ht["ADJCLOSE"];

                    foreach (string s in ht.Keys)
                    {
                        bool           DoAdjust = NeedAdjust;
                        MergeCycleType mct;
                        DoAdjust = false;
                        if (htGroupping[s] != null)
                        {
                            mct = (MergeCycleType)htGroupping[s];
                        }
                        else if (s == "DATE")
                        {
                            mct = dateMergeType;                            // MergeCycleType.OPEN;
                        }
                        else if (s == "VOLUME" || s == "AMOUNT")
                        {
                            mct = MergeCycleType.SUM;
                        }
                        else
                        {
                            try
                            {
                                mct      = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), s);
                                DoAdjust = true;
                            }
                            catch
                            {
                                mct = MergeCycleType.CLOSE;
                            }
                        }
                        MergeCycle(ODATE, NEWDATE, CLOSE, ADJCLOSE, (double[])ht[s], (double[])htCycle[s], mct, DoAdjust);
                    }
                    htAllCycle[dc.ToString()] = htCycle;
                }
                return(htCycle);
            }
        }
示例#15
0
 public DataManager(InstrumentInfo instrumentInfo,DataCycle dataCycle)
 {
 }
示例#16
0
 /*
 public static CookieContainer CookieContainer
 {
     get{return DataManager.cookieContainer;}
     set{DataManager.cookieContainer=value;}
 }
 */
 public DataManager(InstrumentInfo instrumentInfo,DataCycle dataCycle)
 {
     this.instrumentInfo=instrumentInfo;
     this.dataCycle=dataCycle;
 }
示例#17
0
        public Hashtable GetCycleData(DataCycle dc)
        {
            if (((dc.CycleBase == DataCycleBase.DAY) && (dc.Repeat == 1)) && !this.Adjusted)
            {
                return(this.htData);
            }
            Hashtable hashtable = (Hashtable)this.htAllCycle[dc.ToString()];

            if (hashtable == null)
            {
                if (this.htData == null)
                {
                    return(this.htData);
                }
                Hashtable htData = this.htData;
                if (this.intradayInfo != null)
                {
                    htData = this.DoExpandMinute(htData);
                }
                if (htData["CLOSE"] != null)
                {
                    if (htData["OPEN"] == null)
                    {
                        htData["OPEN"] = htData["CLOSE"];
                    }
                    if (htData["HIGH"] == null)
                    {
                        htData["HIGH"] = htData["CLOSE"];
                    }
                    if (htData["LOW"] == null)
                    {
                        htData["LOW"] = htData["CLOSE"];
                    }
                }
                double[] oDATE = (double[])htData["DATE"];
                if (oDATE == null)
                {
                    return(null);
                }
                int[] nEWDATE = new int[oDATE.Length];
                int   num     = -2147483648;
                int   num2    = -1;
                for (int i = 0; i < oDATE.Length; i++)
                {
                    int sequence = this.DataCycle.GetSequence(oDATE[i]);
                    if (sequence > num)
                    {
                        num2++;
                    }
                    nEWDATE[i] = num2;
                    num        = sequence;
                }
                hashtable = new Hashtable();
                foreach (string str in htData.Keys)
                {
                    hashtable[str] = new double[num2 + 1];
                }
                bool     flag     = (this.Adjusted && (htData["ADJCLOSE"] != null)) && (htData["CLOSE"] != null);
                double[] cLOSE    = (double[])htData["CLOSE"];
                double[] aDJCLOSE = (double[])htData["ADJCLOSE"];
                foreach (string str2 in htData.Keys)
                {
                    MergeCycleType oPEN;
                    bool           doAdjust = flag;
                    doAdjust = false;
                    switch (str2)
                    {
                    case "DATE":
                        oPEN = MergeCycleType.OPEN;
                        break;

                    case "VOLUME":
                    case "AMOUNT":
                        oPEN = MergeCycleType.SUM;
                        break;

                    default:
                        try
                        {
                            oPEN     = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), str2);
                            doAdjust = true;
                        }
                        catch
                        {
                            oPEN = MergeCycleType.CLOSE;
                        }
                        break;
                    }
                    this.MergeCycle(oDATE, nEWDATE, cLOSE, aDJCLOSE, (double[])htData[str2], (double[])hashtable[str2], oPEN, doAdjust);
                }
                this.htAllCycle[dc.ToString()] = hashtable;
            }
            return(hashtable);
        }