public void SetUp()
 {
     _dataLoader           = SystemDataLoaderUtils.CreateSubstitute(PricesCount, LastDate);
     _commission           = CommissionUtils.CreateSubstitute();
     _slippage             = SlippageUtils.CreateSusbstitute();
     TestObj               = new PositionsRebalancer(_dataLoader, _commission, _slippage);
     _openPriceLevelCalled = false;
 }
 public void SetUp()
 {
     _dataLoader               = SystemDataLoaderUtils.CreateSubstitute(PricesCount, LastDate);
     _commission               = CommissionUtils.CreateSubstitute();
     _slippage                 = SlippageUtils.CreateSusbstitute();
     TestObj                   = new PositionsCloser(_dataLoader, _commission, _slippage);
     _positionSelectorCalled   = false;
     _closePriceSelectorCalled = false;
 }
예제 #3
0
 public void SetUp()
 {
     _dataLoader           = SystemDataLoaderUtils.CreateSubstitute(PricesCount, LastDate);
     _commission           = CommissionUtils.CreateSubstitute();
     _slippage             = SlippageUtils.CreateSusbstitute();
     TestObj               = new SignalsProcessor(_dataLoader, _commission, _slippage);
     _signalSelectorCalled = false;
     _openPriceLevelCalled = false;
 }
        public void SetUp()
        {
            _dataProvider           = StockDataProviderUtils.CreateSubstitute(DateTime.MinValue);
            _dataLoader             = SystemDataLoaderUtils.CreateSubstituteWithConstantPriceInRange(PricesCount, StartingPrice, PriceRange, LastDate);
            _dataDefinitionProvider = Substitute.For <ISystemDataDefinitionProvider>();
            _signalGeneratorOnOpen  = Substitute.For <ISignalGeneratorOnOpen>();
            _signalGeneratorOnClose = Substitute.For <ISignalGeneratorOnClose>();
            _commission             = CommissionUtils.CreateSubstitute();
            _slippage = SlippageUtils.CreateSusbstitute();
            _mmPositionCloseCalculator = Substitute.For <IMMPositionCloseCalculator>();
            _systemState = new SystemState()
            {
                Cash = InitialCash
            };

            _slippage.CalculateOpen(default, default, default, default).ReturnsForAnyArgs(args => args.ArgAt <float>(3));
 public void SetUp()
 {
     _stock = new StockDefinition()
     {
         Type = StockType.Stock
     };
     _stock2  = new StockDefinition();
     _testObj = new SystemState()
     {
         Cash = CashValue
     };
     _stockPrices      = new StockPricesData(1);
     _dataLoader       = SystemDataLoaderUtils.CreateSubstitute(_stockPrices);
     _commission       = CommissionUtils.CreateSubstitute(Commission);
     _slippage         = SlippageUtils.CreateSusbstitute();
     EntrySignal.Stock = _stock;
 }
        public void CalcCurrentValue_Multiple_MixedCase__CalculatesCashAndPosition()
        {
            _testObj.PositionsActive.Add(CreatePosition(PositionDir.Long, Price1, Vol1));
            _stockPrices.TS[0] = CurrentTS;
            _stockPrices.C[0]  = Close1;
            _testObj.CalcCurrentValue(CurrentTS, _dataLoader);
            _testObj.Equity.Count.ShouldBe(1);
            _testObj.Equity[0].Value.ShouldBe(CashValue + Close1 * Vol1);
            _testObj.Equity[0].TS.ShouldBe(CurrentTS);

            _testObj.CloseAll(CurrentTS2, Close1, _slippage, CommissionUtils.CreateSubstitute());
            _stockPrices.TS[0] = CurrentTS2;
            _stockPrices.C[0]  = Close1;
            _testObj.CalcCurrentValue(CurrentTS2, _dataLoader);
            _testObj.Equity.Count.ShouldBe(2);
            _testObj.Equity[0].Value.ShouldBe(CashValue + Close1 * Vol1);
            _testObj.Equity[0].TS.ShouldBe(CurrentTS);
            _testObj.Equity[1].Value.ShouldBe(CashValue + Close1 * Vol1);
            _testObj.Equity[1].TS.ShouldBe(CurrentTS2);
        }