Esempio n. 1
0
        public InterestRate CreateInterestRate(Instrument instrument, int maturity, InterestRateTenorType maturityType)
        {
            lock (objLock)
            {
                if (!(instrument.InstrumentType == InstrumentType.Deposit || instrument.InstrumentType == InstrumentType.InterestRateSwap))
                {
                    throw new Exception("Instrument is not an Interest Rate");
                }

                string            searchString = "ID = " + instrument.ID;
                string            targetString = null;
                DataTable         table        = Database.DB["Quant"].GetDataTable(_interestRateTableName, targetString, searchString);
                DataRowCollection rows         = table.Rows;

                if (rows.Count == 0)
                {
                    DataRow r = table.NewRow();
                    r["ID"]           = instrument.ID;
                    r["Maturity"]     = maturity;
                    r["MaturityType"] = (int)maturityType;
                    rows.Add(r);
                    Database.DB["Quant"].UpdateDataTable(table);

                    return(InterestRate.FindInterestRate(instrument));
                }
                throw new Exception("InterestRate Already Exists");
            }
        }