Ejemplo n.º 1
0
        // ************************************************************
        // METHODS -- INSERT
        // ************************************************************

        #region

        /// <summary>
        /// Insert data into a table. Data is passed as a line.
        /// The DB line type must (i) be a subclass of GenericDatabaseLine and (ii) match the given table columns.
        /// </summary>
        /// <param name="argLineToInsert"></param>
        public void Insert_OLD <T>(IDtoken id, List <T> argLineToInsert) where T : GenericDatabaseLine
        {
            if (argLineToInsert.Count() > 0)
            {
                // Identify table to be addressed
                string table = argLineToInsert.FirstOrDefault().GetTable();

                // Build SQL command string
                //DateTime dt = (argLineToInsert as T).GetDate();


                string insert_table      = "INSERT into " + table;
                string insert_fields     = "(" + joinString(argLineToInsert.FirstOrDefault().GetAllFields(), " ,", false) + ")";
                string insert_values     = "values (" + joinStringWithDate(argLineToInsert.FirstOrDefault().GetAllFields(), " ,", true) + ")";
                string InsertUndlDataEOD = joinString(new List <string>()
                {
                    insert_table, insert_fields, insert_values
                }, " ", false);

                // Execute SQL command
                using (var connection = new MySqlConnection(connectionString))
                {
                    connection.Execute(InsertUndlDataEOD, argLineToInsert);
                }
            }
        }
Ejemplo n.º 2
0
        private void SetData_myDB_Bond(IDtoken idTok, myFrame data)
        {
            myDB_Connector   myConnect    = new myDB_Connector();
            List <Bond_Line> dataToInsert = data.ToList <Bond_Line>(idTok.DBID);

            myConnect.Insert <Bond_Line>(idTok, dataToInsert);
        }
Ejemplo n.º 3
0
        private void SetData_myDB(IDtoken idTok, string Table, myFrame Data)
        {
            switch (Table)
            {
            case "InterestRate":
                SetData_myDB_InterestRate(idTok, Data);
                break;

            case "Equity":
                SetData_myDB_Equity(idTok, Data);
                break;

            case "EquityVolatility":
                SetData_myDB_EquityVolatility(idTok, Data);
                break;


            case "Bond":
                SetData_myDB_Bond(idTok, Data);
                break;

            default:
            { throw new System.ArgumentException("CH_MappingException", "Connector Helper unable to map the database."); }
            }
        }
Ejemplo n.º 4
0
        // Constructor 2 : Identified only from DBID (int)
        public EquityIndex(int argDBID)
            : base()
        {
            IDtoken myDBID = TokenFactory.New(argDBID);

            this.DBID = myDBID;
        }
Ejemplo n.º 5
0
        // Constructor 2 : Identified only from DBID
        public EquityIndexOption(string argDBID)
            : base()
        {
            IDtoken myDBID = TokenFactory.New(argDBID);

            this.DBID = myDBID;
        }
Ejemplo n.º 6
0
        private void SetData_myDB_EquityVolatility(IDtoken idTok, myFrame data)
        {
            myDB_Connector myConnect = new myDB_Connector();
            List <EquityVolatility_Line> dataToInsert = data.ToList <EquityVolatility_Line>(idTok.DBID);

            myConnect.Insert <EquityVolatility_Line>(idTok, dataToInsert);
        }
Ejemplo n.º 7
0
        // Constructor 4 : Identified only from DBID (int) & Date
        public EquityIndex(int argDBID, DateTime pricingDate)
            : base()
        {
            IDtoken myDBID = TokenFactory.New(argDBID);

            this.pricingDate = pricingDate;
            this.DBID        = myDBID;
        }
Ejemplo n.º 8
0
        private void MapLocalID(IDtoken CompleteID)
        {
            if (CompleteID.DBID == 0)
            {
                throw new System.ArgumentException("FetcherHelperSourceException", "Fetcher Helper: reference line does not contain DBID.");
            }

            this.dbid = new DBID(CompleteID.DBID);
        }
