Exemplo n.º 1
0
        public void loadDBPosition(string position)
        {
            this.instPositionWrapperVMList_ = new ObservableCollection <InstPositionWrapperVM>();

            RiskMonitor.PositionSingletonManger.setReferenceDate(this.ReferenceDate_);

            //db 만들어서 관리 해야함?  ㅇㅇ 그래야함 ㅡ.ㅡㅋ
            instPositionWrapperVMList_.Clear();

            DataBaseManager loader = new DataBaseManager();

            loader.PositionHostInfo_ = new PositionHostInfo(position);

            List <InstPositionInfo> instDataList = loader.loadPositionData();

            foreach (InstPositionInfo item in instDataList)
            {
                InstUriInfo instUri = PositionSingletonManger.CreateInstUriInfo(item.InstCode_, item.InstType_);
                //ResultUriInfo resultUri = CreateResultUriInfo(item.InstCode_, item.InstType_);
                //InstrumentBaseViewModel instBaseVM = InstrumentBaseViewModel.CreateInstBaseVM(instUri, resultUri);
                InstrumentBaseViewModel instBaseVM = InstrumentBaseViewModel.CreateInstBaseVM(instUri);
                instBaseVM.ReferenceDate_ = PositionSingletonManger.referenceDate();

                InstPositionWrapperVM viewModel = new InstPositionWrapperVM(item, instBaseVM);
                instPositionWrapperVMList_.Add(viewModel);
            }
        }
        public void loadDBPosition(string position)
        {
            this.instPositionWrapperVMList_ = new ObservableCollection<InstPositionWrapperVM>();

            RiskMonitor.PositionSingletonManger.setReferenceDate(this.ReferenceDate_);

            //db 만들어서 관리 해야함?  ㅇㅇ 그래야함 ㅡ.ㅡㅋ
            instPositionWrapperVMList_.Clear();

            DataBaseManager loader = new DataBaseManager();
            loader.PositionHostInfo_ = new PositionHostInfo(position);

            List<InstPositionInfo> instDataList = loader.loadPositionData();

            foreach (InstPositionInfo item in instDataList)
            {
                InstUriInfo instUri = PositionSingletonManger.CreateInstUriInfo(item.InstCode_, item.InstType_);
                //ResultUriInfo resultUri = CreateResultUriInfo(item.InstCode_, item.InstType_);
                //InstrumentBaseViewModel instBaseVM = InstrumentBaseViewModel.CreateInstBaseVM(instUri, resultUri);
                InstrumentBaseViewModel instBaseVM = InstrumentBaseViewModel.CreateInstBaseVM(instUri);
                instBaseVM.ReferenceDate_ = PositionSingletonManger.referenceDate();

                InstPositionWrapperVM viewModel = new InstPositionWrapperVM(item, instBaseVM);
                instPositionWrapperVMList_.Add(viewModel);
            }

        }
