StockSharp/StockSharp · error · ArgumentOutOfRangeException

Invalid value.

Error message

Invalid value.

What it means

Thrown by the QuotingProcessor constructor when quotingVolume is less than or equal to zero. QuotingProcessor is the rule-driven quoting engine that fulfills a target volume; a non-positive target means there is nothing to quote, so construction is rejected up front. The message comes from LocalizedStrings.InvalidValue.

Source

Thrown at Algo.Strategies/Quoting/QuotingProcessor.cs:63

	/// <param name="container"><see cref="IMarketRuleContainer"/></param>
	/// <param name="transProvider"><see cref="ITransactionProvider"/></param>
	/// <param name="timeProvider"><see cref="ITimeProvider"/></param>
	/// <param name="mdProvider"><see cref="IMarketDataProvider"/></param>
	/// <param name="isAllowed">Is the strategy allowed to trade.</param>
	/// <param name="useBidAsk">To use the best bid and ask prices from the order book. If the information in the order book is missed, the processor will not recommend any actions.</param>
	/// <param name="useTicks">To use the last trade price, if the information in the order book is missed.</param>
	public QuotingProcessor(
		IQuotingBehavior behavior,
		Security security, Portfolio portfolio,
		Sides quotingSide, decimal quotingVolume, decimal maxOrderVolume,
		TimeSpan timeOut, ISubscriptionProvider subProvider,
		IMarketRuleContainer container, ITransactionProvider transProvider,
		ITimeProvider timeProvider, IMarketDataProvider mdProvider,
		Func<StrategyTradingModes, bool> isAllowed,
		bool useBidAsk, bool useTicks)
	{
		if (quotingVolume <= 0)
			throw new ArgumentOutOfRangeException(nameof(quotingVolume), quotingVolume, LocalizedStrings.InvalidValue);

		if (maxOrderVolume <= 0)
			throw new ArgumentOutOfRangeException(nameof(maxOrderVolume), maxOrderVolume, LocalizedStrings.InvalidValue);

		_security = security ?? throw new ArgumentNullException(nameof(security));
		_portfolio = portfolio ?? throw new ArgumentNullException(nameof(portfolio));
		_quotingSide = quotingSide;
		_quotingVolume = quotingVolume;
		_maxOrderVolume = maxOrderVolume;
		_behavior = behavior ?? throw new ArgumentNullException(nameof(behavior));
		_timeOut = timeOut;
		_subProvider = subProvider ?? throw new ArgumentNullException(nameof(subProvider));
		_container = container ?? throw new ArgumentNullException(nameof(container));
		_transProvider = transProvider ?? throw new ArgumentNullException(nameof(transProvider));
		_timeProvider = timeProvider ?? throw new ArgumentNullException(nameof(timeProvider));
		_mdProvider = mdProvider ?? throw new ArgumentNullException(nameof(mdProvider));
		_isAllowed = isAllowed ?? throw new ArgumentNullException(nameof(isAllowed));
		_useBidAsk = useBidAsk;

View on GitHub (pinned to 601a191de6)

Solutions

  1. Ensure quotingVolume is a positive decimal representing the absolute quantity to quote.
  2. If quotingVolume is computed from a residual, skip constructing the processor when the residual is already <= 0.
  3. Bind the parameter from a validated strategy property (e.g. Volume > 0) rather than a raw input.
  4. Add a preflight assertion in your strategy's OnStarted before instantiating the processor.

Example fix

// before
var proc = new QuotingProcessor(behavior, sec, pf, Sides.Buy, quotingVolume: residual, maxOrderVolume: 10, ...);

// after
if (residual <= 0) { this.LogInfo("Nothing to quote"); return; }
var proc = new QuotingProcessor(behavior, sec, pf, Sides.Buy, quotingVolume: residual, maxOrderVolume: 10, ...);
Defensive patterns

Strategy: validation

Validate before calling

if (quotingVolume <= 0)
{
    this.LogInfo($"Quoting skipped: residual volume {quotingVolume} is not positive.");
    return;
}
var proc = new QuotingProcessor(behavior, sec, pf, side, quotingVolume, maxOrderVolume, timeOut, subProvider, container, transProvider, timeProvider, mdProvider, isAllowed, useBidAsk, useTicks);

Type guard

static bool IsValidQuotingVolume(decimal v) => v > 0;

Prevention

When it happens

Trigger: Constructing 'new QuotingProcessor(...)' with quotingVolume <= 0. The guard is the very first statement in the constructor body, so it fires before any dependency (security, providers) is touched.

Common situations: Deriving quotingVolume from (targetPosition - currentPosition) when the position already meets the target, yielding 0; deserializing a strategy whose Volume parameter was not set; feeding an unset OptimizableParam into the processor.

Related errors


AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13). Data as JSON: /api/errors/c438ebe3d955aa26. Report an issue: GitHub.