-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.py
82 lines (71 loc) · 1.97 KB
/
test.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
73
74
75
76
77
78
79
80
81
82
price = float("552.15")
target = float("557.6715")
stoploss = float("546.6285")
squareoff = round((target - price), 1)
stoploss = round((price - stoploss), 1)
print(stoploss, squareoff, price)
"""
SIGNAL_BOT_URL = "https://api.telegram.org/bot{}".format(SIGNAL_BOT_TOKEN)
SIGNAL_BOT_SEND_URL = (
SIGNAL_BOT_URL + "/sendMessage?chat_id=" + TESTING_GROUP_ID + "&text="
)
ALGOTRADE_BOT_URL = "https://api.telegram.org/bot{}".format(
ALGOTRADE_BOT_TOKEN
)
ALGOTRADE_BOT_SEND_URL = (
ALGOTRADE_BOT_URL + "/sendMessage?chat_id=" + TESTING_GROUP_ID + "&text="
)
"""
"""
x = {
"call": "SHORT",
"interval": "15min",
"price": "1377",
"stock": "RELIANCE",
"stoploss": "1363.725",
"Strategy": "gt_InD_15min_reliance",
"target": "1391",
"time": "2019-04-30 10:30:00",
"autotrade": "1",
"quantity": "100",
}
target = round((float(x["target"]) - float(x["price"])), 1)
stoploss = round((float(x["price"]) - float(x["stoploss"])), 1)
print(target, stoploss)
"""
'''
def update_token_table(_access_token):
"""
Update Token Table with new access token
"""
# Get current datetime in isoformat
dtime = get_datetime()
try:
response = token_table.put_item(
Item = {
'date_stamp': dtime[0],
'time_stamp': dtime[1],
'access_token': _access_token
}
)
except:
return "Error: Token table update failed"
return response['ResponseMetadata']['HTTPStatusCode']
def get_access_token():
"""
Retrieve Access Token from Token Table
"""
# Get current datetime in isoformat
dtime = get_datetime()
try:
response = token_table.query(
KeyConditionExpression=Key('date_stamp').eq(dtime[0]),
ProjectionExpression="access_token",
ScanIndexForward = False,
Limit = 1
)
if not response['I']
except:
return 0
return response['Items'][0]['access_token']
'''