示例#1
0
        protected internal override void OnEquity(double equity)
        {
            if (this.longAccValue == 0 && this.shortAccValue == 0)
            {
                this.longAccValue = this.shortAccValue = this.portfolio.AccountValue;
            }

            var longValue  = this.longAccValue;
            var shortValue = this.shortAccValue;

            foreach (var position in this.portfolio.Positions)
            {
                var value = position.Value;
                if (position.Side == PositionSide.Long)
                {
                    longValue += value;
                }
                else
                {
                    shortValue -= value;
                }
            }
            this.longEquityMax  = Max(longValue, this.longEquityMax);
            this.shortEquityMax = Max(shortValue, this.shortEquityMax);
            this.totalEquityMax = Max(equity, this.totalEquityMax);
            this.longValue      = longValue - this.longEquityMax;
            this.shortValue     = shortValue - this.shortEquityMax;
            this.totalValue     = equity - this.totalEquityMax;
            LongValues.Add(Clock.DateTime, this.longValue);
            ShortValues.Add(Clock.DateTime, this.shortValue);
            TotalValues.Add(Clock.DateTime, this.totalValue);
            Emit();
        }
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == this.type)
     {
         bool changed = false;
         if (statistics.LongValues.Count > LongValues.Count)
         {
             this.longAvg   = (this.longAvg * LongValues.Count + statistics.LongValue) / (LongValues.Count + 1);
             this.longValue = GetStdDev(statistics.LongValues, this.longAvg);
             LongValues.Add(Clock.DateTime, LongValue);
             changed = true;
         }
         if (statistics.ShortValues.Count > this.shortValues.Count)
         {
             this.shortAvg   = (this.shortAvg * this.shortValues.Count + statistics.ShortValue) / (ShortValues.Count + 1);
             this.shortValue = GetStdDev(statistics.ShortValues, this.shortAvg);
             ShortValues.Add(Clock.DateTime, this.shortValue);
             changed = true;
         }
         if (statistics.TotalValues.Count > this.totalValues.Count)
         {
             this.totalAvg   = (this.totalAvg * this.totalValues.Count + statistics.TotalValue) / (TotalValues.Count + 1);
             this.totalValue = GetStdDev(statistics.TotalValues, this.totalAvg);
             TotalValues.Add(Clock.DateTime, this.totalValue);
             changed = true;
         }
         if (changed)
         {
             Emit();
         }
     }
 }
示例#3
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            var changed = false;

            if (statistics.Type == PortfolioStatisticsType.GrossProfit)
            {
                this.grossProfit = statistics;
                changed          = true;
            }
            if (statistics.Type == PortfolioStatisticsType.GrossLoss)
            {
                this.grossLoss = statistics;
                changed        = true;
            }
            if (changed)
            {
                this.longValue = this.shortValue = this.totalValue = 0;
                if (this.grossProfit != null)
                {
                    this.longValue  += this.grossProfit.LongValue;
                    this.shortValue += this.grossProfit.ShortValue;
                    this.totalValue += this.grossProfit.TotalValue;
                }
                if (this.grossLoss != null)
                {
                    this.longValue  += this.grossLoss.LongValue;
                    this.shortValue += this.grossLoss.ShortValue;
                    this.totalValue += this.grossLoss.TotalValue;
                }
                LongValues.Add(Clock.DateTime, this.longValue);
                ShortValues.Add(Clock.DateTime, this.shortValue);
                TotalValues.Add(Clock.DateTime, this.totalValue);
                Emit();
            }
        }
