예제 #1
0
        // takes meta data from the first series
        public ISignalSeries Create( IEnumerable<ISignalSeries> signals )
        {
            if ( !signals.Any() )
            {
                return SignalSeries.Null;
            }

            var dateSignalsMap = CreateDateSignalsMap( signals );

            int expectedSignalCount = signals.Count();
            InterpolateMissingSignals( dateSignalsMap, expectedSignalCount );

            var combinedSignals = GenerateCombinedSignals( dateSignalsMap );

            var masterInputSeries = signals.FirstOrDefault( s => s.Reference.Identifier.Type.Name == DatumNames.Prices );
            if ( masterInputSeries == null )
            {
                // then lets take the reference with max points
                var maxPoints = signals.Max( s => s.Count);
                masterInputSeries = signals.First( s => s.Count == maxPoints );
                // throw new Exception( "We could not find any signal series which seem to reference raw prices" );
            }
            var identifier = new SeriesIdentifier( masterInputSeries.Identifier.Owner, new ObjectDescriptor( "Combined" ), signals.Select( s => s.Identifier ).ToArray() );

            var series = new SignalSeries( masterInputSeries.Reference, identifier, combinedSignals );

            return series;
        }
예제 #2
0
        private IPriceSeries CreateSeries( StockHandle stock, IEnumerable<SimplePrice> prices )
        {
            var seriesId = new SeriesIdentifier(
                new StockObjectIdentifier( stock ),
                new ObjectDescriptor( Name ) );

            return new PriceSeries( seriesId, prices );
        }