Robots on Tinkoff and Binance in JavaScript and + $ 5000;

The entire community of trading robots developers is brewing around Python and C # . When asked why these languages โ€‹โ€‹are the ones they begin to indistinctly grumble about multithreading, the number of ready-made libraries, and sometimes even about semaphores. So I decided to try to get into this hodgepodge, yes, itโ€™s a hodgepodge, thereโ€™s no other name for it.



In general, there are a lot of tools that seem to be suitable straight for work, but so cumbersome and somehow they have everything crammed into different corners and exist in a complete creative mess. At the same time, no one asks the question "how and why does it work like that?", Everyone is just trying to write something in order to make some money, if they are lucky.



As usual with many developers, I was wondering what JavaScript and V8 with JIT are capable of, can it provide the necessary speed for complex mathematics? And initially it all started more as a research mission. And the case, by the way, was a year and a half ago.



So, what we need to develop and launch a trading strategy, for example, at Tinkoff Investments :





  1. JavaScript technical indicators. It's good that they are, albeit not very abundant. Let's take the most popular technicalindicators by downloads





  2. Anything to work with Tinkoff, their invest-openapi-js-sdk library





  3. Let's take the dumbest strategy in the world, for example, 2 SMA - fast and slow, which tend to converge again in case of divergences.





  4. Despite the stupidity of the strategy, you need to optimize it cleverly: either according to Monte Carlo, or using genetics, let's take genetics, because it just sounds more beautiful. Suitable library geneticalgorithm





A little more detail about the strategy and about the divergence of the two SMA lines. It is based on the market's desire for corrections. If the SMA with a faster period goes below the SMA with a slow one, then the market has made a sharp change in price, which with a certain probability will correct backward. In the picture below, such divergences are shown by arrows, almost all of them have a reverse movement. This is a good entry point to buying stocks. Short positions can be entered when the fast SMA has moved sharply above the slow one.





Tesla stock chart and dumb strategy
Tesla stock chart and dumb strategy

, - , .





, SDK . , , , - , , 3 . SDK , GitHub. , .





3 : " - ", . - , . , 30 . , ( ), .



- . , . , , , ...



. , "" .





The butterfly moves randomly

, .



, 100 20 , * *, . .





Butterflies fly to a specified point

- , , . .



, . , , , , , , . ยซ ยป ( ) ยซ ยป ( ). , . .



. , :





= -





, . . .





, , , , . 100 500 .



, , (). .



100 , 100 , , . . , ( ) . , 50. fastSMAPeriod



slowSMAPeriod



, .



, , , , .





, . , : - . , ...





, - - 2 . . , 5 ;) . , , , . . , JavaScript.



async-genetic , . , . - , , " " 2 ( ).



, .





Visualization of deals by strategy

SMA, . . , . - . .



, . . NodeJS , , , . ? . .



, . . , , . - ! , , . , new Date()



. . :





3 , . , , . .





, , . 15 .





, . , - , . 5000$, , .





. , 30-100 . ( ). , .





Debut.





Debut - .  ZenBot, . ,    . - :   - (, , ),   - ( ), .





Debut , . Debut, . :    Binance ( , - ).





" " . .





, , - .








All Articles