コード例 #1
0
ファイル: Program.cs プロジェクト: not-a-dev0/trading-view
        public static void SetupQuotes(TickTraderWebClient client)
        {
            using (var symbolRepository = new SymbolRepository())
                using (var quoteRepository = new QuoteRepository())
                {
                    var symbols = symbolRepository.GetAll().ToList();

                    foreach (var symbol in symbols)
                    {
                        try
                        {
                            var periodicities = client.GetQuoteSymbolPeriodicities(symbol.Name);
                            var barInfo       = client.GetBarsInfo(symbol.Name, periodicities[0]);
                            var bars          = client.GetBars(symbol.Name, periodicities[0], barInfo.AvailableTo, BatchSize);
                            foreach (var bar in bars.Bars)
                            {
                                quoteRepository.AddQuote(new Quote
                                {
                                    SymbolId  = symbol.Id,
                                    Timestamp = bar.Timestamp,
                                    Close     = bar.Close,
                                    High      = bar.High,
                                    Low       = bar.Low,
                                    Open      = bar.Open,
                                    Volume    = bar.Open
                                });
                            }
                        }
                        catch (HttpRequestException e)
                        {
                            Console.WriteLine(e.Message);
                        }
                        catch (SqlException e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                }
        }