示例#4
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == PortfolioStatisticsType.NumOfWinTrades)
     {
         bool changed = false;
         if (statistics.LongValue > this.longWinTrades)
         {
             this.longWinTrades = statistics.LongValue;
             LongValues.Add(Clock.DateTime, this.longValue += 1.0);
             changed = true;
         }
         if (statistics.ShortValue > this.shortWinTrades)
         {
             this.shortWinTrades = statistics.ShortValue;
             ShortValues.Add(Clock.DateTime, this.shortValue += 1.0);
             changed = true;
         }
         if (statistics.TotalValue > this.totalWinTrades)
         {
             this.totalWinTrades = statistics.TotalValue;
             TotalValues.Add(Clock.DateTime, this.totalValue += 1.0);
             changed = true;
         }
         if (changed)
         {
             Emit();
         }
     }
     if (statistics.Type == PortfolioStatisticsType.NumOfLossTrades)
     {
         bool changed = false;
         if (statistics.LongValue > this.longLossTrades)
         {
             this.longLossTrades = statistics.LongValue;
             this.longValue      = 0;
             LongValues.Add(Clock.DateTime, 0);
             changed = true;
         }
         if (statistics.ShortValue > this.shortLossTrades)
         {
             this.shortLossTrades = statistics.ShortValue;
             this.shortValue      = 0;
             ShortValues.Add(Clock.DateTime, 0);
             changed = true;
         }
         if (statistics.TotalValue > this.totalLossTrades)
         {
             this.totalLossTrades = statistics.TotalValue;
             this.totalValue      = 0;
             TotalValues.Add(Clock.DateTime, 0);
             changed = true;
         }
         if (changed)
         {
             Emit();
         }
     }
 }
示例#5
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == PortfolioStatisticsType.DailyReturnPercentStdDev)
     {
         this.totalValue = this.AnnualizedFactor * statistics.TotalValue;
         TotalValues.Add(Clock.DateTime, this.totalValue);
         Emit();
     }
 }
示例#6
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == 66)
     {
         this.totalValue = statistics.TotalValue * AnnualizedFactor;
         TotalValues.Add(Clock.DateTime, this.totalValue);
         Emit();
     }
 }
示例#7
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == PortfolioStatisticsType.AnnualReturn)
     {
         this.totalValue = Pow(1 + Enumerable.Range(0, statistics.TotalValues.Count).Sum(i => statistics.TotalValues[i]) / this.initial, 1.0 / statistics.TotalValues.Count) - 1;
         TotalValues.Add(Clock.DateTime, this.totalValue);
         Emit();
     }
 }
示例#8
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == PortfolioStatisticsType.DailyDownsideRisk)
     {
         this.totalValue = AnnualizedFactor * statistics.TotalValue;
         TotalValues.Add(Clock.DateTime, this.totalValue);
         Emit();
     }
 }
示例#9
0
 protected internal override void OnInit()
 {
     this.shortValue = 1;
     this.longValue  = 1;
     this.totalValue = 1;
     LongValues.Add(Clock.DateTime, this.longValue);
     ShortValues.Add(Clock.DateTime, this.shortValue);
     TotalValues.Add(Clock.DateTime, this.totalValue);
     Subscribe(PortfolioStatisticsType.NetProfit);
     Subscribe(PortfolioStatisticsType.MaxDrawdown);
 }
示例#10
0
 protected internal override void OnInit()
 {
     this.shortValue = 1;
     this.longValue  = 1;
     this.totalValue = 1;
     LongValues.Add(Clock.DateTime, this.longValue);
     ShortValues.Add(Clock.DateTime, this.shortValue);
     TotalValues.Add(Clock.DateTime, this.totalValue);
     base.Subscribe(PortfolioStatisticsType.GrossProfit);
     base.Subscribe(PortfolioStatisticsType.GrossLoss);
 }
示例#11
0
 protected internal override void OnInit()
 {
     this.shortValue = 1;
     this.longValue  = 1;
     this.totalValue = 1;
     LongValues.Add(Clock.DateTime, this.longValue);
     ShortValues.Add(Clock.DateTime, this.shortValue);
     TotalValues.Add(Clock.DateTime, this.totalValue);
     Subscribe(PortfolioStatisticsType.AvgWinTrade);
     Subscribe(PortfolioStatisticsType.AvgLossTrade);
 }
