Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added choice of account for investment #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added choice of account for investment
  • Loading branch information
FirstAfterGod2501 committed May 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f629c5a094c6b805d23d806e73a3bbfbb36a35d2
2 changes: 1 addition & 1 deletion csharp/TraderBot/Program.cs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
using Tinkoff.InvestApi;
using TraderBot;

var builder = Host.CreateDefaultBuilder(args);
var builder = Host.CreateDefaultBuilder();
var host = builder
.ConfigureServices((context, services) =>
{
10 changes: 9 additions & 1 deletion csharp/TraderBot/TradingService.cs
Original file line number Diff line number Diff line change
@@ -26,7 +26,15 @@ public TradingService(ILogger<TradingService> 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}");