Ejemplo n.º 1
0
        public void Snapshot(double fiat, double security, double securityPrice, double benchmarkPrice = 0)
        {
            if (benchmarkPrice == 0)
            {
                benchmarkPrice = securityPrice;
            }

            double portfolioValue = fiat + security * securityPrice;
            bool   hasOne         = Snapshots.Count > 0;
            var    newSnapshot    = new PortfolioSnapshot()
            {
                Time                  = DateTime.Now,
                Fiat                  = fiat,
                Security              = security,
                SecurityPrice         = securityPrice,
                PortfolioValue        = portfolioValue,
                PL                    = Snapshots.Count > 0 ? portfolioValue / Snapshots.Last().PortfolioValue - 1 : 0.0,
                CumulativePL          = hasOne ? portfolioValue / Snapshots.First().PortfolioValue - 1 : 0.0,
                BenchmarkPrice        = benchmarkPrice,
                BenchmarkPL           = hasOne ? benchmarkPrice / Snapshots.Last().BenchmarkPrice - 1 : 0.0,
                BenchmarkCumulativePL = hasOne ? benchmarkPrice / Snapshots.First().BenchmarkPrice - 1 : 0.0
            };

            Snapshots.Add(newSnapshot);
            SnapshotEvent?.Invoke(this, newSnapshot);
            CachedSharpeRatio = null;
        }
Ejemplo n.º 2
0
        private void buttonCapture_Click(object sender, EventArgs e)
        {
            if (SnapshotEvent == null)
            {
                return;
            }

            HImage ho_Image = SnapshotEvent.Invoke();
            int    num      = this._images.Count;

            this._images.Add(ho_Image);
            this.listBox1.Items.Add($"图像 {num + 1:d2}");
            this.listBox1.SelectedIndex = num;
        }
Ejemplo n.º 3
0
        private async void OnTick(object sender, EventArgs e)
        {
            _dispatcherTimer.Stop();

            var getSnapshotCommandDto = new GetSnapshotAdminCommandDto();
            var response =
                await _connection.DispatchCommandAsync <GetSnapshotAdminCommandResponseDto>(getSnapshotCommandDto, CancellationToken.None);

            var snapshotEvent = new SnapshotEvent {
                Snapshot = response
            };

            _eventAggregator.PublishOnUIThread(snapshotEvent);

            _dispatcherTimer.Start();
        }
Ejemplo n.º 4
0
Archivo: Root.cs Proyecto: zedr0n/ZES
 private void ApplyEvent(SnapshotEvent e)
 {
     Id        = e.Id;
     UpdatedAt = e.UpdatedAt;
 }