Browse Source

More trading bot fixes

Eren Yilmaz 5 years ago
parent
commit
c710ffa85c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      trading_bot.py

+ 2 - 2
trading_bot.py

@@ -55,7 +55,7 @@ def notify_expired_orders(orders):
         ownership_id = order[1]
 
         # check if that was one of the bots orders
-        bank_ownership_id = model.get_ownership_id(ownership_id, model.bank_id())
+        bank_ownership_id = model.get_ownership_id(model.ownable_id_by_ownership_id(ownership_id), model.bank_id())
         if ownership_id != bank_ownership_id:
             continue
 
@@ -110,7 +110,7 @@ def notify_order_traded(ownable_id):
     dt_order_placed = datetime.strptime(expiry, '%Y-%m-%d %H:%M:%S') - timedelta(minutes=DEFAULT_ORDER_EXPIRY)
 
     model.cursor.execute('''
-        SELECT SUM(amount) >= 2 * ?
+        SELECT COALESCE(SUM(amount), 0) >= 2 * ?
         FROM transactions
         WHERE ownable_id = ? 
           AND dt > ? -- interestingly >= would be problematic