Browse Source

Implement missing function abs_spread

Eren Yilmaz 5 năm trước cách đây
mục cha
commit
3f689309ee
1 tập tin đã thay đổi với 22 bổ sung0 xóa
  1. 22 0
      model.py

+ 22 - 0
model.py

@@ -1040,6 +1040,28 @@ def new_news(message):
         ''', (message,))
 
 
+def abs_spread(ownable_id):
+    connect()
+
+    cursor.execute('''
+        SELECT 
+            (SELECT MAX("limit") 
+             FROM orders, ownership
+             WHERE ownership.rowid = orders.ownership_id
+             AND ownership.ownable_id = ?
+             AND buy
+             AND NOT stop_loss) AS bid, 
+            (SELECT MIN("limit") 
+             FROM orders, ownership
+             WHERE ownership.rowid = orders.ownership_id
+             AND ownership.ownable_id = ?
+             AND NOT buy
+             AND NOT stop_loss) AS ask
+        ''', (ownable_id, ownable_id,))
+
+    return cursor.fetchone()
+
+
 def ownables():
     connect()