Loading ...

可视化编程体验之 - 动态平衡策略

Author: Zero, Date: 2018-10-12 15:43:24
Tags: Study Visualization

只是体验功能, 正式版本在做完用户调查后上线 你认为这个功能实用吗

  • 实用, 降低门槛, 先提高兴趣, 再研究代码
  • 无用, 直接接触代码比较好
  • 观察, 教孩子学量化也不错, 长大了不当韭菜

{"xml":"<xml xmlns=\"http://www.w3.org/1999/xhtml\">\n  <variables>\n    <variable type=\"\" id=\"opm1F)[XXt8TnZe.Y`4*\">当前行情</variable>\n    <variable type=\"\" id=\"bwb?U1_yiX:~*3ccn.jt\">当前资产</variable>\n    <variable type=\"\" id=\"fhT;l76])[r2v]cu@PGp\">币总市值</variable>\n    <variable type=\"\" id=\"Y$k.q~c}[N*0Gype+oDd\">资产差</variable>\n  </variables>\n  <block type=\"ext_Loop_Interval\" id=\"2_5}1ZFn9CEx-Ku/nt?1\" x=\"18\" y=\"14\">\n    <statement name=\"INPUT_0\">\n      <block type=\"variables_set\" id=\"(B9Do#l;+D*nzbkOE7ui\">\n        <field name=\"VAR\" id=\"opm1F)[XXt8TnZe.Y`4*\" variabletype=\"\">当前行情</field>\n        <value name=\"VALUE\">\n          <block type=\"ext_exchange_GetTicker\" id=\"ed4pQ5oBu2b7tcmGm;u@\">\n            <field name=\"INPUT_0\">0</field>\n          </block>\n        </value>\n        <next>\n          <block type=\"variables_set\" id=\"(]L|NHCAwCbRY9cG2B)d\">\n            <field name=\"VAR\" id=\"bwb?U1_yiX:~*3ccn.jt\" variabletype=\"\">当前资产</field>\n            <value name=\"VALUE\">\n              <block type=\"ext_exchange_GetAccount\" id=\"K9rAY_hc:KHlI4G.3:%2\">\n                <field name=\"INPUT_0\">0</field>\n              </block>\n            </value>\n            <next>\n              <block type=\"variables_set\" id=\"mzoZW%xi$Yy1rf@ct3TY\">\n                <field name=\"VAR\" id=\"fhT;l76])[r2v]cu@PGp\" variabletype=\"\">币总市值</field>\n                <value name=\"VALUE\">\n                  <block type=\"math_arithmetic\" id=\"i@R^,niuw-Xloo00KLoc\">\n                    <field name=\"OP\">MULTIPLY</field>\n                    <value name=\"A\">\n                      <shadow type=\"math_number\" id=\"atz4^?:~jgWKC+azU11$\">\n                        <field name=\"NUM\">1</field>\n                      </shadow>\n                      <block type=\"ext_TickerOf\" id=\"8*hu;x;u||=Vb#4u|fcP\">\n                        <field name=\"INPUT_0\">Last</field>\n                        <value name=\"INPUT_1\">\n                          <block type=\"variables_get\" id=\"5jiBBlF6c9QiocG|,sBB\">\n                            <field name=\"VAR\" id=\"opm1F)[XXt8TnZe.Y`4*\" variabletype=\"\">当前行情</field>\n                          </block>\n                        </value>\n                      </block>\n                    </value>\n                    <value name=\"B\">\n                      <shadow type=\"math_number\" id=\"RYQCcA!,^sCR0ybqK1UO\">\n                        <field name=\"NUM\">1</field>\n                      </shadow>\n                      <block type=\"ext_AccountOf\" id=\",vWh_Wz3uZ*xcX2=:-($\">\n                        <field name=\"INPUT_0\">Stocks</field>\n                        <value name=\"INPUT_1\">\n                          <block type=\"variables_get\" id=\"5~H0;Fg5wJ|Gt8D1mlCw\">\n                            <field name=\"VAR\" id=\"bwb?U1_yiX:~*3ccn.jt\" variabletype=\"\">当前资产</field>\n                          </block>\n                        </value>\n                      </block>\n                    </value>\n                  </block>\n                </value>\n                <next>\n                  <block type=\"variables_set\" id=\"hbs1DlJ7LsOnyrGY0$hs\">\n                    <field name=\"VAR\" id=\"Y$k.q~c}[N*0Gype+oDd\" variabletype=\"\">资产差</field>\n                    <value name=\"VALUE\">\n                      <block type=\"math_arithmetic\" id=\"lgUPZBFGU-,q5/6^MyIK\">\n                        <field name=\"OP\">MINUS</field>\n                        <value name=\"A\">\n                          <shadow type=\"math_number\" id=\"W[{%5}h:Urd66={r{$}|\">\n                            <field name=\"NUM\">1</field>\n                          </shadow>\n                          <block type=\"variables_get\" id=\"[[]52H*;ugs7VIkOG(KQ\">\n                            <field name=\"VAR\" id=\"fhT;l76])[r2v]cu@PGp\" variabletype=\"\">币总市值</field>\n                          </block>\n                        </value>\n                        <value name=\"B\">\n                          <shadow type=\"math_number\" id=\".)z$~`awZjhy[0jH~w#i\">\n                            <field name=\"NUM\">1</field>\n                          </shadow>\n                          <block type=\"ext_AccountOf\" id=\"L858}xOAg:H5ghqE)r!v\">\n                            <field name=\"INPUT_0\">Balance</field>\n                            <value name=\"INPUT_1\">\n                              <block type=\"variables_get\" id=\"bZ`6[;K?Kcta)yoonA5|\">\n                                <field name=\"VAR\" id=\"bwb?U1_yiX:~*3ccn.jt\" variabletype=\"\">当前资产</field>\n                              </block>\n                            </value>\n                          </block>\n                        </value>\n                      </block>\n                    </value>\n                    <next>\n                      <block type=\"controls_if\" id=\"bHMNS]7^XGv8uIj!7mV)\">\n                        <mutation elseif=\"1\"></mutation>\n                        <value name=\"IF0\">\n                          <block type=\"logic_compare\" id=\"WUX%5bGB@W9]^ZJ7N4Kb\">\n                            <field name=\"OP\">GT</field>\n                            <value name=\"A\">\n                              <block type=\"variables_get\" id=\"A9IuZ8B}BKi+oKj{^b6G\">\n                                <field name=\"VAR\" id=\"Y$k.q~c}[N*0Gype+oDd\" variabletype=\"\">资产差</field>\n                              </block>\n                            </value>\n                            <value name=\"B\">\n                              <block type=\"math_arithmetic\" id=\"*I#f0wAu(bbti|$/s`kY\">\n                                <field name=\"OP\">MULTIPLY</field>\n                                <value name=\"A\">\n                                  <shadow type=\"math_number\" id=\"]?`N@FpK;pbGCNZ%S5rk\">\n                                    <field name=\"NUM\">1</field>\n                                  </shadow>\n                                  <block type=\"ext_AccountOf\" id=\"1k~;0),1`UBe/kS/j7C,\">\n                                    <field name=\"INPUT_0\">Balance</field>\n                                    <value name=\"INPUT_1\">\n                                      <block type=\"variables_get\" id=\"r|-reGD;$7~U^LHk1pEu\">\n                                        <field name=\"VAR\" id=\"bwb?U1_yiX:~*3ccn.jt\" variabletype=\"\">当前资产</field>\n                                      </block>\n                                    </value>\n                                  </block>\n                                </value>\n                                <value name=\"B\">\n                                  <shadow type=\"math_number\" id=\"a1?ZF!cM{Rtt8YnSARLj\">\n                                    <field name=\"NUM\">0.05</field>\n                                  </shadow>\n                                </value>\n                              </block>\n                            </value>\n                          </block>\n                        </value>\n                        <statement name=\"DO0\">\n                          <block type=\"ext_Log\" id=\"Qc}LQw@T6:rtYLoEJZ|A\">\n                            <value name=\"VALUE\">\n                              <block type=\"ext_Trade\" id=\"f+iy@8FMAqP@XhF:SVi8\">\n                                <field name=\"INPUT_0\">Sell</field>\n                                <value name=\"INPUT_1\">\n                                  <shadow type=\"math_number\" id=\"=oOIMb|iB0sbiML8uvkK\">\n                                    <field name=\"NUM\">0</field>\n                                  </shadow>\n                                  <block type=\"ext_N\" id=\"xoLcKwiU,CA%2h~seEAK\">\n                                    <value name=\"INPUT_0\">\n                                      <shadow type=\"math_number\" id=\"h+wbX]Y@{6j|m,}PIn^j\">\n                                        <field name=\"NUM\">0</field>\n                                      </shadow>\n                                      <block type=\"math_arithmetic\" id=\"]`jR7]yP6DWp*u~F[NO,\">\n                                        <field name=\"OP\">DIVIDE</field>\n                                        <value name=\"A\">\n                                          <shadow type=\"math_number\" id=\"yK#HpSy8[o,!#py0Q$U1\">\n                                            <field name=\"NUM\">1</field>\n                                          </shadow>\n                                          <block type=\"math_arithmetic\" id=\"6-H-dlq@R5mP*@6K)eV@\">\n                                            <field name=\"OP\">DIVIDE</field>\n                                            <value name=\"A\">\n                                              <shadow type=\"math_number\" id=\"YK`Se]H~B1-jH,^aWj5p\">\n                                                <field name=\"NUM\">1</field>\n                                              </shadow>\n                                              <block type=\"variables_get\" id=\"1WXx-(Vf_EQ%.4xwdg3q\">\n                                                <field name=\"VAR\" id=\"Y$k.q~c}[N*0Gype+oDd\" variabletype=\"\">资产差</field>\n                                              </block>\n                                            </value>\n                                            <value name=\"B\">\n                                              <shadow type=\"math_number\" id=\"Zcun)[a(E$V9;_z,/7El\">\n                                                <field name=\"NUM\">2</field>\n                                              </shadow>\n                                            </value>\n                                          </block>\n                                        </value>\n                                        <value name=\"B\">\n                                          <shadow type=\"math_number\" id=\"`{h}x:,c$2$:QTYzW.mY\">\n                                            <field name=\"NUM\">1</field>\n                                          </shadow>\n                                          <block type=\"ext_TickerOf\" id=\"Fd{UtGo79IL@5q^@-0a0\">\n                                            <field name=\"INPUT_0\">Buy</field>\n                                            <value name=\"INPUT_1\">\n                                              <block type=\"variables_get\" id=\"OW.tji2|N3N+w)=Tj-RS\">\n                                                <field name=\"VAR\" id=\"opm1F)[XXt8TnZe.Y`4*\" variabletype=\"\">当前行情</field>\n                                              </block>\n                                            </value>\n                                          </block>\n                                        </value>\n                                      </block>\n                                    </value>\n                                    <value name=\"INPUT_1\">\n                                      <shadow type=\"math_number\" id=\"ql+8Lcm3{S#67g):0lB;\">\n                                        <field name=\"NUM\">5</field>\n                                      </shadow>\n                                    </value>\n                                  </block>\n                                </value>\n                              </block>\n                            </value>\n                          </block>\n                        </statement>\n                        <value name=\"IF1\">\n                          <block type=\"logic_compare\" id=\"mNgfW_rMOL!tyVQ9gIO*\">\n                            <field name=\"OP\">LT</field>\n                            <value name=\"A\">\n                              <block type=\"variables_get\" id=\"v?2/Y-X={HtE{ikH:PhQ\">\n                                <field name=\"VAR\" id=\"Y$k.q~c}[N*0Gype+oDd\" variabletype=\"\">资产差</field>\n                              </block>\n                            </value>\n                            <value name=\"B\">\n                              <block type=\"math_arithmetic\" id=\".cSBOTTN9^vs.m/q8WzS\">\n                                <field name=\"OP\">MULTIPLY</field>\n                                <value name=\"A\">\n                                  <shadow type=\"math_number\" id=\"]?`N@FpK;pbGCNZ%S5rk\">\n                                    <field name=\"NUM\">1</field>\n                                  </shadow>\n                                  <block type=\"ext_AccountOf\" id=\"(UZoBKXBcXFu/sF9)~@[\">\n                                    <field name=\"INPUT_0\">Balance</field>\n                                    <value name=\"INPUT_1\">\n                                      <block type=\"variables_get\" id=\"=/Y~8cGTUr5yG2zThwm_\">\n                                        <field name=\"VAR\" id=\"bwb?U1_yiX:~*3ccn.jt\" variabletype=\"\">当前资产</field>\n                                      </block>\n                                    </value>\n                                  </block>\n                                </value>\n                                <value name=\"B\">\n                                  <shadow type=\"math_number\" id=\"SjkKBk?htB}:0OOavFdX\">\n                                    <field name=\"NUM\">-0.05</field>\n                                  </shadow>\n                                </value>\n                              </block>\n                            </value>\n                          </block>\n                        </value>\n                        <statement name=\"DO1\">\n                          <block type=\"ext_Log\" id=\"]6QE+AJuCGJcJ!mM79Aw\">\n                            <value name=\"VALUE\">\n                              <block type=\"ext_Trade\" id=\"0I(RwOKo^!Aa,,U,7bUQ\">\n                                <field name=\"INPUT_0\">Buy</field>\n                                <value name=\"INPUT_1\">\n                                  <shadow type=\"math_number\" id=\"=oOIMb|iB0sbiML8uvkK\">\n                                    <field name=\"NUM\">0</field>\n                                  </shadow>\n                                  <block type=\"ext_N\" id=\"cC/pIj)]o5dZtUXcuWW6\">\n                                    <value name=\"INPUT_0\">\n                                      <shadow type=\"math_number\" id=\"tF7B^Y~~dqljm4j)(ay4\">\n                                        <field name=\"NUM\">0</field>\n                                      </shadow>\n                                      <block type=\"math_arithmetic\" id=\"0%k4hie-y))L1%i/+pm5\">\n                                        <field name=\"OP\">DIVIDE</field>\n                                        <value name=\"A\">\n                                          <shadow type=\"math_number\" id=\"yK#HpSy8[o,!#py0Q$U1\">\n                                            <field name=\"NUM\">1</field>\n                                          </shadow>\n                                          <block type=\"math_arithmetic\" id=\",D]OH)D##:[SL!m.Y=If\">\n                                            <field name=\"OP\">DIVIDE</field>\n                                            <value name=\"A\">\n                                              <shadow type=\"math_number\" id=\"YK`Se]H~B1-jH,^aWj5p\">\n                                                <field name=\"NUM\">1</field>\n                                              </shadow>\n                                              <block type=\"variables_get\" id=\"PYESS@O{0h3*hIQloZs*\">\n                                                <field name=\"VAR\" id=\"Y$k.q~c}[N*0Gype+oDd\" variabletype=\"\">资产差</field>\n                                              </block>\n                                            </value>\n                                            <value name=\"B\">\n                                              <shadow type=\"math_number\" id=\"q1+D-kt.!6b[+.Y43Uu^\">\n                                                <field name=\"NUM\">-2</field>\n                                              </shadow>\n                                            </value>\n                                          </block>\n                                        </value>\n                                        <value name=\"B\">\n                                          <shadow type=\"math_number\" id=\"`{h}x:,c$2$:QTYzW.mY\">\n                                            <field name=\"NUM\">1</field>\n                                          </shadow>\n                                          <block type=\"ext_TickerOf\" id=\"l5Nt[6yf,t,A)g]Y=^P+\">\n                                            <field name=\"INPUT_0\">Sell</field>\n                                            <value name=\"INPUT_1\">\n                                              <block type=\"variables_get\" id=\"%zW)lwo8ZB-[bkM,4fPy\">\n                                                <field name=\"VAR\" id=\"opm1F)[XXt8TnZe.Y`4*\" variabletype=\"\">当前行情</field>\n                                              </block>\n                                            </value>\n                                          </block>\n                                        </value>\n                                      </block>\n                                    </value>\n                                    <value name=\"INPUT_1\">\n                                      <shadow type=\"math_number\" id=\"t|}4L?~Z/Pam|e#tZ9,I\">\n                                        <field name=\"NUM\">5</field>\n                                      </shadow>\n                                    </value>\n                                  </block>\n                                </value>\n                              </block>\n                            </value>\n                          </block>\n                        </statement>\n                      </block>\n                    </next>\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=\"B!_::#726BEt/6-?!Ui!\">\n        <field name=\"NUM\">1</field>\n      </shadow>\n    </value>\n  </block>\n</xml>","javascript":"function main() {\n    var _E5_BD_93_E5_89_8D_E8_A1_8C_E6_83_85, _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7, _E5_B8_81_E6_80_BB_E5_B8_82_E5_80_BC, _E8_B5_84_E4_BA_A7_E5_B7_AE;\n\n\n    while (true) {\n        _E5_BD_93_E5_89_8D_E8_A1_8C_E6_83_85 = _C(exchanges[0].GetTicker);\n        _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7 = _C(exchanges[0].GetAccount);\n        _E5_B8_81_E6_80_BB_E5_B8_82_E5_80_BC = _E5_BD_93_E5_89_8D_E8_A1_8C_E6_83_85.Last * _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7.Stocks;\n        _E8_B5_84_E4_BA_A7_E5_B7_AE = _E5_B8_81_E6_80_BB_E5_B8_82_E5_80_BC - _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7.Balance;\n        if (_E8_B5_84_E4_BA_A7_E5_B7_AE > _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7.Balance * 0.05) {\n            Log($.Sell(_N((_E8_B5_84_E4_BA_A7_E5_B7_AE / 2) / _E5_BD_93_E5_89_8D_E8_A1_8C_E6_83_85.Buy, 5)).amount);\n        } else if (_E8_B5_84_E4_BA_A7_E5_B7_AE < _E5_BD_93_E5_89_8D_E8_B5_84_E4_BA_A7.Balance * -0.05) {\n            Log($.Buy(_N((_E8_B5_84_E4_BA_A7_E5_B7_AE / -2) / _E5_BD_93_E5_89_8D_E8_A1_8C_E6_83_85.Sell, 5)).amount);\n        }\n\n        Sleep(1 * 1000);\n    }\n}"}

