From f629c5a094c6b805d23d806e73a3bbfbb36a35d2 Mon Sep 17 00:00:00 2001 From: Alexander <65162943+FirstAfterGod2501@users.noreply.github.com> Date: Mon, 30 May 2022 18:32:09 +0300 Subject: [PATCH] added choice of account for investment --- csharp/TraderBot/Program.cs | 2 +- csharp/TraderBot/TradingService.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/csharp/TraderBot/Program.cs b/csharp/TraderBot/Program.cs index 39669303..29eb60d0 100644 --- a/csharp/TraderBot/Program.cs +++ b/csharp/TraderBot/Program.cs @@ -2,7 +2,7 @@ using Tinkoff.InvestApi; using TraderBot; -var builder = Host.CreateDefaultBuilder(args); +var builder = Host.CreateDefaultBuilder(); var host = builder .ConfigureServices((context, services) => { diff --git a/csharp/TraderBot/TradingService.cs b/csharp/TraderBot/TradingService.cs index 3462dde1..931d3633 100644 --- a/csharp/TraderBot/TradingService.cs +++ b/csharp/TraderBot/TradingService.cs @@ -26,7 +26,15 @@ public TradingService(ILogger logger, InvestApiClient investApi, Settings = settings; Logger.LogInformation($"ETF ticker: {Settings.EtfTicker}"); Logger.LogInformation($"CashCurrency: {Settings.CashCurrency}"); - CurrentAccount = InvestApi.Users.GetAccounts().Accounts[0]; + CurrentAccount = InvestApi.Users.GetAccounts().Accounts[2]; + if(InvestApi.Users.GetAccounts().Accounts.Count > 0) + { + Console.WriteLine("Choose Account:"); + foreach(var acc in InvestApi.Users.GetAccounts().Accounts){ + Console.WriteLine(acc); + } + CurrentAccount = InvestApi.Users.GetAccounts().Accounts[int.Parse(Console.ReadLine())]; + } Logger.LogInformation($"CurrentAccount: {CurrentAccount}"); CurrentInstrument = InvestApi.Instruments.Etfs().Instruments.First(etf => etf.Ticker == Settings.EtfTicker); Logger.LogInformation($"CurrentInstrument: {CurrentInstrument}");