Exemple #1
0
 /// <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));
 }
Exemple #2
0
 /// <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));
 }
Exemple #3
0
 /// <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));
 }
Exemple #4
0
 /// <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));
 }
Exemple #5
0
 public OrderRegisteredStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1252 + " " + strategy;
     Strategy.OrderRegistered += Activate;
 }
Exemple #6
0
 public OrderChangedStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1253 + " " + strategy;
     Strategy.OrderChanged += Activate;
 }
Exemple #7
0
 public PositionManagerStrategyRule(Strategy strategy)
     : this(strategy, v => true)
 {
     Name = LocalizedStrings.Str1250;
 }
Exemple #8
0
 /// <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)
 {
 }
Exemple #9
0
 protected StrategyRule(Strategy strategy)
     : base(strategy)
 {
     Strategy = strategy ?? throw new ArgumentNullException(nameof(strategy));
 }
Exemple #10
0
 public PnLManagerStrategyRule(Strategy strategy)
     : this(strategy, v => true)
 {
     Name = LocalizedStrings.PnLChange;
 }
Exemple #11
0
 /// <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);
 }
Exemple #12
0
 /// <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));
 }
Exemple #13
0
 /// <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)
 {
 }
Exemple #14
0
 /// <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));
 }
Exemple #15
0
 public NewMyTradeStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1251 + " " + strategy;
     Strategy.NewMyTrade += OnStrategyNewMyTrade;
 }
Exemple #16
0
 /// <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));
 }
Exemple #17
0
 /// <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)
 {
 }