Пример #1
0
 def load_cache(self):
     sql = "SELECT id,name,symbol,instrumentTypeId FROM Instruments"
     cache = {}
     for row in tmdb.db_read(self.dbconn, sql):
         (_id, name, symbol, typeId) = row[:]
         instr = oe.factory.create_instrument(name, symbol, typeId, _id)
         cache[instr.name] = instr
     return cache
Пример #2
0
 def load_cache(self):
     sql = "SELECT id,name,symbol,instrumentTypeId FROM Instruments"
     cache = {}
     for row in tmdb.db_read(self.dbconn, sql):
         (_id, name, symbol, typeId) = row[:]
         instr = oe.factory.create_instrument(name, symbol, typeId, _id)
         cache[instr.name] = instr
     return cache
Пример #3
0
 def load_cache(self):
     sql = ('SELECT id,name,tradeTypeId,statusTypeId from Trades '
            'WHERE statusTypeId = {}').format(mappings.OPEN_TRADE_ID)
     cache = {}
     for row in tmdb.db_read(self.dbconn, sql):
         (t_id, name, type_id, status_id) = row[:]
         trade = oe.portfolio.Trade(name, type_id, status_id, t_id)
         cache[trade.name] = trade
     return cache
Пример #4
0
 def load_cache(self):
     sql = ("SELECT id,name,tradeTypeId,statusTypeId from Trades " "WHERE statusTypeId = {}").format(
         mappings.OPEN_TRADE_ID
     )
     cache = {}
     for row in tmdb.db_read(self.dbconn, sql):
         (t_id, name, type_id, status_id) = row[:]
         trade = oe.portfolio.Trade(name, type_id, status_id, t_id)
         cache[trade.name] = trade
     return cache
Пример #5
0
def cache_open_orders():
    for trade in t_cache.cache:
        sql = ('SELECT '
                    'or1.date,or1.brokerOrderId,in1.name,or1.quantity,'
                    'or1.price,or1.commission,or1.openClose,or1.buySell,'
                    'or1.tradeId,or1.id '
                'FROM '
                    'Orders or1 '
                    'JOIN Instruments in1 ON in1.id = or1.instrumentId '
                    'JOIN Trades tr1 ON tr1.id = or1.tradeId '
                'WHERE tr1.id = {}').format(t_cache.cache[trade].id)
        for row in db.db_read(t_cache.dbconn, sql):
            (date, b_id, i_name, qty, price, comm, o_type, action, tradeId, o_id) = row[:]
            order = portfolio.Order(date, b_id, i_cache.cache[i_name], qty, price, comm, o_type, action, tradeId, o_id)
            o_cache.add_obj(b_id, order)  
Пример #6
0
def cache_open_orders():
    for trade in t_cache.cache:
        sql = ('SELECT '
               'or1.date,or1.brokerOrderId,in1.name,or1.quantity,'
               'or1.price,or1.commission,or1.openClose,or1.buySell,'
               'or1.tradeId,or1.id '
               'FROM '
               'Orders or1 '
               'JOIN Instruments in1 ON in1.id = or1.instrumentId '
               'JOIN Trades tr1 ON tr1.id = or1.tradeId '
               'WHERE tr1.id = {}').format(t_cache.cache[trade].id)
        for row in db.db_read(t_cache.dbconn, sql):
            (date, b_id, i_name, qty, price, comm, o_type, action, tradeId,
             o_id) = row[:]
            order = portfolio.Order(date, b_id, i_cache.cache[i_name], qty,
                                    price, comm, o_type, action, tradeId, o_id)
            o_cache.add_obj(b_id, order)