예제 #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));
 }
예제 #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));
 }
예제 #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));
 }
예제 #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));
 }
예제 #5
0
 public OrderRegisteredStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1252 + " " + strategy;
     Strategy.OrderRegistered += Activate;
 }
예제 #6
0
 public OrderChangedStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1253 + " " + strategy;
     Strategy.OrderChanged += Activate;
 }
예제 #7
0
 public PositionManagerStrategyRule(Strategy strategy)
     : this(strategy, v => true)
 {
     Name = LocalizedStrings.Str1250;
 }
예제 #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)
 {
 }
예제 #9
0
 protected StrategyRule(Strategy strategy)
     : base(strategy)
 {
     Strategy = strategy ?? throw new ArgumentNullException(nameof(strategy));
 }
예제 #10
0
 public PnLManagerStrategyRule(Strategy strategy)
     : this(strategy, v => true)
 {
     Name = LocalizedStrings.PnLChange;
 }
예제 #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);
 }
예제 #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));
 }
예제 #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)
 {
 }
예제 #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));
 }
예제 #15
0
 public NewMyTradeStrategyRule(Strategy strategy)
     : base(strategy)
 {
     Name = LocalizedStrings.Str1251 + " " + strategy;
     Strategy.NewMyTrade += OnStrategyNewMyTrade;
 }
예제 #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));
 }
예제 #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)
 {
 }