<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Форум QUIK [тема: CreateDataSource SetUpdateCallbackcallback более чем для одного заказа]</title>
		<link>http://forum.quik.ru</link>
		<description>Новое в теме CreateDataSource SetUpdateCallbackcallback более чем для одного заказа форума  на сайте Форум QUIK [forum.quik.ru]</description>
		<language>ru</language>
		<docs>http://backend.userland.com/rss2</docs>
		<pubDate>Wed, 29 Apr 2026 09:55:54 +0300</pubDate>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66424/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_pukPSkf5" href="/user/3132/" bx-tooltip-user-id="3132">Nikolay</a> написал:<br />Если Владимир сделал вывод, то, конечно, это приговор. Правда странно, почему же оно работает у остальных.<br /><br /> &nbsp;<br />=============<br />А вот и нет. <br /><br />Склоняюсь, к мнению Владимира, что CreateDataSource SetUpdateCallbackcallback - действительно не стабильный.<br /><br />Я лишь незначительно изменил Ваш код: <br /><br />-за место акций SBER и GAZP - изменил на тот, который не открыт в Квике -у меня к примеру - это &quot;PRMB&quot;.<br />-И изменил &quot;on_ds_action&quot; - сделал, чтобы после первого вызова on_ds_action - вызывалась отписка от колбека ds:Close().<br /><br />
====code====
<pre>local is_run = true

local function is_date(val)
&nbsp;&nbsp;&nbsp;&nbsp;local status = pcall(function() return type(val) == "table" and os.time(val); end)
&nbsp;&nbsp;&nbsp;&nbsp;return status
end

local function call_back_processor(action, context)
&nbsp;&nbsp;&nbsp;&nbsp;if not action then return end
&nbsp;&nbsp;&nbsp;&nbsp;return function(index)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action(index, context)
&nbsp;&nbsp;&nbsp;&nbsp;end
end

local function on_ds_action(index, context)
&nbsp;&nbsp;&nbsp;&nbsp;local time = is_date(context.ds:T(index)) and os.time(context.ds:T(index)) or nil

&nbsp;&nbsp;&nbsp;&nbsp;message(tostring(index) .. "&#92;n" .. tostring(context.interval))
&nbsp;&nbsp;&nbsp;&nbsp;context.ds:Close()

end

local function create_ds(context, action)

&nbsp;&nbsp;&nbsp;&nbsp;if not context then return end

&nbsp;&nbsp;&nbsp;&nbsp;local ds, err = _G.CreateDataSource(context.class_code, context.sec_code, context.interval)

