虚拟货币定投策略,结果不给力,仅作记录

结果不给力,从2018年的年初最高点BTC买入到现在7000的价格,

按照这个策略去投,每天定投20USDT,几个月之后,几乎无亏损

熊市结果还是很不错;

但是长线定投的时候,按照最近2年,2016年到2018年,这种定投时间段,效果就不给力了

感觉是一个不错的熊市策略,但是牛市不行;悲催 – -、

仅仅当做记录,代码如下

//BTC 2017-12-16最高点 19299 美元开始定投到 - 降到现在6939美元
let data = {
    "market_cap_by_available_supply": [[1513530254000, 323206425652], [1513616654000, 315295844912], [1513703054000, 309786011860], [1513789454000, 281162265920], [1513875855000, 266354858200], [1513962256000, 216944824162], [1514048657000, 257457833125], [1514135056000, 225810705306], [1514221462000, 236407184745], [1514307861000, 275609331660], [1514394261000, 254651174921], [1514480660000, 241652988220], [1514567062000, 249790633364], [1514653461000, 208771268438], [1514739862000, 238529534662], [1514826261000, 224019828389], [1514912660000, 234397497387], [1514999060000, 257431752652], [1515085461000, 251534579875], [1515171561000, 282802422680], [1515257958000, 291894450410], [1515344660000, 274733532078], [1515431097000, 278951914592.4743], [1515517497000, 282186202846.1043], [1515603897000, 268011553379.5508], [1515690298000, 254585143968.68005], [1515776698000, 250508669380.77014], [1515863097000, 264820223007.5328], [1515949497000, 242380429266.33698], [1516035898000, 254986910473.74048], [1516122298000, 205978352069.29855], [1516208697000, 174736144252.7797], [1516295098000, 200939426829.3745], [1516381498000, 200185750420.19174], [1516467898000, 221930855019.9907], [1516554297000, 195507163352.84586], [1516640698000, 182798636111.94772], [1516727098000, 192727325897.90286], [1516813498000, 188625426192.4785], [1516899897000, 187472634128.85522], [1516986298000, 187727603825.2322], [1517072698000, 194521059252.634], [1517159098000, 198276266224.85623], [1517245498000, 192428441365.75522], [1517331898000, 178227340228.0868], [1517418297000, 169531170504.85205], [1517504699000, 152693883298.81152], [1517591098000, 151465768187.3186], [1517677498000, 156144628147.57187], [1517763898000, 142921620480.2188], [1517850297000, 123924376903.35028], [1517936698000, 118833960588.0788], [1518023097000, 136606542114.83472], [1518109498000, 140239845362.2544], [1518195898000, 143151822254.90463], [1518282298000, 143208970337.20764], [1518368698000, 141635651492.72412], [1518455098000, 147007780305.73178], [1518541498000, 145351132226.50327], [1518627899000, 157136274711.23215], [1518714298000, 167555706829.79572], [1518800699000, 171602654391.917], [1518887098000, 183714745147.60742], [1518973498000, 182305176369.82718], [1519059898000, 188217569885.81915], [1519146298000, 199061690429.46036], [1519232697000, 180930974836.92764], [1519319098000, 170343670118.48608], [1519405497000, 174131210234.75845], [1519491898000, 167947737025.69794], [1519578298000, 160218433559.1315], [1519664698000, 173533374625.59998], [1519751098000, 180814890052.94403], [1519837497000, 177736107440.22894], [1519923899000, 181658573514.7147], [1520010298000, 184571935628.11984], [1520096701000, 194659622025.37564], [1520183101000, 188994946363.30234], [1520269500000, 195266629910.2629], [1520355898000, 186324592498.00348], [1520442299000, 170883510429.0131], [1520528699000, 160298373276.46732], [1520615098000, 149480351031.63745], [1520701498000, 159708270969.90063], [1520787898000, 156670882063.32803], [1520874298000, 158095340195.21017], [1520960699000, 157090607677.38626], [1521047099000, 142434744531.86395], [1521133499000, 137854201236.62915], [1521219897000, 144722891541.3177], [1521306298000, 134801502910.0259], [1521392698000, 125308610667.26315], [1521479098000, 142882482902.41956], [1521565498000, 149967682234.86148], [1521651898000, 151699931367.63876], [1521738298000, 146514425349.27588], [1521824698000, 146719879985.72397], [1521911098000, 151301969708.8654], [1521997498000, 145335034672.24133], [1522083899000, 137596584732.85297], [1522170297000, 137802002044.9617], [1522256697000, 134147535763.1107], [1522343098000, 127493615248.3782], [1522429499000, 114399861350.31384], [1522515898000, 121864545199.2668], [1522602298000, 116192894723.30641], [1522688698000, 119337079904.76889], [1522775098000, 125887776486.58905], [1522861497000, 117257082216.25168], [1522947897000, 114821367015.05739], [1523034298000, 112342062261.15227], [1523120698000, 119411952731.85593], [1523207099000, 118717416664.72658], [1523293497000, 114815616679.65611], [1523379898000, 116135401395.38742], [1523466297000, 117417421776.26517], [1523552699000, 130334469990.19853], [1523639098000, 137052164012.72238], [1523725498000, 135077291790.52249], [1523811898000, 140172573877.35938], [1523898299000, 135471621454.66554], [1523984698000, 137735086234.47586], [1524071098000, 137859926087.43677], [1524157498000, 140632283814.14545], [1524243898000, 144798037368.9495], [1524330299000, 149354289909.62656], [1524416699000, 152019461120.62537], [1524503099000, 151741763301.39334], [1524589498000, 158951019906.32327], [1524675898000, 152601946911.72592], [1524762297000, 151187714490.9732], [1524848699000, 157988856209.91714], [1524935098000, 158592969824.24838], [1525021498000, 157750499842.10516], [1525107899000, 158459417392.36356], [1525194297000, 153218566865.2574], [1525280698000, 155551428985.4603], [1525367098000, 162988276595.12814], [1525453498000, 165083733618.82278], [1525539898000, 169505599052.3919], [1525626298000, 163969713425.08862], [1525712697000, 160015348328.93588], [1525799099000, 156585922292.32132], [1525885498000, 159808967771.3634], [1525971898000, 159554050814.4527], [1526058299000, 147862678016.1918], [1526144698000, 143260258931.23398], [1526231098000, 148821318948.81265], [1526317499000, 150051586251.6243], [1526403899000, 146812476056.41312], [1526490299000, 141594295422.3223], [1527699896000, 125072797226.54942], [1527786296000, 129252268007.53326], [1527872696000, 127455802300.98427], [1527959096000, 130217188343.81284], [1528045496000, 131732745447.21617], [1528131896000, 128373186104.43227], [1528218296000, 129521595203.92198], [1528304696000, 128894386918.23114], [1528391096000, 131830161439.01524], [1528477496000, 130835659193.4974], [1528563896000, 129898334255.61624], [1528650296000, 123764286607.83333], [1528736696000, 115695378529.21223], [1528823096000, 116165544393.18999], [1528909496000, 107844492684.33604], [1528995896000, 112440860690.67351], [1529082296000, 113021491406.2966], [1529168696000, 112141099819.46576], [1529255096000, 112673250512.25601], [1529341496000, 114071283825.6001], [1529427896000, 115412465324.99724], [1529514296000, 115448673247.26479], [1529600666000, 115006543407.99533], [1529687096000, 105901632184.08206], [1529773496000, 104864602173.52052], [1529859896000, 105731203165.96371], [1529946296000, 107840061018.66411], [1530032696000, 106000060978.34808], [1530119096000, 105044218433.14908], [1530205496000, 104714663000.94356], [1530291897000, 100921395685.61656], [1530378297000, 108764334582.46323], [1530464696000, 108261597466.07094], [1530551097000, 111964232200.87982], [1530637496000, 112813232644.92906], [1530723896000, 114199049835.08667], [1530810296000, 113061826995.45656], [1530896697000, 112634318299.8009], [1530983096000, 112759458862.80296], [1531069496000, 115657824864.37718], [1531155896000, 115114554988.45622], [1531242296000, 109089896806.86905], [1531328397000, 109176880870.38033], [1531415022000, 106424853532.99017], [1531501382000, 107433521671.39029], [1531587866000, 107571444941.47827], [1531674266000, 109689725547.20387], [1531760666000, 113830023926.06741], [1531847066000, 116007540073.7131], [1531933466000, 127518597708.36174], [1532019866000, 126600265922.83333], [1532106267000, 126997252579.73804], [1532192666000, 126853140301.84357], [1532279066000, 128851074360.11324], [1532365466000, 132759299863.60416], [1532451866000, 140501762219.3264], [1532538266000, 140314270236.5614], [1532624666000, 140804262671.36252], [1532711066000, 140513044200.61343], [1532797466000, 140321295052.0086], [1532883866000, 140004546259.5455], [1532970266000, 139469720178.95132], [1533056666000, 134387197036.98906], [1533143066000, 129956450361.5039], [1533229467000, 130182050198.36249], [1533315866000, 128826270522.08286], [1533402266000, 120565880066.8075], [1533488666000, 120652271314.14542], [1533575066000, 119488904429.29974], [1533661421000, 122517386383.11615], [1533747867000, 108285363411.62704], [1533834266000, 111020928005.39183], [1533920666000, 110157214271.36383], [1534007066000, 105527373205.54185], [1534093466000, 108797366692.93977], [1534179867000, 108082647845.78406], [1534266267000, 103844871977.20488], [1534352666000, 112991427659.38132], [1534439066000, 109944352647.44402], [1534525467000, 112318036462.60757], [1534611867000, 109083569544.5439], [1534698266000, 109995141521.80179], [1534784666000, 111163378120.62686], [1534871066000, 110874455868.31947], [1534957466000, 110804987173.31259], [1535043866000, 111209622881.84831], [1535130266000, 112994053124.10426], [1535216666000, 115640137097.77155], [1535303066000, 114696431108.87277], [1535389466000, 116245925132.5277], [1535475867000, 120982453240.76308], [1535562266000, 120931247345.32373], [1535631791000, 118738482117.17387]],
    "price_usd": [[1513530254000, 19299], [1513616654000, 18824], [1513703054000, 18493], [1513789454000, 16782], [1513875855000, 15897], [1513962256000, 12947], [1514048657000, 15363], [1514135056000, 13473], [1514221462000, 14103], [1514307861000, 16440], [1514394261000, 15188], [1514480660000, 14412], [1514567062000, 14895], [1514653461000, 12448], [1514739862000, 14220], [1514826261000, 13354], [1514912660000, 13971], [1514999060000, 15342], [1515085461000, 14988], [1515171561000, 16850], [1515257958000, 17389], [1515344660000, 16365], [1515431097000, 16614], [1515517497000, 16805], [1515603897000, 15959], [1515690298000, 15157], [1515776698000, 14913], [1515863097000, 15762], [1515949497000, 14425], [1516035898000, 15174], [1516122298000, 12256], [1516208697000, 10396], [1516295098000, 11953], [1516381498000, 11907], [1516467898000, 13198], [1516554297000, 11625], [1516640698000, 10868], [1516727098000, 11457], [1516813498000, 11212], [1516899897000, 11142], [1516986298000, 11156], [1517072698000, 11558], [1517159098000, 11780], [1517245498000, 11431], [1517331898000, 10586], [1517418297000, 10069], [1517504699000, 9068], [1517591098000, 8994], [1517677498000, 9270], [1517763898000, 8484], [1517850297000, 7356], [1517936698000, 7053], [1518023097000, 8106], [1518109498000, 8321], [1518195898000, 8493], [1518282298000, 8496], [1518368698000, 8401], [1518455098000, 8719], [1518541498000, 8620], [1518627899000, 9317], [1518714298000, 9934], [1518800699000, 10173], [1518887098000, 10890], [1518973498000, 10805], [1519059898000, 11154], [1519146298000, 11796], [1519232697000, 10720], [1519319098000, 10091], [1519405497000, 10315], [1519491898000, 9947], [1519578298000, 9488], [1519664698000, 10276], [1519751098000, 10706], [1519837497000, 10522], [1519923899000, 10753], [1520010298000, 10924], [1520096701000, 11520], [1520183101000, 11183], [1520269500000, 11553], [1520355898000, 11023], [1520442299000, 10108], [1520528699000, 9481], [1520615098000, 8840], [1520701498000, 9444], [1520787898000, 9263], [1520874298000, 9346], [1520960699000, 9286], [1521047099000, 8419], [1521133499000, 8147], [1521219897000, 8552], [1521306298000, 7965], [1521392698000, 7403], [1521479098000, 8440], [1521565498000, 8858], [1521651898000, 8959], [1521738298000, 8652], [1521824698000, 8664], [1521911098000, 8933], [1521997498000, 8580], [1522083899000, 8122], [1522170297000, 8133], [1522256697000, 7917], [1522343098000, 7523], [1522429499000, 6750], [1522515898000, 7190], [1522602298000, 6854], [1522688698000, 7039], [1522775098000, 7424], [1522861497000, 6915], [1522947897000, 6770], [1523034298000, 6623], [1523120698000, 7039], [1523207099000, 6998], [1523293497000, 6767], [1523379898000, 6844], [1523466297000, 6919], [1523552699000, 7679], [1523639098000, 8074], [1523725498000, 7956], [1523811898000, 8256], [1523898299000, 7978], [1523984698000, 8110], [1524071098000, 8117], [1524157498000, 8279], [1524243898000, 8523], [1524330299000, 8790], [1524416699000, 8946], [1524503099000, 8929], [1524589498000, 9352], [1524675898000, 8977], [1524762297000, 8893], [1524848699000, 9292], [1524935098000, 9327], [1525021498000, 9276], [1525107899000, 9317], [1525194297000, 9008], [1525280698000, 9144], [1525367098000, 9580], [1525453498000, 9702], [1525539898000, 9961], [1525626298000, 9635], [1525712697000, 9401], [1525799099000, 9199], [1525885498000, 9387], [1525971898000, 9371], [1526058299000, 8684], [1526144698000, 8412], [1526231098000, 8738], [1526317499000, 8809], [1526403899000, 8618], [1526490299000, 8311], [1527699896000, 7330], [1527786296000, 7573], [1527872696000, 7467], [1527959096000, 7628], [1528045496000, 7716], [1528131896000, 7518], [1528218296000, 7585], [1528304696000, 7547], [1528391096000, 7718], [1528477496000, 7659], [1528563896000, 7603], [1528650296000, 7244], [1528736696000, 6771], [1528823096000, 6798], [1528909496000, 6310], [1528995896000, 6578], [1529082296000, 6611], [1529168696000, 6559], [1529255096000, 6589], [1529341496000, 6670], [1529427896000, 6748], [1529514296000, 6749], [1529600666000, 6723], [1529687096000, 6190], [1529773496000, 6129], [1529859896000, 6178], [1529946296000, 6301], [1530032696000, 6193], [1530119096000, 6136], [1530205496000, 6116], [1530291897000, 5894], [1530378297000, 6352], [1530464696000, 6322], [1530551097000, 6537], [1530637496000, 6586], [1530723896000, 6666], [1530810296000, 6599], [1530896697000, 6574], [1530983096000, 6580], [1531069496000, 6748], [1531155896000, 6716], [1531242296000, 6364], [1531328397000, 6368], [1531415022000, 6207], [1531501382000, 6265], [1531587866000, 6273], [1531674266000, 6396], [1531760666000, 6636], [1531847066000, 6763], [1531933466000, 7433], [1532019866000, 7378], [1532106267000, 7401], [1532192666000, 7391], [1532279066000, 7507], [1532365466000, 7734], [1532451866000, 8184], [1532538266000, 8172], [1532624666000, 8199], [1532711066000, 8182], [1532797466000, 8169], [1532883866000, 8150], [1532970266000, 8118], [1533056666000, 7821], [1533143066000, 7563], [1533229467000, 7575], [1533315866000, 7495], [1533402266000, 7014], [1533488666000, 7018], [1533575066000, 6950], [1533661421000, 7125], [1533747867000, 6297], [1533834266000, 6455], [1533920666000, 6404], [1534007066000, 6134], [1534093466000, 6323], [1534179867000, 6281], [1534266267000, 6034], [1534352666000, 6565], [1534439066000, 6387], [1534525467000, 6524], [1534611867000, 6336], [1534698266000, 6388], [1534784666000, 6455], [1534871066000, 6438], [1534957466000, 6433], [1535043866000, 6456], [1535130266000, 6559], [1535216666000, 6711], [1535303066000, 6656], [1535389466000, 6745], [1535475867000, 7019], [1535562266000, 7015], [1535631791000, 6887]],
    "price_btc": [[1513530254000, 1.00], [1513616654000, 1.00], [1513703054000, 1.00], [1513789454000, 1.00], [1513875855000, 1.00], [1513962256000, 1.00], [1514048657000, 1.00], [1514135056000, 1.00], [1514221462000, 1.00], [1514307861000, 1.00], [1514394261000, 1.00], [1514480660000, 1.00], [1514567062000, 1.00], [1514653461000, 1.00], [1514739862000, 1.00], [1514826261000, 1.00], [1514912660000, 1.00], [1514999060000, 1.00], [1515085461000, 1.00], [1515171561000, 1.00], [1515257958000, 1.00], [1515344660000, 1.00], [1515431097000, 1.01], [1515517497000, 1.02], [1515603897000, 1.02], [1515690298000, 1.02], [1515776698000, 1.02], [1515863097000, 1.02], [1515949497000, 1.02], [1516035898000, 1.01], [1516122298000, 1.02], [1516208697000, 1.01], [1516295098000, 1.01], [1516381498000, 1.01], [1516467898000, 1.01], [1516554297000, 1.01], [1516640698000, 1.01], [1516727098000, 0.9991], [1516813498000, 0.9995], [1516899897000, 1.00], [1516986298000, 0.9999], [1517072698000, 1.00], [1517159098000, 1.00], [1517245498000, 1.00], [1517331898000, 1.00], [1517418297000, 1.00], [1517504699000, 0.9979], [1517591098000, 0.9976], [1517677498000, 0.9980], [1517763898000, 1.00], [1517850297000, 0.9996], [1517936698000, 0.9972], [1518023097000, 1.00], [1518109498000, 0.9989], [1518195898000, 1.00], [1518282298000, 1.01], [1518368698000, 1.00], [1518455098000, 0.9997], [1518541498000, 1.00], [1518627899000, 0.9997], [1518714298000, 1.00], [1518800699000, 1.00], [1518887098000, 1.00], [1518973498000, 1.00], [1519059898000, 1.00], [1519146298000, 1.00], [1519232697000, 1.00], [1519319098000, 1.00], [1519405497000, 1.00], [1519491898000, 1.00], [1519578298000, 1.00], [1519664698000, 1.00], [1519751098000, 1.00], [1519837497000, 1.00], [1519923899000, 1.00], [1520010298000, 1.00], [1520096701000, 1.00], [1520183101000, 1.00], [1520269500000, 1.00], [1520355898000, 1.00], [1520442299000, 1.00], [1520528699000, 1.00], [1520615098000, 1.00], [1520701498000, 1.00], [1520787898000, 1.00], [1520874298000, 1.00], [1520960699000, 1.00], [1521047099000, 1.00], [1521133499000, 1.00], [1521219897000, 1.00], [1521306298000, 1.00], [1521392698000, 1.00], [1521479098000, 1.00], [1521565498000, 1.00], [1521651898000, 1.00], [1521738298000, 1.00], [1521824698000, 1.00], [1521911098000, 1.00], [1521997498000, 1.00], [1522083899000, 1.00], [1522170297000, 1.00], [1522256697000, 1.00], [1522343098000, 1.00], [1522429499000, 1.00], [1522515898000, 1.00], [1522602298000, 1.00], [1522688698000, 1.00], [1522775098000, 1.00], [1522861497000, 1.00], [1522947897000, 1.00], [1523034298000, 1.00], [1523120698000, 1.00], [1523207099000, 1.00], [1523293497000, 1.00], [1523379898000, 1.00], [1523466297000, 1.00], [1523552699000, 1.00], [1523639098000, 1.00], [1523725498000, 1.00], [1523811898000, 1.00], [1523898299000, 1.00], [1523984698000, 1.00], [1524071098000, 1.00], [1524157498000, 1.00], [1524243898000, 1.00], [1524330299000, 1.00], [1524416699000, 1.00], [1524503099000, 1.00], [1524589498000, 1.00], [1524675898000, 1.00], [1524762297000, 1.00], [1524848699000, 1.00], [1524935098000, 1.00], [1525021498000, 1.00], [1525107899000, 1.00], [1525194297000, 1.00], [1525280698000, 1.00], [1525367098000, 1.00], [1525453498000, 1.00], [1525539898000, 1.00], [1525626298000, 1.00], [1525712697000, 1.00], [1525799099000, 1.00], [1525885498000, 1.00], [1525971898000, 1.00], [1526058299000, 1.00], [1526144698000, 1.00], [1526231098000, 1.00], [1526317499000, 1.00], [1526403899000, 1.00], [1526490299000, 1.00], [1527699896000, 1.00], [1527786296000, 1.00], [1527872696000, 1.00], [1527959096000, 1.00], [1528045496000, 1.00], [1528131896000, 1.00], [1528218296000, 1.00], [1528304696000, 1.00], [1528391096000, 1.00], [1528477496000, 1.00], [1528563896000, 1.00], [1528650296000, 1.00], [1528736696000, 1.00], [1528823096000, 1.00], [1528909496000, 1.00], [1528995896000, 1.00], [1529082296000, 1.00], [1529168696000, 1.00], [1529255096000, 1.00], [1529341496000, 1.00], [1529427896000, 1.00], [1529514296000, 1.00], [1529600666000, 1.00], [1529687096000, 1.00], [1529773496000, 1.00], [1529859896000, 1.00], [1529946296000, 1.00], [1530032696000, 1.00], [1530119096000, 1.00], [1530205496000, 1.00], [1530291897000, 1.00], [1530378297000, 1.00], [1530464696000, 1.00], [1530551097000, 1.00], [1530637496000, 1.00], [1530723896000, 1.00], [1530810296000, 1.00], [1530896697000, 1.00], [1530983096000, 1.00], [1531069496000, 1.00], [1531155896000, 1.00], [1531242296000, 1.00], [1531328397000, 1.00], [1531415022000, 1.00], [1531501382000, 1.00], [1531587866000, 1.00], [1531674266000, 1.00], [1531760666000, 1.00], [1531847066000, 1.00], [1531933466000, 1.00], [1532019866000, 1.00], [1532106267000, 1.00], [1532192666000, 1.00], [1532279066000, 1.00], [1532365466000, 1.00], [1532451866000, 1.00], [1532538266000, 1.00], [1532624666000, 1.00], [1532711066000, 1.00], [1532797466000, 1.00], [1532883866000, 1.00], [1532970266000, 1.00], [1533056666000, 1.00], [1533143066000, 1.00], [1533229467000, 1.00], [1533315866000, 1.00], [1533402266000, 1.00], [1533488666000, 1.00], [1533575066000, 1.00], [1533661421000, 1.00], [1533747867000, 1.00], [1533834266000, 1.00], [1533920666000, 1.00], [1534007066000, 1.00], [1534093466000, 1.00], [1534179867000, 1.00], [1534266267000, 1.00], [1534352666000, 1.00], [1534439066000, 1.00], [1534525467000, 1.00], [1534611867000, 1.00], [1534698266000, 1.00], [1534784666000, 1.00], [1534871066000, 1.00], [1534957466000, 1.00], [1535043866000, 1.00], [1535130266000, 1.00], [1535216666000, 1.00], [1535303066000, 1.00], [1535389466000, 1.00], [1535475867000, 1.00], [1535562266000, 1.00], [1535631791000, 1.00]],
    "vol_usd": [[1513530254000, 13785200000], [1513616654000, 13935800000], [1513703054000, 16050200000], [1513789454000, 22161900000], [1513875855000, 17621200000], [1513962256000, 19530600000], [1514048657000, 15341800000], [1514135056000, 11991200000], [1514221462000, 10572600000], [1514307861000, 13048000000], [1514394261000, 11511700000], [1514480660000, 12163600000], [1514567062000, 12445500000], [1514653461000, 13919300000], [1514739862000, 13083000000], [1514826261000, 9547980000], [1514912660000, 18755900000], [1514999060000, 17922500000], [1515085461000, 20952700000], [1515171561000, 22466800000], [1515257958000, 20220600000], [1515344660000, 15897400000], [1515431097000, 6045342693.71686], [1515517497000, 5460531976.014013], [1515603897000, 18117000000], [1515690298000, 6813707504.475638], [1515776698000, 5103051417.8562355], [1515863097000, 3892944864.1619554], [1515949497000, 3776786804.7236676], [1516035898000, 3985066959.7812276], [1516122298000, 7035843455.815421], [1516208697000, 9827033118.514456], [1516295098000, 8268598940.480916], [1516381498000, 5075527324.332989], [1516467898000, 5221953722.293799], [1516554297000, 4666948898.992569], [1516640698000, 9346290000], [1516727098000, 5722857716.427507], [1516813498000, 3153258202.500999], [1516899897000, 3383528066.794372], [1516986298000, 4893561157.255445], [1517072698000, 3445623534.4350557], [1517159098000, 9074441513.301668], [1517245498000, 7181940000], [1517331898000, 7187410000], [1517418297000, 9472900000], [1517504699000, 8439230000], [1517591098000, 13752500000], [1517677498000, 7777140000], [1517763898000, 6732323240.885495], [1517850297000, 7715720000], [1517936698000, 13731300000], [1518023097000, 10732200000], [1518109498000, 10511292266.471413], [1518195898000, 7795650710.009166], [1518282298000, 8246768385.072687], [1518368698000, 7241030515.697452], [1518455098000, 6326099392.747569], [1518541498000, 6453889779.309274], [1518627899000, 8007353125.183114], [1518714298000, 8755828678.871384], [1518800699000, 8810366874.914562], [1518887098000, 8838454384.283766], [1518973498000, 9625363635.541346], [1519059898000, 7994830433.293], [1519146298000, 9443246092.936401], [1519232697000, 10812663063.789467], [1519319098000, 8963394108.917843], [1519405497000, 8385850927.745741], [1519491898000, 7489106263.954898], [1519578298000, 6081937555.913583], [1519664698000, 7528119578.212077], [1519751098000, 7803861064.5296955], [1519837497000, 7375052190.734697], [1519923899000, 7269455531.448156], [1520010298000, 8158993671.232047], [1520096701000, 6998699165.607816], [1520183101000, 6033424559.023921], [1520269500000, 6816577840.66132], [1520355898000, 7145710917.677778], [1520442299000, 7960325849.263897], [1520528699000, 8871978640.603176], [1520615098000, 9292071347.799292], [1520701498000, 6614372513.534789], [1520787898000, 6706032971.15401], [1520874298000, 7005519185.32844], [1520960699000, 7394467004.856807], [1521047099000, 5991664174.314378], [1521133499000, 8238863798.595153], [1521219897000, 6125374216.310501], [1521306298000, 4727769823.302301], [1521392698000, 5554676102.552807], [1521479098000, 7739120321.447537], [1521565498000, 6639699068.019078], [1521651898000, 6655384385.434742], [1521738298000, 6055604037.729397], [1521824698000, 5760310382.85865], [1521911098000, 6323885601.022917], [1521997498000, 5170252142.319469], [1522083899000, 5384074608.499685], [1522170297000, 6440974530.757729], [1522256697000, 5352828007.306588], [1522343098000, 5776835777.856059], [1522429499000, 7501769319.149553], [1522515898000, 5295777535.007373], [1522602298000, 4711214258.823667], [1522688698000, 4638807560.003491], [1522775098000, 5535354131.751965], [1522861497000, 5337603784.780071], [1522947897000, 5874638492.657438], [1523034298000, 4227312595.1056986], [1523120698000, 4268171344.09488], [1523207099000, 3859772360.161975], [1523293497000, 4856084836.566156], [1523379898000, 4507262323.347402], [1523466297000, 4495334377.619384], [1523552699000, 8882208345.478918], [1523639098000, 8437198446.10381], [1523725498000, 6225748418.914432], [1523811898000, 5650549587.374457], [1523898299000, 5860376430.086735], [1523984698000, 6855095190.883667], [1524071098000, 6982296497.655257], [1524157498000, 7770303721.922134], [1524243898000, 8149893316.303956], [1524330299000, 9116061403.979181], [1524416699000, 7140047526.031059], [1524503099000, 7253951284.503153], [1524589498000, 9574598797.566847], [1524675898000, 12520386321.425196], [1524762297000, 9280390646.012598], [1524848699000, 8312843023.159257], [1524935098000, 8728898510.507645], [1525021498000, 9016571052.735447], [1525107899000, 8242812648.297266], [1525194297000, 8314063027.3472], [1525280698000, 6780848518.496947], [1525367098000, 9135435923.065165], [1525453498000, 9231245066.785067], [1525539898000, 7933359328.908642], [1525626298000, 7743312263.4674425], [1525712697000, 7391699810.050773], [1525799099000, 7544526362.578444], [1525885498000, 7381974699.270453], [1525971898000, 6823158698.806506], [1526058299000, 9267249581.29556], [1526144698000, 7461754931.079817], [1526231098000, 5897879354.312901], [1526317499000, 7944220780.5615], [1526403899000, 7110708367.789153], [1526490299000, 7247314365.206509], [1527699896000, 5223163313.861939], [1527786296000, 5161769300.639363], [1527872696000, 5261834978.662544], [1527959096000, 5104752872.958763], [1528045496000, 5187726639.352945], [1528131896000, 5243135689.841504], [1528218296000, 5167579064.40362], [1528304696000, 4847491668.112579], [1528391096000, 5679689259.114932], [1528477496000, 4624548914.125527], [1528563896000, 3992805672.891175], [1528650296000, 4675377445.04964], [1528736696000, 6102465120.617255], [1528823096000, 4480617570.59565], [1528909496000, 5455128122.42234], [1528995896000, 5232964789.544486], [1529082296000, 4622025696.061024], [1529168696000, 3615561445.026817], [1529255096000, 3209110143.8810997], [1529341496000, 3732388090.6970463], [1529427896000, 4310893833.524231], [1529514296000, 3971548570.289818], [1529600666000, 3539037949.152267], [1529687096000, 4562063091.709525], [1529773496000, 3833494078.3603706], [1529859896000, 4226647132.71707], [1529946296000, 5505284434.970645], [1530032696000, 4327266535.729973], [1530119096000, 3594608713.0808935], [1530205496000, 3171461382.236039], [1530291897000, 3807376524.390637], [1530378297000, 5040746048.931525], [1530464696000, 3413391728.6598434], [1530551097000, 4268080376.864214], [1530637496000, 4037798697.6463213], [1530723896000, 4487593669.222654], [1530810296000, 4173394585.228833], [1530896697000, 4082899435.0227933], [1530983096000, 3703783882.545808], [1531069496000, 3602394369.007739], [1531155896000, 3344359996.4214582], [1531242296000, 3899714319.5466533], [1531328397000, 3291760961.872437], [1531415022000, 2953956104.1189103], [1531501382000, 3007985306.743002], [1531587866000, 3096039748.6770926], [1531674266000, 2926637613.9563622], [1531760666000, 3836645710.2820854], [1531847066000, 3926981057.6016374], [1531933466000, 6379766961.4995775], [1532019866000, 5388036339.567731], [1532106267000, 4728876277.703505], [1532192666000, 4111377800.5480127], [1532279066000, 3515293426.172337], [1532365466000, 4816895757.315796], [1532451866000, 6479921094.883971], [1532538266000, 5680932954.500195], [1532624666000, 4490104873.131306], [1532711066000, 5407329957.061505], [1532797466000, 3643564665.7703376], [1532883866000, 3547436799.037858], [1532970266000, 3861391921.799101], [1533056666000, 5011948187.569835], [1533143066000, 4162998035.577149], [1533229467000, 3758673747.5378733], [1533315866000, 3919606303.5750566], [1533402266000, 3710789975.19755], [1533488666000, 3071567654.694351], [1533575066000, 3138434955.6108813], [1533661421000, 3612358403.8015347], [1533747867000, 4546323472.360269], [1533834266000, 3937586046.8496323], [1533920666000, 3593843718.19468], [1534007066000, 3731371185.179549], [1534093466000, 3331817196.182767], [1534179867000, 3515174618.628518], [1534266267000, 5017664574.933824], [1534352666000, 4393150482.916972], [1534439066000, 3953325232.54109], [1534525467000, 4567389330.418232], [1534611867000, 3767591522.4959583], [1534698266000, 2931947275.7523236], [1534784666000, 3127764296.8631654], [1534871066000, 3230719939.737575], [1534957466000, 3477309879.8525176], [1535043866000, 3220435754.3102713], [1535130266000, 3095185747.7872143], [1535216666000, 3192398671.3631873], [1535303066000, 2867978924.9789433], [1535389466000, 3080756756.985261], [1535475867000, 4047160679.910816], [1535562266000, 3808893890.5135303], [1535631791000, 3652143981.43766]]
};

