소스 검색

Implement missing function abs_spread

Eren Yilmaz 5 년 전
부모
커밋
3f689309ee
1개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  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()