namespace StockSharp.Fix;
using StockSharp.Messages;
///
/// Reads and writes the values of a stop condition that is held as a plain
/// .
///
///
/// A condition carries its values in a name-keyed bag, which is how it travels the wire. A caller
/// holding one as the base type can only reach those values by naming the keys itself, and a name
/// spelled differently in two places compiles and then silently loses the value - a take-profit
/// arriving at the venue as a stop-loss. The names live here, once, and callers ask for the value.
///
public static class StopConditionValues
{
///
/// The flavour of the stop: which way it triggers, and whether it follows the price.
///
/// The condition, which may be .
/// The flavour, or when it states none.
public static FixStopOrderTypes? GetStopFlavour(this OrderCondition condition)
=> (FixStopOrderTypes?)condition?.Parameters.TryGetValue(nameof(FixOrderCondition.Type));
///
/// States the flavour of the stop.
///
/// The condition.
/// Which way it triggers, and whether it follows the price.
/// is .
public static void SetStopFlavour(this OrderCondition condition, FixStopOrderTypes flavour)
{
if (condition is null)
throw new ArgumentNullException(nameof(condition));
condition.Parameters[nameof(FixOrderCondition.Type)] = flavour;
}
}