Пример #1
0
        public IHttpActionResult GetSymbol([FromUri] string symbol = null)
        {
            using (var symbolRepository = new SymbolRepository())
            {
                var symbolModel = symbolRepository.FindByName(symbol).FirstOrDefault();

                if (symbolModel == null)
                {
                    return(NotFound());
                }

                return(Ok(JsonConvert.SerializeObject(new
                {
                    description = symbolModel.Name,
                    name = symbolModel.Name,
                    minmov = 1,
                    minmov2 = 0,
                    has_intraday = false,
                    has_no_volume = false,
                    pointvalue = 1,
                    pricescale = 100,
                    supported_pesolutions = new[] { "D" },
                    ticker = symbolModel.Name
                })));
            }
        }
Пример #2
0
        public IHttpActionResult FindSymbols(
            [FromUri] string query    = null, [FromUri] string type = null,
            [FromUri] string exchange = null, [FromUri] int?limit   = null)
        {
            using (var symbolRepository = new SymbolRepository())
            {
                var foundSymbols = symbolRepository
                                   .FindByName(query)
                                   .Take(limit ?? 30)
                                   .ToList();

                if (foundSymbols.Count == 0)
                {
                    return(NotFound());
                }

                return(Ok(foundSymbols.Select(s => new { symbol = s.Name, full_name = s.Name })));
            }
        }