forked from morefinances/qlua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetQuoteLevel5.lua
More file actions
75 lines (49 loc) · 1.42 KB
/
getQuoteLevel5.lua
File metadata and controls
75 lines (49 loc) · 1.42 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function OnInit()
SumOffer = 0
SumBid = 0
end
function OnStop()
end
function main()
do_it = true
if m_t==nil then
m_t=AllocTable()
AddColumn(m_t, 1, "Ïðîäàæè", true, QTABLE_INT_TYPE, 12)
AddColumn(m_t, 2, "Ïîêóïêè", true, QTABLE_INT_TYPE, 12)
AddColumn(m_t, 3, "bid/offer", true, QTABLE_DOUBLE_TYPE, 10)
CreateWindow(m_t)
SetWindowPos(m_t, 500, 447, 300, 110)
SetWindowCaption(m_t, "bid/offer àíàëèç")
InsertRow(m_t,-1)
end
while do_it do
quotelvl = getQuoteLevel2("TQBR", "SBER")
if quotelvl then
if quotelvl.offer then
for i = quotelvl.offer_count, 1, -1 do
offer = tonumber(quotelvl.offer[i].price)
quant = tonumber(quotelvl.offer[i].quantity)
SumOffer = SumOffer + 10 * offer * quant
end
end
if quotelvl.bid then
for i = quotelvl.bid_count, 1, -1 do
bid = tonumber(quotelvl.bid[i].price)
quant = tonumber(quotelvl.bid[i].quantity)
SumBid = SumBid + 10 * bid * quant
end
end
SetCell(m_t, 1, 1, tostring(string.format("%.0f",SumOffer)))
SetCell(m_t, 1, 2, tostring(string.format("%.0f",SumBid)))
if SumBid > 0 then
a = SumOffer / SumBid
else
a = " "
end
SetCell(m_t, 1, 3, tostring(string.format("%.2f",a)))
SumOffer = 0
SumBid = 0
end
sleep(1000)
end
end