Exemplo n.º 1
0
        /// <summary>
        /// Create an OrderProfile from this existing order
        /// </summary>
        /// <returns>A TTAPI OrderProfile object</returns>
        /// <remarks>There is a problem with using the TTAPI method to create a copy of an order</remarks>
        public OrderProfile CloneProfile()
        {
            ReadOnlyCollection <OrderFeed> feeds = Instrument.TTAPI_Instrument.GetValidOrderFeeds();
            OrderFeed feed = feeds[1];

            OrderRoute.GetOrderRoute(Instrument, Market.Name);
            OrderProfile profile = new OrderProfile(feed, Instrument.TTAPI_Instrument);

            profile.AccountName         = TTAPI_Order.AccountName;
            profile.AccountType         = TTAPI_Order.AccountType;
            profile.BuySell             = TTAPI_Order.BuySell;
            profile.Destination         = TTAPI_Order.Destination;
            profile.FFT2                = TTAPI_Order.FFT2;
            profile.FFT3                = TTAPI_Order.FFT3;
            profile.GiveUp              = TTAPI_Order.GiveUp;
            profile.IsAutomated         = TTAPI_Order.IsAutomated;
            profile.LimitPrice          = TTAPI_Order.LimitPrice;
            profile.MinimumQuantity     = TTAPI_Order.MinimumQuantity;
            profile.Modifiers           = TTAPI_Order.Modifiers;
            profile.OpenClose           = TTAPI_Order.OpenClose;
            profile.OrderQuantity       = TTAPI_Order.OrderQuantity;
            profile.OrderTag            = TTAPI_Order.OrderTag;
            profile.OrderType           = TTAPI_Order.OrderType;
            profile.PriceCheck          = TTAPI_Order.PriceCheck;
            profile.Restriction         = TTAPI_Order.Restriction;
            profile.StopPrice           = TTAPI_Order.StopPrice;
            profile.StopTriggerQuantity = TTAPI_Order.StopTriggerQuantity;
            profile.SubUserId           = TTAPI_Order.SubUserId;
            profile.TimeInForce         = TTAPI_Order.TimeInForce;
            profile.UserName            = TTAPI_Order.UserName;
            profile.UserTag             = TTAPI_Order.UserTag;

            return(profile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Static method to return an OrderRoute for a given instrument and market
        /// </summary>
        /// <param name="instrument">TTInstrument for this order route</param>
        /// <param name="marketName">Market for this order route (i.e. "CME", "CBOT", etc.)</param>
        /// <returns>OrderRoute object to use when sending orders for the specified instrument</returns>
        public static OrderRoute GetOrderRoute(TTInstrument instrument, string marketName)
        {
            string                      accountInfoString = null;
            IResourceReader             reader            = null;
            Dictionary <string, string> loginResources    = new Dictionary <string, string>();

            try
            {
                reader = new ResourceReader("Account.resources");
                IDictionaryEnumerator dict = reader.GetEnumerator();
                while (dict.MoveNext())
                {
                    string key = dict.Key.ToString();
                    if (key.Equals(marketName))
                    {
                        accountInfoString = dict.Value.ToString();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            OrderRoute route = null;

            if (accountInfoString != null)
            {
                route = new OrderRoute();

                string[] values      = accountInfoString.Split(',');
                string   feedName    = values[0];
                string   accountName = values[1];
                string   accountType = values[2];
                ReadOnlyCollection <OrderFeed> feeds = instrument.EnabledOrderFeeds;
                foreach (OrderFeed feed in feeds)
                {
                    if (feed.Name.Equals(feedName))
                    {
                        route.OrderFeed = feed;
                        break;
                    }
                }
                route.AccountName = accountName;
                route.AccountType = (AccountType)Enum.Parse(typeof(AccountType), accountType);
            }

            return(route);
        }