Ejemplo n.º 1
0
        public static List <HouseBreakReport> GenerateHousebreakReport(List <BhavCopy> bhavList, DateTime givenDate)
        {
            List <HouseBreakReport> housebreaksReport = new List <HouseBreakReport>();

            if (bhavList.Count < 40)
            {
                return(new List <HouseBreakReport>());
            }
            for (int i = bhavList.Count - 30; i < bhavList.Count; i++)
            {
                BhavCopy motherCandle    = bhavList[i - 1];
                BhavCopy insideDayCandle = bhavList[i];
                // Check for inside day
                if (IsInsideDay(motherCandle, insideDayCandle))
                {
                    // move till the mother candle high or low breaks
                    for (int j = i + 1; j < bhavList.Count; j++)
                    {
                        if (IsCurrentCandleBreakOutOfMotherCandle(motherCandle, bhavList[j]))
                        {
                            HouseBreakReport hbInfo = new HouseBreakReport();
                            hbInfo.MotherCandleHigh   = motherCandle.H;
                            hbInfo.MotherCandleLow    = motherCandle.L;
                            hbInfo.MotherCandleDate   = motherCandle.Date;
                            hbInfo.NumberofCandles    = j - i;
                            hbInfo.Ticker             = motherCandle.Ticker;
                            hbInfo.BreakOutCandleDate = bhavList[j].Date;
                            if (bhavList[j].C > motherCandle.H)
                            {
                                hbInfo.BullOrBear = "Bullish";
                            }
                            else if (bhavList[j].C <= motherCandle.L)
                            {
                                hbInfo.BullOrBear = "Bearish";
                            }
                            else
                            {
                                hbInfo.BullOrBear = "";
                            }

                            housebreaksReport.Add(hbInfo);
                            //Move the indices
                            i = j;
                            break;
                        }
                        else
                        {
                        }
                    }
                }
            }
            return(housebreaksReport);
        }
Ejemplo n.º 2
0
        private Housebreak CreateHousebreakObjectFromHBR(HouseBreakReport hbr, Ticker ticker)
        {
            Housebreak hb = new Housebreak();

            hb.FK_Ticker_Id     = ticker.Id;
            hb.MotherCandleHigh = hbr.MotherCandleHigh;
            hb.MotherCandleLow  = hbr.MotherCandleLow;
            hb.MotherCandleDate = hbr.MotherCandleDate;

            hb.NumberOfCandles    = hbr.NumberofCandles;
            hb.BreakoutCandleDate = hbr.BreakOutCandleDate;

            hb.Ticker = null; // BUG: if this is assigned ticker object, then it trys to
                              //insert ticker row into tickers table.  so made it  null to fix

            return(hb);
        }
Ejemplo n.º 3
0
        public List <HouseBreakReport> GenerateHousebreakReport(DateTime givenDate)
        {
            IStockScreener          stockScreener             = new StockScreener();
            List <string>           tickerNames               = dbAccessLayer.GetTickerNames();
            List <HouseBreakReport> AllStocksHouseBreakReport = new List <HouseBreakReport>();

            foreach (string ticker in tickerNames)
            {
                List <BhavCopy>         quotesList  = dbAccessLayer.GetQuotes(ticker);
                List <HouseBreakReport> houseBreaks = HousebreakScanner.GenerateHousebreakReport(quotesList, givenDate);
                if (houseBreaks.Count > 0)
                {
                    HouseBreakReport hb = houseBreaks[houseBreaks.Count - 1];
                    AllStocksHouseBreakReport.Add(hb);
                }
            }

            return(AllStocksHouseBreakReport);
        }