示例#1
0
        public List <Signal> GenerateOnClose(DateTime ts, int leadingIndex, SystemState systemState)
        {
            List <Signal> result = new List <Signal>();

            SimplexFundsDataCalculator.Calculate(_fundsData, ts, _avgProfitRange, _avgChangeRange, _dataRange, _dataLoader);

            float portfolioValue = new SystemValueCalculator().Calc(systemState, ts, _dataLoader);

            float[] balance = SimplexExecutor.Execute(_fundsData,
                                                      portfolioValue, _acceptableSingleDD, _riskSigmaMultiplier, _maxSinglePositionSize, _maxPortfolioRisk, _truncateBalanceToNthPlace);
            result.Add(CreateSignal(balance, _dataRange, _fundsData));

            LogData(ts, balance);
            return(result);
        }
示例#2
0
        public SignalsSimplexMultiFunds(ISystemDataLoader dataLoader, IStockDataProvider dataProvider, ISystemExecutionLogger systemExecutionLogger, MOParams systemParams)
        {
            _avgProfitRange            = systemParams.Get(SimplexMultiFundsParams.AvgProfitRange).As <int>();
            _avgChangeRange            = systemParams.Get(SimplexMultiFundsParams.AvgChangeRange).As <int>();
            _acceptableSingleDD        = systemParams.Get(SimplexMultiFundsParams.AcceptableSingleDD).As <double>();
            _riskSigmaMultiplier       = systemParams.Get(SimplexMultiFundsParams.RiskSigmaMultiplier).As <double>();
            _maxSinglePositionSize     = systemParams.Get(SimplexMultiFundsParams.MaxSinglePositionSize).As <double>();
            _maxPortfolioRisk          = systemParams.Get(SimplexMultiFundsParams.MaxPortfolioRisk).As <double>();
            _truncateBalanceToNthPlace = systemParams.Get(SimplexMultiFundsParams.TruncateBalanceToNthPlace).As <int>();

            _aggressiveFunds = _fundsNames.Select((_, i) => i > 0).ToArray();
            if (_fundsNames.Length != _aggressiveFunds.Length)
            {
                throw new Exception("_fundsNames != _aggressiveFunds");
            }

            _dataLoader            = dataLoader;
            _systemExecutionLogger = systemExecutionLogger;
            _dataRange             = StockDataRange.Monthly;
            _fundsData             = new SimplexFundsData(_fundsNames.Length);
            SimplexFundsDataCalculator.Initialize(_fundsData, _fundsNames, dataProvider);
        }