Exemple #1
0
 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);
        }
Exemple #3
0
        public IObservable <FxRate> GetPricesFor(CurrencyPairIdentifier currencyPair)
        {
            if (!KnownCurrencies.Any(x => x.Equals(currencyPair)))
            {
                throw new ArgumentOutOfRangeException();
            }

            return(_source.GetPriceStream(currencyPair.Symbol));
        }
Exemple #4
0
        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;
        }
Exemple #5
0
 public FxRate(CurrencyPairIdentifier currencyPair, decimal rate)
 {
     CurrencyPair = currencyPair;
     Rate         = rate;
 }
Exemple #6
0
 private static IPriceGenerator CreatePriceGenerator(CurrencyPairIdentifier symbol,
                                                     decimal initial, int precision)
 {
     return(new MeanReversionRandomWalkPriceGenerator(symbol, initial,
                                                      precision));
 }
Exemple #7
0
 public FxRateTerm(string termId, CurrencyPairIdentifier identifier) :
     base(termId)
 {
     Identifier = identifier;
 }