Ejemplo n.º 9
0
        private void MapExternalID(string source, IDtoken CompleteID)
        {
            if (CompleteID[source] == null)
            {
                throw new System.ArgumentException("FetcherHelperExtIDException", "Fetcher Helper: Unable to get the external ID from the reference line.");
            }

            this.externalID = (string)CompleteID[source];
        }
Ejemplo n.º 10
0
        protected void MapSource(IDtoken CompleteID)
        {
            if (CompleteID.Source1 == null)
            {
                throw new System.ArgumentException("FetcherHelperSourceException", "Fetcher Helper unable to map the source from reference table.");
            }

            source = CompleteID.Source1;
        }
Ejemplo n.º 11
0
        // ************************************************************
        // METHODS -- INSERT DATA
        // ************************************************************

        #region Insert data


        public void SetData(IDtoken idTok, string Database, string Table, myFrame Data)
        {
            switch (Database)
            {
            case "myDB":
                SetData_myDB(idTok, Table, Data);
                break;

            default:
            { throw new System.ArgumentException("CH_MappingException", "Connector Helper unable to map the database."); }
            }
        }
Ejemplo n.º 12
0
        protected myFrame EndOfDay(IDtoken referenceToken, DateTime startDate = new DateTime(), DateTime endDate = new DateTime())
        {
            if (startDate == DateTime.MinValue)
            {
                startDate = _historyStartDate;
            }
            if (endDate == DateTime.MinValue)
            {
                endDate = _historyEndDate;
            }

            HistoricalDataRequest myRequest = new HistoricalDataRequest(referenceToken, startDate, endDate);

            return(_localDatabase.GetEODPrices(myRequest));
        }
        private myFrame EndOfDay(IDtoken referenceToken, DateTime startDate = new DateTime(), DateTime endDate = new DateTime())
        {
            if (startDate == DateTime.MinValue)
            {
                startDate = optionTradeDates().LastOrDefault().ToDateTime();
            }
            if (endDate == DateTime.MinValue)
            {
                endDate = optionTradeDates().FirstOrDefault().ToDateTime();
            }

            HistoricalDataRequest myRequest = new HistoricalDataRequest(referenceToken, startDate, endDate);

            return(_localDatabase.GetEODPrices(myRequest));
        }
Ejemplo n.º 14
0
        private Dictionary <string, string> MapExtIDs(IDtoken Idtoken)
        {
            Dictionary <string, string> output = new Dictionary <string, string>();

            string[] availableSources = Enum.GetNames(typeof(ExternalSources));

            foreach (string key in availableSources)
            {
                if (!(Idtoken[(string)key] == ""))
                {
                    output[key] = (string)Idtoken[key];
                }
            }

            return(output);
        }
Ejemplo n.º 15
0
 // Constructor 2 : Full fledged
 public myDepositRate(DateTime PricingDate_,
                      Period DepoPeriod_,
                      IDtoken argDBID_,
                      int DepoFixingDays_,
                      BusinessDayConvention DepoBusDayConv_,
                      DayCounter DepoDayCounter_,
                      string DepoCurrency_)
     : base(PricingDate_: PricingDate_, Currency_: DepoCurrency_, _IdToken: argDBID_)
 {
     //this.PricingDate = PricingDate_;      // moved up to base class (myRate)
     this.DepoPeriod = DepoPeriod_;
     //this.DBID = argDBID_;                 // moved up to base class (myRate)
     this.DepoFixingDays = DepoFixingDays_;
     this.DepoBusDayConv = DepoBusDayConv_;
     this.DepoDayCounter = DepoDayCounter_;
     //this.DepoCurrency = DepoCurrency_;    // moved up to base class (myRate)
 }
Ejemplo n.º 16
0
        // Constructor 2 : Full fledged

        public myDepositRateEUR(DateTime PricingDate_,
                                Period Period_,
                                IDtoken argDBID_,
                                int FixingDays_,
                                BusinessDayConvention BDC_,
                                DayCounter DayCounter_)


            : base(
                PricingDate_: PricingDate_,
                DepoPeriod_: Period_,
                argDBID_: argDBID_,
                DepoFixingDays_: FixingDays_,
                DepoBusDayConv_: BDC_,
                DepoDayCounter_: DayCounter_,
                DepoCurrency_: "EUR"
                )
        {
        }