let BigNumber = require('bignumber.js');

let pricesAry = [];

/*
* BTC 6939
* ETH 282
* EOS 5.83
* LTC 60.02
* ETC 12.66
* */
let coinPrices = 7000;//当前虚拟币的价格
let baseUsdt = 12000;
let standard = 20;//每天买多少USDT的虚拟币
let step = 3;//波动的幅度

console.log(`账上初始金额:${baseUsdt} USDT  / ${parseFloat(baseUsdt * 6.84).toFixed(2)} RMB`);
data.price_usd.forEach(ele => {
    let tempObj = {
        timestamp: ele[0],
        timeBeau: unix2human(ele[0]),
        price: ele[1],//虚拟币单价
        isD: {
            falg: false,//是否操作了 止盈损
            amount: 0,//卖出数量
            price: 0,//卖出价格
            usdt: 0,//卖出虚拟币得到的USDT
        },
        isC: {
            falg: false,//是否操作了 止盈损
            amount: 0,//卖出数量
            price: 0,//卖出价格
            usdt: 0,//卖出虚拟币得到的USDT
        },
        isB: {
            falg: false,//是否操作了 止盈损
            amount: 0,//卖出数量
            price: 0,//卖出价格
            usdt: 0,//卖出虚拟币得到的USDT
        },
        isA: {
            falg: false,//是否操作了 止盈损
            amount: 0,//卖出数量
            price: 0,//卖出价格
            usdt: 0,//卖出虚拟币得到的USDT
        }
    };
    // 止盈或者止损
    pricesAry.forEach(item => {
        // item.price;
        let val = getProfit(ele[1], item.price);
        let lv01 = 8,
            lv02 = 12,
            lv03 = 18,
            lv04 = 28;
        let price = ele[1];
        let isSellA = ((val > lv01) || val < -lv01);
        let isSellB = ((val > lv02) || val < -lv02);
        let isSellC = ((val > lv03) || val < -lv03);
        let isSellD = ((val > lv04) || val < -lv04);
        let isGo = true;

        if (item.isA.falg === false && isSellA && isGo) {
            isGo = false;
            let amount = item.amount / 5;
            let usdt = amount * price; //卖出虚拟币得到的USDT
            item.isA = {
                falg: true,//是否操作了 止盈损
                amount: amount,//卖出数量
                price: price,//卖出价格
                usdt: usdt,//卖出虚拟币得到的USDT
            };
            item.todayBuyCoinBalance = BigNumber(item.todayBuyCoinBalance).minus(amount).toString();
            item.sellUsdt = BigNumber(item.sellUsdt).plus(usdt).toString();
        }
        if (item.isB.falg === false && isSellB && isGo) {
            isGo = false;
            let amount = item.amount / 4;
            let usdt = amount * price; //卖出虚拟币得到的USDT
            item.isB = {
                falg: true,//是否操作了 止盈损
                amount: amount,//卖出数量
                price: price,//卖出价格
                usdt: usdt,//卖出虚拟币得到的USDT
            };
            item.todayBuyCoinBalance = BigNumber(item.todayBuyCoinBalance).minus(amount).toString();
            item.sellUsdt = BigNumber(item.sellUsdt).plus(usdt).toString();
        }
        if (item.isC.falg === false && isSellC && isGo) {
            isGo = false;
            let amount = item.amount / 3;
            let usdt = amount * price; //卖出虚拟币得到的USDT
            item.isC = {
                falg: true,//是否操作了 止盈损
                amount: amount,//卖出数量
                price: price,//卖出价格
                usdt: usdt,//卖出虚拟币得到的USDT
            };
            item.todayBuyCoinBalance = BigNumber(item.todayBuyCoinBalance).minus(amount).toString();
            item.sellUsdt = BigNumber(item.sellUsdt).plus(usdt).toString();
        }
        if (item.isD.falg === false && isSellD && isGo) {
            isGo = false;
            let amount = item.amount / 3;
            let usdt = amount * price; //卖出虚拟币得到的USDT
            item.isD = {
                falg: true,//是否操作了 止盈损
                amount: amount,//卖出数量
                price: price,//卖出价格
                usdt: usdt,//卖出虚拟币得到的USDT
            };

            item.todayBuyCoinBalance = BigNumber(item.todayBuyCoinBalance).minus(amount).toString();
            item.sellUsdt = BigNumber(item.sellUsdt).plus(usdt).toString();
        }


    });

    //加大或者减小 买入量
    let nowPrice = ele[1];
    let AAA = pricesAry.length - 1;
    let BBB = pricesAry.length - 5;
    let CCC = pricesAry.length - 7;
    let DDD = pricesAry.length - 15;

    let yesterdayA = pricesAry[AAA] ? pricesAry[AAA].price : ele[1];
    let yesterdayB = pricesAry[BBB] ? pricesAry[BBB].price : ele[1];
    let yesterdayC = pricesAry[CCC] ? pricesAry[CCC].price : ele[1];
    let yesterdayD = pricesAry[DDD] ? pricesAry[DDD].price : ele[1];

    let lv1 = getProfit(nowPrice, yesterdayA);
    let lv2 = getProfit(nowPrice, yesterdayB);
    let lv3 = getProfit(nowPrice, yesterdayC);
    let lv4 = getProfit(nowPrice, yesterdayD);

    let todayBuy = standard;
    let lv1Val = 10,
        lv2Val = 15,
        lv3Val = 25,
        lv4Val = 30;
    if (lv1 > lv1Val) {
        todayBuy = todayBuy - step;
    } else if (lv1 < -lv1Val) {
        todayBuy = todayBuy + step;
    }
    if (lv2 > lv2Val) {
        todayBuy = todayBuy - step * 2;
    } else if (lv2 < -lv2Val) {
        todayBuy = todayBuy + step * 2;
    }
    if (lv3 > lv3Val) {
        todayBuy = todayBuy - step * 3;
    } else if (lv3 < -lv3Val) {
        todayBuy = todayBuy + step * 3;
    }
    if (lv4 > lv4Val) {
        todayBuy = todayBuy - step * 4;
    } else if (lv4 < -lv4Val) {
        todayBuy = todayBuy + step * 4;
    }

    // console.log(todayBuy);
    tempObj.usdt = todayBuy;//买多少USDT的虚拟币
    tempObj.amount = tempObj.usdt / ele[1];//用USDT买了多少虚拟币;
    tempObj.todayBuyCoinBalance = tempObj.amount;//本日买的虚拟币还剩多少
    baseUsdt = baseUsdt - tempObj.usdt;
    tempObj.sellUsdt = 0;//卖多少USDT的虚拟币
    pricesAry.push(tempObj);
});
// console.log(pricesAry);

