Пример #1
0
        /// <summary>
        /// Creates a user defined universe symbol
        /// </summary>
        /// <param name="securityType">The security</param>
        /// <param name="market">The market</param>
        /// <returns>A symbol for user defined universe of the specified security type and market</returns>
        public static Symbol CreateSymbol(SecurityType securityType, string market)
        {
            var ticker = string.Format("qc-universe-userdefined-{0}-{1}", market.ToLower(), securityType);
            SecurityIdentifier sid;

            switch (securityType)
            {
            case SecurityType.Base:
                sid = SecurityIdentifier.GenerateBase(ticker, market);
                break;

            case SecurityType.Equity:
                sid = SecurityIdentifier.GenerateEquity(SecurityIdentifier.DefaultDate, ticker, market);
                break;

            case SecurityType.Option:
                sid = SecurityIdentifier.GenerateOption(SecurityIdentifier.DefaultDate, ticker, market, 0, 0, 0);
                break;

            case SecurityType.Forex:
                sid = SecurityIdentifier.GenerateForex(ticker, market);
                break;

            case SecurityType.Cfd:
                sid = SecurityIdentifier.GenerateCfd(ticker, market);
                break;

            case SecurityType.Commodity:
            case SecurityType.Future:
            default:
                throw new NotImplementedException("The specified security type is not implemented yet: " + securityType);
            }

            return(new Symbol(sid, ticker));
        }
Пример #2
0
        /// <summary>
        /// Get the Lean <see cref = "Symbol"/> object given its ticker, security type and market.
        /// </summary>
        /// <param name="ticker">The asset symbol name</param>
        /// <param name="type">The asset security type</param>
        /// <param name="market">The asset market</param>
        /// <returns><see cref = "Symbol"/> object wrapped in a <see cref = "PyObject"/></returns>
        public PyObject GetSymbol(string ticker, string type = "Equity", string market = null)
        {
            var securityType = (SecurityType)Enum.Parse(typeof(SecurityType), type, true);

            SecurityIdentifier sid;

            if (securityType == SecurityType.Cfd)
            {
                sid = SecurityIdentifier.GenerateCfd(ticker, market ?? Market.Oanda);
            }
            else if (securityType == SecurityType.Equity)
            {
                sid = SecurityIdentifier.GenerateEquity(ticker, market ?? Market.USA);
            }
            else if (securityType == SecurityType.Forex)
            {
                sid = SecurityIdentifier.GenerateForex(ticker, market ?? Market.FXCM);
            }
            else
            {
                return("Invalid security type. Use Equity, Forex or Cfd.".ToPython());
            }

            // Add symbol to cache
            SymbolCache.Set(ticker, new Symbol(sid, ticker));

            return(SymbolCache.GetSymbol(ticker).ToPython());
        }
Пример #3
0
        public void NonExistantData_WillBeDownloaded_Unsuccessfully()
        {
            var nonExistentData = _api.DownloadData(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                    Resolution.Minute, new DateTime(1989, 10, 11));

            Assert.IsFalse(nonExistentData);
        }
