@@ -23,6 +23,7 @@ public class TradingService : BackgroundService
2323 protected readonly ILogger < TradingService > Logger ;
2424 protected readonly IHostApplicationLifetime Lifetime ;
2525 protected readonly TradingSettings Settings ;
26+ protected readonly string ConfigurationName ;
2627 protected readonly Account CurrentAccount ;
2728 protected readonly string Figi ;
2829 protected readonly int LotSize ;
@@ -40,45 +41,46 @@ public class TradingService : BackgroundService
4041 protected readonly ConcurrentDictionary < decimal , long > LotsSets ;
4142 protected readonly ConcurrentDictionary < string , decimal > ActiveSellOrderSourcePrice ;
4243
43- public TradingService ( ILogger < TradingService > logger , InvestApiClient investApi , IHostApplicationLifetime lifetime , TradingSettings settings )
44+ public TradingService ( ILogger < TradingService > logger , InvestApiClient investApi , IHostApplicationLifetime lifetime , TradingSettings settings , string configurationName = "Default" )
4445 {
4546 Logger = logger ;
4647 InvestApi = investApi ;
4748 Lifetime = lifetime ;
4849 Settings = settings ;
49- Logger . LogInformation ( $ "Instrument: { settings . Instrument } ") ;
50- Logger . LogInformation ( $ "Ticker: { settings . Ticker } ") ;
51- Logger . LogInformation ( $ "CashCurrency: { settings . CashCurrency } ") ;
52- Logger . LogInformation ( $ "AccountIndex: { settings . AccountIndex } ") ;
53- Logger . LogInformation ( $ "MinimumProfitSteps: { settings . MinimumProfitSteps } ") ;
54- Logger . LogInformation ( $ "MarketOrderBookDepth: { settings . MarketOrderBookDepth } ") ;
55- Logger . LogInformation ( $ "MinimumMarketOrderSizeToChangeBuyPrice: { settings . MinimumMarketOrderSizeToChangeBuyPrice } ") ;
56- Logger . LogInformation ( $ "MinimumMarketOrderSizeToChangeSellPrice: { settings . MinimumMarketOrderSizeToChangeSellPrice } ") ;
57- Logger . LogInformation ( $ "MinimumMarketOrderSizeToBuy: { settings . MinimumMarketOrderSizeToBuy } ") ;
58- Logger . LogInformation ( $ "MinimumMarketOrderSizeToSell: { settings . MinimumMarketOrderSizeToSell } ") ;
50+ ConfigurationName = configurationName ;
51+ Logger . LogInformation ( $ "[{ ConfigurationName } ] Instrument: { settings . Instrument } ") ;
52+ Logger . LogInformation ( $ "[{ ConfigurationName } ] Ticker: { settings . Ticker } ") ;
53+ Logger . LogInformation ( $ "[{ ConfigurationName } ] CashCurrency: { settings . CashCurrency } ") ;
54+ Logger . LogInformation ( $ "[{ ConfigurationName } ] AccountIndex: { settings . AccountIndex } ") ;
55+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MinimumProfitSteps: { settings . MinimumProfitSteps } ") ;
56+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MarketOrderBookDepth: { settings . MarketOrderBookDepth } ") ;
57+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MinimumMarketOrderSizeToChangeBuyPrice: { settings . MinimumMarketOrderSizeToChangeBuyPrice } ") ;
58+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MinimumMarketOrderSizeToChangeSellPrice: { settings . MinimumMarketOrderSizeToChangeSellPrice } ") ;
59+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MinimumMarketOrderSizeToBuy: { settings . MinimumMarketOrderSizeToBuy } ") ;
60+ Logger . LogInformation ( $ "[{ ConfigurationName } ] MinimumMarketOrderSizeToSell: { settings . MinimumMarketOrderSizeToSell } ") ;
5961 MinimumTimeToBuy = TimeSpan . Parse ( settings . MinimumTimeToBuy ?? "00:00:00" , CultureInfo . InvariantCulture ) ;
60- Logger . LogInformation ( $ "MinimumTimeToBuy: { MinimumTimeToBuy } ") ;
62+ Logger . LogInformation ( $ "[ { ConfigurationName } ] MinimumTimeToBuy: { MinimumTimeToBuy } ") ;
6163 MaximumTimeToBuy = TimeSpan . Parse ( settings . MaximumTimeToBuy ?? "23:59:59" , CultureInfo . InvariantCulture ) ;
62- Logger . LogInformation ( $ "MaximumTimeToBuy: { MaximumTimeToBuy } ") ;
63- Logger . LogInformation ( $ "EarlySellOwnedLotsDelta: { settings . EarlySellOwnedLotsDelta } ") ;
64- Logger . LogInformation ( $ "EarlySellOwnedLotsMultiplier: { settings . EarlySellOwnedLotsMultiplier } ") ;
65- Logger . LogInformation ( $ "LoadOperationsFrom: { settings . LoadOperationsFrom } ") ;
64+ Logger . LogInformation ( $ "[ { ConfigurationName } ] MaximumTimeToBuy: { MaximumTimeToBuy } ") ;
65+ Logger . LogInformation ( $ "[ { ConfigurationName } ] EarlySellOwnedLotsDelta: { settings . EarlySellOwnedLotsDelta } ") ;
66+ Logger . LogInformation ( $ "[ { ConfigurationName } ] EarlySellOwnedLotsMultiplier: { settings . EarlySellOwnedLotsMultiplier } ") ;
67+ Logger . LogInformation ( $ "[ { ConfigurationName } ] LoadOperationsFrom: { settings . LoadOperationsFrom } ") ;
6668
6769 var currentTime = DateTime . UtcNow . TimeOfDay ;
68- Logger . LogInformation ( $ "Current time: { currentTime } ") ;
70+ Logger . LogInformation ( $ "[ { ConfigurationName } ] Current time: { currentTime } ") ;
6971
7072 var accounts = InvestApi . Users . GetAccounts ( ) . Accounts ;
71- Logger . LogInformation ( " Accounts:") ;
73+ Logger . LogInformation ( $ "[ { ConfigurationName } ] Accounts:") ;
7274 for ( int i = 0 ; i < accounts . Count ; i ++ )
7375 {
74- Logger . LogInformation ( $ "[{ i } ]: { accounts [ i ] } ") ;
76+ Logger . LogInformation ( $ "[{ ConfigurationName } ] [ { i } ]: { accounts [ i ] } ") ;
7577 }
7678 if ( settings . AccountIndex < 0 || settings . AccountIndex >= accounts . Count )
7779 {
78- throw new ArgumentException ( $ "Account index { settings . AccountIndex } is out of range. Please select a valid account index ({ 0 } -{ accounts . Count - 1 } ).") ;
80+ throw new ArgumentException ( $ "[ { ConfigurationName } ] Account index { settings . AccountIndex } is out of range. Please select a valid account index ({ 0 } -{ accounts . Count - 1 } ).") ;
7981 }
8082 CurrentAccount = accounts [ settings . AccountIndex ] ;
81- Logger . LogInformation ( $ "CurrentAccount (with { settings . AccountIndex } index): { CurrentAccount } ") ;
83+ Logger . LogInformation ( $ "[ { ConfigurationName } ] CurrentAccount (with { settings . AccountIndex } index): { CurrentAccount } ") ;
8284
8385 if ( settings . Instrument == Instrument . Etf )
8486 {
0 commit comments