Ejemplo n.º 1
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));
        }
Ejemplo n.º 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()));
        }
Ejemplo n.º 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 );
        }
Ejemplo n.º 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() );
        }
Ejemplo n.º 5
0
 public ScopedTable Query( long ownerId, DateClause dateClause )
 {
     return Query( ownerId, dateClause, null );
 }
Ejemplo n.º 6
0
 public ScopedTable Query(long ownerId, DateClause dateClause)
 {
     return(Query(ownerId, dateClause, null));
 }
Ejemplo n.º 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 );
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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 );
        }
Ejemplo n.º 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 );
 }