コード例 #1
0
 public void Dispose()
 {
     if (_telegramClient != null)
     {
         _telegramClient.Dispose();
         _telegramClient = null;
     }
     _onBarModules.Clear();
     _onTickModules.Clear();
     _allModules.Clear();
     _orderSpacingModules.Clear();
     _takeProfitModule = null;
     _stopLossModule   = null;
     _lotSizeModule    = null;
     foreach (var pipeline in _orderPipelines)
     {
         pipeline.Dispose();
     }
     _orderPipelines.Clear();
 }
コード例 #2
0
        internal void AddModule(ModuleBase module)
        {
            module.Strategy = this;
            module.Settings = this.Settings;

            _allModules.Add(module);

            // Validate and show available settings for module
            if (module is IValidateSettings)
            {
                ValidateModuleSettings((IValidateSettings)module);
            }

            // Setup modules that respond to OnTick
            if (module is IOnTick)
            {
                _onTickModules.Add((IOnTick)module);
            }
            // Setup modules that respond to OnBar
            if (module is IOnBar)
            {
                _onBarModules.Add((IOnBar)module);
            }

            // Baseline order modules
            if (module is ITakeProfit)
            {
                _takeProfitModule = (ITakeProfit)module;
            }

            if (module is IStopLoss)
            {
                _stopLossModule = (IStopLoss)module;
            }

            if (module is ILotSize)
            {
                _lotSizeModule = (ILotSize)module;
            }

            if (module is IOrderFilter)
            {
                _orderSpacingModules.Add((IOrderFilter)module);
            }

            if (module is IPositionClosed)
            {
                _positionClosed.Add((IPositionClosed)module);
            }

            if (module is IPositionOpened)
            {
                _positionOpened.Add((IPositionOpened)module);
            }

            if (module is IPositionModified)
            {
                _positionModifed.Add((IPositionModified)module);
            }

            if (module is IBeforeMarketOrder)
            {
                _beforeMarketOrder.Add((IBeforeMarketOrder)module);
            }
        }