Exemplo n.º 3
0
        public bool addInstrument(InstrumentBaseViewModel instBaseVM)
        {
            if (!Loader_.hasInstDB(instBaseVM.ItemCode_))
            {
                InstPositionWrapperVM wrapperVM = new InstPositionWrapperVM(instBaseVM);
                this.instPositionWrapperVMList_.Add(wrapperVM);

                // 중복 체크
                Loader_.addInstDB(wrapperVM);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void addUnderFromPosition(InstPositionWrapperVM instPositionWrapperVM)
        {
            StandardInstBaseViewModel stand = instPositionWrapperVM.InstBaseVM_ as StandardInstBaseViewModel;

            UnderlyingViewModel underlyingVM = stand.InstrumentViewModel_.getUnderlying();

            // inst에서 하던under 로 하던 나중에 결정하자으

            bool pickFlag = this.underlyingPickerViewModel_.pickUnderlying(underlyingVM);

            if (pickFlag)
            {
                GreekUnderlyingResultWrapperViewModel greekWrapperVM = new GreekUnderlyingResultWrapperViewModel(underlyingVM);
                this.greekWrapperVMList_.Add(greekWrapperVM);
            }
        }
        private void addUnderFromPosition(InstPositionWrapperVM instPositionWrapperVM)
        {
            StandardInstBaseViewModel stand = instPositionWrapperVM.InstBaseVM_ as StandardInstBaseViewModel;

            UnderlyingViewModel underlyingVM = stand.InstrumentViewModel_.getUnderlying();

            // inst에서 하던under 로 하던 나중에 결정하자으 

            bool pickFlag = this.underlyingPickerViewModel_.pickUnderlying(underlyingVM);

            if (pickFlag)
            {
                GreekUnderlyingResultWrapperViewModel greekWrapperVM = new GreekUnderlyingResultWrapperViewModel(underlyingVM);
                this.greekWrapperVMList_.Add(greekWrapperVM);
            }
            

        }
        public bool addInstrument(InstrumentBaseViewModel instBaseVM)
        {

            if (!Loader_.hasInstDB(instBaseVM.ItemCode_))
            {
                InstPositionWrapperVM wrapperVM = new InstPositionWrapperVM(instBaseVM);
                this.instPositionWrapperVMList_.Add(wrapperVM);

                // 중복 체크
                Loader_.addInstDB(wrapperVM);
                return true;
            }
            else 
            {
                return false;
            }
            
        }
        public void addInstDB(InstPositionWrapperVM wrapperVM)
        {
            SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\Data_Interface\\MarketDataBase.sdf");

            try
            {

                DataTable tb = new DataTable();

                SqlCeCommand command = connection.CreateCommand();
                connection.Open();

                SqlCeCommand delCommand = connection.CreateCommand();
                //delCommand.CommandText = "DELETE FROM CORRELATION WHERE DATE ='" + ReferenceDate_.ToString("yyyyMMdd") + "'";
                //delCommand.ExecuteNonQuery();

                string KR_CODE = QueryStr.wrapComma(wrapperVM.KRCode_);
                string INST_NAME = QueryStr.wrapComma(wrapperVM.InstName_);
                string INST_CODE = QueryStr.wrapComma(wrapperVM.InstCode_);
                string BOOKED_DATE = QueryStr.wrapComma(wrapperVM.BookedDate_);
                string UNBOOKED_DATE = QueryStr.wrapComma(wrapperVM.UnBookedDate_);
                string MATURITY_DATE = QueryStr.wrapComma(wrapperVM.MaturityDate_);
                string INST_TYPE = QueryStr.wrapComma(wrapperVM.InstType_);
                string FILE_NAME = QueryStr.wrapComma(wrapperVM.FileName_);
                string POSITION_NAME = QueryStr.wrapComma(wrapperVM.PositionName_);
                string COUNTERPARTY = QueryStr.wrapComma(wrapperVM.CounterParty_);
                string NOTIONAL = QueryStr.wrapComma(wrapperVM.Notional_);
                string CURRENCY = QueryStr.wrapComma(wrapperVM.Currency_);
                string FUND_CODE = QueryStr.wrapComma(wrapperVM.FundCode_);
                string FUND_NAME = QueryStr.wrapComma(wrapperVM.FundName_);

                command.CommandText = "INSERT INTO POSITIONMASTER (KR_CODE,INST_NAME,INST_CODE,BOOKED_DATE,UNBOOKED_DATE," + 
                                      " MATURITY_DATE,INST_TYPE,FILE_NAME,POSITION_NAME,COUNTERPARTY," + 
                                      " NOTIONAL,CURRENCY,FUND_CODE,FUND_NAME) " +
                                      " VALUES (" + KR_CODE + "," +
                                                    INST_NAME + "," +
                                                    INST_CODE + "," +
                                                    BOOKED_DATE + "," +
                                                    UNBOOKED_DATE + "," +
                                                    MATURITY_DATE + "," +
                                                    INST_TYPE + "," +
                                                    FILE_NAME + "," +
                                                    POSITION_NAME + "," +
                                                    COUNTERPARTY + "," +
                                                    NOTIONAL + "," +
                                                    CURRENCY + "," +
                                                    FUND_CODE + "," +
                                                    FUND_NAME + ")";
                                                  

                    //command.ExecuteNonQuery();

                    //command.Parameters.Add("@pdate", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pcode_a", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pname_a", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pcode_b", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pname_b", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pcorr", SqlDbType.NVarChar);
                    //command.Parameters.Add("@ptype", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pvendor", SqlDbType.NVarChar);
                    //command.Parameters.Add("@pdescription", SqlDbType.NVarChar);

                    //foreach (DataRow item in tb.Rows)
                    //{
                    //    string code_a = item["STOCK_ID"].ToString();
                    //    string code_b = item["OTHER_ID"].ToString();

                    //    if (code_a != code_b)
                    //    {
                    //        command.Parameters["@pdate"].Value = item["STD_DATE"].ToString();
                    //        command.Parameters["@pcode_a"].Value = code_a;
                    //        command.Parameters["@pname_a"].Value = "null";
                    //        command.Parameters["@pcode_b"].Value = code_b;
                    //        command.Parameters["@pname_b"].Value = "null";
                    //        command.Parameters["@pcorr"].Value = item["CORR"].ToString();
                    //        command.Parameters["@ptype"].Value = "History";
                    //        command.Parameters["@pvendor"].Value = "MRO";
                    //        command.Parameters["@pdescription"].Value = "This is test";

                    //        command.ExecuteNonQuery();
                    //    }
                    //}

                command.ExecuteNonQuery();

                connection.Close();

            }
            catch (SqlCeException e)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : MRO DB Load");
                throw;
            }
        }
        public void addInstDB(InstPositionWrapperVM wrapperVM)
        {
            SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\Data_Interface\\MarketDataBase.sdf");

            try
            {
                DataTable tb = new DataTable();

                SqlCeCommand command = connection.CreateCommand();
                connection.Open();

                SqlCeCommand delCommand = connection.CreateCommand();
                //delCommand.CommandText = "DELETE FROM CORRELATION WHERE DATE ='" + ReferenceDate_.ToString("yyyyMMdd") + "'";
                //delCommand.ExecuteNonQuery();

                string KR_CODE       = QueryStr.wrapComma(wrapperVM.KRCode_);
                string INST_NAME     = QueryStr.wrapComma(wrapperVM.InstName_);
                string INST_CODE     = QueryStr.wrapComma(wrapperVM.InstCode_);
                string BOOKED_DATE   = QueryStr.wrapComma(wrapperVM.BookedDate_);
                string UNBOOKED_DATE = QueryStr.wrapComma(wrapperVM.UnBookedDate_);
                string MATURITY_DATE = QueryStr.wrapComma(wrapperVM.MaturityDate_);
                string INST_TYPE     = QueryStr.wrapComma(wrapperVM.InstType_);
                string FILE_NAME     = QueryStr.wrapComma(wrapperVM.FileName_);
                string POSITION_NAME = QueryStr.wrapComma(wrapperVM.PositionName_);
                string COUNTERPARTY  = QueryStr.wrapComma(wrapperVM.CounterParty_);
                string NOTIONAL      = QueryStr.wrapComma(wrapperVM.Notional_);
                string CURRENCY      = QueryStr.wrapComma(wrapperVM.Currency_);
                string FUND_CODE     = QueryStr.wrapComma(wrapperVM.FundCode_);
                string FUND_NAME     = QueryStr.wrapComma(wrapperVM.FundName_);

                command.CommandText = "INSERT INTO POSITIONMASTER (KR_CODE,INST_NAME,INST_CODE,BOOKED_DATE,UNBOOKED_DATE," +
                                      " MATURITY_DATE,INST_TYPE,FILE_NAME,POSITION_NAME,COUNTERPARTY," +
                                      " NOTIONAL,CURRENCY,FUND_CODE,FUND_NAME) " +
                                      " VALUES (" + KR_CODE + "," +
                                      INST_NAME + "," +
                                      INST_CODE + "," +
                                      BOOKED_DATE + "," +
                                      UNBOOKED_DATE + "," +
                                      MATURITY_DATE + "," +
                                      INST_TYPE + "," +
                                      FILE_NAME + "," +
                                      POSITION_NAME + "," +
                                      COUNTERPARTY + "," +
                                      NOTIONAL + "," +
                                      CURRENCY + "," +
                                      FUND_CODE + "," +
                                      FUND_NAME + ")";


                //command.ExecuteNonQuery();

                //command.Parameters.Add("@pdate", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcode_a", SqlDbType.NVarChar);
                //command.Parameters.Add("@pname_a", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcode_b", SqlDbType.NVarChar);
                //command.Parameters.Add("@pname_b", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcorr", SqlDbType.NVarChar);
                //command.Parameters.Add("@ptype", SqlDbType.NVarChar);
                //command.Parameters.Add("@pvendor", SqlDbType.NVarChar);
                //command.Parameters.Add("@pdescription", SqlDbType.NVarChar);

                //foreach (DataRow item in tb.Rows)
                //{
                //    string code_a = item["STOCK_ID"].ToString();
                //    string code_b = item["OTHER_ID"].ToString();

                //    if (code_a != code_b)
                //    {
                //        command.Parameters["@pdate"].Value = item["STD_DATE"].ToString();
                //        command.Parameters["@pcode_a"].Value = code_a;
                //        command.Parameters["@pname_a"].Value = "null";
                //        command.Parameters["@pcode_b"].Value = code_b;
                //        command.Parameters["@pname_b"].Value = "null";
                //        command.Parameters["@pcorr"].Value = item["CORR"].ToString();
                //        command.Parameters["@ptype"].Value = "History";
                //        command.Parameters["@pvendor"].Value = "MRO";
                //        command.Parameters["@pdescription"].Value = "This is test";

                //        command.ExecuteNonQuery();
                //    }
                //}

                command.ExecuteNonQuery();

                connection.Close();
            }
            catch (SqlCeException e)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : MRO DB Load");
                throw;
            }
        }