-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN.py
74 lines (54 loc) · 2.07 KB
/
MAIN.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
'''#!/usr/bin/python'''
import cgi, cgitb, sys, re, os, inspect
import LoadData
import PatProcess
cgitb.enable()
SYMBOLS = []
def testPatterns(data):
print(data)
def UpdateStocks(getSyms=False, getQuotes=False):
global SYMBOLS
if getSyms is True:
LoadData.downloadSymbols()
if getQuotes is True:
LoadData._downloadStocks('nasdaq')
LoadData._downloadStocks('nyse')
SYMBOLS = LoadData._getSymbols()
def AS(sym=None):
global SYMBOLS
UpdateStocks()
if len(SYMBOLS) < 1 and sym is None:
print("Not enough stocks loaded.")
return
# If a single stock symbol has been passed, only test that symbol.
if isinstance(sym, str):
print("Will test: " + sym)
tester = PatProcess.Test(LoadData.historicalData(sym))
tester.parse()
# Otherwise, test them all.
else:
for s in SYMBOLS[1:20]:
print("Will test:" + s[0])
#Patterns.test(LoadData.historicalData(s[0]))
AS("TEST")
'''
Get historical data:
http://ichart.finance.yahoo.com/table.csv?s=AAPL&c=1962
Details: http://etraderzone.com/free-scripts/47-historical-quotes-yahoo.html
Get complete stock quote list:
http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download
(replace exchange=nasdaq with exchange=nyse for nyse symbols).
More info:
http://benjisimon.blogspot.com/2009/01/truly-simple-stock-api.html
# ------------------------------------------
# Disable buffering for live AJAX feed
class Unbuffered:
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout=Unbuffered(sys.stdout)
'''