public OrderInfo(Context _context, double howMuchUSD) { if (_context.User == null) { _context.IsLive = false; _context.IsPaper = true; } if (_context.IsLive && _context.IsPaper == false) { // binance ID } else { Id = CryptoCore.Classes.Globals.RandomNumber(10000000, 99999999).ToString(); } IsOpen = true; ParentContext = _context; BuyAmountInUSD = howMuchUSD; BuyCandle = _context.LastCandle; BuyPrice = BuyCandle.MidPrice; CoinAmount = Globals.GetPercentage((float)BuyAmountInUSD, (float)BuyPrice) / 100f; }
public double GetEquityNOT_USED(CandleInfo candle) { var allOrders = GetAllOrders(); double totalEquity = 0f; foreach (var ord in allOrders) { var alreadyClosed = false; if (ord.SellCandle != null && ord.SellCandle.OpenTime <= candle.OpenTime) { alreadyClosed = true; } if (ord.BuyCandle.OpenTime > candle.OpenTime) { break; } if (alreadyClosed) { // we have closed, we calculate using the sellcandle totalEquity += ord.CoinAmount * ord.SellCandle.MidPrice; } else { totalEquity += ord.CoinAmount * candle.MidPrice; } } return(totalEquity); }