コード例 #1
0
ファイル: CGE.cs プロジェクト: w1r2p1/GekkoTimeseries
        private static void PHelper(CesNode node, out string oLeft, out string oRight)
        {
            if (node.IsLeaf())
            {
                oLeft  = oString + node.parent.leftChild.priceId;
                oRight = oString + node.parent.rightChild.priceId;
                return;
            }

            if (node.leftChild.IsLeaf())
            {
                oLeft = oString + node.leftChild.priceId;                           //not a leaf node
            }
            else
            {
                oLeft = "1.0";
            }

            if (node.rightChild.IsLeaf())
            {
                oRight = oString + node.rightChild.priceId;                            //not a leaf node
            }
            else
            {
                oRight = "1.0";
            }
        }
コード例 #2
0
ファイル: CGE.cs プロジェクト: w1r2p1/GekkoTimeseries
 static void Walk2(CesNode node)
 {
     if (node.xCode != null)
     {
         Writeln(node.xCode);
     }
     if (!node.IsLeaf())  //could just as well test .rightChild == null
     {
         //Not a leaf node
         Walk2(node.leftChild);
         Walk2(node.rightChild);
     }
 }
コード例 #3
0
ファイル: CGE.cs プロジェクト: w1r2p1/GekkoTimeseries
        private static string GetCosts(CesNode node)
        {
            string ss = null;

            if (node.IsLeaf())
            {
                ss += "(o" + node.priceId + " * o" + node.volumeId + ")";
            }
            else
            {
                for (int i = 0; i < node.childrenPriceId.Count; i++)
                {
                    ss += "o" + node.childrenPriceId[i] + " * o" + node.childrenVolumeId[i] + " + ";
                }
                ss = ss.Substring(0, ss.Length - 3);
                ss = "(" + ss + ")";
            }
            return(ss);
        }
コード例 #4
0
ファイル: CGE.cs プロジェクト: w1r2p1/GekkoTimeseries
        static void Walk(CesNode node)
        {
            if (!node.IsLeaf())  //could just as well test .rightChild == null
            {
                //Not a leaf node
                Walk(node.leftChild);
                Walk(node.rightChild);

                string costNum = GetCosts(node.leftChild);
                string costDen = GetCosts(node);

                string oLeft;
                string oRight;
                PHelper(node, out oLeft, out oRight);

                node.pCode = "frml _i   " + node.priceId + " = " + "CES_UC(" + node.leftChild.priceId + node.leftChild.eff + "/" + oLeft + ", " + node.rightChild.priceId + node.rightChild.eff + "/" + oRight + ", " + costNum + " / " + costDen + ", " + node.sigma + ");";
            }
            else
            {
                //Leaf node
                ccCode += node.priceId + " * " + node.volumeId + " + ";
            }

            if (node.parent == null)
            {
            }
            else
            {
                string oLeft;
                string oRight;
                PHelper(node.parent, out oLeft, out oRight);
                string s = "CES_XR";
                if (node.isLeftNode)
                {
                    s = "CES_XL";
                }
                string xx = GetCosts(node.parent.leftChild);
                string zz = GetCosts(node);
                string yy = GetCosts(node.parent);
                if (node.IsLeaf())
                {
                    zz = "o" + node.volumeId;
                }
                string ww  = node.parent.volumeId;
                string yy2 = yy;
                string qq1 = null;
                string qq2 = null;
                string qq3 = null;
                if (node.parent.parent == null)
                {
                    ww = activityString;
                    yy = oString + activityString;
                    //qq1 = "/" + node.volumeId.Replace("d", "eff");  //HACK HACK
                    //if (!node.parent.leftChild.priceId.Contains(aggString)) qq2 = qq1;
                    //if (!node.parent.rightChild.priceId.Contains(aggString)) qq3 = qq1;
                }

                string right = zz + node.eff + " * " + s + "(" + ww + "/" + yy + " , " + node.parent.leftChild.priceId + node.parent.leftChild.eff + "/" + oLeft + qq2 + " , " + node.parent.rightChild.priceId + node.parent.rightChild.eff + "/ " + oRight + qq3 + " , " + xx + " / " + yy2 + ", " + node.parent.sigma + ");";
                if (node.volumeId.StartsWith("d") && ww.StartsWith("y"))
                {
                    string uuu = node.volumeId.Replace("d", "y");  //HACK HACK
                    node.xCode = "frml _i   " + uuu + "=" + uuu + "+" + node.volumeId + " - " + right;
                }
                else
                {
                    node.xCode = "frml _i   " + node.volumeId + " = " + right;
                }
            }
        }