Пример #4
0
 public void GetMethod_WithNonEquitySecurity_ShouldThrowException()
 {
     Assert.Throws <NotSupportedException>(() =>
     {
         _yahooDataDownloader.Get(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", "USA"), "EURUSD"), Resolution.Daily, new DateTime(2017, 2, 1), new DateTime(2017, 2, 2));
     });
 }
Пример #5
0
 public void SymbolTypeNameHandling()
 {
     const string json = @"{'$type':'QuantConnect.Symbol, QuantConnect.Common', 'Value':'EURGBP', 'ID': 'EURGBP 5O'}";
     var expected = new Symbol(SecurityIdentifier.GenerateForex("EURGBP", Market.FXCM), "EURGBP");
     var actual = JsonConvert.DeserializeObject<Symbol>(json, Settings);
     Assert.AreEqual(expected, actual);
 }
Пример #6
0
        public void BacktestingData_CanBeDownloadedAndSaved_Successfully()
        {
            var minutePath = Path.Combine(_dataFolder, "forex/oanda/minute/eurusd/20131011_quote.zip");
            var dailyPath  = Path.Combine(_dataFolder, "forex/oanda/daily/eurusd.zip");

            if (File.Exists(dailyPath))
            {
                File.Delete(dailyPath);
            }

            if (File.Exists(minutePath))
            {
                File.Delete(minutePath);
            }

            var downloadedMinuteData = _api.DownloadData(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                         Resolution.Minute, new DateTime(2013, 10, 11));
            var downloadedDailyData = _api.DownloadData(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                        Resolution.Daily, new DateTime(2013, 10, 07));

            Assert.IsTrue(downloadedMinuteData);
            Assert.IsTrue(downloadedDailyData);

            Assert.IsTrue(File.Exists(dailyPath));
            Assert.IsTrue(File.Exists(minutePath));
        }
Пример #7
0
        public void HandlesListTicksWithDifferentSymbols()
        {
            // the first serialized Tick object has a Symbol of EURGBP and the second has EURUSD, but the output
            const string json =
                "{'$type':'System.Collections.Generic.List`1[[QuantConnect.Data.BaseData, QuantConnect.Common]], mscorlib','$values':[" +

                "{'$type':'QuantConnect.Data.Market.Tick, QuantConnect.Common'," +
                "'TickType':0,'Quantity':1,'Exchange':'','SaleCondition':'','Suspicious':false," +
                "'BidPrice':1.11895,'AskPrice':1.11898,'LastPrice':1.11895,'DataType':2,'IsFillForward':false," +
                "'Time':'2015-09-22T01:26:44.676','EndTime':'2015-09-22T01:26:44.676'," +
                "'Symbol':{'$type':'QuantConnect.Symbol, QuantConnect.Common','Value':'EURUSD', 'ID': 'EURUSD 5O'}," +
                "'Value':1.11895,'Price':1.11895}," +

                "{'$type':'QuantConnect.Data.Market.Tick, QuantConnect.Common'," +
                "'TickType':0,'Quantity':1,'Exchange':'','SaleCondition':'','Suspicious':false," +
                "'BidPrice':0.72157,'AskPrice':0.72162,'LastPrice':0.72157,'DataType':2,'IsFillForward':false," +
                "'Time':'2015-09-22T01:26:44.675','EndTime':'2015-09-22T01:26:44.675'," +
                "'Symbol':{'$type':'QuantConnect.Symbol, QuantConnect.Common','Value':'EURGBP', 'ID': 'EURGBP 5O'}," +
                "'Value':0.72157,'Price':0.72157}," +

                "]}";

            var actual = JsonConvert.DeserializeObject <List <BaseData> >(json, Settings);

            Assert.IsFalse(actual.All(x => x.Symbol == new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.FXCM), "EURUSD")));
        }
Пример #8
0
        public void ComparesTheSameAsStringCompareAndIgnoresCase()
        {
            var a = new Symbol(SecurityIdentifier.GenerateForex("a", Market.FXCM), "a");
            var z = new Symbol(SecurityIdentifier.GenerateForex("z", Market.FXCM), "z");

            Assert.AreEqual(string.Compare("a", "Z", StringComparison.OrdinalIgnoreCase), a.CompareTo(z));
            Assert.AreEqual(string.Compare("z", "A", StringComparison.OrdinalIgnoreCase), z.CompareTo(a));
        }
Пример #9
0
 public void BackwardsCompatibleJson()
 {
     var symbol = new Symbol(SecurityIdentifier.GenerateForex("a", Market.FXCM), "a");
     var json = JsonConvert.SerializeObject(symbol, new JsonSerializerSettings{Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.All});
     var oldSymbol = JsonConvert.DeserializeObject<OldSymbol>(json);
     Assert.AreEqual("A", oldSymbol.Value);
     Assert.AreEqual("A", oldSymbol.Permtick);
 }
