コード例 #1
0
        public TradingStrategyEvaluator(
            int numberOfAccounts,
            int accountId,
            ICapitalManager capitalManager,
            ITradingStrategy strategy,
            IDictionary <ParameterAttribute, object> strategyParameters,
            ITradingDataProvider provider,
            StockBlockRelationshipManager relationshipManager,
            TradingSettings settings,
            ILogger logger,
            StreamWriter dumpDataWriter)
        {
            if (numberOfAccounts <= 0 || accountId < 0 || accountId >= numberOfAccounts)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (strategy == null || provider == null || settings == null)
            {
                throw new ArgumentNullException();
            }

            _numberOfAccounts        = numberOfAccounts;
            _accountId               = accountId;
            _strategy                = strategy;
            _strategyParameterValues = strategyParameters;

            _provider = provider;

            _settings = settings;

            _equityManager  = new EquityManager(capitalManager, _settings.PositionFrozenDays);
            _context        = new StandardEvaluationContext(_provider, _equityManager, logger, settings, dumpDataWriter, relationshipManager);
            _tradingTracker = new TradingTracker(capitalManager.InitialCapital);
        }
コード例 #2
0
        public TradingStrategyPredicator(
            double initialCapital,
            double currentCapital,
            ITradingStrategy strategy,
            IDictionary <ParameterAttribute, object> strategyParameters,
            ITradingDataProvider provider,
            StockBlockRelationshipManager relationshipManager,
            int positionFrozenDays,
            IEnumerable <Position> activePositions,
            ILogger logger)
        {
            if (strategy == null || provider == null)
            {
                throw new ArgumentNullException();
            }

            _strategy = strategy;
            _strategyParameterValues = strategyParameters;

            _provider = provider;

            _equityManager = new EquityManager(new SimpleCapitalManager(initialCapital, currentCapital), positionFrozenDays);
            _unprocessedActivePositions = activePositions.ToList();

            _context = new StandardEvaluationContext(_provider, _equityManager, logger, null, null, relationshipManager);
        }