Example #1
0
        /// <summary>
        /// Verifies the alert.
        /// </summary>
        /// <param name="alert">The alert.</param>
        /// <returns></returns>
        public VerifyResult VerifyAlert(Alert alert)
        {
            VerifyResult result = new VerifyResult();

            int tradingDate = new TickerBLL(_unit).GetLatestTradingDateByShareZone(alert.ShareId, alert.ZoneId);

            result = new ScanCalculator(_unit).CheckDailyMatch(alert.ShareId, tradingDate, alert.Formula);

            return(result);
        }
Example #2
0
        /// <summary>
        /// Uploads the history price ticker.
        /// </summary>
        /// <param name="symbol">The symbol.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public void UploadHistoryPriceTicker(string symbol, DateTime start, DateTime end)
        {
            TickerBLL tbll = new TickerBLL(_unit);

            List <Ticker> tickerList = tbll.GetDailyShareTickerFromYahoo(symbol, start, end);

            if (tickerList != null && tickerList.Count > 0)
            {
                tbll.SaveTickersToDB(tickerList);
            }
        }
Example #3
0
        private List <Entity.Indicator> GetIndicatorsForTrade(TradePosition position, int dateToProcess)
        {
            List <Entity.Indicator> iList = new List <Entity.Indicator>();

            int startDate = this.GetPositionStartDate(position);

            IndicatorBLL iBll = new IndicatorBLL(_unit);

            iList = iBll.GetIndicatorListByShareDate(position.ShareId, startDate, dateToProcess).OrderByDescending(p => p.TradingDate).ToList();
            List <Ticker> tList = new TickerBLL(_unit).GetTickerListByShareDB(position.ShareId, startDate, dateToProcess).OrderByDescending(p => p.TradingDate).ToList();

            iBll.PopulateIndicatorsWithTickers(iList, tList);

            return(iList.OrderBy(p => p.TradingDate).ToList());
        }
Example #4
0
        private Ticker[] GetTickers(int shareID, int startDate, int?endDate)
        {
            Ticker[] tickerResult = null;

            // -1 for no criteria
            int end = -1;

            if (endDate.HasValue)
            {
                end = endDate.Value;
            }

            tickerResult = new TickerBLL(_unit).GetTickerListByShareDB(shareID, startDate, end).ToArray();

            return(tickerResult);
        }
        public void PopulateReview(TradeReview review)
        {
            TransactionBLL   tBLL  = new TransactionBLL(_unit);
            TradePositionBLL tpBll = new TradePositionBLL(_unit);
            IndicatorBLL     iBll  = new IndicatorBLL(_unit);
            TickerBLL        tkBll = new TickerBLL(_unit);

            OutPosition pos = tpBll.GetOutPositionById(review.TradePositionId);

            Transaction entryTr = tBLL.GetByID(pos.EntryTransactionId);

            Entity.Indicator entryInd = iBll.GetIndicatorByShareDate(pos.ShareId, entryTr.TradingDate);
            Ticker           entryT   = tkBll.GetTickerByDate(pos.ShareId, entryTr.TradingDate);

            iBll.PopulateIndicatorWithTicker(entryInd, entryT);

            review.IsEntryLong = pos.Size > 0 ? true : false;

            if (entryInd.BB_Low.HasValue && entryInd.BB_High.HasValue)
            {
                review.BBEntryPercent = 100 * (entryTr.Price - entryInd.BB_Low.Value) / (entryInd.BB_High.Value - entryInd.BB_Low.Value);
            }

            review.EntryPercent = 100 * (entryTr.Price - entryInd.Low.Value) / (entryInd.High.Value - entryInd.Low.Value);

            if (pos.ExitTransactionId.HasValue)
            {
                Transaction      exitTr  = new TransactionBLL(_unit).GetByID(pos.ExitTransactionId.Value);
                Entity.Indicator exitInd = new IndicatorBLL(_unit).GetIndicatorByShareDate(pos.ShareId, exitTr.TradingDate);
                Ticker           exitT   = tkBll.GetTickerByDate(pos.ShareId, exitTr.TradingDate);
                iBll.PopulateIndicatorWithTicker(exitInd, exitT);

                if (exitInd.BB_Low.HasValue && exitInd.BB_High.HasValue)
                {
                    review.BBExitPercent = 100 * (exitTr.Price - exitInd.BB_Low.Value) / (exitInd.BB_High.Value - exitInd.BB_Low.Value);
                }

                review.ExitPercent = 100 * (exitTr.Price - exitInd.Low.Value) / (exitInd.High.Value - exitInd.Low.Value);

                review.DaysSpan = pos.Days;
                review.Diff     = pos.Diff;
                review.Diff_Per = pos.Diff_Per;
            }
        }
Example #6
0
        public AlertResult CheckAlert(Alert alert, int tradingDate)
        {
            VerifyResult result            = null;
            AlertResult  aResult           = null;
            int          latestTradingDate = new TickerBLL(_unit).GetLatestTradingDateByShareZone(alert.ShareId, alert.ZoneId);

            if (latestTradingDate >= tradingDate)
            {
                result = VerifyAlert(alert);

                aResult = new AlertResult
                {
                    AlertId     = alert.Id,
                    IsMatch     = result.IsMatch,
                    Message     = result.ErrorMessage,
                    TradingDate = result.TradingDate,
                    ShareId     = alert.ShareId,
                    ZoneId      = alert.ZoneId,
                    ProcessDT   = DateTime.Now
                };
            }
            return(aResult);
        }
 public TradeSimulateOrderBLL(IUnitWork unit) : base(unit)
 {
     tBll = new TickerBLL(_unit);
 }