Пример #10
0
        /// <summary>
        /// Creates a user defined universe symbol
        /// </summary>
        /// <param name="securityType">The security</param>
        /// <param name="market">The market</param>
        /// <returns>A symbol for user defined universe of the specified security type and market</returns>
        public static Symbol CreateSymbol(SecurityType securityType, string market)
        {
            var ticker = $"qc-universe-userdefined-{market.ToLowerInvariant()}-{securityType}";
            SecurityIdentifier sid;

            switch (securityType)
            {
            case SecurityType.Base:
                sid = SecurityIdentifier.GenerateBase(null, ticker, market);
                break;

            case SecurityType.Equity:
                sid = SecurityIdentifier.GenerateEquity(SecurityIdentifier.DefaultDate, ticker, market);
                break;

            case SecurityType.Option:
                var underlying = SecurityIdentifier.GenerateEquity(SecurityIdentifier.DefaultDate, ticker, market);
                sid = SecurityIdentifier.GenerateOption(SecurityIdentifier.DefaultDate, underlying, market, 0, 0, 0);
                break;

            case SecurityType.FutureOption:
                var underlyingFuture = SecurityIdentifier.GenerateFuture(SecurityIdentifier.DefaultDate, ticker, market);
                sid = SecurityIdentifier.GenerateOption(SecurityIdentifier.DefaultDate, underlyingFuture, market, 0, 0, 0);
                break;

            case SecurityType.IndexOption:
                var underlyingIndex = SecurityIdentifier.GenerateIndex(ticker, market);
                sid = SecurityIdentifier.GenerateOption(SecurityIdentifier.DefaultDate, underlyingIndex, market, 0, 0, OptionStyle.European);
                break;

            case SecurityType.Forex:
                sid = SecurityIdentifier.GenerateForex(ticker, market);
                break;

            case SecurityType.Cfd:
                sid = SecurityIdentifier.GenerateCfd(ticker, market);
                break;

            case SecurityType.Index:
                sid = SecurityIdentifier.GenerateIndex(ticker, market);
                break;

            case SecurityType.Future:
                sid = SecurityIdentifier.GenerateFuture(SecurityIdentifier.DefaultDate, ticker, market);
                break;

            case SecurityType.Crypto:
                sid = SecurityIdentifier.GenerateCrypto(ticker, market);
                break;

            case SecurityType.Commodity:
            default:
                throw new NotImplementedException($"The specified security type is not implemented yet: {securityType}");
            }

            return(new Symbol(sid, ticker));
        }
Пример #11
0
        public void ImplicitOperatorsAreInverseFunctions()
        {
#pragma warning disable 0618 // This test requires implicit operators
            var    eurusd       = new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.FXCM), "EURUSD");
            string stringEurusd = eurusd;
            Symbol symbolEurusd = stringEurusd;
            Assert.AreEqual(eurusd, symbolEurusd);
#pragma warning restore 0618
        }
Пример #12
0
        public void TryDownload_NonExistent_Data()
        {
            var api = CreateApiAccessor();

            var nonExistentData = api.DownloadData(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                   Resolution.Minute, new DateTime(1989, 10, 11));

            Assert.IsFalse(nonExistentData);
        }
Пример #13
0
        public void ValidForexDataLinks(string ticker, string market, DateTime date, Resolution resolution, TickType tickType)
        {
            var path = LeanData.GenerateRelativeZipFilePath(
                new Symbol(SecurityIdentifier.GenerateForex(ticker, market), ticker),
                date, resolution, tickType);
            var dataLink = ApiClient.ReadDataLink(path, TestOrganization);

            Assert.IsTrue(dataLink.Success);
            Assert.IsFalse(dataLink.Url.IsNullOrEmpty());
        }
Пример #14
0
        private static Symbol ConvertSymbol(string instrument, SecurityType securityType)
        {
            if (securityType == SecurityType.Forex)
            {
                instrument = instrument.Trim('_');
                return(new Symbol(SecurityIdentifier.GenerateForex(instrument, Market.Oanda), instrument));
            }

            throw new NotImplementedException("The specified security type is not yet implemented: " + securityType);
        }
Пример #15
0
        public void OandaDataLinks_CanBeRetrieved_Successfully()
        {
            var minuteDataLink = _api.ReadDataLink(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                   Resolution.Minute, new DateTime(2013, 10, 07));
            var dailyDataLink = _api.ReadDataLink(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                  Resolution.Daily, new DateTime(2013, 10, 07));

            Assert.IsTrue(minuteDataLink.Success);
            Assert.IsTrue(dailyDataLink.Success);
        }
        public void GeneratesForexSecurityIdentifier()
        {
            var eurusd = SecurityIdentifier.GenerateForex("EURUSD", Market.FXCM);

            // verify various values
            Assert.Throws <InvalidOperationException>(() => { var x = eurusd.Date; });
            Assert.AreEqual(Market.FXCM, eurusd.Market);
            Assert.AreEqual(SecurityType.Forex, eurusd.SecurityType);
            Assert.AreEqual("EURUSD", eurusd.Symbol);

            Console.WriteLine(eurusd);
        }
