-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.py
More file actions
81 lines (58 loc) · 2.18 KB
/
Example.py
File metadata and controls
81 lines (58 loc) · 2.18 KB
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
#from APICaller import AlphaVantageAPI
#import matplotlib.pyplot as py
import pandas as pd
#import numpy as np
from SQLServer import SQLServer
from CommandCreator import CommandCreator
#import time
nasdaq = pd.read_csv("AMEX.csv").iloc[:, :-1]
nasdaq = nasdaq.sort_values(by=['Symbol'])
f = open('AMEX.csv', 'r')
f.readline()
contents = f.readline()
symbols = []
while contents is not None and contents != "":
ind = 0
string = ""
while ind < len(contents):
string += contents[ind]
if contents[ind + 1] == str(","):
ind = len(contents)
ind += 1
print(string)
symbols.append(string)
contents = f.readline()
sql = SQLServer(Server="DESKTOP-T107VRL\SQLEXPRESS", Database="MarketAnalysis", trustedConnection=True)
commandBuilder = CommandCreator()
command = commandBuilder.BuildInsertCommand("AMEX_Symbols", commandValues = { "Symbol":1 }, dataSet = symbols)
sql.ExecuteCommand(command)
tempSet = []
epoch = 0
for index, row in nasdaq.iterrows():
tempSet.insert(index - (epoch * 499), row['Symbol'])
#The maximum insert size is 500 items, don't exceed that
if index % 499 == 0:
command = commandBuilder.BuildInsertCommand("AMEX", commandValues = { "Symbol":1 }, dataSet = tempSet)
sql.ExecuteCommand(command)
print(command)
# file = open("querries.sql", "a+")
# file.write(command)
# file.flush()
# file.close()
#sql.ExecuteCommand(command)
tempSet = []
#time.sleep(20)
epoch = epoch + 1
updateSet = []
for index, row in nasdaq.iterrows():
command = commandBuilder.BuildUpdateCommand("NYSE_Symbols", commandValues = { "CompanyName":row["Name"] }, queryFilter={ "Symbol":row["Symbol"]})
sql.ExecuteCommand(command)
print(command)
print(command)
from CommandCreator import CommandCreator, CrudType
#api = AlphaVantageAPI()
#msftSet = api.GetTimeSeries('MSFT')
com = CommandCreator()
command = com.CrudCommand(CrudType.INSERT, "AMEX",
commandValues = { "TimeStamp":1, "Open":2, "High":3, "Low":4, "Close":5, "Volume":6},
dataSet = msftSet)