-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstockscreener_v1_3.lua
More file actions
158 lines (107 loc) · 3.28 KB
/
stockscreener_v1_3.lua
File metadata and controls
158 lines (107 loc) · 3.28 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
function OnInit()
tikers = {}
progname = "stockscreener v1.3 light : "
mBlack = RGB(0,0,0)
mWhite = RGB(255,255,255)
mRed = RGB(254,203,220)
mGreen = RGB(210,247,221)
mDGreen = RGB(154, 237, 179)
mDRed = RGB(253, 162, 191)
startind = 0
end
function OnStop()
message(progname.." финиш.")
do_it = false
end
function exc_tik(stock) -- исключение бумаг с нулевыми оборотами
t = {
"ACKO",
"GAZC",
"GAZS",
"GAZT",
"MGNZ"
}
for i, v in ipairs(t) do
if v == stock then return 1 end
end
return 0
end
function main()
message(progname.." старт работы.")
do_it = true
if m_t==nil then
m_t=AllocTable()
for u = 1, 20 do
if u%2 == 1 then
lencolumn = 9
celltype = QTABLE_STRING_TYPE
else
lencolumn = 6
celltype = QTABLE_DOUBLE_TYPE
end
AddColumn(m_t, u, " ", true, celltype, lencolumn)
end
CreateWindow(m_t)
SetWindowPos(m_t,690,0,1000,500)
SetWindowCaption(m_t, progname.." скринер акций Московской Биржи")
for i=1, 25 do
InsertRow(m_t,-1)
end
end
sec_list = getClassSecurities("TQBR") -- тикеры в одну строчку
mColumn = 1
mRow = 1
xCoord = {}
yCoord = {}
xy={}
-- разбивка строки с тикерами
for TIKER in string.gmatch(sec_list, "[^,]+") do
if exc_tik(TIKER) == 0 then
tikers[#tikers + 1]=TIKER
SetCell(m_t, mRow, mColumn, tikers[#tikers])
xCoord[TIKER] = mColumn
yCoord[TIKER] = mRow
mRow = mRow + 1
if mRow == 26 then
mRow = 1
mColumn = mColumn + 2
end
sleep(65)
end
end
DELTA = {}
while do_it do
for i = 1 , #tikers do
delta = getParamEx("TQBR", tikers[i], "LASTCHANGE")
if startind == 0 or DELTA[tikers[i]]~=tonumber(delta.param_value) then
SetCell(m_t, yCoord[tikers[i]], xCoord[tikers[i]], tikers[i])
SetCell(m_t, yCoord[tikers[i]], xCoord[tikers[i]] + 1, delta.param_image)
if tonumber(delta.param_value) < 0 then
Highlight(m_t, yCoord[tikers[i]], xCoord[tikers[i]], mDRed, mBlack, 500)
Highlight(m_t, yCoord[tikers[i]], xCoord[tikers[i]] + 1 , mDRed, mBlack, 500)
SetColor(m_t, yCoord[tikers[i]], xCoord[tikers[i]], mRed, mBlack, mRed, mBlack)
SetColor(m_t, yCoord[tikers[i]], xCoord[tikers[i]] + 1, mRed, mBlack, mRed, mBlack)
end
if tonumber(delta.param_value) > 0 then
Highlight(m_t, yCoord[tikers[i]], xCoord[tikers[i]], mDGreen, mBlack, 500)
Highlight(m_t, yCoord[tikers[i]], xCoord[tikers[i]] + 1, mDGreen, mBlack, 500)
SetColor(m_t, yCoord[tikers[i]], xCoord[tikers[i]], mGreen, mBlack, mGreen, mBlack)
SetColor(m_t, yCoord[tikers[i]], xCoord[tikers[i]] + 1, mGreen, mBlack, mGreen, mBlack)
end
DELTA[tikers[i]]=tonumber(delta.param_value)
if startind == 0 then
sleep(75)
else
sleep(5)
end
end
if startind == 0 then
DELTA[tikers[i]] = tonumber(delta.param_value)
end
if startind == 0 and i == #tikers then startind = 1 end
sleep(5)
end
if IsWindowClosed(m_t) then OnStop() end
sleep(10000)
end
end