コード例 #1
0
        public void SetAttributes(Dictionary <string, string> attributes)
        {
            InstrumentKey instrumentKey;
            bool          boolValue = false;

            foreach (string key in attributes.Keys)
            {
                if (key.Equals("Name"))
                {
                    Name = attributes[key];
                }
                else if (key.Equals("FilterInstrumentKey") && TTConvert.TryCreateInstrumentKey(attributes[key], out instrumentKey))
                {
                    this.FilterByInstrument(instrumentKey);
                    this.m_FilterType = FilterType.Instrument;
                }
                else if (key.Equals("FilterAccount"))
                {
                    this.FilterByAccount(attributes[key]);
                    this.m_FilterType = FilterType.Account;
                }
                else if (key.Equals("LogAllFills") && bool.TryParse(attributes[key], out boolValue))
                {
                    this.m_LogAllFillPropertiesFromTT = boolValue;
                }
            }
        }
コード例 #2
0
        public void SetAttributes(Dictionary <string, string> attributes)
        {
            InstrumentName name;
            InstrumentKey  ttkey;

            foreach (string key in attributes.Keys)
            {
                if (key.Equals("Name") && InstrumentName.TryDeserialize(attributes["Name"], out name))
                {
                    this.Name = name;
                }
                else if (key.Equals("Key") && TTConvert.TryCreateInstrumentKey(attributes["Key"], out ttkey))
                {
                    this.Key = ttkey;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a fill event from the pair-wise info in drop.
        /// Allowed keys:
        ///     Time - the time the drop was made.
        ///     LocalFillTime - local time fill was received.
        /// </summary>
        /// <param name="pairs"></param>
        /// <returns></returns>
        private FillEventArgs CreateFillEvent(Dictionary <string, string> pairs)
        {
            string sQty;
            string sPrice;

            if (pairs.TryGetValue("Qty", out sQty) && pairs.TryGetValue("Price", out sPrice))
            {
                UV.Lib.OrderHubs.Fill aFill = UV.Lib.OrderHubs.Fill.Create();
                aFill.Qty   = Convert.ToInt32(sQty);
                aFill.Price = Convert.ToDouble(sPrice);

                // Extract fill times.
                if (pairs.ContainsKey("LocalFillTime"))
                {
                    aFill.LocalTime = Convert.ToDateTime(pairs["LocalFillTime"]);                    // use fill time, if available.
                }
                else
                {
                    aFill.LocalTime = Convert.ToDateTime(pairs["Time"]);                             // else use last drop time- legacy approach
                }
                // Extract TT's instrument key.
                InstrumentKey key;
                string        sForeignKey;
                if (pairs.TryGetValue("ForeignKey", out sForeignKey) && TTConvert.TryCreateInstrumentKey(sForeignKey, out key))
                {
                    FillEventArgs e = new FillEventArgs(key, FillType.InitialPosition, aFill);
                    return(e);   // success!
                }
                else
                {
                    Log.NewEntry(LogLevel.Error, "Failed to recreate instrument key from {0}.", sForeignKey);
                    return(null);
                }
            }
            else
            {
                Log.NewEntry(LogLevel.Error, "Failed to create a fill event");
                return(null);
            }
        }// CreateFillEvent()
コード例 #4
0
        public void SetAttributes(Dictionary <string, string> attributes)
        {
            this.Fill = new UV.Lib.OrderHubs.Fill();
            ((IStringifiable)this.Fill).SetAttributes(attributes);

            FillType type;

            TradingTechnologies.TTAPI.InstrumentKey ttInstrumentKey;
            foreach (string key in attributes.Keys)
            {
                if (key == "Type" && Enum.TryParse <FillType>(attributes[key], out type))
                {
                    this.Type = type;
                }
                else if (key == "InstrumentKey" && TTConvert.TryCreateInstrumentKey(attributes[key], out ttInstrumentKey))
                {
                    this.TTInstrumentKey = ttInstrumentKey;
                }
                else if (key == "FillKey")
                {
                    this.FillKey = attributes[key];
                }
            }
        }