示例#12
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == this.type)
     {
         this.longValue = Max(this.longValue, statistics.LongValue);
         LongValues.Add(Clock.DateTime, this.longValue);
         this.shortValue = Max(this.shortValue, statistics.ShortValue);
         ShortValues.Add(Clock.DateTime, this.shortValue);
         this.totalValue = Max(this.totalValue, statistics.TotalValue);
         TotalValues.Add(Clock.DateTime, this.totalValue);
         Emit();
     }
 }
示例#13
0
 protected internal override void OnRoundTrip(TradeInfo trade)
 {
     if (trade.IsLong)
     {
         LongValues.Add(Clock.DateTime, this.longValue += 1);
     }
     else
     {
         ShortValues.Add(Clock.DateTime, this.shortValue += 1);
     }
     TotalValues.Add(Clock.DateTime, this.totalValue += 1);
     Emit();
 }
示例#14
0
 protected internal override void OnRoundTrip(TradeInfo trade)
 {
     if (trade.IsLong)
     {
         this.longValue = trade.NetPnL;
         LongValues.Add(Clock.DateTime, this.longValue);
     }
     else
     {
         this.shortValue = trade.NetPnL;
         ShortValues.Add(Clock.DateTime, this.shortValue);
     }
     this.totalValue = trade.NetPnL;
     TotalValues.Add(Clock.DateTime, this.totalValue);
     Emit();
 }
示例#15
0
 protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
 {
     if (statistics.Type == PortfolioStatisticsType.DailyReturnPercent)
     {
         this.sumsq += Pow(Max(0, statistics.TotalValue - Threshold), 2);
         if (statistics.TotalValue < 0)
         {
             this.count++;
         }
         if (this.count > 0)
         {
             this.totalValue = Sqrt(this.sumsq / this.count);
             TotalValues.Add(Clock.DateTime, this.totalValue);
             Emit();
         }
     }
 }
示例#16
0
        public async Task <TotalValues> TotalValues()
        {
            using (var context = new DataContext())
            {
                TotalValues totalValues = new TotalValues();

                totalValues.TotalDeaths = await context.CountryDetails.SumAsync(x => x.Death);

                totalValues.TotalCure = await context.CountryDetails.SumAsync(x => x.Cure);

                totalValues.TotalPatient = await context.CountryDetails.SumAsync(x => x.Patient);

                totalValues.Total = totalValues.TotalCure + totalValues.TotalDeaths + totalValues.TotalPatient;


                return(totalValues);
            }
        }
示例#17
0
 protected internal override void OnEquity(double equity)
 {
     if (this.dateTime == DateTime.MinValue)
     {
         this.dateTime = Clock.DateTime;
         this.initial  = equity;
     }
     if (Clock.DateTime.Year > this.dateTime.Year)
     {
         if (this.initial != 0)
         {
             this.totalValue = (equity - this.initial) / this.initial;
             TotalValues.Add(Clock.DateTime, this.totalValue);
             Emit();
         }
         this.dateTime = Clock.DateTime;
         this.initial  = equity;
     }
 }
示例#18
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;

            if (statistics.Type == PortfolioStatisticsType.AvgWinTrade)
            {
                this.avgWinTrades = statistics;
                changed           = true;
            }
            if (statistics.Type == PortfolioStatisticsType.AvgLossTrade)
            {
                this.avgLossTrades = statistics;
                changed            = true;
            }
            if (changed && this.avgWinTrades != null && this.avgLossTrades != null)
            {
                bool updated = false;
                if (this.avgLossTrades.LongValue != 0)
                {
                    this.longValue = Abs(this.avgWinTrades.LongValue / this.avgLossTrades.LongValue);
                    LongValues.Add(Clock.DateTime, this.longValue);
                    updated = true;
                }
                if (this.avgLossTrades.ShortValue != 0.0)
                {
                    this.shortValue = Math.Abs(this.avgWinTrades.ShortValue / this.avgLossTrades.ShortValue);
                    ShortValues.Add(Clock.DateTime, this.shortValue);
                    updated = true;
                }
                if (this.avgLossTrades.TotalValue != 0.0)
                {
                    this.totalValue = Abs(this.avgWinTrades.TotalValue / this.avgLossTrades.TotalValue);
                    TotalValues.Add(Clock.DateTime, this.totalValue);
                    updated = true;
                }
                if (updated)
                {
                    Emit();
                }
            }
        }