&nbsp;&nbsp;&nbsp;&nbsp;if not ds then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_G.message(err, 3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return
&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;if ds and action then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ds:SetUpdateCallback(call_back_processor(action, context))
&nbsp;&nbsp;&nbsp;&nbsp;end
&nbsp;&nbsp;&nbsp;&nbsp;context.ds = ds

&nbsp;&nbsp;&nbsp;&nbsp;return ds
end

function _G.main()

&nbsp;&nbsp;&nbsp;&nbsp;create_ds({sec_code = 'PRMB', class_code = 'TQBR', interval = _G.INTERVAL_W1}, on_ds_action)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --VLHZ
&nbsp;&nbsp;&nbsp;&nbsp;create_ds({sec_code = 'PRMB', class_code = 'TQBR', interval = _G.INTERVAL_MN1}, on_ds_action)

&nbsp;&nbsp;&nbsp;&nbsp;while is_run do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_G.sleep(100)
&nbsp;&nbsp;&nbsp;&nbsp;end
end

function _G.OnStop()
&nbsp;&nbsp;&nbsp;&nbsp;is_run = false
end</pre>
=============
<br /><br />А вот в чем &quot;гамно&quot; этого СreateDataSource::SetUpdateCallback.<br /><br />Если Вы запустите - этот скрипт - Вы увидите следующее поведение:<br />-В первый запуск скрипта &nbsp; - колбек вызовется два раз: один раз для интервала INTERVAL_MN1 и один раз для INTERVAL_MN1. Тут все логично и правильно.<br />-Во второй запуск скрипта &nbsp;- колбек вызовется только ОДИН раз - только для одного интервала!<br /><br />А теперь скажите, что СreateDataSource не &quot;гамно&quot; ? <br />
			<i>24.10.2022 14:03:45, Quikos.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66424/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66424/topic7696/</guid>
			<pubDate>Mon, 24 Oct 2022 14:03:45 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66399/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Все, путем подбора разобрался.<br />Спасибо! <br />
			<i>20.10.2022 20:09:39, Quikos.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66399/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66399/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 20:09:39 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66395/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_EnS15pC7" href="/user/3132/" bx-tooltip-user-id="3132">Nikolay</a> написал:<br />Ну, видимо, потому, что пытаетесь произвести конкатенацию числа и строки <br />my_table_data_history_candle_:Size() .. &quot;\n&quot;<br /><br />Обратно работает, а вот число..строка уже нет<br /><br />&gt; print(5..&#39;a&#39;)<br />stdin:1: malformed number near &#39;5..&#39;<br />&gt; print(&#39;a&#39;..5)<br />a5<br /><br />Лучше не злоупотреблять динамичностью языка. Либо просто ошиблись с расстановкой скобки для tostring. Также не понятно что это за переменные my_int_1 и my_int_2. Не вижу инициализации. А раз они nil, то соединяете строку с nil.<br />=============<br />Дааа ннннннеееет.<br />Я же пишу, что &quot;callback вызывается ТОЛЬКО для сбера.&quot;<br />То есть колбек срабатывает, но только заказанный последним. <br />
			<i>20.10.2022 19:02:01, Quikos.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66395/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66395/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 19:02:01 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66394/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Ну, видимо, потому, что пытаетесь произвести конкатенацию числа и строки <br />my_table_data_history_candle_:Size() .. &quot;\n&quot;<br /><br />Обратно работает, а вот число..строка уже нет<br /><br />&gt; print(5..&#39;a&#39;)<br />stdin:1: malformed number near &#39;5..&#39;<br />&gt; print(&#39;a&#39;..5)<br />a5<br /><br />Лучше не злоупотреблять динамичностью языка. Либо просто ошиблись с расстановкой скобки для tostring. Также не понятно что это за переменные my_int_1 и my_int_2. Не вижу инициализации. А раз они nil, то соединяете строку с nil. <br />
			<i>20.10.2022 18:52:50, Nikolay.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66394/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66394/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 18:52:50 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66393/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Работает.<br />Почему же у меня не работает. <br />
			<i>20.10.2022 18:39:36, Quikos.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66393/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66393/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 18:39:36 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66391/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Мазохисты.. <img src="http://forum.quik.ru/upload/main/smiles/5/icon_smile.png" border="0" data-code=":smile:" data-definition="SD" alt=":smile:" style="width:16px;height:16px;" title="С улыбкой" class="bx-smile" /> <br /><br />У Владимира не CreateDataSource или там SetUpdateCallbackcallback, в первую очередь, потому, что он даже не пытался эту хрень использовать, ибо ему нужны, как минимум, сотни тикеров и, соответственно, тысячи свечей. И я даже не спрашиваю, работает ли что там у кого бы то ни было - я и так прекрасно знаю: сколько-нибудь удовлетворительно это дерьмо работать НЕ МОЖЕТ. <br />
			<i>20.10.2022 18:24:01, Владимир.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66391/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66391/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 18:24:01 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66390/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Если Владимир сделал вывод, то, конечно, это приговор. Правда странно, почему же оно работает у остальных.<br /><br />Вот, специально проверил, версия Квика 8.7.3<br />
====code====
<pre>local is_run = true

local function is_date(val)
&nbsp;&nbsp;&nbsp;&nbsp;local status = pcall(function() return type(val) == "table" and os.time(val); end)
&nbsp;&nbsp;&nbsp;&nbsp;return status
end

local function call_back_processor(action, context)
&nbsp;&nbsp;&nbsp;&nbsp;if not action then return end
&nbsp;&nbsp;&nbsp;&nbsp;return function(index)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action(index, context)
&nbsp;&nbsp;&nbsp;&nbsp;end
end

local function on_ds_action(index, context)
&nbsp;&nbsp;&nbsp;&nbsp;local time = is_date(context.ds:T(index)) and os.time(context.ds:T(index)) or nil
&nbsp;&nbsp;&nbsp;&nbsp;_G.message(string.format('new ds index %d %s %s|%s last close %.5f', index, time and os.date('%d.%m.%Y %H:%M:%S', time), context.sec_code, context.class_code, context.ds:C(index)))
end

local function create_ds(context, action)

&nbsp;&nbsp;&nbsp;&nbsp;if not context then return end

&nbsp;&nbsp;&nbsp;&nbsp;local ds, err = _G.CreateDataSource(context.class_code, context.sec_code, context.interval)

&nbsp;&nbsp;&nbsp;&nbsp;if not ds then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_G.message(err, 3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return
&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;if ds and action then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ds:SetUpdateCallback(call_back_processor(action, context))
&nbsp;&nbsp;&nbsp;&nbsp;end
&nbsp;&nbsp;&nbsp;&nbsp;context.ds = ds

&nbsp;&nbsp;&nbsp;&nbsp;return ds
end

function _G.main()

&nbsp;&nbsp;&nbsp;&nbsp;create_ds({sec_code = 'SBER', class_code = 'TQBR', interval = _G.INTERVAL_W1}, on_ds_action)
&nbsp;&nbsp;&nbsp;&nbsp;create_ds({sec_code = 'GAZP', class_code = 'TQBR', interval = _G.INTERVAL_MN1}, on_ds_action)

&nbsp;&nbsp;&nbsp;&nbsp;while is_run do
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_G.sleep(100)
&nbsp;&nbsp;&nbsp;&nbsp;end
end

function _G.OnStop()
&nbsp;&nbsp;&nbsp;&nbsp;is_run = false
end</pre>
============= <br />
			<i>20.10.2022 18:03:25, Nikolay.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66390/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66390/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 18:03:25 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message66388/topic7696/">CreateDataSource SetUpdateCallbackcallback более чем для одного заказа</a></b> <i>SetUpdateCallbackcallback более чем для одного заказа</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Я понимаю, что &quot;CreateDataSource гавно&quot;, но мне уже чисто из любопытства интересно.<br />Я уже перешел чисто на Lua.<br /><br />У кого нибудь работает CreateDataSource SetUpdateCallbackcallback - более, чем для одного инструмента ??<br /><br />Вот простой тестовый код на чистом Lua:<br /><br /><br />
====code====
<pre>function my_callback_CreateDataSource_HISTORY_1(my_table_data_history_candle_, code_class_, code_paper_, interval_, interval_string_)

message("SIZE_TABLE:" ..tostring(my_table_data_history_candle_:Size() .. "&#92;n" .. ":" ..&nbsp;&nbsp;code_paper_ ..":" .. interval_string_ ..":" ..my_int_1))

end




function my_callback_CreateDataSource_HISTORY_2(my_table_data_history_candle_, code_class_, code_paper_, interval_, interval_string_)

message("SIZE_TABLE:" ..tostring(my_table_data_history_candle_:Size() .. "&#92;n" .. ":" ..&nbsp;&nbsp;code_paper_ ..":" .. interval_string_..":" ..my_int_2))

end








-----------------------------------------------------------------------------------------------------------int main:-----------------------------------------------------------------------------------------------------


function main()


local code_class_1= "TQBR"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
local code_paper_1= "GAZP"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
local intervakla_1= INTERVAL_MN1
local intervakla_string_1 = "INTERVAL_MN1"



my_table_1, error_desc_1 = CreateDataSource(code_class_1, code_paper_1, intervakla_1)&nbsp;&nbsp;


------------------------Проверка на ошибки:-------------------
if error_desc_1 ~= nil then 
message("1:" .. error_desc_1)
end
--------------------------------------------------------------

my_table_1:SetUpdateCallback(function(idx)my_callback_CreateDataSource_HISTORY_1(my_table_1, code_class_1, code_paper_1, intervakla_1, intervakla_string_1) end)








local code_class_2= "TQBR"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
local code_paper_2= "SBER"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
local intervakla_2= INTERVAL_W1
local intervakla_string_2 = "INTERVAL_W1"


my_table_2, error_desc_2 = CreateDataSource(code_class_2, code_paper_2, intervakla_2) 

------------------------Проверка на ошибки:-------------------
if error_desc_2 ~= nil then 
message("2:" .. error_desc_2)
end
--------------------------------------------------------------


my_table_2:SetUpdateCallback(function(idx)my_callback_CreateDataSource_HISTORY_1(my_table_2, code_class_2, code_paper_2, intervakla_2, intervakla_string_2) end)





-------------------------
while not stopped do 
sleep(1)
end 
-------------------------



end -- end main()</pre>
=============
<br /><br /><br />То есть я просто заказываю SetUpdateCallback - для Газпрома и Сбера, но callback вызывается ТОЛЬКО для сбера.<br />КТО НИБУДЬ получал callback - сразу более, чем по одному инстурменту ?? <br /><br />Или я что то конкретно не так делаю ?? <br />
			<i>20.10.2022 16:32:56, Quikos.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message66388/topic7696/</link>
			<guid>http://forum.quik.ru/messages/forum10/message66388/topic7696/</guid>
			<pubDate>Thu, 20 Oct 2022 16:32:56 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
	</channel>
</rss>
