-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_functions.py
72 lines (56 loc) · 1.69 KB
/
_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from config import *
def store_current_price(params):
# connect DB
conn = sqlite3.connect(DB)
c = conn.cursor()
# Insert a row of data
c.execute(
"INSERT INTO stock_prices VALUES ('%s','%s',%f)"
% (params['date_time'], params['symbol'], params['price'])
)
# Save (commit) the changes'%s'" % symbol
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
def store_best_limits(params):
# Insert a row of data
c.execute(
"INSERT INTO limits VALUES ('%s','%s', %f, %f, %f, %f)"
% (
strftime("%Y-%m-%d %H:%M:%S", gmtime()),
params['symbol'],
params['bottom'],
params['top'],
params['start_money'],
params['earned_money']
)
)
# Save (commit) the changes'%s'" % symbol
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
def store_user_limits(params):
# Insert a row of data
c.execute(
"INSERT INTO user_limits (date_time, symbol, bottom, top) VALUES ('%s','%s', %f, %f)"
% (
strftime("%Y-%m-%d %H:%M:%S", gmtime()),
params['symbol'],
params['bottom'],
params['top']
)
)
# Save (commit) the changes'%s'" % symbol
conn.commit()
# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()
def fetch_user_limits(symbol):
# Insert a row of data
# Do this instead
t = (symbol,)
c.execute("SELECT bottom, top FROM user_limits WHERE symbol=? ORDER BY id DESC LIMIT 1", t)
return c.fetchone()
# print(fetch_user_limits('MSFT'))