Пример #17
0
        public void GetLinks_ToDownloadData_ForOanda()
        {
            var api = CreateApiAccessor();

            var minuteDataLink = api.ReadDataLink(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                  Resolution.Minute, new DateTime(2013, 10, 07));
            var dailyDataLink = api.ReadDataLink(new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.Oanda), "EURUSD"),
                                                 Resolution.Daily, new DateTime(2013, 10, 07));

            Assert.IsTrue(minuteDataLink.Success);
            Assert.IsTrue(dailyDataLink.Success);
        }
Пример #18
0
        public void ImplicitOperatorsReturnSIDOnFailure()
        {
#pragma warning disable 0618 // This test requires implicit operators
            // this doesn't exist in the symbol cache
            var    eurusd       = new Symbol(SecurityIdentifier.GenerateForex("NOT-A-SECURITY", Market.FXCM), "EURUSD");
            string stringEurusd = eurusd;
            Assert.AreEqual(eurusd.ID.ToString(), stringEurusd);

            Symbol notASymbol = "this will not resolve to a proper Symbol instance";
            Assert.AreEqual(Symbol.Empty, notASymbol);
#pragma warning restore 0618
        }
Пример #19
0
        static SecurityIdentifier GetSid(string symbol, SecurityType securityType)
        {
            if (securityType == SecurityType.Forex)
            {
                return(SecurityIdentifier.GenerateForex(symbol, Market.Dukascopy));
            }
            if (securityType == SecurityType.Cfd)
            {
                return(SecurityIdentifier.GenerateCfd(symbol, Market.Dukascopy));
            }

            throw new NotImplementedException("The specfied security type has not been implemented yet: " + securityType);
        }
Пример #20
0
        private static Symbol ConvertSymbol(string instrument, SecurityType securityType)
        {
            if (securityType == SecurityType.Forex)
            {
                return(new Symbol(SecurityIdentifier.GenerateForex(instrument, Market.Oanda), instrument));
            }
            if (securityType == SecurityType.Cfd)
            {
                return(new Symbol(SecurityIdentifier.GenerateCfd(instrument, Market.Oanda), instrument));
            }

            throw new NotImplementedException("The specfied security type has not been implemented yet: " + securityType);
        }
Пример #21
0
        public void TryGetTicker()
        {
            SymbolCache.Set("EURUSD", Symbols.EURUSD);

            string ticker;

            Assert.IsTrue(SymbolCache.TryGetTicker(Symbols.EURUSD, out ticker));
            Assert.AreEqual(Symbols.EURUSD.Value, ticker);

            var symbol = new Symbol(SecurityIdentifier.GenerateForex("NOT A FOREX PAIR", Market.FXCM), "EURGBP");

            Assert.IsFalse(SymbolCache.TryGetTicker(symbol, out ticker));
            Assert.AreEqual(default(string), ticker);
        }
Пример #22
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader"/> to read from.</param><param name="objectType">Type of the object.</param><param name="existingValue">The existing value of object being read.</param><param name="serializer">The calling serializer.</param>
        /// <returns>
        /// The object value.
        /// </returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var jObject = JObject.Load(reader);

            // create order instance based on order type field
            var orderType = (OrderType)jObject["Type"].Value <int>();
            var order     = CreateOrder(orderType, jObject);

            // populate common order properties
            order.Id           = jObject["Id"].Value <int>();
            order.Quantity     = jObject["Quantity"].Value <int>();
            order.Status       = (OrderStatus)jObject["Status"].Value <int>();
            order.Time         = jObject["Time"].Value <DateTime>();
            order.Tag          = jObject["Tag"].Value <string>();
            order.Quantity     = jObject["Quantity"].Value <int>();
            order.Price        = jObject["Price"].Value <decimal>();
            order.SecurityType = (SecurityType)jObject["SecurityType"].Value <int>();
            order.BrokerId     = jObject["BrokerId"].Select(x => x.Value <long>()).ToList();
            order.ContingentId = jObject["ContingentId"].Value <int>();

            if (jObject.SelectTokens("Symbol.ID").Any())
            {
                var sid    = SecurityIdentifier.Parse(jObject.SelectTokens("Symbol.ID").Single().Value <string>());
                var ticker = jObject.SelectTokens("Symbol.Value").Single().Value <string>();
                order.Symbol = new Symbol(sid, ticker);
            }
            else
            {
                // provide for backwards compatibility
                var ticker = jObject.SelectTokens("Symbol.Value").Single().Value <string>();

                SecurityIdentifier sid;
                if (order.SecurityType == SecurityType.Equity)
                {
                    sid = GetEquitySid(ticker, order.Time.Date);
                }
                else if (order.SecurityType == SecurityType.Forex)
                {
                    sid = SecurityIdentifier.GenerateForex(ticker, Market.FXCM);
                }
                else
                {
                    throw new NotImplementedException("The specified security type has not been implemented yet: " + order.SecurityType);
                }

                order.Symbol = new Symbol(sid, ticker);
            }

            return(order);
        }
