Example #1
0
        // Constructor 2 : Interest Rate Line
        public myFrame_old(List <InterestRate_Line> databaseLine)
        {
            // 1. Perform checks on number of series @TODO
            if (databaseLine.Count() != 0)
            {
                // 2. Extract fields from any DB line
                List <string> fieldsList = databaseLine.FirstOrDefault().GetDataFields();

                // 3. Initialize the dict
                foreach (string field in fieldsList)
                {
                    data[field] = new mySeries();
                }


                // 4. Fill the dict
                foreach (InterestRate_Line line in databaseLine)
                {
                    foreach (string field in fieldsList)
                    {
                        data[field].pushback(line.Date, (double)line[field]);
                    }
                }
            }
        }
Example #2
0
        // ************************************************************
        // LOAD-RELATED METHODS
        // ************************************************************

        #region

        // LOAD THE OBJECT FROM A DICT OF DICT
        public void fromDictOfDict(SortedDictionary <string, SortedDictionary <DateTime, double> > argDictOfDict)
        {
            foreach (string mySeriesName in argDictOfDict.Keys)
            {
                mySeries mymySeries = new mySeries(argDictOfDict[mySeriesName]);
                this.add(mySeriesName, mymySeries);
            }
        }
Example #3
0
 // REPLACE mySeries WITHIN EXISTING FRAME
 public void replace(string argmySeriesName, mySeries argmySeries)
 {
     if (this.data.ContainsKey(argmySeriesName))
     {
         this.remove(argmySeriesName);
         this.add(argmySeriesName, argmySeries);
     }
 }
Example #4
0
        // ADD FRAME TO FRAME
        public void add(string argmySeriesName, mySeries argmySeries)
        {
            // Perform sanity checks
            // @TODO : to be implemented

            // Add to frame
            this.data[argmySeriesName] = argmySeries;
        }
Example #5
0
        // MERGE INDEX
        public SortedSet <DateTime> mergeIndex(mySeries argmySeries)
        // previously hashset
        {
            // http://www.dotnetperls.com/combine-keys
            SortedSet <DateTime> ans = new SortedSet <DateTime>(this.data.Keys);

            ans.UnionWith(argmySeries.data.Keys);
            return(ans);
        }
Example #6
0
        // POWERS
        public mySeries Power(double argExp)
        {
            mySeries answer = new mySeries();

            foreach (DateTime dt in this.data.Keys)
            {
                answer[dt] = Math.Pow(this[dt], argExp);
            }

            return(answer);
        }
Example #7
0
        // LOGARITHM LN
        public mySeries LN(double argExp)
        {
            mySeries answer = new mySeries();

            foreach (DateTime dt in this.data.Keys)
            {
                answer[dt] = Math.Log(argExp * this[dt]);
            }

            return(answer);
        }
Example #8
0
        public static mySeries operator -(double num, mySeries den)
        {
            mySeries answer = new mySeries();

            foreach (DateTime dt in den.data.Keys)
            {
                answer[dt] = num - den[dt];
            }

            return(answer);
        }
Example #9
0
        public static mySeries operator -(mySeries num, double den)
        {
            mySeries answer = new mySeries();

            foreach (DateTime dt in num.data.Keys)
            {
                answer[dt] = num[dt] - den;
            }

            return(answer);
        }
Example #10
0
        // CONCAT mySeries
        public mySeries concat(mySeries argmySeries)
        {
            SortedDictionary <DateTime, double> ans = new SortedDictionary <DateTime, double>(this.data);

            foreach (DateTime dt in argmySeries.data.Keys.Where(x => !this.data.Keys.Contains(x)))
            {
                ans.Add(dt, argmySeries.data[dt]);
            }

            return(new mySeries(ans));
        }
Example #11
0
        // SWAP FRAME WITHIN FRAME
        public mySeries swap(string argmySeriesName, mySeries argmySeries)
        {
            mySeries ans = new mySeries();

            if (this.data.ContainsKey(argmySeriesName))
            {
                ans = this.pop(argmySeriesName);
                this.add(argmySeriesName, argmySeries);
            }

            return(ans);
        }
Example #12
0
        // POP FRAME FROM FRAME
        public mySeries pop(string argmySeriesName)
        {
            mySeries ans = new mySeries();

            if (this.data.ContainsKey(argmySeriesName))
            {
                ans = this.data[argmySeriesName];
                this.remove(argmySeriesName);
            }

            return(ans);
        }
Example #13
0
        // SUBTRACTION

        public static mySeries operator -(mySeries num, mySeries den)
        {
            mySeries ansNum = num.merge(den);
            mySeries ansDen = den.merge(num);

            mySeries answer = new mySeries();

            foreach (DateTime dt in ansNum.data.Keys)
            {
                answer[dt] = ansNum[dt] - ansDen[dt];
            }

            return(answer);
        }