Skip to content

Commit e18a71d

Browse files
committed
Fix bug
1 parent 12de870 commit e18a71d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

csharp/TraderBot/TradingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ private bool IsTimeToBuy()
657657
private async Task<(decimal, decimal)> GetCashBalance(bool forceRemote = false)
658658
{
659659
var response = (await InvestApi.Operations.GetPositionsAsync(new PositionsRequest { AccountId = CurrentAccount.Id }));
660-
var balanceFree = (decimal)response.Money.First(m => m.Currency == Settings.CashCurrency);
660+
var balanceFree = response.Money.Any() ? (decimal)response.Money.First(m => m.Currency == Settings.CashCurrency) : 0;
661661
var balanceLocked = response.Blocked.Any() ? (decimal)response.Blocked.First(m => m.Currency == Settings.CashCurrency) : 0;
662662
Logger.LogInformation($"Local cash balance, {Settings.CashCurrency}: {CashBalanceFree} ({CashBalanceLocked} locked)");
663663
Logger.LogInformation($"Remote cash balance, {Settings.CashCurrency}: {balanceFree} ({balanceLocked} locked)");

0 commit comments

Comments
 (0)