/// <summary> /// To create the initialized order object of sell order at market price. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="volume">The volume. If <see langword="null" /> value is passed, then <see cref="Strategy.Volume"/> value is used.</param> /// <returns>The initialized order object.</returns> /// <remarks> /// The order is not registered, only the object is created. /// </remarks> public static Order SellAtMarket(this Strategy strategy, decimal?volume = null) { return(strategy.CreateOrder(Sides.Sell, null, volume)); }
/// <summary> /// To create a rule for event of profit change. /// </summary> /// <param name="strategy">The strategy, based on which the profit change will be traced.</param> /// <returns>Rule.</returns> public static MarketRule <Strategy, decimal> WhenPnLChanged(this Strategy strategy) { return(new PnLManagerStrategyRule(strategy)); }
/// <summary> /// To create a rule for the event of occurrence new strategy trade. /// </summary> /// <param name="strategy">The strategy, based on which trade occurrence will be traced.</param> /// <returns>Rule.</returns> public static MarketRule <Strategy, MyTrade> WhenNewMyTrade(this Strategy strategy) { return(new NewMyTradeStrategyRule(strategy)); }
/// <summary> /// To create a rule for event of change of any strategy order. /// </summary> /// <param name="strategy">The strategy, based on which orders change will be traced.</param> /// <returns>Rule.</returns> public static MarketRule <Strategy, Order> WhenOrderChanged(this Strategy strategy) { return(new OrderChangedStrategyRule(strategy)); }
public OrderRegisteredStrategyRule(Strategy strategy) : base(strategy) { Name = LocalizedStrings.Str1252 + " " + strategy; Strategy.OrderRegistered += Activate; }
public OrderChangedStrategyRule(Strategy strategy) : base(strategy) { Name = LocalizedStrings.Str1253 + " " + strategy; Strategy.OrderChanged += Activate; }
public PositionManagerStrategyRule(Strategy strategy) : this(strategy, v => true) { Name = LocalizedStrings.Str1250; }
/// <summary> /// Initializes a new instance of the <see cref="StrategyParam"/>. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="id">Parameter identifier.</param> /// <param name="name">Parameter name.</param> /// <param name="type">The type of the parameter value.</param> public StrategyParam(Strategy strategy, string id, string name, Type type) : this(strategy, id, name, type, default) { }
protected StrategyRule(Strategy strategy) : base(strategy) { Strategy = strategy ?? throw new ArgumentNullException(nameof(strategy)); }
public PnLManagerStrategyRule(Strategy strategy) : this(strategy, v => true) { Name = LocalizedStrings.PnLChange; }
/// <summary> /// To get the strategy start-up mode (paper trading or real). /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="isEmulation">If the paper trading mode is used - <see langword="true" />, otherwise - <see langword="false" />.</param> public static void SetIsEmulation(this Strategy strategy, bool isEmulation) { strategy.Environment.SetValue(_isEmulationModeKey, isEmulation); }
/// <summary> /// To get the strategy start-up mode (paper trading or real). /// </summary> /// <param name="strategy">Strategy.</param> /// <returns>If the paper trading mode is used - <see langword="true" />, otherwise - <see langword="false" />.</returns> public static bool GetIsEmulation(this Strategy strategy) { return(strategy.Environment.GetValue(_isEmulationModeKey, false)); }
/// <summary> /// Initializes a new instance of the <see cref="StrategyParam"/>. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="name">Parameter name.</param> /// <param name="type">The type of the parameter value.</param> /// <param name="initialValue">The initial value.</param> public StrategyParam(Strategy strategy, string name, Type type, object initialValue) : this(strategy, name, name, type, initialValue) { }
/// <summary> /// To create a rule for event of strategy error (transition of state <see cref="Strategy.ErrorState"/> into <see cref="LogLevels.Error"/>). /// </summary> /// <param name="strategy">The strategy, based on which error will be expected.</param> /// <param name="processChildStrategyErrors">Process the child strategies errors.</param> /// <returns>Rule.</returns> public static MarketRule <Strategy, Exception> WhenError(this Strategy strategy, bool processChildStrategyErrors = false) { return(new ErrorStrategyRule(strategy, processChildStrategyErrors)); }
public NewMyTradeStrategyRule(Strategy strategy) : base(strategy) { Name = LocalizedStrings.Str1251 + " " + strategy; Strategy.NewMyTrade += OnStrategyNewMyTrade; }
/// <summary> /// To create the initialized order object for sell. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="price">Price.</param> /// <param name="volume">The volume. If <see langword="null" /> value is passed, then <see cref="Strategy.Volume"/> value is used.</param> /// <returns>The initialized order object.</returns> /// <remarks> /// The order is not registered, only the object is created. /// </remarks> public static Order SellAtLimit(this Strategy strategy, decimal price, decimal?volume = null) { return(strategy.CreateOrder(Sides.Sell, price, volume)); }
/// <summary> /// Initializes a new instance of the <see cref="StrategyParam"/>. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="name">Parameter name.</param> /// <param name="type">The type of the parameter value.</param> public StrategyParam(Strategy strategy, string name, Type type) : this(strategy, name, name, type) { }