示例#19
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;

            if (statistics.Type == PortfolioStatisticsType.NumOfWinTrades)
            {
                this.numOfWinTrades = statistics;
                changed             = true;
            }
            if (statistics.Type == PortfolioStatisticsType.NumOfTrades)
            {
                this.numOfTrades = statistics;
                changed          = true;
            }
            if (changed && this.numOfWinTrades != null && this.numOfTrades != null)
            {
                bool updated = false;
                if (this.numOfTrades.LongValue != 0)
                {
                    this.longValue = this.numOfWinTrades.LongValue / this.numOfTrades.LongValue;
                    LongValues.Add(Clock.DateTime, this.longValue);
                    updated = true;
                }
                if (this.numOfTrades.ShortValues.Count != 0)
                {
                    this.shortValue = this.numOfWinTrades.ShortValue / this.numOfTrades.ShortValue;
                    ShortValues.Add(Clock.DateTime, this.shortValue);
                    updated = true;
                }
                if (this.numOfTrades.TotalValues.Count != 0)
                {
                    this.totalValue = this.numOfWinTrades.TotalValue / this.numOfTrades.TotalValue;
                    TotalValues.Add(Clock.DateTime, this.totalValue);
                    updated = true;
                }
                if (updated)
                {
                    Emit();
                }
            }
        }
示例#20
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;

            if (statistics.Type == PortfolioStatisticsType.NetProfit)
            {
                this.netProfit = statistics;
                changed        = true;
            }
            if (statistics.Type == PortfolioStatisticsType.MaxDrawdown)
            {
                this.maxDrawdown = statistics;
                changed          = true;
            }
            if (changed && this.netProfit != null && this.maxDrawdown != null)
            {
                bool updated = false;
                if (this.maxDrawdown.LongValue != 0)
                {
                    this.longValue = Abs(this.netProfit.LongValue / this.maxDrawdown.LongValue);
                    LongValues.Add(Clock.DateTime, this.longValue);
                    updated = true;
                }
                if (this.maxDrawdown.ShortValue != 0)
                {
                    this.shortValue = Abs(this.netProfit.ShortValue / this.maxDrawdown.ShortValue);
                    ShortValues.Add(Clock.DateTime, this.shortValue);
                    updated = true;
                }
                if (this.maxDrawdown.TotalValue != 0)
                {
                    this.totalValue = Math.Abs(this.netProfit.TotalValue / this.maxDrawdown.TotalValue);
                    TotalValues.Add(Clock.DateTime, this.totalValue);
                    updated = true;
                }
                if (updated)
                {
                    Emit();
                }
            }
        }
示例#21
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;

            if (statistics.Type == PortfolioStatisticsType.GrossProfit)
            {
                this.grossProfit = statistics;
                changed          = true;
            }
            if (statistics.Type == PortfolioStatisticsType.GrossLoss)
            {
                this.grossLoss = statistics;
                changed        = true;
            }
            if (changed && this.grossProfit != null && this.grossLoss != null)
            {
                bool updated = false;
                if (this.grossLoss.LongValue != 0)
                {
                    this.longValue = this.grossProfit.LongValue / -this.grossLoss.LongValue;
                    LongValues.Add(base.Clock.DateTime, this.longValue);
                    updated = true;
                }
                if (this.grossLoss.ShortValue != 0)
                {
                    this.shortValue = this.grossProfit.ShortValue / -this.grossLoss.ShortValue;
                    ShortValues.Add(Clock.DateTime, this.shortValue);
                    updated = true;
                }
                if (this.grossLoss.TotalValue != 0.0)
                {
                    this.totalValue = this.grossProfit.TotalValue / -this.grossLoss.TotalValue;
                    TotalValues.Add(Clock.DateTime, this.totalValue);
                    updated = true;
                }
                if (updated)
                {
                    Emit();
                }
            }
        }
