Необходимо каждый день находить код обновляемого инструмента. Из данных имеется только лишь его префикс от короткого имени. Обычно делается следующим кодом:
Проблема в том, что часто (процентов 20% случаев) запуск кода дает ошибку ACCESS VIOLATION. Есть ли иной способ решить задачу?
| Код |
|---|
function findSecurity()
local mdt = 0
local now = os.time()
local foundcode = ""
for i = 0,getNumberOf("SECURITIES") - 1 do
local row = getItem("SECURITIES", i)
if(row.class_code == "PSAU") and (autolib.CheckAssetName(row.short_name) == true) then
--message(row.short_name)
local info = getSecurityInfo(row.class_code, row.code)
if info ~= nil then
local expdt = strDateToEpoch(info.mat_date)
--message(tostring(info) .. " " .. tostring(expdt) .. " " .. tostring(now))
if expdt > mdt and expdt > now then
mdt = info.mat_date
foundcode = row.code
--message(tostring(info.mat_date) )
end
end
end
end
if foundcode ~= "" then
autobuyerlib.LogU8(string.format("Найден инструмент %s", foundcode))
end
end
|