added 'by pair' functionality
This commit is contained in:
parent
6a0eedf7d6
commit
285a3b6de0
|
|
@ -4,14 +4,20 @@ import sqlite3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
amount_of_deals = sys.argv[1]
|
amount_of_deals = sys.argv[1]
|
||||||
|
pair = None
|
||||||
|
if len(sys.argv) > 2:
|
||||||
|
pair = sys.argv[2]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("Usage: python3 last_n_deals.py int")
|
print("Usage: python3 last_n_deals.py int <pair>")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
connection = sqlite3.connect('profits_database.db')
|
connection = sqlite3.connect('profits_database.db')
|
||||||
cursor = connection.cursor()
|
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()
|
deals = cursor.fetchall()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue