internal ClosingStrategyPortfolioManager(BaseClosingStrategy strategy) { this.closeStrategy = strategy; positionKey = FormatKey(PortfolioManagementConstants.PORTFOLIO_POSITION_KEY, closeStrategy); if (IsPortfolioOrPositionStopLossEnabled) AddOpenPositionToPortfolio(); }
internal static void ValidateClosingSymbol(BaseClosingStrategy strategy) { if (strategy.IsCurrentInstrumentIwmAndIgnorable()) return; string closingSymbolKey = string.Format(ClosingPositionConstants.CLOSING_SYMBOL_KEY, strategy.Instrument.Symbol, strategy.Instrument.Type); if (!Strategy.Global.ContainsKey(closingSymbolKey)) { lock(LockObjectManager.LockObject) { if (!Strategy.Global.ContainsKey(closingSymbolKey)) { Strategy.Global.Add(closingSymbolKey, closingSymbolKey); } } } else { throw new ApplicationException( string.Format( "The symbol '{0}' is already attached to another closing strategy. You cannot run multiple closing strategies for the same symbol.", strategy.Instrument.Symbol)); } }
private static string FormatKey(string formatString, BaseClosingStrategy strategy) { return string.Format(formatString, strategy.Instrument.Symbol, strategy.Instrument.Type); }