资源加载中... loading...

可视化期货下单范例

Author: 发明者量化-小小梦, Date: 2018-12-11 21:04:02
Tags: StudyVisualization

  • 1、主循环 中故意放了一个 异常抛出。所以运行会有错误 并且停止。

{"xml":"<xml xmlns=\"http://www.w3.org/1999/xhtml\">\n  <variables>\n    <variable type=\"\" id=\"u4zzWBAfKf^/o,Nl7t]B\">id</variable>\n    <variable type=\"\" id=\"C8|46-~zMSg*+p@s)o/9\">ret</variable>\n  </variables>\n  <block type=\"ext_exchange_SetMarginLevel\" id=\"4%!N}0E/VmZC`Pyzyj-w\" x=\"-145\" y=\"307\">\n    <field name=\"INPUT_0\">0</field>\n    <value name=\"INPUT_1\">\n      <shadow type=\"math_number\" id=\"g@oaUq|h3VA/Wib4vOdG\">\n        <field name=\"NUM\">10</field>\n      </shadow>\n      <block type=\"math_number\" id=\",b0~r^i0fbqTAO~gNIKr\">\n        <field name=\"NUM\">10</field>\n      </block>\n    </value>\n    <next>\n      <block type=\"ext_exchange_SetContractType\" id=\"WoZ!+y-IM4-7563=q@NN\">\n        <field name=\"INPUT_0\">0</field>\n        <value name=\"INPUT_1\">\n          <shadow type=\"text\" id=\"V%YlwXnm7R;8/rN8V/Vc\">\n            <field name=\"TEXT\"></field>\n          </shadow>\n          <block type=\"text\" id=\"-[s[h)Y6JBWbOx`jzYXW\">\n            <field name=\"TEXT\">this_week</field>\n          </block>\n        </value>\n        <next>\n          <block type=\"ext_exchange_SetDirection\" id=\"zm[zJHE:aZ(rZozeQ9=i\">\n            <field name=\"INPUT_0\">0</field>\n            <field name=\"INPUT_1\">buy</field>\n            <next>\n              <block type=\"variables_set\" id=\"z?^i-)lP4I|mnCpr,lQ/\">\n                <field name=\"VAR\" id=\"u4zzWBAfKf^/o,Nl7t]B\" variabletype=\"\">id</field>\n                <value name=\"VALUE\">\n                  <block type=\"ext_exchange_Trade\" id=\"rPiiLr[l6~XbSCrKqe.7\">\n                    <field name=\"INPUT_0\">0</field>\n                    <field name=\"INPUT_1\">Buy</field>\n                    <value name=\"INPUT_2\">\n                      <shadow type=\"math_number\" id=\"}1hHoJh1QHRx/XZF7)Vb\">\n                        <field name=\"NUM\">0</field>\n                      </shadow>\n                      <block type=\"math_number\" id=\"1%w-;/@aqQACH/IfUb]N\">\n                        <field name=\"NUM\">8000</field>\n                      </block>\n                    </value>\n                    <value name=\"INPUT_3\">\n                      <shadow type=\"math_number\" id=\"i/#8P;(]EN4G~BhTI=pY\">\n                        <field name=\"NUM\">0</field>\n                      </shadow>\n                      <block type=\"math_number\" id=\")2J}1KLpc3$JjWm9rL*r\">\n                        <field name=\"NUM\">2</field>\n                      </block>\n                    </value>\n                  </block>\n                </value>\n                <next>\n                  <block type=\"ext_Loop_Interval\" id=\"@1q/g!{UqZI%v:ab,vmo\">\n                    <statement name=\"INPUT_0\">\n                      <block type=\"variables_set\" id=\"{;Gs}#@*F$p+I8UNN`w$\">\n                        <field name=\"VAR\" id=\"C8|46-~zMSg*+p@s)o/9\" variabletype=\"\">ret</field>\n                        <value name=\"VALUE\">\n                          <block type=\"ext_exchange_GetPosition\" id=\"Yu|vv$/fpTeD/]--{xMA\">\n                            <field name=\"INPUT_0\">0</field>\n                          </block>\n                        </value>\n                        <next>\n                          <block type=\"ext_Log\" id=\"[LzAIdfv55RYLmg#w$P^\">\n                            <value name=\"VALUE\">\n                              <block type=\"variables_get\" id=\"kAp7%I|{`(N^Tp,FT)Vv\">\n                                <field name=\"VAR\" id=\"C8|46-~zMSg*+p@s)o/9\" variabletype=\"\">ret</field>\n                              </block>\n                            </value>\n                            <next>\n                              <block type=\"ext_Log\" id=\"10CZ|8F$:P!u,{4[3orN\">\n                                <value name=\"VALUE\">\n                                  <block type=\"ext_PositionOf\" id=\"1|=t4Na7d!VBQM3ezhd~\">\n                                    <field name=\"INPUT_2\">Price</field>\n                                    <value name=\"INPUT_0\">\n                                      <block type=\"variables_get\" id=\"@jw1pX^ralF/L5[1+IG)\">\n                                        <field name=\"VAR\" id=\"C8|46-~zMSg*+p@s)o/9\" variabletype=\"\">ret</field>\n                                      </block>\n                                    </value>\n                                    <value name=\"INPUT_1\">\n                                      <shadow type=\"math_number\" id=\"WF$OpApq@tWpv8OV#9c(\">\n                                        <field name=\"NUM\">0</field>\n                                      </shadow>\n                                      <block type=\"math_number\" id=\"jGtvlM4A*-B$~}j%BbbV\">\n                                        <field name=\"NUM\">0</field>\n                                      </block>\n                                    </value>\n                                  </block>\n                                </value>\n                                <next>\n                                  <block type=\"ext_Exception\" id=\"`B3;`{F0CMbsi*~EK:Ko\">\n                                    <value name=\"INPUT_0\">\n                                      <shadow type=\"text\" id=\"tM-|0ty:/M@yA|-l#1Wg\">\n                                        <field name=\"TEXT\">stop</field>\n                                      </shadow>\n                                      <block type=\"text\" id=\"VAR3,|5`L^3%J$Zw=-Xs\">\n                                        <field name=\"TEXT\">stop</field>\n                                      </block>\n                                    </value>\n                                  </block>\n                                </next>\n                              </block>\n                            </next>\n                          </block>\n                        </next>\n                      </block>\n                    </statement>\n                    <value name=\"INPUT_1\">\n                      <shadow type=\"math_number\" id=\"sPfW]66Mhs?*NF}l^NMt\">\n                        <field name=\"NUM\">60</field>\n                      </shadow>\n                    </value>\n                  </block>\n                </next>\n              </block>\n            </next>\n          </block>\n        </next>\n      </block>\n    </next>\n  </block>\n</xml>","javascript":"function main() {\n    var id, ret;\n\n\n    exchanges[0].SetMarginLevel(10) exchanges[0].SetContractType('this_week');\n    exchanges[0].SetDirection('buy');\n    id = exchanges[0].Buy(8000, 2);\n    while (true) {\n        ret = _C(exchanges[0].GetPosition);\n        Log(ret);\n        Log(ret[0].Price);\n        throw 'stop';\n        Sleep(60 * 1000);\n    }\n}"}

Related

More