Example #1
0
        private static string BuildHtmlTable(string p_tableTitle, MaskItems p_maskItems, double p_pctChgTotalAMean)
        {
            //StringBuilder sb = new StringBuilder(@"<b>" + p_tableTitle + @":</b><br> <table class=""strategyNoteTable1"" width=""400"">");
            StringBuilder sb = new StringBuilder(@"<b>" + p_tableTitle + @":</b><br> <table class=""strategyNoteTable1"">");
            sb.Append(@"<th>Day</th><th>nSamples</th><th>WinPct</th><th>&nbsp; aMean &nbsp; </th><th>gMean</th><th>Median</th><th>StDev</th><th>StError</th><th>t-value(0)</th>" +
                @"<th><div title=""P is calculated by one tailed, one sample T-test"">p-value(0)</div></th>" +
                @"<th><div title=""With at least 1-P=95% probability: the real population mean (of the daily%changes on day T) > 0 {or opposite if T-value negative}"">Signif>0</div></th>" +
                @"<th>t-value(mean)</th>" +
                @"<th><div title=""P is calculated by one tailed, one sample T-test"">p-value(mean)</div></th>" +
                @"<th><div title=""With at least 1-P=95% probability: the real population mean (of the daily%changes on day T) > allDayMean {or opposite if T-value negative}"">Signif>mean</div></th>");

            bool isRowEven = false;     // 1st Row is Odd
            for (int i = 16; i >= 0; i--)   // write only from T-17 to T+17
            {
                if (p_maskItems.Backward[i].Samples.Count() == 0)
                    continue;

                CalculateSampleStats(ref p_maskItems.Backward[i], p_pctChgTotalAMean);
                BuildHtmlTableRow(p_tableTitle, "T-" + (i + 1).ToString(), isRowEven, ref p_maskItems.Backward[i], sb);
                isRowEven = !isRowEven;
            }

            for (int i = 0; i <= 16; i++)  // write only from T-17 to T+17
            {
                if (p_maskItems.Forward[i].Samples.Count() == 0)
                    continue;
                CalculateSampleStats(ref p_maskItems.Forward[i], p_pctChgTotalAMean);
                BuildHtmlTableRow(p_tableTitle, "T+" + (i + 1).ToString(), isRowEven, ref p_maskItems.Forward[i], sb);
                isRowEven = !isRowEven;
            }

            sb.Append("</table>");
            return sb.ToString();
        }
Example #2
0
        private static MaskItems CreateMaskItems(string p_dailyMarketDirectionMaskStr)
        {
            MaskItems maskItems = new MaskItems() { Forward = new MaskItem[30], Backward = new MaskItem[30] };     // (initialized to null: Neutral, not bullish, not bearish)   // trading days; max. 25 is expected.

            for (int k = 0; k < 30; k++)
            {
                maskItems.Forward[k].Samples = new List<Tuple<DateTime, double>>();
                maskItems.Backward[k].Samples = new List<Tuple<DateTime, double>>();
            }

            int iInd = p_dailyMarketDirectionMaskStr.IndexOf('.');
            if (iInd != -1)
            {
                for (int i = iInd + 1; i < p_dailyMarketDirectionMaskStr.Length; i++)
                {
                    Utils.StrongAssert(i - (iInd + 1) < 30, "Mask half-length length should be less than 30: " + p_dailyMarketDirectionMaskStr);
                    switch (p_dailyMarketDirectionMaskStr[i])
                    {
                        case 'U':
                            maskItems.Forward[i - (iInd + 1)].IsBullish = true;
                            break;
                        case 'D':
                            maskItems.Forward[i - (iInd + 1)].IsBullish = false;
                            break;
                        case '0':
                            maskItems.Forward[i - (iInd + 1)].IsBullish = null;
                            break;
                        default:
                            throw new Exception("Cannot interpret p_dailyMarketDirectionMaskTotM: " + p_dailyMarketDirectionMaskStr);
                        //break;
                    }
                }
                for (int i = iInd - 1; i >= 0; i--)
                {
                    Utils.StrongAssert((iInd - 1) - i < 30, "Mask half-length length should be less than 30: " + p_dailyMarketDirectionMaskStr);
                    switch (p_dailyMarketDirectionMaskStr[i])
                    {
                        case 'U':
                            maskItems.Backward[(iInd - 1) - i].IsBullish = true;
                            break;
                        case 'D':
                            maskItems.Backward[(iInd - 1) - i].IsBullish = false;
                            break;
                        case '0':
                            maskItems.Backward[(iInd - 1) - i].IsBullish = null;
                            break;
                        default:
                            throw new Exception("Cannot interpret p_dailyMarketDirectionMaskTotM: " + p_dailyMarketDirectionMaskStr);
                        //break;
                    }
                }
            }

            return maskItems;
        }