From 285a3b6de076009f93273d049c0963c4591393ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Fri, 29 Nov 2024 12:03:44 -0300 Subject: [PATCH] added 'by pair' functionality --- profits/last_n_deals.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/profits/last_n_deals.py b/profits/last_n_deals.py index 98a82d7..c8e66de 100644 --- a/profits/last_n_deals.py +++ b/profits/last_n_deals.py @@ -4,14 +4,20 @@ import sqlite3 try: amount_of_deals = sys.argv[1] + pair = None + if len(sys.argv) > 2: + pair = sys.argv[2] except Exception as e: print(e) - print("Usage: python3 last_n_deals.py int") + print("Usage: python3 last_n_deals.py int ") sys.exit() connection = sqlite3.connect('profits_database.db') cursor = connection.cursor() -cursor.execute(f'SELECT * FROM profits_table ORDER BY timestamp DESC LIMIT {amount_of_deals}') +extra_query = "" +if pair: + extra_query = f"WHERE pair = '{pair}'" +cursor.execute(f'SELECT * FROM profits_table {extra_query} ORDER BY timestamp DESC LIMIT ?', (amount_of_deals,)) deals = cursor.fetchall() connection.close()