Пример #23
0
        public void SerializesToSymbolValue()
        {
            const string symbolValue = "ABC";
            const string sidSymbol   = "EURUSD";
            var          holding     = new Holding {
                Symbol = new Symbol(SecurityIdentifier.GenerateForex(sidSymbol, Market.FXCM), symbolValue)
            };
            var serialized = JsonConvert.SerializeObject(holding, new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            });

            Console.WriteLine(serialized);
            Assert.IsFalse(serialized.Contains(sidSymbol));
            Assert.IsTrue(serialized.Contains(symbolValue));
        }
Пример #24
0
        /// <summary>
        /// Converts an FXCM symbol to a QuantConnect symbol
        /// </summary>
        private static Symbol ConvertSymbol(Instrument instrument)
        {
            var symbol       = instrument.getSymbol().Replace("/", "");
            var securityType = GetSecurityType(instrument);

            switch (securityType)
            {
            case SecurityType.Forex:
                return(new Symbol(SecurityIdentifier.GenerateForex(symbol, Market.FXCM), symbol));

            case SecurityType.Cfd:
                return(new Symbol(SecurityIdentifier.GenerateCfd(symbol, Market.FXCM), symbol));
            }

            throw new ArgumentException("The specified security type is not supported: " + securityType);
        }
Пример #25
0
        public void HandlesListTicks()
        {
            const string json = @"{'$type':'System.Collections.Generic.List`1[[QuantConnect.Data.BaseData, QuantConnect.Common]], mscorlib',
'$values':[{'$type':'QuantConnect.Data.Market.Tick, QuantConnect.Common',
'TickType':0,'Quantity':1,'Exchange':'',
'SaleCondition':'',
'Suspicious':false,'BidPrice':0.72722,'AskPrice':0.7278,'BidSize':0,'AskSize':0,'LastPrice':0.72722,'DataType':2,'IsFillForward':false,'Time':'2015-09-18T16:52:37.379',
'EndTime':'2015-09-18T16:52:37.379',
'Symbol':{'$type':'QuantConnect.Symbol, QuantConnect.Common',
'Value':'EURGBP',
'ID':'EURGBP 5O'},'Value':0.72722,'Price':0.72722}]}";

            var expected = new Symbol(SecurityIdentifier.GenerateForex("EURGBP", Market.FXCM),  "EURGBP");
            var settings = Settings;
            var actual = JsonConvert.DeserializeObject<List<BaseData>>(json, settings);
            Assert.AreEqual(expected, actual[0].Symbol);
        }
Пример #26
0
 private TestCaseData[] GetSymbolCreateTestCaseData()
 {
     return(new []
     {
         new TestCaseData("SPY", SecurityType.Equity, Market.USA, new Symbol(SecurityIdentifier.GenerateEquity("SPY", Market.USA), "SPY")),
         new TestCaseData("EURUSD", SecurityType.Forex, Market.FXCM, new Symbol(SecurityIdentifier.GenerateForex("EURUSD", Market.FXCM), "EURUSD")),
         new TestCaseData("SPY", SecurityType.Option, Market.USA, new Symbol(SecurityIdentifier.GenerateOption(SecurityIdentifier.DefaultDate, Symbols.SPY.ID, Market.USA, 0, default(OptionRight), default(OptionStyle)), "?SPY"))
     });
 }
