forked from brunopereiracosta/finetic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyFuncs.py
34 lines (25 loc) · 818 Bytes
/
MyFuncs.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
import datetime
def date_to_weekday(sheet):
return [date.weekday() for date in sheet['Date'].tolist()]
def date_to_yearday(sheet):
return [(date-datetime.datetime(year=date.year,month=1,day=1)).days for date in sheet['Date'].tolist()]
def read_sheet(sheet):
return sheet['Last Price'].tolist(), date_to_yearday(sheet), date_to_weekday(sheet)
def error(arr):
return [(arr[i]-arr[i-1])/arr[i-1] for i in range(1,len(arr))]
# # bruno testing
# import pandas as pd
# import time
# # clock
# start = time.time()
# xls = pd.ExcelFile('./SECRET ADMIRER.xlsx')
# end = time.time()
# elapsed = end - start
# print(elapsed)
# USDEUR = xls.parse(xls.sheet_names.index('EURUSD BGN'))
# a = date_to_weekday(USDEUR)
# b = date_to_yearday(USDEUR)
# c = read_sheet(USDEUR)
# print(a[0])
# print(b[0])
# print(c[1][0])