let totalSell=0;
let amount = 0;
let total = 0;
pricesAry.forEach(item => {
    totalSell = BigNumber(totalSell).plus(item.sellUsdt).toNumber();
    total = BigNumber(total).plus(item.usdt).toNumber();
    amount = BigNumber(amount).plus(item.todayBuyCoinBalance).toNumber();
});

console.log(`
一共定投 ${pricesAry.length} 天
买币花费:${total}USDT / ${parseFloat(total * 6.84).toFixed(2)} RMB
`);

console.log(`账户剩余金额:${baseUsdt}USDT / ${parseFloat(baseUsdt * 6.84).toFixed(2)} RMB

账户持币数量:${amount} 
当前市值:${parseFloat(coinPrices * amount).toFixed(2)} USDT  

卖币得的USDT:${totalSell}  / ${parseFloat(totalSell * 6.84).toFixed(2)} RMB

利润:${parseFloat((coinPrices * amount) +totalSell - total  ).toFixed(2)} USDT
收益:${parseFloat(((coinPrices * amount) +totalSell - total) / total * 100).toFixed(4)}%

--------- 总结 ------------
投入=> ${parseFloat(total * 6.84).toFixed(2)} RMB 
利润=> ${parseFloat(((coinPrices * amount)+totalSell - total) * 6.84).toFixed(2)} RMB
`);

function unix2human(v) {
    let dateObj = new Date(v);
    let UnixTimeToDate = dateObj.getFullYear() + '/'
        + (dateObj.getMonth() + 1) + '/'
        + dateObj.getDate() + ' '
        + dateObj.getHours() + ':' +
        dateObj.getMinutes() + ':' +
        dateObj.getSeconds();
    return UnixTimeToDate;
};

function getProfit(now, before) {
    return BigNumber(now).minus(before).dividedBy(before).multipliedBy(100).toString();
}

 

~~~

未经允许不得转载:朱邦邦的博客 » 虚拟货币定投策略,结果不给力,仅作记录

赞 (0)

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址