Esempio n. 1
0
        public void ArivaSomePrices()
        {
            DatumLocator locator = new DatumLocator( "StockPrices",
                new Site( "Ariva",
                    new Navigation( DocumentType.Html,
                        OS.CombinePaths( TestDataRoot, "Recognition", "ariva.prices.${stock.isin}.html" ) ),
                    new PathTableFormat( "Ariava.Prices",
                        "/BODY[0]/DIV[5]/DIV[0]/DIV[3]/DIV[0]/TABLE[${TableIndex}]",
                        new FormatColumn( "date", typeof( DateTime ), "dd.MM.yy" ),
                        new FormatColumn( "open", typeof( double ), "000000,0000" ),
                        new FormatColumn( "close", typeof( double ), "000000,0000" ),
                        new FormatColumn( "volume", typeof( int ), "000000,0000" ) )
                        {
                            SkipRows = new int[] { 0, 1 },
                            SkipColumns = new int[] { 0, 3, 4 }
                        },
                    new DataContent( "Euro" ) ) );

            LookupPolicy fetchPolicy = new LookupPolicy();
            fetchPolicy.Lut[ "${stock.isin}" ] = "DE0005003404";
            fetchPolicy.Lut[ "${TableIndex}" ] = "0";

            var webScrapSC = new ServiceProvider().Browser();
            var provider = new GenericDatumProvider( webScrapSC, locator, fetchPolicy, null );

            var result = provider.Fetch();

            Assert.AreEqual( "/BODY[0]/DIV[5]/DIV[0]/DIV[3]/DIV[0]/TABLE[${TableIndex}]", ((PathTableFormat)locator.Sites[ 0 ].Format).Path );

            Assert.IsNotNull( result );
            Assert.IsNotNull( result.ResultTable );

            var table = result.ResultTable;

            Assert.AreEqual( 21, table.Rows.Count );

            Assert.AreEqual( 4, table.Columns.Count );
            Assert.AreEqual( "date", table.Columns[ 0 ].ColumnName );
            Assert.AreEqual( "open", table.Columns[ 1 ].ColumnName );
            Assert.AreEqual( "close", table.Columns[ 2 ].ColumnName );
            Assert.AreEqual( "volume", table.Columns[ 3 ].ColumnName );

            Assert.AreEqual( GetDate( "2008-07-07" ), (DateTime)table.Rows[ 0 ][ "date" ] );
            Assert.AreEqual( 38.37d, (double)table.Rows[ 0 ][ "open" ], 0.000001d );
            Assert.AreEqual( 38.93d, (double)table.Rows[ 0 ][ "close" ], 0.000001d );
            Assert.AreEqual( 1155400, (int)table.Rows[ 0 ][ "volume" ] );

            Assert.AreEqual( GetDate( "2008-06-09" ), (DateTime)table.Rows[ 20 ][ "date" ] );
            Assert.AreEqual( 45.21d, (double)table.Rows[ 20 ][ "open" ], 0.000001d );
            Assert.AreEqual( 44.50d, (double)table.Rows[ 20 ][ "close" ], 0.000001d );
            Assert.AreEqual( 1113865, (int)table.Rows[ 20 ][ "volume" ] );
        }
Esempio n. 2
0
        public void TupleProperty()
        {
            var site = new Site( "Ariva",
                   new Navigation( DocumentType.Html, string.Empty ),
                   new SeparatorSeriesFormat( "Ariava.Prices" )
                       {
                           Anchor = Anchor.ForRow( new StringContainsLocator( 0, ">>${TableIndex}<<" ) )
                       },
                   new DataContent( "Euro" ) );

            var fetchPolicy = new LookupPolicy();
            fetchPolicy.Lut[ "${TableIndex}" ] = "0";

            var format = (SeparatorSeriesFormat)fetchPolicy.GetFormat( site );

            Assert.That( ( (StringContainsLocator)format.Anchor.Row ).Pattern, Is.EqualTo( ">>0<<" ) );
        }
Esempio n. 3
0
        public void ArivaEps_DE0005140008()
        {
            var locator = new DatumLocator( "Eps",
                new Site( "Ariva",
                    new Navigation( DocumentType.Html,
                        OS.CombinePaths( TestDataRoot, "Recognition", "ariva.fund.${stock.isin}.html" ) ),
                    new PathSeriesFormat( "Ariava.Eps" )
                    {
                        Path = "/BODY[0]/DIV[5]/DIV[0]/DIV[3]/TABLE[7]/TBODY[0]/TR[5]/TD[1]",
                        TimeAxisPosition = 1,
                        Expand = CellDimension.Row,
                        SeriesNamePosition = 0,
                        ValueFormat = new FormatColumn( "value", typeof( double ), "000000,0000" ),
                        TimeAxisFormat = new FormatColumn( "year", typeof( int ), "0000" )
                    },
                    new DataContent( "Euro" ) ) );

            var fetchPolicy = new LookupPolicy();
            fetchPolicy.Lut[ "${stock.isin}" ] = "DE0005140008";

            var webScrapSC = new ServiceProvider().Browser();
            var provider = new GenericDatumProvider( webScrapSC, locator, fetchPolicy, null );

            var result = provider.Fetch();

            Assert.IsNotNull( result );
            Assert.IsNotNull( result.ResultTable );

            var table = result.ResultTable;

            Assert.AreEqual( 6, table.Rows.Count );

            Assert.AreEqual( 2002, (int)table.Rows[ 0 ][ 1 ] );
            Assert.AreEqual( 0.64d, (double)table.Rows[ 0 ][ 0 ], 0.00001d );
            Assert.AreEqual( 2007, (int)table.Rows[ 5 ][ 1 ] );
            Assert.AreEqual( 13.65d, (double)table.Rows[ 5 ][ 0 ], 0.00001d );
        }