forked from onewaymyway/stockTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyStock.py
47 lines (39 loc) · 1018 Bytes
/
myStock.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
dRule='float(data["zf"])>10 or float(data["zf"])<-9';
def getStockList(fileName):
rules={};
stocks=[];
f=open(fileName,"r",encoding="utf-8");
data=f.readlines();
f.close();
for line in data:
line=line.strip();
cr=line.split(",");
code=cr[0];
if len(cr)>1:
trule=cr[1];
else:
trule=dRule;
rules[code]=trule;
stocks.append(code);
rst={};
rst["stocks"]=stocks;
rst["rules"]=rules;
return rst;
codeType={
"6":"sh",
"0":"sz",
"3":"sz"
}
def adptStockCode(code):
return code+"."+codeType[code[0]];
def getStocks(stockList):
rst=[];
for stock in stockList:
rst.append(adptStockCode(stock));
return rst;
class Stocks:
def __init__(self,file="stockList.txt"):
data=getStockList(file);
self.stocks=data["stocks"];
self.rules=data["rules"];
self.stocksA=getStocks(self.stocks);