示例#22
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            var changed = false;

            if (statistics.Type == PortfolioStatisticsType.CompoundAnnualGrowthRate)
            {
                this.cagr = statistics;
                changed   = true;
            }
            if (statistics.Type == PortfolioStatisticsType.MaxDrawdownPercent)
            {
                this.maxDrawdownPercent = statistics;
                changed = true;
            }
            if (changed && this.cagr != null && this.maxDrawdownPercent != null && this.maxDrawdownPercent.TotalValue != 0)
            {
                this.totalValue = Abs(this.cagr.TotalValue / this.maxDrawdownPercent.TotalValue);
                TotalValues.Add(Clock.DateTime, this.totalValue);
                Emit();
            }
        }
示例#23
0
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;

            if (statistics.Type == PortfolioStatisticsType.AvgAnnualReturnPercent)
            {
                this.avgReturnPercent = statistics;
                changed = true;
            }
            if (statistics.Type == PortfolioStatisticsType.AnnualDownsideRisk)
            {
                this.downsideRisk = statistics;
                changed           = true;
            }
            if (changed && this.avgReturnPercent != null && this.downsideRisk != null && this.downsideRisk.TotalValue != 0)
            {
                this.totalValue = (this.avgReturnPercent.TotalValue - RiskFreeReturn) / this.downsideRisk.TotalValue;
                TotalValues.Add(Clock.DateTime, this.totalValue);
                Emit();
            }
        }
示例#24
0
        private void fillTotalValues(properties props)
        {
            TotalValues.Collection.Clear(); //don't want duplicate elements
            #region TotalValues members
            var tv1 = new TotalValues("Leisure", props.leisure.totalLeisure, "Szórakozás");
            //   var tv2 = new TotalValues("Income", props.totalIncome, "Bevétel");
            var tv3  = new TotalValues("Media", props.media.TotalMedia, "Média");
            var tv4  = new TotalValues("Housing", props.housing.TotalHousing, "Lakhatás");
            var tv5  = new TotalValues("PublicUtils", props.publicUtils.TotalPublicUtils, "Közművek");
            var tv6  = new TotalValues("Transportation", props.transportation.TotalTransportation, "Közlekedés");
            var tv7  = new TotalValues("Household", props.household.TotalHousehold, "Háztartás");
            var tv8  = new TotalValues("Foods", props.food.TotalFoods, "Élelmiszer");
            var tv9  = new TotalValues("Children", props.children.TotalChildren, "Gyermekek");
            var tv10 = new TotalValues("Savings", props.savings.TotalSavings, "Megtakarítások");
            var tv11 = new TotalValues("Insurances", props.insurances.TotalInsurances, "Biztosítások");
            var tv12 = new TotalValues("Others", props.others.TotalOthers, "Egyéb kiadások");

            propGrid.Refresh();
            propGridCustom.Refresh();
            var customCollection = new TotalValues("Custom", myProperties.TotalValue, "Saját kiadások");

            TotalValues.Collection.Add(tv1);
            TotalValues.Collection.Add(customCollection);   //tv2
            TotalValues.Collection.Add(tv3);
            TotalValues.Collection.Add(tv4);
            TotalValues.Collection.Add(tv5);
            TotalValues.Collection.Add(tv6);
            TotalValues.Collection.Add(tv7);
            TotalValues.Collection.Add(tv8);
            TotalValues.Collection.Add(tv9);
            TotalValues.Collection.Add(tv10);
            TotalValues.Collection.Add(tv11);
            TotalValues.Collection.Add(tv12);

            #endregion

            updateLabels();
        }