private void CreateDummyTable( bool addData ) { // define the table myTable = new TableSchema( "dummy", new DataColumn( "stock_id", typeof( long ) ), new DataColumn( "date", typeof( string ) ), new DataColumn( "eps", typeof( double ) ) ); myTable.Create(); if ( addData ) { var table = myTable.Manager().Query( CurrentStockId ); // add dummy values to table DataRow row = table.NewRow(); row[ "stock_id" ] = CurrentStockId; row[ "date" ] = "2007"; row[ "eps" ] = 20.5d; table.Add( row ); row = table.NewRow(); row[ "stock_id" ] = CurrentStockId; row[ "date" ] = "2005"; row[ "eps" ] = 12.5d; table.Add( row ); row = table.NewRow(); row[ "stock_id" ] = CurrentStockId; row[ "date" ] = "2006"; row[ "eps" ] = 17.3d; table.Add( row ); } }
public IEnumerable<DataRow> Query( TableSchema schema ) { if ( Interpreter.Context.Scope.TryFrom != null && Interpreter.Context.Scope.TryTo != null ) { return schema.QueryByScope().Rows; } else { return schema.Manager().Query( Interpreter.Context.Scope.Stock.GetId( schema.OwnerIdColumn ) ).Rows; } }
protected void CreateTimeSeries( TableSchema table, params double[] values ) { var dataTable = table.Manager().Query( CurrentStockId ); int i = 0; foreach ( var value in values ) { DataRow row = dataTable.NewRow(); row[ "stock_id" ] = CurrentStockId; row[ "year" ] = 2000 + i++; row[ "value" ] = value; dataTable.Add( row ); } }
private void SetupInterpreter() { AddDummyStock(); TableSchema schema = new TableSchema( "stock_price", new DataColumn( "traded_stock_id", typeof( long ) ), new DataColumn( "date", typeof( string ) ), new DataColumn( "close", typeof( double ) ) ) .Create(); // we have a datum so we need the table now ScopedTable table = schema.Manager().Query( CurrentStockId ); AddStockPrice( table, "2000-12-12 00:00", 12.2d ); AddStockPrice( table, "2000-12-11 00:00", 12.1d ); AddStockPrice( table, "2000-12-13 00:00", 12.3d ); AddStockPrice( table, "2001-12-12 00:00", 13.2d ); AddStockPrice( table, "2001-12-11 00:00", 13.1d ); AddStockPrice( table, "2001-12-13 00:00", 13.3d ); AddStockPrice( table, "2002-12-12 00:00", 14.2d ); AddStockPrice( table, "2002-12-11 00:00", 14.1d ); AddStockPrice( table, "2002-12-13 00:00", 14.3d ); AddStockPrice( table, "2003-12-12 00:00", 15.2d ); AddStockPrice( table, "2003-12-11 00:00", 15.1d ); AddStockPrice( table, "2003-12-13 00:00", 15.3d ); AddStockPrice( table, "2004-12-12 00:00", 16.2d ); AddStockPrice( table, "2004-12-11 00:00", 16.1d ); AddStockPrice( table, "2004-12-13 00:00", 16.3d ); }