Esempio n. 1
0
        public void JudgeShape(ICustomLog log)
        {
            int tTypeCount     = 0;
            int revTTypeCount  = 0;
            int crossTypeCount = 0;

            foreach (KeyValuePair <DateTime, IStockData> entry in DailyStocks_)
            {
                if (ShapeJudger.IsCross(entry.Value))
                {
                    crossTypeCount++;
                }

                if (ShapeJudger.IsT(entry.Value))
                {
                    tTypeCount++;
                }

                if (ShapeJudger.IsReverseT(entry.Value))
                {
                    revTTypeCount++;
                }
            }

            log.LogInfo("Total Count = " + DailyStocks_.Count
                        + ", Cross = " + crossTypeCount
                        + ", T = " + tTypeCount
                        + ", Rev T = " + revTTypeCount);
        }
Esempio n. 2
0
        public override ICollection <StockOper> GetOper(DateTime day, IAccount account)
        {
            IStockData curProp = stockHistory.GetStock(day);

            if (!CheckStock(curProp, day))
            {
                return(null);
            }

            _Averager.AddVal(curProp.Amount);
            _SlopeCalc.AddVal(curProp.EndPrice); // 计算收盘价斜率

            if (!_Averager.IsEnough() || !_SlopeCalc.IsEnough())
            {
                return(null);
            }

            ICollection <StockOper> opers = new List <StockOper>();
            double avgMinAmount           = _Averager.GetValue() * (1 - _BuyMargin);
            double avgMaxAmount           = _Averager.GetValue() * (1 + _SellMargin);

            ShapeJudger judger = new ShapeJudger(curProp);

            //if ((curProp.Amount < avgMinAmount) && (judger.IsCross() && _SlopeCalc.IsDownPeriod()))
            if ((curProp.Amount < avgMinAmount) && ShapeJudger.IsCross(curProp))
            {
                // 成交地量,十字星,买入
                int stockCount = Transaction.GetCanBuyStockCount(account.BankRoll,
                                                                 curProp.EndPrice);
                if (stockCount > 0)
                {
                    StockOper oper = new StockOper(curProp.EndPrice, stockCount, OperType.Buy);
                    opers.Add(oper);
                    return(opers);
                }
            }
            else if ((curProp.Amount > avgMaxAmount) && _SlopeCalc.IsRisePeriod())
            {
                // 上涨过程,成交天量,卖出
                if (stockHolder.HasStock())
                {
                    StockOper oper = new StockOper(curProp.EndPrice, stockHolder.StockCount(), OperType.Sell);
                    opers.Add(oper);
                    return(opers);
                }
            }

            if (judger.IsReverseT())
            {
                // 倒T型,卖出
                if (stockHolder.HasStock())
                {
                    StockOper oper = new StockOper(curProp.EndPrice, stockHolder.StockCount(), OperType.Sell);
                    opers.Add(oper);
                    return(opers);
                }
            }

            return(null);
        }