Пример #1
0
        public void TestVolatAll()
        {
            IMarketProvider moex = GetMoex();
            IMarketProvider cbr  = GetCbr();

            DataProvider.Input.CombinedProvider.Provider provider =
                new DataProvider.Input.CombinedProvider.Provider(new List <IMarketProvider>()
            {
                moex,
                cbr
            });

            Core.Mir.Environment environment =
                new Core.Mir.Environment();
            environment.Market = new MarketData(provider);

            CalculationOneData calculation = new CalculateVolat.Volat();

            calculation.ReportDate = new DateTime(2018, 05, 12);
            Dictionary <string, object> pars = new Dictionary <string, object>()
            {
                { CalculateVolat.Volat.WINDOW, 5 },
                { CalculateVolat.Volat.MINIMAL_AMOUT, 90 },
            };

            calculation.SetParams(pars);
            calculation.Environment = environment;

            calculation.Run();
        }
Пример #2
0
        public void Yield_()
        {
            IMarketProvider moex = GetMoex();
            IMarketProvider cbr  = GetCbr();

            DataProvider.Input.CombinedProvider.Provider provider =
                new DataProvider.Input.CombinedProvider.Provider(
                    new List <IMarketProvider>()
            {
                moex,
                cbr
            });

            Core.Mir.Environment environment =
                new Core.Mir.Environment();
            environment.Market = new Core.Mir.MarketData(provider);

            CalculationOneData calculation =
                new Yield();

            calculation.Environment = environment;
            calculation.ReportDate  = new DateTime(2018, 05, 14);
            calculation.Run();

            foreach (var x in calculation.returnResultSet().TimeSeries)
            {
                if (x.Value.Series.ContainsKey(calculation.ReportDate))
                {
                    string message = string.Format("{0}\t{1}", x.Key.Ident, x.Value.Series[calculation.ReportDate]);
                    Console.WriteLine(message);
                }
            }
        }
        public void TestCalculateVar()
        {
            IMarketProvider moex = GetMoex();
            IMarketProvider cbr  = GetCbr();

            DataProvider.Input.CombinedProvider.Provider provider =
                new DataProvider.Input.CombinedProvider.Provider(new List <IMarketProvider>()
            {
                moex,
                cbr
            });

            Core.Mir.Environment environment =
                new Core.Mir.Environment();
            environment.Market = new MarketData(provider);

            CalculationOneData calculation = new Var();

            calculation.ReportDate = new DateTime(2018, 05, 04);
            Dictionary <string, object> pars = new Dictionary <string, object>()
            {
                { Var.WINDOW, 5 },
                { Var.QUANTILE, 0.9m },
            };

            calculation.SetParams(pars);
            calculation.Environment = environment;
            bool result = false;

            try
            {
                result = calculation.Run();
            }
            catch
            {
                result = false;
            }
            #region Settings Output
            #region Выгрузка данных в мир
            if (result)
            {
                #region Settings outputProvider
                string mirConnection = ConfigurationManager.AppSettings["mirconnection"];
                DataProvider.Output.Mir.Mapping outMapping = new DataProvider.Output.Mir.Mapping();

                outMapping.AI = new Dictionary <Enum, string>()
                {
                    #region Финансовые инструменты
                    { FinType.Equity, "12" },
                    { FinType.Bond, "13" },
                    { FinType.Fund, "14" },
                    { FinType.Certificate, "15" },
                    { FinType.DepositaryReceipt, "16" },
                    { FinType.FxRate, "20" },
                    { TimeSeriesAttribute.Var, "21675" },
                    #endregion
                };

                outMapping.TKE = new Dictionary <KeyValuePair <Type, string>, Enum>()
                {
                    #region Валюта
                    { new KeyValuePair <Type, string>(typeof(Currencies), "CHF"), Currencies.CHF },
                    { new KeyValuePair <Type, string>(typeof(Currencies), "EUR"), Currencies.EUR },
                    { new KeyValuePair <Type, string>(typeof(Currencies), "GBP"), Currencies.GBP },
                    { new KeyValuePair <Type, string>(typeof(Currencies), "RUB"), Currencies.RUB },
                    { new KeyValuePair <Type, string>(typeof(Currencies), "RUR"), Currencies.RUB },
                    { new KeyValuePair <Type, string>(typeof(Currencies), "USD"), Currencies.USD },
                    #endregion
                };


                outMapping.ET = new Dictionary <Enum, Type>()
                {
                    { ScalarAttribute.DetailedType, typeof(FinTypeDetailedLevel) },
                    { ScalarAttribute.Currency, typeof(Currencies) },
                    { ScalarAttribute.FinType, typeof(FinType) },
                };

                mirConnection = "Host = localhost; Username =postgres; Password =roman; Database =MIR";
                using (var outProvider = new DataProvider.Output.Mir.Provider(mirConnection, outMapping))
                {
                    outProvider.SetParams(new Dictionary <string, object>()
                    {
                        { DataProvider.Output.Mir.Provider.SCALAR, "CALCULATED" },
                        { DataProvider.Output.Mir.Provider.QUOTE, "CALCULATED" }
                    });

                    outProvider.Save(calculation.returnResultSet());
                }



                #endregion
            }
            #endregion

            #region Выгрузка данных в Excel
            string excelPath     = @"C:\Users\RomanBushuev\YandexDisk\MarketData\Reports\Var\";
            string excelFileName = string.Format("{0}.xlsx",
                                                 calculation.ReportDate.ToString("yyyy.MM.dd"));

            DataProvider.Output.Excel.Provider excelProvider =
                new DataProvider.Output.Excel.Provider(excelPath + excelFileName);

            excelProvider.Save(calculation.returnResultSet());
            #endregion
            #endregion
        }