Если используете QUIK, то вот скрипт, рассчитывающий комиссию:
function main()
local class = "SPBFUT"
local secList = getClassSecurities(class)
local function ErlstSec(ft)
if #ft > 3 and string.match(secList, ft) then
return ft
end
local e = "z"
for v in string.gmatch(secList, ft.."%u%d") do
local f = string.reverse(v)
e = (e<f) and e or f
end
return string.reverse(e)
end
local function Rnd(x,n)
return math.floor(x*10^n+0.5)/10^n
end
local function MsgWin(nm,cms)
if IsWindowClosed(t_id) == false then -- Открыто.
height = height + 15 -- +Высота строки. 15
end
if IsWindowClosed(t_id) == nil then -- Не существует.
t_id = AllocTable()
AddColumn(t_id, 1, "", true, QTABLE_STRING_TYPE, 14)
AddColumn(t_id, 2, "", true, QTABLE_DOUBLE_TYPE, 7)
CreateWindow(t_id)
height = 58 -- Высота окна с одной строкой. 58
end
SetWindowCaption(t_id, "Комиссия")
SetWindowPos(t_id, 400, 300, 146, height) -- X, Y, ширина, высота окна. 146
row = InsertRow(t_id, -1)
SetCell(t_id, row, 1, nm)
SetCell(t_id, row, 2, cms)
end
-- Базовая ставка комиссии групп. https://www.moex.com/s93
local bscRate = {
cur = 0.00462, -- Валютный
idx = 0.0066, -- Индексный
cmdt = 0.0132, -- Товарный
prc = 0.0165, -- Процентный
stk = 0.0198 -- Фондовый
}
-- Группа фьючерса.
local fts = {
GZ = "stk",
LK = "stk",
RN = "stk",
SR = "stk",
VB = "stk",
GK = "stk",
MM = "idx",
NA = "idx",
RM = "idx",
GD = "cmdt",
SF = "idx",
BR = "cmdt",
NG = "cmdt",
Si = "cur",
CR = "cur",
Eu = "cur",
ED = "cur",
IMOEXF = "idx",
CNYRUBF = "cur",
USDRUBF = "cur"
}
for f, b in pairs(fts) do
local sec = ErlstSec(f)
if sec ~= "z" then
--PrintVar(sec)
local futPrice = getParamEx(class, sec, "PREVSETTLEPRICE").param_value -- Расчетная цена предыдущего клиринга. https://www.moex.com/s93#tranz
local stpCost = getParamEx(class, sec, "STEPPRICE").param_value
local secInfo = getSecurityInfo(class, sec)
--TableLog(secInfo)
local priseStep = secInfo.min_price_step
local name = secInfo.name
local coms = string.format("%.2f", futPrice*stpCost*bscRate[b]/(priseStep*100))
--local coms = string.format("%.2f", Rnd(futPrice*Rnd(stpCost/priseStep,5),2)*bscRate[b]/100)
MsgWin(name,coms)
end
end
end

