public ScopedTable Query(long ownerId, DateClause dateClause, OriginClause originClause)
        {
            DataTable table = null;

            if (Schema.DateColumn != null)
            {
                if (Schema.DateIsYear)
                {
                    table = myDB.Query(FindByOwnerIdAndFromToCmd, ownerId, dateClause.From.Year, dateClause.To.Year);
                }
                else
                {
                    table = myDB.Query(FindByOwnerIdAndFromToCmd, ownerId,
                                       Maui.TypeConverter.DateToString(dateClause.From), Maui.TypeConverter.DateToString(dateClause.To));
                }
            }
            else
            {
                table = myDB.Query(FindByOwnerIdCmd, ownerId);
            }

            table.RowChanged += OnRowChanged;
            table.RowDeleted += OnRowChanged;

            return(new ScopedTable(Schema, table, originClause));
        }
Beispiel #2
0
        public ScopedTable Query(long ownerId, DateClause dateClause, OriginClause originClause)
        {
            Expression <Func <DataRow, bool> > RowFilter = row => (long)row[Schema.OwnerIdColumn] == ownerId;

            if (Schema.DateColumn != null)
            {
                if (Schema.DateIsYear)
                {
                    RowFilter = RowFilter.And(row => dateClause.IsInRange(row.GetDate(Schema).Year));
                }
                else
                {
                    RowFilter = RowFilter.And(row => dateClause.IsInRange(row.GetDate(Schema)));
                }
            }

            return(new ScopedTable(Schema, Table, originClause, RowFilter.Compile()));
        }
Beispiel #3
0
        public static StockPriceSeries GetStockPrices( this MauiX.IQuery self, StockHandle stock, DateClause dateClause, Timeframe timeframe )
        {
            var table = self.GetPriceData( stock, dateClause );

            var q = from row in table.Rows
                    select new StockPrice(
                        (long)row[ "id" ],
                        stock.TradedStock,
                        row.GetDate( table.Schema ),
                        row[ "open" ] != DBNull.Value ? (double?)row[ "open" ] : null,
                        row[ "high" ] != DBNull.Value ? (double?)row[ "high" ] : null,
                        row[ "low" ] != DBNull.Value ? (double?)row[ "low" ] : null,
                        (double)row[ "close" ],
                        ( row[ "volume" ] != DBNull.Value ? (int)(long)row[ "volume" ] : 0 )
                         );

            return new StockPriceSeries( stock.TradedStock, q, timeframe );
        }
Beispiel #4
0
        public ScopedTable Query( long ownerId, DateClause dateClause, OriginClause originClause )
        {
            Expression<Func<DataRow, bool>> RowFilter = row => (long)row[ Schema.OwnerIdColumn ] == ownerId;

            if ( Schema.DateColumn != null )
            {
                if ( Schema.DateIsYear )
                {
                    RowFilter = RowFilter.And( row => dateClause.IsInRange( row.GetDate( Schema ).Year ) );
                }
                else
                {
                    RowFilter = RowFilter.And( row => dateClause.IsInRange( row.GetDate( Schema ) ) );
                }
            }

            return new ScopedTable( Schema, Table, originClause, RowFilter.Compile() );
        }
Beispiel #5
0
 public ScopedTable Query( long ownerId, DateClause dateClause )
 {
     return Query( ownerId, dateClause, null );
 }
Beispiel #6
0
 public ScopedTable Query(long ownerId, DateClause dateClause)
 {
     return(Query(ownerId, dateClause, null));
 }
Beispiel #7
0
        public ScopedTable Query( long ownerId, DateClause dateClause, OriginClause originClause )
        {
            DataTable table = null;
            if ( Schema.DateColumn != null )
            {
                if ( Schema.DateIsYear )
                {
                    table = myDB.Query( FindByOwnerIdAndFromToCmd, ownerId, dateClause.From.Year, dateClause.To.Year );
                }
                else
                {
                    table = myDB.Query( FindByOwnerIdAndFromToCmd, ownerId,
                        Maui.TypeConverter.DateToString( dateClause.From ), Maui.TypeConverter.DateToString( dateClause.To ) );
                }
            }
            else
            {
                table = myDB.Query( FindByOwnerIdCmd, ownerId );
            }

            table.RowChanged += OnRowChanged;
            table.RowDeleted += OnRowChanged;

            return new ScopedTable( Schema, table, originClause );
        }
Beispiel #8
0
        public static StockPriceSeries GetStockPrices(this MauiX.IQuery self, StockHandle stock, DateClause dateClause, Timeframe timeframe)
        {
            var table = self.GetPriceData(stock, dateClause);

            var q = from row in table.Rows
                    select new StockPrice(
                (long)row["id"],
                stock.TradedStock,
                row.GetDate(table.Schema),
                row["open"] != DBNull.Value ? (double?)row["open"] : null,
                row["high"] != DBNull.Value ? (double?)row["high"] : null,
                row["low"] != DBNull.Value ? (double?)row["low"] : null,
                (double)row["close"],
                (row["volume"] != DBNull.Value ? (int)(long)row["volume"] : 0)
                );

            return(new StockPriceSeries(stock.TradedStock, q, timeframe));
        }
Beispiel #9
0
 public static ScopedTable GetPriceData(this MauiX.IQuery self, StockHandle stock, DateClause dateClause)
 {
     return(self.Select(Engine.ServiceProvider.TomScripting().GetManager(
                            Config.Instance.DailyStockPriceTable).Schema, stock, dateClause));
 }
Beispiel #10
0
        public static ScopedTable Select(this MauiX.IQuery self, TableSchema schema, StockHandle stock, DateClause dateClause)
        {
            var mgr = Engine.ServiceProvider.TomScripting().GetManager(schema.Name);

            return(mgr.Query(stock.GetId(schema.OwnerIdColumn), dateClause, OriginClause.Default));
        }
Beispiel #11
0
        public static ScopedTable Select( this MauiX.IQuery self, TableSchema schema, StockHandle stock, DateClause dateClause )
        {
            var mgr = Engine.ServiceProvider.TomScripting().GetManager( schema.Name );

            return mgr.Query( stock.GetId( schema.OwnerIdColumn ), dateClause, OriginClause.Default );
        }
Beispiel #12
0
 public static ScopedTable GetPriceData( this MauiX.IQuery self, StockHandle stock, DateClause dateClause )
 {
     return self.Select( Engine.ServiceProvider.TomScripting().GetManager(
         Config.Instance.DailyStockPriceTable ).Schema, stock, dateClause );
 }