Example #1
0
 // 得到某一天的股票属性
 public IStockData GetStock(DateTime dt)
 {
     if (DailyStocks_.ContainsKey(dt))
     {
         return(DailyStocks_[dt]);
     }
     return(null);
 }
Example #2
0
        public void AddStock(DateTime dt, IStockData stock)
        {
            if (!DailyStocks_.ContainsKey(dt))
            {
                DailyStocks_.Add(dt, stock);
            }
            else
            {
                // ???
                // 2009-08-25
            }

            MinDate = (MinDate > dt) ? dt : MinDate;
            MaxDate = (MaxDate < dt) ? dt : MaxDate;
        }
Example #3
0
        public bool IsOperSuccess(DateTime dt, StockOper oper)
        {
            if (oper == null)
            {
                return(false);
            }

            if (oper.Type == OperType.NoOper)
            {
                return(true);
            }

            if (!DailyStocks_.ContainsKey(dt))
            {
                return(false);
            }

            IStockData stock = DailyStocks_[dt];

            return(IsValidOperation(stock, oper));
        }
Example #4
0
        public bool IsOperSuccess(DateTime dt, StockOper oper)
        {
            if (!DailyStocks_.ContainsKey(dt))
            {
                return(false);
            }
            if (oper == null)
            {
                return(false);
            }

            if (oper.Type == OperType.NoOper)
            {
                return(true);
            }

            StockData stock = DailyStocks_[dt];

            switch (oper.Type)
            {
            case OperType.Buy:
                if (oper.UnitPrice >= stock.MinPrice)
                {
                    return(true);
                }
                break;

            case OperType.Sell:
                if (oper.UnitPrice <= stock.MaxPrice)
                {
                    return(true);
                }
                break;

            default:
                break;
            }

            return(false);
        }