예제 #1
0
        public Symbol GetPriceBySymbol(int symbolId, int exchangeId)
        {
            if (generatedData.Count != 0)
            {
                Feed data = generatedData.Last()[symbolId];

                symbolInfo = symbolList.SingleOrDefault(x => x.Id == symbolId);
                symbolInfo.DefaultVal = data.LTP;
            }
            return symbolInfo;
        }
예제 #2
0
        public static List<StockModel.Symbol> GetSymbolForMarket(Exchange exchange)
        {
            // Method to get all the company names & their symbols and set their default value & Id
            int i = 1;

            Random random = new Random();
            List<StockModel.Symbol> symbols = new List<StockModel.Symbol>();
            string jsonString;
            string symbolFilePath = string.Empty;

            //exchange specific symbol file paths are configured
            symbolFilePath = WebConfigurationManager.AppSettings[exchange.ToString() + "_SymbolFilePath"];

            //exchange specific symbol file paths are not configured. Pick Defaults.
            if (string.IsNullOrEmpty(symbolFilePath))
            {
                symbolFilePath = WebConfigReader.Read("SymbolFilePath");
            }

            jsonString = System.IO.File.ReadAllText(symbolFilePath);

            JArray jsonArray = JsonConvert.DeserializeObject<JArray>(jsonString);

            foreach (JObject jsonObject in jsonArray)
            {
                StockModel.Symbol symbol = new StockModel.Symbol();
                foreach (var property in jsonObject)
                {
                    if (property.Key == "Name")
                    {
                        symbol.SymbolName = property.Value.ToString();
                    }
                    if (property.Key == "Symbol")
                    {
                        symbol.SymbolCode = property.Value.ToString();
                    }

                    symbol.DefaultVal = random.NextDouble() * 1000;
                    symbol.Id = i;
                }
                i = i + 1;
                symbols.Add(symbol);
            }

            return symbols;
        }
예제 #3
0
        public static List <StockModel.Symbol> GetSymbolForMarket(Exchange exchange)
        {
            // Method to get all the company names & their symbols and set their default value & Id
            int i = 1;

            Random random = new Random();
            List <StockModel.Symbol> symbols = new List <StockModel.Symbol>();
            string jsonString;
            string symbolFilePath = string.Empty;

            //exchange specific symbol file paths are configured
            symbolFilePath = WebConfigurationManager.AppSettings[exchange.ToString() + "_SymbolFilePath"];

            //exchange specific symbol file paths are not configured. Pick Defaults.
            if (string.IsNullOrEmpty(symbolFilePath))
            {
                symbolFilePath = WebConfigReader.Read("SymbolFilePath");
            }

            jsonString = System.IO.File.ReadAllText(symbolFilePath);

            JArray jsonArray = JsonConvert.DeserializeObject <JArray>(jsonString);

            foreach (JObject jsonObject in jsonArray)
            {
                StockModel.Symbol symbol = new StockModel.Symbol();
                foreach (var property in jsonObject)
                {
                    if (property.Key == "Name")
                    {
                        symbol.SymbolName = property.Value.ToString();
                    }
                    if (property.Key == "Symbol")
                    {
                        symbol.SymbolCode = property.Value.ToString();
                    }

                    symbol.DefaultVal = random.NextDouble() * 1000;
                    symbol.Id         = i;
                }
                i = i + 1;
                symbols.Add(symbol);
            }

            return(symbols);
        }