From 9540a921913741dff595435105b9dfa1c132dca4 Mon Sep 17 00:00:00 2001 From: Crynners Date: Thu, 26 Aug 2021 22:10:38 +0200 Subject: [PATCH] resolves #5, resolves #6 --- CryptoBotCore/BotStrategies/AccumulationBot.cs | 16 ++++++++++++---- CryptoBotCore/Models/CoinMateCredentials.cs | 14 -------------- 2 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 CryptoBotCore/Models/CoinMateCredentials.cs diff --git a/CryptoBotCore/BotStrategies/AccumulationBot.cs b/CryptoBotCore/BotStrategies/AccumulationBot.cs index 6b00de4..2f41010 100644 --- a/CryptoBotCore/BotStrategies/AccumulationBot.cs +++ b/CryptoBotCore/BotStrategies/AccumulationBot.cs @@ -97,10 +97,13 @@ public async Task Tick() double fee_cost = (withdrawFee / available); + double TAKER_FEE = cryptoExchangeAPI.getTakerFee(); double buyPrice = ((FiatBalance - FiatAfterBuy) / TAKER_FEE) / (available - init); + var feeInFiat = (withdrawFee * buyPrice).ToString("N2"); + sbInformationMessage.Append("Accumulation: " + (available - init).ToString("N8") + " " + BotConfiguration.Currency + " for " + BotConfiguration.ChunkSize.ToString("N2") + $" {BotConfiguration.Fiat} @ " + (buyPrice).ToString("N2") + $" {BotConfiguration.Fiat}").Append("\r\n"); //Send them home @@ -125,18 +128,20 @@ public async Task Tick() if (!BotConfiguration.WithdrawalEnabled) reason.Add("Turned off"); + var maxWithdrawalFeeInFiat = (BotConfiguration.MaxWithdrawalPercentageFee * buyPrice).ToString("N2"); + List limits = new List { - (BotConfiguration.MaxWithdrawalPercentageFee * 100).ToString("N2") + " %" + $"{(BotConfiguration.MaxWithdrawalPercentageFee * 100).ToString("N2")} % ({maxWithdrawalFeeInFiat} {BotConfiguration.Fiat})" }; if (BotConfiguration.MaxWithdrawalAbsoluteFee != -1) { - limits.Add($"{BotConfiguration.MaxWithdrawalAbsoluteFee.ToString()} {BotConfiguration.Currency}"); + limits.Add($"{BotConfiguration.MaxWithdrawalAbsoluteFee.ToString("N2")} {BotConfiguration.Fiat}"); } - sbInformationMessage.Append("Withdrawal: Denied - [" + String.Join(", ", reason) + "] - fee cost " + (fee_cost * 100).ToString("N2") + " %, limit " + + sbInformationMessage.Append($"Withdrawal: Denied - [{String.Join(", ", reason)}] - fee cost {(fee_cost * 100).ToString("N2")} % ({feeInFiat} {BotConfiguration.Fiat}), limit " + String.Join(" AND ", limits)).Append("\r\n"); } @@ -171,6 +176,9 @@ public async Task Tick() var profit = ((accumulationSummary.AccumulatedCryptoAmount * buyPrice) / accumulationSummary.InvestedFiatAmount) - 1; + var currentCryptoBalance = afterBalance.Where(x => x.currency == BotConfiguration.Currency).Sum(x => x.available); + var currentCryptoBalanceInFiat = currentCryptoBalance * buyPrice; + StringBuilder sb = new StringBuilder(); sb.Append("🛒 [ACTIONS]").Append("\r\n"); sb.Append(sbInformationMessage.ToString()); @@ -182,7 +190,7 @@ public async Task Tick() sb.Append("Current Profit: " + (profit * 100).ToString("N2") + " % (" + (profit * accumulationSummary.InvestedFiatAmount).ToString("N2") + $" {BotConfiguration.Fiat})").Append("\r\n"); sb.Append("Fiat balance: " + FiatAfterBuy.ToString("N2") + $" {BotConfiguration.Fiat}").Append("\r\n"); - sb.Append("Current balance: " + afterBalance.Where(x => x.currency == BotConfiguration.Currency).Sum(x => x.available).ToString("N8") + " " + BotConfiguration.Currency).Append("\r\n"); + sb.Append($"Current balance: {currentCryptoBalance.ToString("N8")} {BotConfiguration.Currency} ({currentCryptoBalanceInFiat.ToString("N2")} {BotConfiguration.Fiat})").Append("\r\n"); await SendMessageAsync(sb.ToString()); } diff --git a/CryptoBotCore/Models/CoinMateCredentials.cs b/CryptoBotCore/Models/CoinMateCredentials.cs deleted file mode 100644 index aa14cb0..0000000 --- a/CryptoBotCore/Models/CoinMateCredentials.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Extensions.Configuration; -using System; -using System.Collections.Generic; -using System.Text; - -namespace CryptoBotCore.Models -{ - public class CoinMateCredentials - { - public int ClientId { get; set; } - public string PublicKey { get; set; } - public string PrivateKey { get; set; } - } -}