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()