Пример #27
0
        /// <summary>
        /// Ensures that we have a data feed to conver this currency into the base currency.
        /// This will add a subscription at the lowest resolution if one is not found.
        /// </summary>
        /// <param name="securities">The security manager</param>
        /// <param name="subscriptions">The subscription manager used for searching and adding subscriptions</param>
        /// <param name="marketHoursDatabase">A security exchange hours provider instance used to resolve exchange hours for new subscriptions</param>
        public void EnsureCurrencyDataFeed(SecurityManager securities, SubscriptionManager subscriptions, MarketHoursDatabase marketHoursDatabase)
        {
            if (Symbol == CashBook.AccountCurrency)
            {
                SecuritySymbol  = QuantConnect.Symbol.Empty;
                _isBaseCurrency = true;
                ConversionRate  = 1.0m;
                return;
            }

            if (subscriptions.Count == 0)
            {
                throw new InvalidOperationException("Unable to add cash when no subscriptions are present. Please add subscriptions in the Initialize() method.");
            }

            // we require a subscription that converts this into the base currency
            string normal = Symbol + CashBook.AccountCurrency;
            string invert = CashBook.AccountCurrency + Symbol;

            foreach (var config in subscriptions.Subscriptions.Where(config => config.SecurityType == SecurityType.Forex))
            {
                if (config.Symbol.Value == normal)
                {
                    SecuritySymbol = config.Symbol;
                    return;
                }
                if (config.Symbol.Value == invert)
                {
                    SecuritySymbol       = config.Symbol;
                    _invertRealTimePrice = true;
                    return;
                }
            }

            // get the market from the first Forex subscription
            string market = (from config in subscriptions.Subscriptions
                             where config.SecurityType == SecurityType.Forex
                             select config.Market).FirstOrDefault() ?? Market.FXCM;

            // if we've made it here we didn't find a subscription, so we'll need to add one
            var currencyPairs     = Forex.Forex.CurrencyPairs.Select(x => new Symbol(SecurityIdentifier.GenerateForex(x, market), x));
            var minimumResolution = subscriptions.Subscriptions.Min(x => x.Resolution);
            var objectType        = minimumResolution == Resolution.Tick ? typeof(Tick) : typeof(TradeBar);

            foreach (var symbol in currencyPairs)
            {
                if (symbol.Value == normal || symbol.Value == invert)
                {
                    _invertRealTimePrice = symbol.Value == invert;
                    var marketHoursDbEntry = marketHoursDatabase.GetEntry(market, symbol, SecurityType.Forex);
                    var exchangeHours      = marketHoursDbEntry.ExchangeHours;
                    // set this as an internal feed so that the data doesn't get sent into the algorithm's OnData events
                    var config   = subscriptions.Add(objectType, symbol, minimumResolution, marketHoursDbEntry.DataTimeZone, exchangeHours.TimeZone, false, true, false, true);
                    var security = new Forex.Forex(exchangeHours, this, config, 1m);
                    SecuritySymbol = config.Symbol;
                    securities.Add(config.Symbol, security);
                    Log.Trace("Cash.EnsureCurrencyDataFeed(): Adding " + symbol.ToString() + " for cash " + Symbol + " currency feed");
                    return;
                }
            }

            // if this still hasn't been set then it's an error condition
            throw new ArgumentException(string.Format("In order to maintain cash in {0} you are required to add a subscription for Forex pair {0}{1} or {1}{0}", Symbol, CashBook.AccountCurrency));
        }
Пример #28
0
        public void ComparesAgainstStringIgnoringCase()
        {
            var a = new Symbol(SecurityIdentifier.GenerateForex("a", Market.FXCM), "a");

            Assert.AreEqual(0, a.CompareTo("A"));
        }
Пример #29
0
        public void ComparesAgainstStringWithoutException()
        {
            var a = new Symbol(SecurityIdentifier.GenerateForex("a", Market.FXCM), "a");

            Assert.AreEqual(0, a.CompareTo("a"));
        }
Пример #30
0
        public void CompareToItselfReturnsZero()
        {
            var sym = new Symbol(SecurityIdentifier.GenerateForex("sym", Market.FXCM), "sym");

            Assert.AreEqual(0, sym.CompareTo(sym));
        }