private IObservable <Unit> RegisterPriceTrigger(CurrencyPairIdentifier identifier) { return(_timer .Where(_ => _priceGenerators[Random.Next(_priceGenerators.Count)].Identifier.Symbol == identifier.Symbol) .Select(_ => Unit.Default)); }
public override Func <IReadOnlyList <IGrammarTerm>, decimal> VisitFxRateFunc(MyGrammarParser.FxRateFuncContext context) { var termId = context.GetText(); var currencyPair = context.currencyPair().GetText(); var term = new FxRateTerm(termId, CurrencyPairIdentifier.ParseExact(currencyPair)); _terms.Add(term); return(x => x.First(t => t.TermId == term.TermId).Value); }
public IObservable <FxRate> GetPricesFor(CurrencyPairIdentifier currencyPair) { if (!KnownCurrencies.Any(x => x.Equals(currencyPair))) { throw new ArgumentOutOfRangeException(); } return(_source.GetPriceStream(currencyPair.Symbol)); }
public MeanReversionRandomWalkPriceGenerator( CurrencyPairIdentifier identifier, decimal initial, int precision, decimal reversionCoefficient = 0.001m, decimal volatility = 5m) { _initial = initial; _precision = precision; _reversion = reversionCoefficient; var power = (decimal)Math.Pow(10, precision); _vol = volatility * 1m / power; Identifier = identifier; }
public FxRate(CurrencyPairIdentifier currencyPair, decimal rate) { CurrencyPair = currencyPair; Rate = rate; }
private static IPriceGenerator CreatePriceGenerator(CurrencyPairIdentifier symbol, decimal initial, int precision) { return(new MeanReversionRandomWalkPriceGenerator(symbol, initial, precision)); }
public FxRateTerm(string termId, CurrencyPairIdentifier identifier) : base(termId) { Identifier = identifier; }