Advertisement
XXM

SuperScalp.lua

XXM
Dec 24th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.71 KB | None | 0 0
  1. -- SuperScalp.lua, © hismatullin.h@gmail.com, xsharp.ru
  2. -- с возможностями полного протоколирования действий программы.
  3. local ver = '1.41'  --  11.11.2016
  4. local lastPos = 0
  5. local lastPrice = 0
  6. local string_gmatch=string.gmatch
  7. local string_find=string.find
  8. local string_sub=string.sub
  9. local string_len=string.len
  10. local string_format=string.format
  11. local math_modf=math.modf
  12. local SeaGreen=12713921     --  RGB(193, 255, 193)
  13. local RosyBrown=12698111    --  RGB(255, 193, 193)
  14. local logFile
  15. local trades = {} -- Таблица_01 - получили сделку
  16. local _trades = {} -- временная таблица наших сделок для отлова дублей в QUIK ver. 7.1.0
  17. local orders = {}   --  Таблица заявок
  18. local scriptPath = getScriptPath()
  19. local Terminal_Version=getInfoParam('VERSION')
  20. local function versionLess(ver1,ver2)
  21.     local begin,ver_1=0
  22.     for ver_2 in string_gmatch(ver2,'%d+') do
  23.         _,begin,ver_1=string_find(ver1,'(%d+)',begin+1)
  24.         if ver_1~=ver_2 then return not ver_1 or ver_1+0<ver_2+0 end
  25.     end
  26.     return false
  27. end
  28. local table_insert = table.sinsert
  29. local table_remove = table.sremove
  30. local table_concat = table.sconcat
  31. -----
  32. local dc = QTABLE_DEFAULT_COLOR
  33. local testQuik = true -- подписка на OnTransReply, OnTrade, OnOrder
  34. --local testQuik = false -- без подписки
  35. function firm_id()
  36.   for i = 0, getNumberOf("money_limits") - 1 do
  37.     local row = getItem("money_limits", i)
  38.     if row ~= nil and row.firmid ~= nil then
  39.       local ss = tostring(string_sub(row.firmid, 2, 2))
  40.       if ss == "C" or ss == "R" or ss == "B" then
  41.         return tostring(row.firmid)
  42.       end
  43.     end
  44.   end
  45.   return nil
  46. end
  47. local tostring__ = tostring
  48. function tostring(x)
  49.     if math.tointeger(x) then
  50.         return string_format("%0i",x)
  51.     end
  52.     return tostring__(x)
  53. end
  54.  
  55. local is_forts = true
  56. --настройки
  57. function getInitParameter()
  58.     if is_forts then
  59.         account = 'SPBFUT001ad'
  60.         classCode = 'SPBFUT'
  61.         secCode = 'SiH1'
  62.         OpenSlippage = 50
  63.     else
  64.         account="NL0011100043"
  65.         ClientCode = "1133"
  66.         classCode = 'QJSIM'
  67.         secCode = 'SBER'
  68.         OpenSlippage = 0.5
  69.         firm_id = firm_id()
  70.         message('firm_id = '..firm_id)
  71.     end
  72.     workSize = 5    -- рабочий размер
  73.     logFileName1 = 'logFile1.txt'   -- файл для укороченного протоколирования коллбэков
  74.     logFileName2 = 'logFile2.txt'   -- файл для печати всех полей коллбэков
  75. end
  76. --
  77.  
  78.  
  79. function getHRTime()
  80.     return os.date("%X", os.time())
  81. end
  82. --
  83.  
  84. function event_callback_tblH(t_id, msg, par1, par2)
  85.     if msg == QTABLE_LBUTTONDOWN then   -- нажата левая кнопка мыши
  86.         local mes = ''
  87.         lastPos = futures_position()
  88.         local status = tonumber(getParamEx(classCode, secCode,"status").param_value)
  89.         local mes = secCode..', '..classCode..', нажато: купить-. status = '..status
  90.         message(mes)
  91.         if status ~= 1 or par1 == 1 then -- если бумага не торгуется, заявку не подаем
  92.             Highlight(t_id, par1, par2, RosyBrown, dc, 500)     -- подсветка, RosyBrown
  93.             if status ~= 1 then
  94.                 mes = 'Ошибка: клиринг!'
  95.                 message(mes); io_log(mes);
  96.             end
  97.             return
  98.         end
  99.         Highlight(t_id, par1, par2, SeaGreen, dc, 500)      -- подсветка SeaGreen
  100.         if par1 == 2 and par2 == 1 then
  101.             if lastPos < 0 then
  102.                 mes = secCode..'; нажато: купить, '..-lastPos
  103.                 Buy(classCode, secCode, -lastPos, 'CloseShort')
  104.             --elseif    lastPos == 0 then
  105.             else
  106.                 mes = secCode..'; нажато: купить, '..workSize
  107.                 Buy(classCode, secCode, workSize, 'OpenLong')
  108.             --else
  109.             --  mes = secCode..'; нажато: купить. Мы в лонгах, не покупаем!'
  110.             end
  111.         elseif par1 == 2 and par2 == 2 then -- продать, левая кнопка
  112.             if lastPos > 0 then
  113.                 mes = secCode..'; нажато: продать, '..lastPos
  114.                 Sell(classCode, secCode, lastPos, 'CloseLong')
  115.             --elseif    lastPos == 0 then
  116.             else
  117.                 mes = secCode..'; нажато: продать, '..workSize
  118.                 Sell(classCode, secCode, workSize, 'OpenShort')
  119.             --else
  120.             --  mes = secCode..'; нажато: продать. Мы в шортах, не продаем!'
  121.             end
  122.         elseif par1 == 2 and par2 == 3 then -- закрыть позиции
  123.             if lastPos > 0 then
  124.                 mes = secCode..'; нажато: закрыть лонги, '..lastPos
  125.                 Sell(classCode, secCode, lastPos, 'CloseAll')
  126.             elseif  lastPos < 0 then
  127.                 mes = secCode..'; нажато: закрыть шорты, '..-lastPos
  128.                 Buy(classCode, secCode, -lastPos, 'CloseAll')
  129.             else
  130.                 mes = secCode..'; нажато: закрыть. Нет позиций для закрытия!'
  131.             end
  132.         elseif par1 == 3 and par2 == 1 then
  133.             if lastPos < 0 then
  134.                 mes = secCode..'; нажато: купить-, '..-lastPos
  135.                 BuyBid(classCode, secCode, -lastPos, 'CloseShort')
  136.             --elseif    lastPos == 0 then
  137.             else
  138.                 BuyBid(classCode, secCode, workSize, 'OpenLong')
  139.                 mes = secCode..'; нажато: купить-, '..workSize
  140.             --else
  141.             --  mes = secCode..'; нажато: купить-. Мы в лонгах, не покупаем!'
  142.             end
  143.         elseif par1 == 3 and par2 == 2 then
  144.             if lastPos > 0 then
  145.                 SellOffer(classCode, secCode, lastPos, 'CloseLong')
  146.                 mes = secCode..'; нажато: продать+, '..lastPos
  147.             --elseif    lastPos == 0 then
  148.             else
  149.                 SellOffer(classCode, secCode, workSize, 'OpenShort')
  150.                 mes = secCode..'; нажато: продать+, '..workSize
  151.             --else
  152.             --  mes = secCode..'; нажато: продать+. Мы в шортах, не продаем!'
  153.             end
  154.         elseif par1 == 3 and par2 == 3 then
  155.             mes = secCode..'; нажато: Снять все заявки!'
  156.             KillOrders()
  157.         end
  158.         message(mes); io_log(mes);
  159.     elseif msg == QTABLE_CLOSE then
  160.         OnStop()
  161.     end
  162. end
  163. --
  164.  
  165. QTable ={}
  166. QTable.__index = QTable
  167. -- Создать и инициализировать экземпляр таблицы QTable
  168. function QTable.new()
  169.     local t_id = AllocTable()
  170.     if t_id ~= nil then
  171.         q_table = {}
  172.         setmetatable(q_table, QTable)
  173.         q_table.t_id=t_id
  174.         q_table.caption = ""
  175.         q_table.created = false
  176.         q_table.curr_col=0
  177.         -- таблица с описанием параметров столбцов
  178.         q_table.columns={}
  179.         return q_table
  180.     else
  181.         return nil
  182.     end
  183. end
  184. tblH = QTable:new() -- для ручной торговли
  185. --
  186.  
  187. function get_trans_id()
  188.     local s = tostring(os.clock())
  189.     local x, g = string_find(s, "(%d+)")
  190.     s = string_sub(s, g + 2)
  191.     for i = 1, 3 - string_len(s) do
  192.         s = "0" .. s
  193.     end
  194.     return os.date("%H%M%S") .. s
  195. end
  196. --
  197.  
  198. function send_order(client, class, seccode, account, operation, quantity, price)
  199.     account = 'blablabla'
  200.     local mes = 'send_order, client = '..client..', class = '.. class..', seccode = '..seccode..', account = '..account
  201.     ..', quantity = '..quantity.. ', operation = '..operation.. ', price = '..price
  202.     message(mes)
  203.     local trans_id = get_trans_id()
  204.     rus = false
  205.     --rus = true
  206.     if rus then
  207.         trans_params = {
  208.             CLASSCODE = class,
  209.             CLIENT_CODE = client,
  210.             SECCODE = seccode,
  211.             ACCOUNT = account,
  212.             TYPE = new_type,
  213.             TRANS_ID = trans_id,
  214.             OPERATION = operation,
  215.             QUANTITY = tostring(quantity),
  216.             PRICE = tostring(price),
  217.             ACTION = "NEW_ORDER"
  218.             }
  219.     else
  220.         if operation == "B" then
  221.             operation = 'Покупка'
  222.         else
  223.             operation = 'Продажа'
  224.         end
  225.         trans_params = {
  226.             ["TRANS_ID"] = trans_id,
  227.             ["Комментарий"] = client,
  228.             ["ACTION"] = "Ввод заявки",
  229.             ["CLASSCODE"] = class,
  230.             ["Тип"] = "Лимитированная",
  231.             ["Условие исполнения"] = "Поставить в очередь",
  232.             ["Класс"] = class,
  233.             ["Инструмент"] = seccode,
  234.             ["Количество"] = tostring(quantity),
  235.             ["Цена"] = tostring(price),
  236.             ['К/П'] = operation,
  237.             ["Торговый счет"] = account
  238.             }
  239.     end
  240.     return sendTransaction(trans_params)
  241. end
  242. --
  243.  
  244. function Buy(classCode, secCode, size, action)
  245.     local best_offer = getParamEx(classCode, secCode, "offer").param_value
  246.     local buyPrice = best_offer + (OpenSlippage or 0)
  247.     local res = send_order(action, classCode, secCode, account, "B", size, buyPrice)
  248.     if string_len(res) ~= 0 then
  249.         local mes = 'Ошибка: '..res..', '.. action..', '..secCode..', '.."B"..', '..size..', price='..buyPrice
  250.         message(mes,3); io_log(mes);
  251.     end
  252. end
  253. --
  254.  
  255. function Sell(classCode, secCode, size, action)
  256.     local best_bid = getParamEx(classCode, secCode, "bid").param_value
  257.     local sellPrice = best_bid - (OpenSlippage or 0)
  258.     local res = send_order(action, classCode, secCode, account, "S", size, sellPrice)
  259.     if string_len(res) ~= 0 then
  260.         local mes = 'Ошибка: '..res..', '.. action..', '..secCode..', '.."S"..', '..size..', price='..sellPrice
  261.         message(mes,3); io_log(mes);
  262.     end
  263. end
  264. --
  265.  
  266. function BuyBid(classCode, secCode, size, action)
  267.     local best_bid = getParamEx(classCode, secCode, "bid").param_value
  268.     local buyPrice = best_bid - (OpenSlippage or 0)
  269.     local res = send_order(action, classCode, secCode, account, "B", size, buyPrice)
  270.     message('res = '..res)
  271.     if string_len(res) ~= 0 then
  272.         local mes = 'Ошибка: '..res..', '.. action..', '..secCode..', '.."B"..', '..size..', price='..buyPrice
  273.         message(mes,3); io_log(mes);
  274.     end
  275. end
  276. --
  277.  
  278. function SellOffer(classCode, secCode, size, action)
  279.     local best_offer = getParamEx(classCode, secCode, "offer").param_value
  280.     local sellPrice = best_offer + (OpenSlippage or 0)
  281.     local res = send_order(action, classCode, secCode, account, "S", size, sellPrice)
  282.     if string_len(res) ~= 0 then
  283.         local mes = 'Ошибка: '..res..', '.. action..', '..secCode..', '.."S"..', '..size..', price='..sellPrice
  284.         message(mes,3); io_log(mes);
  285.     end
  286. end
  287. --
  288.  
  289. function KillOrders()
  290.     local NumberOf = getNumberOf("orders")
  291.     for i = 0, NumberOf - 1 do
  292.         local ord = getItem("orders", i)
  293.         if ord.sec_code == secCode and ord.account == account  then
  294.             local order_flag = get_order_status(ord.flags)
  295.             if order_flag.status == "active" then
  296.                 trans_id = get_trans_id()
  297.                 local trans_params = {
  298.                         ["CLASSCODE"] = classCode,
  299.                         ["TRANS_ID"] = trans_id,
  300.                         ["ACTION"] = "KILL_ORDER",
  301.                         ["ORDER_KEY"] = tostring(ord.order_num)
  302.                         }
  303.                 local res =  sendTransaction(trans_params)
  304.                 if 0 < string_len(res) then
  305.                     local mes = 'Ошибка: '..res
  306.                     message(mes,3); io_log(mes);
  307.                 end
  308.             end
  309.         end
  310.     end
  311. end
  312. --
  313.  
  314. function HandleBS()
  315.     local t = tblH.t_id
  316.     AddColumn(t, 1, 'Бумага', true,QTABLE_CACHED_STRING_TYPE,12)
  317.     AddColumn(t, 2, 'ТЧП', true,QTABLE_STRING_TYPE,12)
  318.     AddColumn(t, 3, 'Цена послед.', true,QTABLE_STRING_TYPE,17)
  319.     CreateWindow(t)
  320.     SetWindowCaption(t, "SuperScalp "..ver) --SetWindowCaption(t, "Scalper:"..account)
  321.     SetWindowPos(t, 0, 100, 250, 120)
  322.     local li=InsertRow(t, -1)
  323.     SetCell(t, li, 1, secCode)
  324.     SetCell(t, li, 2, lastPos)
  325.     SetCell(t, li, 3, '7503')   --Ожидание
  326.     local li=InsertRow(t, -1)
  327.     SetCell(t, li, 1, 'Купить')
  328.     SetCell(t, li, 2, 'Продать')
  329.     SetCell(t, li, 3, 'Закрыть')
  330.     local li=InsertRow(t, -1)
  331.     SetCell(t, li, 1, 'купить —')
  332.     SetCell(t, li, 2, 'продать +')
  333.     SetCell(t, li, 3, 'Снять все')
  334.     SetTableNotificationCallback(t,event_callback_tblH)
  335. end
  336. --
  337.  
  338. --прочитать ТТП и вытащить ТЧП.
  339. function futures_position()
  340.     if is_forts then
  341.         local count=getNumberOf("futures_client_holding") --Позиции по клиентским счетам (фьючерсы)
  342.         for i=0,count-1, 1 do
  343.             local row=getItem("futures_client_holding",i)
  344.             if row.trdaccid~=nil then
  345.                 local seccode=row.sec_code      --Код фьючерсного контракта, "Инструмент"
  346.                 local totn=row.totalnet         --Текущие чистые позиции    "ТЧП"
  347.                 if seccode == secCode then
  348.                     return totn
  349.                 end
  350.             end
  351.         end
  352.     else
  353.         local t = getDepoEx(firm_id, ClientCode, secCode, account, 0)
  354.         if t then
  355.             local T = t.currentbal
  356.             SetCell(tblH.t_id, 1, 2, tostring(T))
  357.             positionColor(T)
  358.             return T
  359.         end
  360.     end
  361.     return 0
  362. end
  363. --
  364.  
  365. function positionColor(tot)
  366.     if tot>0 then
  367.         SetColor(tblH.t_id,1,2, SeaGreen, dc, dc, dc)   -- подсветка SeaGreen
  368.     elseif tot<0 then
  369.         SetColor(tblH.t_id,1,2, RosyBrown, dc, dc, dc)  -- подсветка, RosyBrown
  370.     else   
  371.         SetColor(tblH.t_id,1,2,dc, dc, dc, dc)
  372.     end
  373. end
  374. --
  375.  
  376. function get_order_status(flags)
  377.   local rt = {}
  378.   local band = bit.band
  379.   local tobit = bit.tobit
  380.   if band(tobit(flags), 1) ~= 0 and band(tobit(flags), 2) == 0 then
  381.     rt.status = "active"
  382.   elseif band(tobit(flags), 1) == 0 and band(tobit(flags), 2) ~= 0 then
  383.     rt.status = "cancelled"
  384.   elseif band(tobit(flags), 1) == 0 and band(tobit(flags), 2) == 0 then
  385.     rt.status = "filled"
  386.   else
  387.     rt.status = "unknown"
  388.   end
  389.   if band(tobit(flags), 4) ~= 0 then
  390.     rt.operation = "S"
  391.   else
  392.     rt.operation = "B"
  393.   end
  394.   return rt
  395. end
  396. --
  397.  
  398. --запись лога с текущим простым временем
  399. function io_log(str)
  400.     local file, err = io.open(logFile, "a")
  401.     assert(file, "Ошибка записи "..logFile..", \n"..str)
  402.     local str0 = getHRTime()    -- время с миллисекундами
  403.     str0 = str0..'; '.. str
  404.     file:write(str0 .. "\n")
  405.     file:flush()
  406.     file:close()
  407.     return true
  408. end
  409. --
  410.  
  411. if testQuik then
  412.     -- 2.2.17 - Функция вызывается терминалом QUIK при получении ответа на транзакцию пользователя.
  413.     function OnTransReply(reply)
  414.         if reply.account == account then
  415.             if running then
  416.                 local mes =  reply.sec_code..'; OnTrans, o_n '..reply.order_num..', '..tostring(reply.price)..' x '..
  417.                 tostring(reply.quantity)..', t_id = '..reply.trans_id
  418.                 message(mes); io_log(mes);
  419.             end
  420.             toLog(scriptPath..'\\'..logFileName2,reply, 'reply')
  421.         end
  422.     end
  423.     -- 2.2.3 Функция вызывается терминалом QUIK при получении сделки.
  424.     function OnTrade(trade)
  425.         if trade.account == account then    -- только если заявка из нашего счета - 01.11.2014
  426.             if running then
  427.                 if not _trades[trade.trade_num] then
  428.                     local mes = trade.sec_code..'; OnTrade, 1, o_n = '..trade.order_num..', t_n = '..trade.trade_num..' ('..trade.price..'x'..trade.qty..')'
  429.                     message(mes); io_log(mes);
  430.                     _trades[trade.trade_num] = true  -- Добавим в очередь
  431.                     _trades[trade.tradenum] = 1
  432.                     table_insert(trades,trade)
  433.                 else   
  434.                     _trades[trade.tradenum] = _trades[trade.tradenum] + 1
  435.                     local mes = trade.sec_code..'; OnTrade, '.._trades[trade.tradenum]..', o_n = '..trade.order_num..', t_n = '..trade.trade_num..' ('..trade.price..'x'..trade.qty..')'
  436.                     message(mes); io_log(mes);
  437.                 end
  438.                 toLog(scriptPath..'\\'..logFileName2,trade, 'trade')
  439.             end
  440.         end
  441.     end
  442.     --2.2.4 OnOrder Функция вызывается терминалом QUIK при получении новой заявки или при изменении параметров существующей заявки.
  443.     function OnOrder(order)
  444.         if order.account == account then
  445.             local order_flag = get_order_status(order.flags)
  446.             local op = order_flag.operation
  447.             local mes = order.sec_code..'; OnOrder, '..op.. ', o_n = '..order.order_num..' ('..order.price..'x'..order.qty.."), t_id = "..order.trans_id..', flag = '..order.flags..", "..order.brokerref..", balance = "..order.balance..', '..order_flag.status
  448.             io_log(mes)
  449.             toLog(scriptPath..'\\'..logFileName2,order, 'order')
  450.         end
  451.     end
  452. end
  453. --
  454.  
  455. function toLog(file_path,value,txt)
  456.     -- запись в файл параметра value
  457.     -- value может быть числом, строкой или таблицей
  458.     -- file_path  -  путь к файлу
  459.     -- файл открывается на дозапись и закрывается после записи строки
  460.     local now = getHRTime() -- c мс
  461.     if file_path~=nil and value~=nil then
  462.         local lf, err = io.open(file_path, "a")
  463.         assert(lf, "Ошибка записи "..file_path..", \n")
  464.         if lf~=nil then
  465.             lf:write(txt.."\n")
  466.             if type(value)=="string" or type(value)=="number" then
  467.                 lf:write(now.." "..value.."\n")
  468.             elseif type(value)=='boolean' then
  469.                 lf:write(now.." "..tostring(value).."\n")
  470.             elseif type(value)=="table" then
  471.                 lf:write(now.."\n"..table2string(value).."\n")
  472.             end
  473.             lf:flush()
  474.             if io.type(lf)=="file" then lf:close() end
  475.         end
  476.     end
  477. end
  478. --
  479.  
  480. function table2string(table)
  481.     local k,v,str=0,0,""
  482.     for k,v in pairs(table) do
  483.         if type(v)=="string" or type(v)=="number" then
  484.             str=str..k.."="..v..';\n'   --  в 1
  485.             --str=str..k.."="..v..'; '  --  в 2
  486.         elseif type(v)=="table"then
  487.             str=str..k.."={\n"..table2string(v).."};\n"
  488.         elseif type(v)=="function" or type(v)=='boolean' then
  489.             str=str..k..'='..tostring(v)..';\n'
  490.         end
  491.     end
  492.     return str
  493. end
  494. --
  495.  
  496. -- 2.2.8    OnFuturesClientHolding
  497. -- Функция вызывается терминалом QUIK при изменении позиции по срочному рынку.
  498. function OnFuturesClientHolding(tab)
  499.     local sec_code = tab.sec_code
  500.     local totalnet = tab.totalnet
  501.     if running and sec_code == secCode then -- выбираем нужную нам бумагу
  502.         local t= tonumber(totalnet)
  503.         if t ~= nil then
  504.             SetCell(tblH.t_id, 1, 2, tostring(totalnet), totalnet)
  505.             positionColor(t)
  506.         end
  507.     end
  508. end
  509. --
  510. -- 2.2.5  Функция вызывается терминалом QUIK при получении изменений текущей позиции по счету.
  511. -- (ТОЛЬКО ДЛЯ БРОКЕРА).
  512. function OnAccountBalance(acc_bal)
  513.     if acc_bal.sec_code==secCode then
  514.         local t= acc_bal.currentpos
  515.         if t ~= nil then
  516.             SetCell(tblH.t_id, 1, 2, tostring(t))
  517.             positionColor(t)
  518.         end
  519.     end
  520. end
  521.  
  522. --  2.2.18  OnParam
  523. --  Функция вызывается терминалом QUIK при изменении текущих параметров.
  524. function OnParam(class, seccode)
  525.     if seccode == secCode then -- выбираем нужную нам бумагу
  526.         local lp = tonumber(getParamEx(class, seccode, "last").param_value)
  527.         if lp > lastPrice then
  528.             Highlight(tblH.t_id, 1, 3, SeaGreen, dc, 1000)      -- подсветка мягкий, зеленый
  529.             lastPrice = lp  -- цена последней сделки
  530.             SetCell(tblH.t_id, 1, 3, tostring(lastPrice))
  531.         elseif lp < lastPrice then
  532.             Highlight(tblH.t_id, 1, 3, RosyBrown, dc, 1000)     -- подсветка
  533.             lastPrice = lp
  534.             SetCell(tblH.t_id, 1, 3, tostring(lastPrice))
  535.         end
  536.     end
  537. end
  538. --
  539.  
  540. -- 2.2.24 OnStop
  541. -- Функция вызывается терминалом QUIK при остановке скрипта из диалога управления и при
  542. -- закрытии терминала QUIK.
  543. function OnStop()
  544.     local mes = 'Stop SuperScalp.'
  545.     message(mes); io_log(mes);
  546.     running = false
  547.     DestroyTable(tblH.t_id)
  548. end
  549. --
  550.  
  551. -- 2.2.25 OnInit
  552. -- Функция вызывается терминалом QUIK перед вызовом функции main().
  553. function OnInit()
  554.     getInitParameter()
  555.     logFile = scriptPath..'\\'..logFileName1
  556.     local mes = 'Start SuperScalp '..ver..', QUIK '..Terminal_Version
  557.     message(mes); io_log(mes);
  558.     running = true
  559.     HandleBS()
  560.     lastPos = futures_position()
  561.     SetCell(tblH.t_id, 1, 2, tostring(lastPos))
  562.     positionColor(lastPos)
  563. end
  564. --
  565.  
  566. -- 2.2.26 main
  567. -- Функция, реализующая основной поток выполнения в скрипте.
  568. function main()
  569.     while running do
  570.         sleep(1000)
  571.         if not is_forts then
  572.             local t = getDepoEx(firm_id, ClientCode, secCode, account, 0)
  573.             local T = t.currentbal
  574.             SetCell(tblH.t_id, 1, 2, tostring(T))
  575.             positionColor(T)
  576.         end
  577.        
  578.     end
  579. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement