-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGlobals.py
49 lines (39 loc) · 1.9 KB
/
Globals.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
import datetime as datetime
from collections import defaultdict
import pickle
# 1 - Stooq
# 2 - Finam.ru
# As the data is in 5 min interval, so 12 * 5 would be next hour
# rolling mean 25 minutes, as the data is in 5 minute interval
rolling_mean = 5
next_prediction = 60
lag = 12
do_prediction = True
Stocks = []
Stocks.append({'name':'Apple Inc.','symbol':'AAPL','zone':'America/New_York',
'selection':2,'data_file':'Data/AAPL.csv',
'source_zone':'Europe/Moscow','from_file':False,
'from_cloud' : False,'getLive' : True,'max_from_google':False,'max_days':1})
#
# Stocks.append({'name':'Chine Mobile Ltd','symbol':'0941','zone':'Asia/Hong_Kong',
# 'selection':1,'data_file':'Data/941.csv',
# 'source_zone':'Europe/Warsaw','from_file':False,
# 'from_cloud' :False,'getLive' : True,'max_from_google':False,'max_days':1})
# Stocks.append({'name':'Chine Mobile Ltd','symbol':'0941','zone':'Asia/Hong_Kong',
# 'selection':1,'data_file':'Data/11B.csv',
# 'source_zone':'Europe/Warsaw','from_file':True,
# 'from_cloud' : False,'getLive' : True})
def days_between(d1, d2):
d3 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d %I:%M")
d4 = datetime.datetime.strptime(d2, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d %I:%M")
newd3 = datetime.datetime.strptime(d3, "%Y-%m-%d %I:%M")
newd4 = datetime.datetime.strptime(d4, "%Y-%m-%d %I:%M")
return (newd4 - newd3).days
def minutes_between(d1, d2):
d3 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M")
d4 = datetime.datetime.strptime(d2, "%Y-%m-%d %H:%M")
return abs((d4 - d3).seconds / 60)
def add_minute(d1, m):
d2 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M")
update = d2 + datetime.timedelta(minutes=m)
return update.strftime("%Y-%m-%d %H:%M")