19 lines
450 B
Python
19 lines
450 B
Python
import time
|
|
import psycopg2
|
|
|
|
SLEEP=5
|
|
|
|
def get_db_connection_live():
|
|
return psycopg2.connect(host='127.0.0.1', database='live_acctval', user='joseph')
|
|
|
|
dbconn = get_db_connection_live()
|
|
cur = dbconn.cursor()
|
|
try:
|
|
while True:
|
|
cur.execute('SELECT pnl FROM pnl_intra ORDER BY id DESC LIMIT 1')
|
|
bleh = cur.fetchone()
|
|
print(round(bleh[0], 2), flush=True)
|
|
time.sleep(SLEEP)
|
|
finally:
|
|
cur.close()
|
|
dbconn.close() |