/// <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 ezOrderProfile CloneProfile() { //ReadOnlyCollection<ezOrderFeed> feeds = Instrument.TTAPI_Instrument.GetValidOrderFeeds(); ReadOnlyCollection <ezOrderFeed> feeds = null; ezOrderFeed feed = feeds[1]; EZOrderRoute.GetOrderRoute(Instrument, Market.Name); ezOrderProfile profile = new ezOrderProfile(feed, Instrument.BaseInstrument); 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); }
/// <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 EZOrderRoute GetOrderRoute(EZInstrument 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(); } } EZOrderRoute route = null; if (accountInfoString != null) { route = new EZOrderRoute(); string[] values = accountInfoString.Split(','); string feedName = values[0]; string accountName = values[1]; string accountType = values[2]; ReadOnlyCollection <ezOrderFeed> feeds = instrument.EnabledOrderFeeds; foreach (ezOrderFeed feed in feeds) { if (feed.Name.Equals(feedName)) { route.OrderFeed = feed; break; } } route.AccountName = accountName; route.AccountType = (zAccountType)Enum.Parse(typeof(zAccountType), accountType); } return(route); }