Ejemplo n.º 17
0
        // Constructor 2 : Normal usage

        /*
         * public mySwapRate(DateTime PricingDate, string Currency, IDtoken argDBID)
         * {
         *  this.PricingDate = PricingDate;
         *  this.Currency = Currency;
         *  this._DBID = argDBID;
         * }
         *
         */


        // Constructor 3 : Full fledged
        public mySwapRate(DateTime PricingDate_,
                          Frequency Frequency_,
                          Period Period_,
                          IDtoken argDBID_,
                          Period ForwardStart_,
                          BusinessDayConvention SwapFixedLegBDC_,
                          DayCounter SwapFixedLegDayCounter_,
                          IborIndex SwapFloatingLegIndex_,
                          string SwapCurrency_) : base(PricingDate_: PricingDate_, Currency_: SwapCurrency_, _IdToken: argDBID_)
        {
            //this.PricingDate = PricingDate_;          // moved up to base class (myRate)
            this.SwapFixedLegFrequency = Frequency_;
            //this.DBID = argDBID_;                     // moved up to base class (myRate)
            this.ForwardStart         = ForwardStart_;
            this.SwapFixedLegBDC      = SwapFixedLegBDC_;
            this.SwapFixedLegDayCount = SwapFixedLegDayCounter_;
            this.SwapFloatingLegIndex = SwapFloatingLegIndex_;
            //this.SwapCurrency = SwapCurrency_;        // moved up to base class (myRate)
            this.SwapPeriod = Period_;
        }
Ejemplo n.º 18
0
        // Constructor 2 : Normal usage

        public mySwapRateEUR(DateTime PricingDate_,
                             Frequency Frequency_,
                             Period Period_,
                             IDtoken argDBID_,
                             Period ForwardStart_,
                             BusinessDayConvention SwapFixedLegBDC_,
                             DayCounter SwapFixedLegDayCounter_,
                             IborIndex SwapFloatingLegIndex_)

            : base(
                PricingDate_: PricingDate_,
                Frequency_: Frequency_,
                Period_: Period_,
                argDBID_: argDBID_,
                ForwardStart_: ForwardStart_,
                SwapFixedLegBDC_: SwapFixedLegBDC_,
                SwapFixedLegDayCounter_: SwapFixedLegDayCounter_,
                SwapFloatingLegIndex_: SwapFloatingLegIndex_,
                SwapCurrency_: "EUR"
                )
        {
        }
Ejemplo n.º 19
0
        private Dictionary <string, string> MapSources(IDtoken Idtoken)
        {
            List <string> fields = new List <string>()
            {
                "Source1", "Source2", "Source3", "Source4", "Source5"
            };

            Dictionary <string, string> output = new Dictionary <string, string>()
            {
                { "Source1", "" }, { "Source2", "" }, { "Source3", "" }, { "Source4", "" }, { "Source5", "" }
            };

            foreach (string key in fields)
            {
                if (!(Idtoken[(string)key] == ""))
                {
                    output[key] = (string)Idtoken[key];
                }
            }

            return(output);
        }
Ejemplo n.º 20
0
 // Constructor 2 : Common usage
 public myRate(DateTime PricingDate_, string Currency_, IDtoken _IdToken)
 {
     this.PricingDate  = PricingDate_;
     this.DBID         = _IdToken;
     this.DepoCurrency = Currency_;
 }
Ejemplo n.º 21
0
 // Constructor 3 : Identified only from IDToken
 public EquityIndex(IDtoken idToken)
     : base()
 {
     this.DBID = idToken;
 }
Ejemplo n.º 22
0
 // Constructor 5 : Identified only from IDToken & Date
 public EquityIndex(IDtoken idToken, DateTime pricingDate)
     : base()
 {
     this.pricingDate = pricingDate;
     this.DBID        = idToken;
 }
Ejemplo n.º 23
0
        // Accès aux données de la base via le helper
        protected myFrame EndOfDay(int referenceDBID, DateTime startDate = new DateTime(), DateTime endDate = new DateTime())
        {
            IDtoken thisToken = GetToken(referenceDBID);

            return(EndOfDay(thisToken, startDate, endDate));
        }