forked from morefinances/qlua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoextickers.lua
More file actions
49 lines (36 loc) · 1.81 KB
/
moextickers.lua
File metadata and controls
49 lines (36 loc) · 1.81 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
-- To read comments, use the encoding:: Windows-1251
--[[
Скрипт делает выгрузку всех торгуемых акций на Московской Бирже (иногда встречаются варианты с нулевыми объемами, но с индикативными ценами).
Сохраняет результат в файл C:\files\tickers.csv. Параллельно выводит список с разбивкой по 5 бумаг в строку в терминале.
]]--
function main()
message('[ = = = = = = = = = = start = = = = = = = = = = ]')
datetime = os.date("!*t",os.time())
message('')
message(os.date("%d.%m.%Y"))
message('Начало работы скрипта '..os.date("%X",os.time()))
DirectionSaveFile=tostring("C:\\files\\tickers.csv")
my_csv=io.open(DirectionSaveFile,"w")
sec_list = getClassSecurities("TQBR") -- тикеры в одну строчку
ind = 1 -- индекс подсчета количество бумаг
sprint = "" -- склейка массивов для вывода
-- разбивка строки с тикерами
for TIKER in string.gmatch(sec_list, "[^,]+") do
-- запись в файл
my_csv:write(TIKER.."\n")
sprint = sprint..tostring(ind).."/ "..TIKER.." "
ind = ind + 1 -- индекс бумаги
if ind%5 == 1 then
message(sprint)
sprint = ""
end
sleep(5)
end
if sprint ~= "" then message(sprint) end
-- -- закрытие файла
my_csv:flush()
my_csv:close()
message('Завершение работы скрипта '.. os.date("%X",os.time()))
message('Общее количество торгуемых бумаг : '..tostring(ind - 1))
message("[ = = = = = = = = = = end = = = = = = = = = = ]")
end