Esempio n. 1
0
        private void OnMarginChanged(object sender, ExchangePricesEventArgs e)
        {
            var x = e.BtxMargin;

            ChangeControl(() =>
            {
                HandleException(() =>
                {
                    if (x.WalletBalance.HasValue)
                    {
                        BtcBalance = BitmexMargin.ToBtc(x.WalletBalance.Value, 5);
                        LogMarginEvent("Balance " + lblBalance.Content);
                    }
                    if (x.MarginBalance.HasValue)
                    {
                        BtcMargin = BitmexMargin.ToBtc(x.MarginBalance.Value, 5);
                    }
                    if (x.AvailableMargin.HasValue)
                    {
                        BtcMargin = BitmexMargin.ToBtc(x.AvailableMargin.Value, 5);
                        if (x.MarginUsedPcnt.HasValue)
                        {
                            if (x.MarginUsedPcnt.Value != 0)
                            {
                                var pcnt = Math.Round(100 - x.MarginUsedPcnt.Value * 100, 1);
                                lblAvailMargin.Content = String.Format("{0} ({1}%)", lblAvailMargin.Content.ToString(), pcnt.ToString("0.0"));
                            }
                        }
                    }
                });
            });
        }
Esempio n. 2
0
 private void SetPositionCost(BitmexPositionData pos)
 {
     if (pos.PosCost.HasValue)
     {
         this.Value = String.Format("{0} XBT", BitmexMargin.ToBtc(Math.Abs(pos.PosCost.Value), 5).ToString("0.00000"));
     }
 }
Esempio n. 3
0
 private void SetMargin(BitmexPositionData pos)
 {
     if (pos.PosMargin.HasValue)
     {
         this.PositionMargin = BitmexMargin.ToBtc(pos.PosMargin.Value, 5).ToString("0.00000") + " XBT";
     }
 }
Esempio n. 4
0
 private void SetProfit(BitmexPositionData pos)
 {
     if (pos.RealisedPnl.HasValue)
     {
         var value = BitmexMargin.ToBtc(pos.RealisedPnl.Value);
         this.RealisedProfit = String.Format("{0} XBT", value.ToString("0.00000000"));
     }
 }