Exemple #1
0
 def lookup(table_name, index):
     dbm = DBManager.get_instance()
     cursor = dbm.get_cursor()
     exec_string = "SELECT * FROM '{tn}' WHERE id = {i}".format(
         tn=table_name, i=index)
     cursor.execute(exec_string)
     return Trade.from_tuple(table_name, cursor.fetchone())
Exemple #2
0
 def get_trade(table_name, date):
     dbm = DBManager.get_instance()
     cursor = dbm.get_cursor()
     exec_string = "SELECT * FROM '{tn}' WHERE date = {d}".format(
         tn=table_name, d=date)
     cursor.execute(exec_string)
     return Trade.from_tuple(table_name, cursor.fetchone())
Exemple #3
0
    def get_trade_array(table_name):

        ##returns a cursor pointing to all candles linked to the table_name
        cursor = TradeTable.get_trade_cursor(table_name)
        trades = []

        ##loop through cursor and add all candles to array
        row = cursor.fetchone()
        while row is not None:
            t = Trade.from_tuple(table_name, row)
            trades.append(t)
            row = cursor.fetchone()
        return trades
Exemple #4
0
    def get_trades_in_range(table_name, date_low, date_high, type):
        dbm = DBManager.get_instance()
        cursor = dbm.get_cursor()
        exec_string = "SELECT * FROM '{tn}' WHERE date >= {d_low} AND date <= {d_high} AND type = '{t}'".format(
            tn=table_name, d_low=date_low, d_high=date_high, t=type)
        cursor.execute(exec_string)
        trades = []

        t = cursor.fetchone()
        while t is not None:
            trade = Trade.from_tuple(table_name, t)
            trades.append(trade)
            t = cursor.fetchone()
        return trades