Browse Source

do not show stop loss orders in orders_on

Eren Yilmaz 6 years ago
parent
commit
8abc18e0d8
2 changed files with 3 additions and 7 deletions
  1. 1 1
      client_controller.py
  2. 2 6
      model.py

+ 1 - 1
client_controller.py

@@ -330,7 +330,7 @@ def orders_on(obj_name=None):
     success = 'data' in response
     if success:
         print(_my_tabulate(response['data'],
-                           headers=['My', 'Buy?', 'Name', 'Size', 'Limit', 'stop-loss', 'Expires', 'No.'],
+                           headers=['My', 'Buy?', 'Name', 'Size', 'Limit', 'Expires', 'No.'],
                            tablefmt="pipe"))
     else:
         if 'error_message' in response:

+ 2 - 6
model.py

@@ -378,7 +378,7 @@ def get_ownable_orders(user_id, ownable_id):
     cursor.execute('''
         SELECT 
             CASE 
-                WHEN ownership.user_id = ? THEN ' X '
+                WHEN ownership.user_id = ? THEN 'X'
                 ELSE NULL
             END,
             CASE 
@@ -388,17 +388,13 @@ def get_ownable_orders(user_id, ownable_id):
             ownables.name, 
             orders.ordered_amount - orders.executed_amount, 
             orders."limit", 
-            CASE 
-                WHEN orders."limit" IS NULL THEN NULL 
-                WHEN orders.stop_loss THEN 'Yes'
-                ELSE 'No'
-            END, 
             datetime(orders.expiry_dt, 'localtime'),
             orders.rowid
         FROM orders, ownables, ownership
         WHERE ownership.ownable_id = ?
         AND ownership.ownable_id = ownables.rowid
         AND orders.ownership_id = ownership.rowid
+        AND (orders.stop_loss IS NULL OR NOT orders.stop_loss)
         ORDER BY ownables.name ASC, orders.stop_loss ASC, orders.buy DESC, orders."limit" ASC
         ''', (user_id, ownable_id,))