Пример #1
0
        static void BuildRef(FutureManager mgr, string exchangeid, string productid)
        {
            List <Future> lstfuture = mgr.GetFutures(exchangeid, productid);

            List <IndexFuture> lstidx = new List <IndexFuture>();

            foreach (Future future in lstfuture)
            {
                if (future.FutureType == EnumFutureType.Reference)
                {
                    string futureid = mgr.GetRealFuture(future.ID);
                    if (futureid.Length > 0 && mgr.HasFuture(futureid))
                    {
                        future.RealFuture = mgr[futureid];
                    }
                }
                else if (future.FutureType == EnumFutureType.Index)
                {
                    lstidx.Add(future as IndexFuture);
                }
            }

            foreach (IndexFuture idxfuture in lstidx)
            {
                foreach (Future future in lstfuture)
                {
                    if (future.FutureType == EnumFutureType.Normal)
                    {
                        idxfuture.Add(future);
                    }
                }

                if (mgr.HasFuture(productid + "9999"))
                {
                    idxfuture.RealFuture = mgr[productid + "9999"].RealFuture;
                }
            }
        }
Пример #2
0
        internal static void Set(XmlDocument doc, XmlElement root, FutureProduct product, FutureManager mgr)
        {
            XmlAttribute attr = doc.CreateAttribute(IdAttr);

            attr.Value = product.ProductID;
            root.Attributes.Append(attr);

            attr       = doc.CreateAttribute(NameAttr);
            attr.Value = product.ProductName;
            root.Attributes.Append(attr);

            if (product.AllSlice != null && product.AllSlice.Count > 0)
            {
                StringBuilder builder = new StringBuilder();
                foreach (TimeSlice slice in product.AllSlice)
                {
                    builder.Append(slice.BeginTime.ToString()).Append(",")
                    .Append(slice.EndTime.ToString()).Append(",");
                }

                builder.Remove(builder.Length - 1, 1);

                attr       = doc.CreateAttribute(TradingTimeAttr);
                attr.Value = builder.ToString();
                root.Attributes.Append(attr);
            }

            List <Future> futurelist = mgr.GetFutures(product.ExchangeID, product.ProductID);

            foreach (Future future in futurelist)
            {
                XmlElement subTagNode = doc.CreateElement(FutureTag);
                root.AppendChild(subTagNode);

                FutureXml.Set(doc, subTagNode, future);
            }
        }