private void ResetState() { _state = PriceState.Initial; LatestBreakoutPrice = 0.0; LowestPriceAfterBreakout = 0.0; _intervalBetweenLastBreakoutAndRerising = 0; }
private void SetBreakoutState(double lowestPrice) { _state = PriceState.Breakout; LowestPrice = lowestPrice; BouncePrice = 0.0; BouncePercentage = 0.0; _minBouncePrice = LowestPrice * (1 + _minBouncePercentage / 100.0); }
private void ResetState() { _state = PriceState.Initial; LowestPrice = 0.0; BouncePrice = 0.0; BouncePercentage = 0.0; _minBouncePrice = 0.0; }
private void UpdateState(Bar bar) { _lowest.Update(bar.ClosePrice); double lowestPrice = _lowest.Value; bool breakout = Math.Abs(lowestPrice - bar.ClosePrice) < 1e-6; switch (_state) { case PriceState.Initial: if (breakout) { SetBreakoutState(lowestPrice); } break; case PriceState.Breakout: if (breakout) { SetBreakoutState(lowestPrice); } else { if (bar.ClosePrice > _minBouncePrice) { _state = PriceState.Bounce; BouncePrice = bar.ClosePrice; BouncePercentage = (bar.ClosePrice - LowestPrice) / LowestPrice * 100.0; } } break; case PriceState.Bounce: if (breakout) { SetBreakoutState(lowestPrice); } else { ResetState(); } break; } _values[0] = _state == PriceState.Bounce ? 1.0 : 0.0; }
public QuoteMessage TryGenerate(string assetPair, bool isBuy, double price, DateTime timestamp, int assetPairAccuracy) { var assetPairId = assetPair.Trim(); if (string.IsNullOrEmpty(assetPairId)) { throw new ArgumentNullException(nameof(assetPair)); } _assetMarketStates.TryGetValue(assetPairId, out var oldState); var newPriceState = new PriceState(price, timestamp); var newState = isBuy ? new MarketState(oldState?.Ask, newPriceState) : new MarketState(newPriceState, oldState?.Bid); _assetMarketStates[assetPairId] = newState; return(TryCreateMidQuote(assetPairId, newState, assetPairAccuracy)); }
public ScheduleTimeBase(PriceState state_, int hourStart_, int hourEnd_) : base (state_) { m_hourStart = hourStart_; m_hourEnd = hourEnd_; }
private void UpdateState(Bar bar) { double price = BarPriceSelector.Select(bar, _priceSelector); _highest.Update(price); double highestPrice = _highest.Value; bool breakout = Math.Abs(highestPrice - price) < 1e-6; switch (_state) { case PriceState.Initial: if (breakout) { _state = PriceState.Breakout; LatestBreakoutPrice = highestPrice; LowestPriceAfterBreakout = 0.0; _intervalBetweenLastBreakoutAndRerising = 0; } break; case PriceState.Breakout: if (breakout) { LatestBreakoutPrice = highestPrice; } else { _state = PriceState.Degrading; LowestPriceAfterBreakout = bar.ClosePrice; _intervalBetweenLastBreakoutAndRerising = 1; } break; case PriceState.Degrading: if (bar.ClosePrice <= LowestPriceAfterBreakout) { LowestPriceAfterBreakout = bar.ClosePrice; _intervalBetweenLastBreakoutAndRerising++; } else { if (_intervalBetweenLastBreakoutAndRerising >= _minInterval && _intervalBetweenLastBreakoutAndRerising <= _maxInterval) { _state = PriceState.Rising; } else { ResetState(); } } break; case PriceState.Rising: ResetState(); break; } }
public void PriceState_Soda_Displays_OneDollar() { VendingMachineState state = new PriceState(_context, new List <Coin>(), new List <Coin>(), _productInfoRepository, new List <string>(), new List <Coin>(), 100); Assert.AreEqual("PRICE: $1.00", state.Display()); }
public ScheduleCcy(Currency ccy_, PriceState state_, int hourStart_, int hourEnd_) : base(state_,hourStart_,hourEnd_) { m_ccy = ccy_; }
public ScheduleBase(PriceState source_) { Source = source_; }
public ScheduleFXGroup(PriceState source_, SI.Data.FXGroup group_, int hourStart_, int hourEnd_) : base(source_, hourStart_,hourEnd_) { m_group = group_; }