Ejemplo n.º 1
0
 public void Setup()
 {
     this.logger              = new NullLogger <FixedIncomeHighVolumeJudgementMapper>();
     this.context             = A.Fake <IFixedIncomeHighVolumeJudgementContext>();
     this.financialInstrument = A.Fake <IFinancialInstrument>();
     A.CallTo(() => this.context.Security).Returns(this.financialInstrument);
 }
Ejemplo n.º 2
0
 public TimeSeriesTrendClassification(
     IFinancialInstrument instrument,
     TimeSeriesTrend trend,
     DateTime commencementUtc,
     DateTime terminationUtc,
     TimeSegment timeSegment)
 {
     this.Instrument      = instrument ?? throw new ArgumentNullException(nameof(instrument));
     this.Trend           = trend;
     this.CommencementUtc = commencementUtc;
     this.TerminationUtc  = terminationUtc;
     this.TimeSegment     = timeSegment;
 }
Ejemplo n.º 3
0
        public DealerOrder(
            IFinancialInstrument instrument,
            string reddeerTradeId,
            string tradeId,
            DateTime?placedDate,
            DateTime?bookedDate,
            DateTime?amendedDate,
            DateTime?rejectedDate,
            DateTime?cancelledDate,
            DateTime?filledDate,
            DateTime?createdDate,
            string traderId,
            string dealerName,
            string notes,
            string tradeCounterParty,
            OrderTypes orderType,
            OrderDirections orderDirection,
            Currency currency,
            Currency settlementCurrency,
            OrderCleanDirty cleanDirty,
            decimal?accumulatedInterest,
            string dealerOrderVersion,
            string dealerOrderVersionLinkId,
            string dealerOrderGroupId,
            Money?limitPrice,
            Money?averageFillPrice,
            decimal?orderedVolume,
            decimal?filledVolume,
            decimal?optionStrikePrice,
            DateTime?optionExpirationDate,
            OptionEuropeanAmerican tradeOptionEuropeanAmerican)
            : base(placedDate, bookedDate, amendedDate, rejectedDate, cancelledDate, filledDate)
        {
            this.Instrument           = instrument ?? throw new ArgumentNullException(nameof(instrument));
            this.ReddeerDealerOrderId = reddeerTradeId ?? string.Empty;
            this.DealerOrderId        = tradeId ?? string.Empty;

            this.CreatedDate = createdDate;

            this.DealerId            = traderId ?? string.Empty;
            this.DealerName          = dealerName ?? string.Empty;
            this.Notes               = notes ?? string.Empty;
            this.DealerCounterParty  = tradeCounterParty ?? string.Empty;
            this.OrderType           = orderType;
            this.OrderDirection      = orderDirection;
            this.Currency            = currency;
            this.SettlementCurrency  = settlementCurrency;
            this.CleanDirty          = cleanDirty;
            this.AccumulatedInterest = accumulatedInterest;

            this.DealerOrderVersion       = dealerOrderVersion;
            this.DealerOrderVersionLinkId = dealerOrderVersionLinkId;
            this.DealerOrderGroupId       = dealerOrderGroupId;

            this.LimitPrice             = limitPrice;
            this.AverageFillPrice       = averageFillPrice;
            this.OrderedVolume          = orderedVolume;
            this.FilledVolume           = filledVolume;
            this.OptionStrikePrice      = optionStrikePrice;
            this.OptionExpirationDate   = optionExpirationDate;
            this.OptionEuropeanAmerican = tradeOptionEuropeanAmerican;
        }
        public ITimeSeriesTrendClassification Classify(
            List <EquityInstrumentIntraDayTimeBar> timeBars,
            IFinancialInstrument financialInstrument,
            DateTime commencement,
            DateTime termination,
            TimeSegment timeSegment)
        {
            if (timeBars == null || !timeBars.Any())
            {
                this._logger?.LogWarning("Received an empty or null time bars collection");

                return(new TimeSeriesTrendClassification(
                           financialInstrument,
                           TimeSeriesTrend.Unclassified,
                           commencement,
                           termination,
                           timeSegment));
            }

            var orderedTimeBars = timeBars.OrderBy(_ => _.TimeStamp).ToList();

            // basic implementation for initial work - we will make this more sophisticated in response to tests
            var initial = orderedTimeBars.FirstOrDefault();
            var final   = orderedTimeBars.LastOrDefault();

            if (initial == null || final == null)
            {
                return(new TimeSeriesTrendClassification(
                           financialInstrument,
                           TimeSeriesTrend.Unclassified,
                           commencement,
                           termination,
                           timeSegment));
            }

            // TODO take a volatiltiy measure and return chaotic if volatiltiy is high
            if (final.SpreadTimeBar.Price.Value > initial.SpreadTimeBar.Price.Value)
            {
                return(new TimeSeriesTrendClassification(
                           financialInstrument,
                           TimeSeriesTrend.Increasing,
                           commencement,
                           termination,
                           timeSegment));
            }

            if (final.SpreadTimeBar.Price.Value < initial.SpreadTimeBar.Price.Value)
            {
                return(new TimeSeriesTrendClassification(
                           financialInstrument,
                           TimeSeriesTrend.Decreasing,
                           commencement,
                           termination,
                           timeSegment));
            }

            return(new TimeSeriesTrendClassification(
                       financialInstrument,
                       TimeSeriesTrend.Unclassified,
                       commencement,
                       termination,
                       timeSegment));
        }