public string GetInfo() { var price = CurrencyProvider.FindPriceByTime(Data.CurrentTime, Data.Account.CurrencyName); var estimatePrice = Data.Account.BtcCount + Data.Account.CurrencyCount * price; if (price == -1) { estimatePrice = -1000; } return($"Актер: {Data.Guid}" + Environment.NewLine + $"Счет: {Data.Account.BtcCount}BTC" + Environment.NewLine + $"Счет валюты: {Data.Account.CurrencyCount}{Data.Account.CurrencyName}" + Environment.NewLine + $"Последнее время действия: {Data.LastActionTime}" + Environment.NewLine + $"Текущее время: {Data.CurrentTime}" + Environment.NewLine + $"Сомнения покупки: {Data.HesitationToBuy}" + Environment.NewLine + $"Сомнения продажи: {Data.HesitationToSell}" + Environment.NewLine + $"Тип: {Data.ActorType}" + Environment.NewLine + $"Количество предсказаний: {Data.Predictions.Count}" + Environment.NewLine + $"Количество транзакций: {Data.Transactions.Count}" + Environment.NewLine + $"Оценочное состояние: " + (estimatePrice == -1000 ? "нет данных" : estimatePrice.ToString()) + Environment.NewLine); }
public void CommitTransaction(Account account, decimal sumBtc, OperationType operationType, DateTime transactionTime, ICurrencyProvider provider) { // TODO: вынести в конструктор Time = transactionTime; Type = operationType; BtcCount = sumBtc; CurrencyPrice = provider.FindPriceByTime(transactionTime, account.CurrencyName); if (CurrencyPrice <= 0) { this.TransactionResult = TransactionResult.Failed; // TODO: Логгер return; } if (operationType == OperationType.Buy) { if (account.BtcCount - sumBtc + Const.TransactionSumBtcCommision < 0) { TransactionResult = TransactionResult.Failed; return; } account.BtcCount -= sumBtc + Const.TransactionSumBtcCommision; account.CurrencyCount += sumBtc / CurrencyPrice; } else if (operationType == OperationType.Sell) { if (account.CurrencyCount - (sumBtc + Const.TransactionSumBtcCommision) / CurrencyPrice < 0) { TransactionResult = TransactionResult.Failed; return; } account.CurrencyCount -= sumBtc / CurrencyPrice; account.BtcCount += sumBtc - Const.TransactionSumBtcCommision; } else { this.TransactionResult = TransactionResult.Error; } TransactionResult = TransactionResult.Success; }