示例#1
0
        void Analysize(Chart ch)
        {
            if (GetCheckOnTime(ch.Date))
            {
                Short.Pop();
                Long.Pop();
            }
            Short.Push(Short.Count > 0 ? EMA.Make(specify.Short, Short.Count, ch.Price, Short.Peek()) : EMA.Make(ch.Price));
            Long.Push(Long.Count > 0 ? EMA.Make(specify.Long, Long.Count, ch.Price, Long.Peek()) : EMA.Make(ch.Price));
            double popShort = Short.Pop(), popLong = Long.Pop();
            int    i, quantity = Short.Count > 1 && Long.Count > 1 ? popShort - popLong - (Short.Peek() - Long.Peek()) > 0 ? 1 : -1 : 0;
            var    max = specify.Assets / (specify.Code.Length == 8 ? ch.Price * Const.TransactionMultiplier * Const.MarginRate200402 : ch.Price);

            Short.Push(popShort);
            Long.Push(popLong);

            if (ch.Date > 99999999 && ch.Date.ToString().Substring(6, 4).Equals("1545"))
            {
                info.Save(ch, specify);

                return;
            }
            if (ch.Date > 99999999 && info.Quantity != 0 && GetRemainingDate(specify.Code, ch.Date))
            {
                for (i = Math.Abs(info.Quantity); i > 0; i--)
                {
                    info.Operate(ch, info.Quantity > 0 ? -1 : 1);
                }

                return;
            }
            if (ch.Date > 99999999 && Math.Abs(info.Quantity + quantity) < max)
            {
                info.Operate(ch, quantity);
            }

            else if (ch.Date > 99999999 && Math.Abs(info.Quantity) > max)
            {
                info.Operate(ch, info.Quantity > 0 ? -1 : 1);
            }
        }
示例#2
0
        internal void SetStatisticalStorage(string date, double price, bool over)
        {
            if (over || Array.Exists(Information.RemainingDay, o => o.Equals(date)))
            {
                while (Quantity != 0)
                {
                    if (verify)
                    {
                        statement.Enqueue(new Conclusion
                        {
                            Time        = ConvertDateTime(date),
                            Division    = string.Concat(Quantity > 0 ? sell : buy, conclusion),
                            Price       = price.ToString("F2"),
                            OrderNumber = Count.ToString("N0")
                        });
                    }
                    Quantity += Quantity > 0 ? -1 : 1;
                    SetConclusion(price);
                }
            }
            Revenue = CumulativeRevenue - Commission;
            long revenue = Revenue - TodayRevenue, unrealized = (long)(Quantity == 0 ? 0 : (Quantity > 0 ? price - PurchasePrice : PurchasePrice - price) * Const.TransactionMultiplier * Math.Abs(Quantity));
            var  avg = EMA.Make(++Accumulative, SetWeight(revenue + unrealized - UnRealize), Before);

            games.Enqueue(new Models.Strategics
            {
                Primary    = Convert.ToString(GetPrimary(game.Assets, game.Code, game.Commission, game.MarginRate, game.RollOver), 0x10),
                Assets     = game.Assets,
                Code       = game.Code,
                Commission = game.Commission,
                MarginRate = game.MarginRate,
                Strategy   = game.Strategy,
                RollOver   = game.RollOver,
                BaseTime   = game.BaseTime,
                BaseShort  = game.BaseShort,
                BaseLong   = game.BaseLong,
                NonaTime   = game.NonaTime,
                NonaShort  = game.NonaShort,
                NonaLong   = game.NonaLong,
                OctaTime   = game.OctaTime,
                OctaShort  = game.OctaShort,
                OctaLong   = game.OctaLong,
                HeptaTime  = game.HeptaTime,
                HeptaShort = game.HeptaShort,
                HeptaLong  = game.HeptaLong,
                HexaTime   = game.HexaTime,
                HexaShort  = game.HexaShort,
                HexaLong   = game.HexaLong,
                PentaTime  = game.PentaTime,
                PentaShort = game.PentaShort,
                PentaLong  = game.PentaLong,
                QuadTime   = game.QuadTime,
                QuadShort  = game.QuadShort,
                QuadLong   = game.QuadLong,
                TriTime    = game.TriTime,
                TriShort   = game.TriShort,
                TriLong    = game.TriLong,
                DuoTime    = game.DuoTime,
                DuoShort   = game.DuoShort,
                DuoLong    = game.DuoLong,
                MonoTime   = game.MonoTime,
                MonoShort  = game.MonoShort,
                MonoLong   = game.MonoLong,
                Date       = date,
                Unrealized = unrealized,
                Revenue    = revenue,
                Cumulative = CumulativeRevenue - Commission,
                Fees       = (int)(Commission - TodayCommission),
                Statistic  = (int)avg
            });
            if (Count > 5000)
            {
                new ExceptionMessage(game.Strategy, string.Concat(date, '_', Count));
            }

            Before          = avg;
            TodayCommission = (int)Commission;
            TodayRevenue    = Revenue;
            UnRealize       = unrealized;
            SellOrder.Clear();
            BuyOrder.Clear();
            Residue.Clear();
            Count = 0;
        }
示例#3
0
 protected internal void Analysize(Chart chart)
 {
     if (GetCheckOnTime(chart.Date))
     {
         Short.Pop();
         Long.Pop();
     }
     Short.Push(Short.Count > 0 ? EMA.Make(specify.Short, Short.Count, chart.Price, Short.Peek()) : EMA.Make(chart.Price));
     Long.Push(Long.Count > 0 ? EMA.Make(specify.Long, Long.Count, chart.Price, Long.Peek()) : EMA.Make(chart.Price));
 }