The resource loading... loading...

Dynamic balance strategy of blockly

Author: Zero, Date: 2018-10-12 15:43:00
Tags: StudyVisualization

Quick experience of programmatic transactions, a first-in-the-minute experience is essential

Do you think visual programming is useful?

  • It's practical, it lowers the threshold, it increases the interest, and then it studies the code.
  • It's useless, it's better to have direct access to the code.
  • Observation, teaching children to quantify is good, growing up with bad cabbage

{"xml":"<xml xmlns=\"https://developers.google.com/blockly/xml\">\n  <variables>\n    <variable id=\"opm1F)[XXt8TnZe.Y`4*\">当前行情</variable>\n    <variable id=\"bwb?U1_yiX:~*3ccn.jt\">当前资产</variable>\n    <variable id=\"fhT;l76])[r2v]cu@PGp\">币总市值</variable>\n    <variable 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*\">当前行情</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\">当前资产</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\">币总市值</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*\">当前行情</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\">当前资产</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\">资产差</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\">币总市值</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\">当前资产</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\">资产差</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\">当前资产</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\">资产差</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*\">当前行情</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\">资产差</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\">当前资产</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\">资产差</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*\">当前行情</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":"/*backtest\nstart: 2023-01-01 00:00:00\nend: 2023-08-16 00:00:00\nperiod: 1d\nbasePeriod: 1h\nexchanges: [{\"eid\":\"Binance\",\"currency\":\"BTC_USDT\"}]\n*/\nfunction 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\nwhile(true){  _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((function(){var r = $.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)); return r ? r.amount : 0; })());} 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((function(){var r = $.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)); return r ? r.amount : 0; })());}\n\nSleep(1*1000);}\n}"}

Related

More

bamsmenIt's a very nice feature, and I'm ready to tell students about it when they start programming.

NightskyTeaching kids to quantify is good, growing up not eating spinach This bull, I'm here because I had a snack at BITMEX.

yaoyaobutaoPlease fill in the BB indicator as soon as possible.

zhuanqianIt's nice to be able to describe something, to be able to be a hero, to be able to observe, to teach children about quantity, to be able to grow up with bad cuisines".

wulaDo you want to ask if this feature supports futures?

Light cloudsI'm so happy to be here. I'm so happy to be here.

jkyeiThank you, very good. I hope to do another commodity futures.

jacob210Support, allowing some strategic thinking to be tested with visualization implementations and then refined with code.

q23250That's great!

jkyeiGood, pioneering. Can you make visualizations run on a touchscreen system, if possible, with a huge number of users?

snowboy good

kmmkkPlease support!

TbancoI'm going to kill you.

ZeroCommodity futures are also supported, so you can select the built-in trading library to see if you want to use it.

ZeroThis is a full-screen editor that supports touchscreen.