Related

More

lllwww10215 请问!如果交易逻辑是利用KDJ指标的高点高于前一个高点就买入,低点低于前一个低点就卖出,这样的策略应该如何编程那?还有如何设置自动交易的时候是利用的1个小时的KDJ还是1天的KDJ为判断指标?

Nightsky 教孩子学量化也不错, 长大了不当韭菜 这话牛,我就是因为在BITMEX当了一回韭菜才来这的

yaoyaobutao 请尽快补充布林带指标 bb

zhuanqian 描述有点东西,是个狠角色 “- 观察, 教孩子学量化也不错, 长大了不当韭菜"

wula 想问一下这个功能支持期货吗

ruinslovecat 实用, 降低门槛, 先提高兴趣, 再研究代码

mydhades 很实用,对于直观理解策略思路和培养兴趣都会有一定的帮助!

轻轻的云 介个太好玩了。直接堆积木就行了。O(∩_∩)O

jkyei 谢谢,很好。希望再做个商品期货的。

jacob210 支持,可以让一些策略思维先用可视化实现进行测试,再通过代码来完善

q23250 妙啊!支持!

jkyei 好,开拓性的。可否做出可视化运行在触屏系统的,如能行的话用户数巨大

snowboy good

yuxi214 挺好的,编程老鸟都想体验一把

13087005272 支持!!

whitebaby 牛逼!

code000 赞啊

Zero 支持, 商品期货也支持, 可以勾选上内置的交易类库就可以

Zero 这个本来就支持触屏的, 编辑器全屏就可以了