{"id":364080,"date":"2024-05-21T02:09:44","date_gmt":"2024-05-21T02:09:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364080"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364080","title":{"rendered":"<span>\u0422\u043e\u0440\u0433\u043e\u0432\u044b\u0439 \u0431\u043e\u0442 \u043d\u0430 Python \u0441 \u043d\u0443\u043b\u044f (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Binance API), \u0447\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u0412\u0410\u0416\u041d\u041e<\/strong>: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0430 <strong>\u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445.<\/strong> \u0422\u043e\u0440\u0433\u043e\u0432\u043b\u044f \u043d\u0430 \u0431\u0438\u0440\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 <strong>\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0440\u0438\u0441\u043a\u043e\u043c<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a <strong>\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0443\u0431\u044b\u0442\u043a\u0430\u043c<\/strong>.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e <\/strong><a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\"><strong>\u0441\u0441\u044b\u043b\u043a\u0435<\/strong><\/a><strong>.<\/strong><\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u0438 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435)<\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u043d\u0430 <code>python<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <strong>Binance API<\/strong>. \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u043c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0435 \u0446\u0435\u043d\u044b \u043d\u0430 \u043f\u0430\u0440\u0435 ETHUSDT. \u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c\u0438. <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a>:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0446\u0435\u043d\u0443 \u0430\u043a\u0442\u0438\u0432\u0430 \u043d\u0430 \u0431\u0438\u0440\u0436\u0435 (\u0431\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 BID \u0438\u043b\u0438 ASK \u0432 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435);<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0437\u0430 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430: \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043d\u0433 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0448\u043e\u0440\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0437\u0430 \u043d\u0438\u0436\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430: \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0448\u043e\u0440\u0442 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043d\u0433.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <code>python<\/code>:<\/p>\n<pre><code class=\"python\"># imports and functions are omitted here as they stay exactly the same   # flags to track the exchanges to avoid duplicated entries in_short = False in_long = False  # main loop while True:     # get latest price for the symbol     latest_price = client.futures_symbol_ticker(symbol=symbol)['price']     latest_price = float(latest_price)          # check the condition (these conditions could be substitued by any other)     if \"&lt;condintion>\":         # if we are in long position, close it         if in_long:             long_close(symbol=symbol, quantity=1)             in_long = False         # if we are not in short position, open it         if not in_short:             short_open(symbol=symbol, quantity=1)             in_short = True     elif \"&lt;other_contition>\":         # if we are in long position, close it         if not in_long:             long_open(symbol=symbol, quantity=1)             in_long = True         # if we are in short position, close it         if in_short:             short_close(symbol=symbol, quantity=1)             in_short = False      # 1 second sleep     time.sleep(1)<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f <code>&lt;condition><\/code> \u0438 <code>&lt;other_condition><\/code> \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<h2>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 (\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435) \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u043c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0430\u043a\u0442\u0438\u0432\u0435 (\u0442\u043e\u0440\u0433\u043e\u0432\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0430\u043a\u0442\u0438\u0432\u0430\u043c\u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e <em>\u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0433\u043e<\/em> \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430) \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u0445 (\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0446\u0435\u043d\u0435 \u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 &#171;\u0432\u043d\u0435\u0448\u043d\u0438\u0445&#187; \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u043d\u0430 \u0440\u044b\u043d\u043e\u043a):<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 (moving average crossover)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u043c\u0438 \u0438 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043b\u043e\u043d\u0433, \u043a\u043e\u0433\u0434\u0430 \u043b\u0438\u043d\u0438\u044f \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445 \u0438 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0448\u043e\u0440\u0442, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0438\u0438 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u043b\u0438\u043d\u0438\u0438 \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b (channel breakout)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b, \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0446\u0435\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 n \u0441\u0432\u0435\u0447, \u0430 \u043d\u0438\u0436\u043d\u044f\u044f &#8212; \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 n \u0441\u0432\u0435\u0447.<\/p>\n<\/li>\n<li>\n<p><strong>\u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (Bollinger bands)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b, \u043d\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. <\/p>\n<p><em>\u0412\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 = \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f + 2 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b; <\/em><\/p>\n<p><em>\u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 = \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f &#8212; 2 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b<sup>.<\/sup><\/em> <\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <\/p>\n<p><em>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445) \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0448\u043e\u0440\u0442. \u0428\u043e\u0440\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 (\u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437). <\/em><\/p>\n<p><em>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437) \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u043e\u043d\u0433. \u041b\u043e\u043d\u0433 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 (\u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445).<\/em><\/p>\n<\/li>\n<\/ol>\n<h2>\u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430, \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0440\u0443\u0434\u0430).<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<blockquote>\n<p><strong>\u041b\u0438\u043d\u0438\u0438 (\u043f\u043e\u043b\u043e\u0441\u044b) \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/strong>\u00a0(<em>Bollinger bands<\/em>)\u00a0\u2014\u00a0\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00a0\u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A2%D0%B5%D1%85%D0%BD%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9_%D0%B0%D0%BD%D0%B0%D0%BB%D0%B8%D0%B7\" rel=\"noopener noreferrer nofollow\"> <\/a>\u0430\u043d\u0430\u043b\u0438\u0437\u0430\u00a0\u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445 \u0440\u044b\u043d\u043a\u043e\u0432, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b\u00a0\u0430\u043a\u0446\u0438\u0438, \u0442\u043e\u0432\u0430\u0440\u0430 \u0438\u043b\u0438 \u0432\u0430\u043b\u044e\u0442\u044b.<\/p>\n<\/blockquote>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u043e\u0442 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u043e\u043d\u0430 \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0430\u0434. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0446\u0435\u043d\u0430\u0445 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f 5 \u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445 \u0441\u0432\u0435\u0447\u0435\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0430 (\u0441\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0438\u0436\u0435), \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"BB_{high}(n) = MA(n) + 2 STD(n);\\quad BB_{low}(n) = MA(n) - 2STD(n)\" alt=\"BB_{high}(n) = MA(n) + 2 STD(n);\\quad BB_{low}(n) = MA(n) - 2STD(n)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff5\/f87\/57e\/ff5f8757e289bbbcc5a61cf7c5316d44.svg\" width=\"577\" height=\"23\"\/><\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0446\u0435\u043d\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0434\u0436\u0435\u0440\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">\u0426\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">\u0421\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442)<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442)<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">\u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:00<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.0<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:05<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:10<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.1<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:15<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.133333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.57735<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.248803<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.017863<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:25<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.1<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:30<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.5<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.2<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:35<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.333333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.152753<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.638838<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.027828<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:40<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.0<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.233333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.251661<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.736656<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.730011<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:45<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">99.5<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">99.9<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.360555<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.621110<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.178890<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 <em>\u0440\u0438\u0441\u0443\u043d\u043a\u0435 1<\/em> \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u0438\u043d\u0438\u0439 \u0438 \u0444\u0438\u043e\u043b\u0435\u0442\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442\u0430), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f (\u043e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 \u0446\u0432\u0435\u0442). \u041f\u043e\u043c\u0438\u043c\u043e \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043e\u043a (\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438). \u041e\u043d\u0438 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438. \u0412\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0443\u043d\u043a\u0442\u0438\u0440\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0434\u0435\u043b\u043a\u0443, \u0430 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043f\u043b\u043e\u0448\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f &#8212; \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043a\u0438. \u0427\u0438\u0441\u043b\u043e \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e \u0432\u043d\u0438\u0437\u0443 \u0441\u0434\u0435\u043b\u043a\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0435\u0435 \u0434\u043e\u0445\u043e\u0434 (\u0443\u0431\u044b\u0442\u043e\u043a) \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/acf\/981\/cba\/acf981cbadea8fa445a0d4aed2cf7cbd.png\" alt=\"\u0420\u0438\u0441 1. \u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043e\u043a \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439\" title=\"\u0420\u0438\u0441 1. \u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043e\u043a \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439\" width=\"1890\" height=\"1058\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/acf\/981\/cba\/acf981cbadea8fa445a0d4aed2cf7cbd.png\"\/><\/p>\n<div><figcaption>\u0420\u0438\u0441 1. \u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043e\u043a \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<h2>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e \u0432\u044b\u0448\u0435 \u0434\u043b\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <code>python<\/code>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043e\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0446\u0435\u043d\u044b \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0446\u0435\u043d\u0443 \u0430\u043a\u0442\u0438\u0432\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0432\u0435\u0447\u0438, \u0442\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442 (\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>5 \u043c\u0438\u043d\u0443\u0442<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c).<\/p>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/h3>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432 5 \u043c\u0438\u043d\u0443\u0442 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442):<\/p>\n<pre><code class=\"python\">import numpy as np import time from datetime import datetime from binance.client import Client  # list to keep all closing prices prices = []  # lists to keep all stats needed moving_average_values = [] bollinger_band_high_values = [] bollinger_band_low_values = []  # flags to track the exchanges to avoid duplicated entries in_short = False in_long = False  # period of Bollinger bands period = 3  last_time = \"\"  # main loop while True:     current_time = datetime.now()     # if current candlestick has closed and current time is not equal to the     # latest record (to avoid duplicated price records)     if current_time.minute % 5 == 0 and current_time.strftime('%Y-%m-%d %H:%M') != last_time:         last_time = current_time.strftime('%Y-%m-%d %H:%M')         # get latest price for the symbol         latest_price = client.futures_symbol_ticker(symbol=symbol)['price']         latest_price = float(latest_price)         prices.append(latest_price)              # print latest price with current time         print(current_time, latest_price)          # calculate moving average and deviation         ma = np.mean(prices[-period:])         moving_average_values.append(ma)          std = np.std(prices[-period:], ddof=1)          # calculate Bollinger bands         bb_high = ma + 2 * std         bb_low = ma - 2 * std          bollinger_band_high_values.append(bb_high)         bollinger_band_low_values.append(bb_low)<\/code><\/pre>\n<h3>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0445\u043e\u0434\u0430 (\u0432\u044b\u0445\u043e\u0434\u0430) \u0432 \u0441\u0434\u0435\u043b\u043a\u0438<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0434\u0435\u043b\u043a\u0443:<\/p>\n<pre><code class=\"python\"># check if current closing price is higher than the upper band # but previous closing price is lower than the upper band # this indicates that the crossing occured on current candlestick if prices[-2] &lt; bollinger_band_high_values[-2] and prices[-1] > bollinger_band_high_values[-1]:     # if we are not in short position, open it     if not in_short:         short_open(symbol=symbol, quantity=1)         in_short = True  # check if current closing price is lower than the lower band # but previous closing price is higher than the lower band # this indicates that the crossing occured on current candlestick if prices[-1] &lt; bollinger_band_low_values[-1] and prices[-2] > bollinger_band_low_values[-2]:     # if we are not in long position, open it     if not in_long:         long_open(symbol=symbol, quantity=1)         in_long = True<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043a\u0438:<\/p>\n<pre><code class=\"python\"># check if current closing price is lower than the moving average # but previous closing price is higher than the moving average # this indicates that the crossing occured on current candlestick if prices[-2] > moving_average_values[-2] and prices[-1] &lt; moving_average_values[-1]:     if in_short:         short_close(symbol=symbol, quantity=1)         in_short = False  # vice versa if prices[-2] &lt; moving_average_values[-2] and prices[-1] > moving_average_values[-1]:     if in_long:         long_close(symbol=symbol, quantity=1)         in_long = False<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e!<\/p>\n<pre><code class=\"python\">import numpy as np import time from datetime import datetime from binance.client import Client  # exchange operations: def short_open(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='SELL',                                  type='MARKET',                                  quantity=quantity)      def short_close(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='BUY',                                  type='MARKET',                                  quantity=quantity)      def long_open(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='BUY',                                  type='MARKET',                                  quantity=quantity)  def long_close(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='SELL',                                  type='MARKET',                                  quantity=quantity)  # initialize Client with your API keys api_key = \"&lt;your_api_key>\" api_secret = \"&lt;your_private_api_key>\" client = Client(api_key,  api_secret)  # traded symbol symbol = \"ETHUSDT\"  # list to keep all closing prices prices = []  # lists to keep all stats needed moving_average_values = [] bollinger_band_high_values = [] bollinger_band_low_values = []  # flags to track the exchanges to avoid duplicated entries in_short = False in_long = False  # period of Bollinger bands period = 3  last_time = \"\"  # main loop while True:     current_time = datetime.now()     # if current candlestick has closed and current time is not equal to the     # latest record (to avoid duplicated price records)     if current_time.minute % 5 == 0 and current_time.strftime('%Y-%m-%d %H:%M') != last_time:         last_time = current_time.strftime('%Y-%m-%d %H:%M')         # get latest price for the symbol         latest_price = client.futures_symbol_ticker(symbol=symbol)['price']         latest_price = float(latest_price)         prices.append(latest_price)              # print latest price with current time         print(current_time, latest_price)          # calculate moving average and deviation         ma = np.mean(prices[-period:])         moving_average_values.append(ma)          std = np.std(prices[-period:], ddof=1)          # calculate Bollinger bands         bb_high = ma + 2 * std         bb_low = ma - 2 * std          bollinger_band_high_values.append(bb_high)         bollinger_band_low_values.append(bb_low)          # descion of the strategy         # short exchanges         if prices[-2] &lt; bollinger_band_high_values[-2] and prices[-1] > bollinger_band_high_values[-1]:             if not in_short:                 short_open(symbol=symbol, quantity=1)                 in_short = True          if prices[-2] > moving_average_values[-2] and prices[-1] &lt; moving_average_values[-1]:             if in_short:                 short_close(symbol=symbol, quantity=1)                 in_short = False          # long conditions         if prices[-1] &lt; bollinger_band_low_values[-1] and prices[-2] > bollinger_band_low_values[-2]:             if not in_long:                 long_open(symbol=symbol, quantity=1)                 in_long = True                  if prices[-2] &lt; moving_average_values[-2] and prices[-1] > moving_average_values[-1]:             if in_long:                 long_close(symbol=symbol, quantity=1)                 in_long = False      time.sleep(1)<\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/783384\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0427\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u0445?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">36.11% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a<\/span><span class=\"tm-article-poll__answer-votes\">13<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 36.11%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">38.89% <\/span><span class=\"tm-article-poll__answer-label\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439<\/span><span class=\"tm-article-poll__answer-votes\">14<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 38.89%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">13.89% <\/span><span class=\"tm-article-poll__answer-label\">\u0412\u0441\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e!<\/span><span class=\"tm-article-poll__answer-votes\">5<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 13.89%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">5.56% <\/span><span class=\"tm-article-poll__answer-label\">\u0412\u0441\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e!<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 5.56%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">41.67% <\/span><span class=\"tm-article-poll__answer-label\">\u041c\u043d\u0435 \u0432\u0441\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f<\/span><span class=\"tm-article-poll__answer-votes\">15<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 41.67%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 36 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.   \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 10 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/783384\/\"> https:\/\/habr.com\/ru\/articles\/783384\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u0412\u0410\u0416\u041d\u041e<\/strong>: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0430 <strong>\u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445.<\/strong> \u0422\u043e\u0440\u0433\u043e\u0432\u043b\u044f \u043d\u0430 \u0431\u0438\u0440\u0436\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 <strong>\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0440\u0438\u0441\u043a\u043e\u043c<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a <strong>\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0443\u0431\u044b\u0442\u043a\u0430\u043c<\/strong>.<\/p>\n<p><strong>\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e <\/strong><a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\"><strong>\u0441\u0441\u044b\u043b\u043a\u0435<\/strong><\/a><strong>.<\/strong><\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u0438 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435)<\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u043d\u0430 <code>python<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <strong>Binance API<\/strong>. \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u043c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0435 \u0446\u0435\u043d\u044b \u043d\u0430 \u043f\u0430\u0440\u0435 ETHUSDT. \u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043b\u0443\u0436\u0438\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0432\u0430\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c\u0438. <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a>:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0446\u0435\u043d\u0443 \u0430\u043a\u0442\u0438\u0432\u0430 \u043d\u0430 \u0431\u0438\u0440\u0436\u0435 (\u0431\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 BID \u0438\u043b\u0438 ASK \u0432 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435);<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0437\u0430 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430: \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043d\u0433 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0448\u043e\u0440\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0448\u043b\u0438 \u0437\u0430 \u043d\u0438\u0436\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430: \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0448\u043e\u0440\u0442 \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043b\u043e\u043d\u0433.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u044b\u0448\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <code>python<\/code>:<\/p>\n<pre><code class=\"python\"># imports and functions are omitted here as they stay exactly the same   # flags to track the exchanges to avoid duplicated entries in_short = False in_long = False  # main loop while True:     # get latest price for the symbol     latest_price = client.futures_symbol_ticker(symbol=symbol)['price']     latest_price = float(latest_price)          # check the condition (these conditions could be substitued by any other)     if \"&lt;condintion>\":         # if we are in long position, close it         if in_long:             long_close(symbol=symbol, quantity=1)             in_long = False         # if we are not in short position, open it         if not in_short:             short_open(symbol=symbol, quantity=1)             in_short = True     elif \"&lt;other_contition>\":         # if we are in long position, close it         if not in_long:             long_open(symbol=symbol, quantity=1)             in_long = True         # if we are in short position, close it         if in_short:             short_close(symbol=symbol, quantity=1)             in_short = False      # 1 second sleep     time.sleep(1)<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f <code>&lt;condition><\/code> \u0438 <code>&lt;other_condition><\/code> \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<h2>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 (\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435) \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u043c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0430\u043a\u0442\u0438\u0432\u0435 (\u0442\u043e\u0440\u0433\u043e\u0432\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0430\u043a\u0442\u0438\u0432\u0430\u043c\u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e <em>\u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0433\u043e<\/em> \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430) \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u0445 (\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c\u0438 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0446\u0435\u043d\u0435 \u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438 \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 &#171;\u0432\u043d\u0435\u0448\u043d\u0438\u0445&#187; \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u043d\u0430 \u0440\u044b\u043d\u043e\u043a):<\/p>\n<ol>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 (moving average crossover)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u043c\u0438 \u0438 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043b\u043e\u043d\u0433, \u043a\u043e\u0433\u0434\u0430 \u043b\u0438\u043d\u0438\u044f \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445 \u0438 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0448\u043e\u0440\u0442, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0438\u0438 \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u043b\u0438\u043d\u0438\u0438 \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b (channel breakout)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b, \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0446\u0435\u043d\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 n \u0441\u0432\u0435\u0447, \u0430 \u043d\u0438\u0436\u043d\u044f\u044f &#8212; \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 n \u0441\u0432\u0435\u0447.<\/p>\n<\/li>\n<li>\n<p><strong>\u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (Bollinger bands)<\/strong>: \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u043e\u0438\u0442 \u043a\u043e\u0440\u0438\u0434\u043e\u0440 \u0446\u0435\u043d\u044b, \u043d\u043e \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. <\/p>\n<p><em>\u0412\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 = \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f + 2 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b; <\/em><\/p>\n<p><em>\u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 = \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f &#8212; 2 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b<sup>.<\/sup><\/em> <\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <\/p>\n<p><em>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445) \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0448\u043e\u0440\u0442. \u0428\u043e\u0440\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 (\u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437). <\/em><\/p>\n<p><em>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437) \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u043e\u043d\u0433. \u041b\u043e\u043d\u0433 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u043e\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 (\u0441\u043d\u0438\u0437\u0443 \u0432\u0432\u0435\u0440\u0445).<\/em><\/p>\n<\/li>\n<\/ol>\n<h2>\u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430, \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0440\u0443\u0434\u0430).<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<blockquote>\n<p><strong>\u041b\u0438\u043d\u0438\u0438 (\u043f\u043e\u043b\u043e\u0441\u044b) \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/strong>\u00a0(<em>Bollinger bands<\/em>)\u00a0\u2014\u00a0\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u00a0\u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A2%D0%B5%D1%85%D0%BD%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9_%D0%B0%D0%BD%D0%B0%D0%BB%D0%B8%D0%B7\" rel=\"noopener noreferrer nofollow\"> <\/a>\u0430\u043d\u0430\u043b\u0438\u0437\u0430\u00a0\u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445 \u0440\u044b\u043d\u043a\u043e\u0432, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u0446\u0435\u043d\u044b\u00a0\u0430\u043a\u0446\u0438\u0438, \u0442\u043e\u0432\u0430\u0440\u0430 \u0438\u043b\u0438 \u0432\u0430\u043b\u044e\u0442\u044b.<\/p>\n<\/blockquote>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0438 \u0446\u0435\u043d\u044b \u043e\u0442 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u043e\u043d\u0430 \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0430\u0434. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0446\u0435\u043d\u0430\u0445 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f 5 \u043c\u0438\u043d\u0443\u0442\u043d\u044b\u0445 \u0441\u0432\u0435\u0447\u0435\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0430 (\u0441\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0438\u0436\u0435), \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b:<\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0446\u0435\u043d\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0434\u0436\u0435\u0440\u0430:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">\u0426\u0435\u043d\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">\u0421\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442)<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442)<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">\u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:00<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.0<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:05<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<td>\n<p align=\"left\"><em>NaN<\/em><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:10<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.1<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:15<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.1<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.133333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.57735<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.248803<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.017863<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:25<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.1<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:30<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.5<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.3<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.2<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:35<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.2<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.333333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.152753<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.638838<\/p>\n<\/td>\n<td>\n<p align=\"left\">100.027828<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:40<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">100.0<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">100.233333<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.251661<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.736656<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.730011<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"84\" width=\"84\">\n<p align=\"left\">12:45<\/p>\n<\/td>\n<td data-colwidth=\"85\" width=\"85\">\n<p align=\"left\">99.5<\/p>\n<\/td>\n<td data-colwidth=\"148\" width=\"148\">\n<p align=\"left\">99.9<\/p>\n<\/td>\n<td data-colwidth=\"140\" width=\"140\">\n<p align=\"left\">0.360555<\/p>\n<\/td>\n<td data-colwidth=\"134\" width=\"134\">\n<p align=\"left\">100.621110<\/p>\n<\/td>\n<td>\n<p align=\"left\">99.178890<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 <em>\u0440\u0438\u0441\u0443\u043d\u043a\u0435 1<\/em> \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 (\u0441\u0438\u043d\u0438\u0439 \u0438 \u0444\u0438\u043e\u043b\u0435\u0442\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442\u0430), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f (\u043e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 \u0446\u0432\u0435\u0442). \u041f\u043e\u043c\u0438\u043c\u043e \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043e\u043a (\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438). \u041e\u043d\u0438 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438. \u0412\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0443\u043d\u043a\u0442\u0438\u0440\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0434\u0435\u043b\u043a\u0443, \u0430 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043f\u043b\u043e\u0448\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f &#8212; \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043a\u0438. \u0427\u0438\u0441\u043b\u043e \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e \u0432\u043d\u0438\u0437\u0443 \u0441\u0434\u0435\u043b\u043a\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0435\u0435 \u0434\u043e\u0445\u043e\u0434 (\u0443\u0431\u044b\u0442\u043e\u043a) \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0438\u0441 1. \u041b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0434\u0435\u043b\u043e\u043a \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439<\/figcaption><\/div>\n<\/figure>\n<h2>\u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 Python<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e \u0432\u044b\u0448\u0435 \u0434\u043b\u044f \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <code>python<\/code>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043e\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0446\u0435\u043d\u044b \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/782892\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0446\u0435\u043d\u0443 \u0430\u043a\u0442\u0438\u0432\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0432\u0435\u0447\u0438, \u0442\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442 (\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>5 \u043c\u0438\u043d\u0443\u0442<\/code> \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c).<\/p>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430<\/h3>\n<p>\u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043b\u0438\u043d\u0438\u0438 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0432 5 \u043c\u0438\u043d\u0443\u0442 \u0441 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c 3 \u0441\u0432\u0435\u0447\u0438 (15 \u043c\u0438\u043d\u0443\u0442):<\/p>\n<pre><code class=\"python\">import numpy as np import time from datetime import datetime from binance.client import Client  # list to keep all closing prices prices = []  # lists to keep all stats needed moving_average_values = [] bollinger_band_high_values = [] bollinger_band_low_values = []  # flags to track the exchanges to avoid duplicated entries in_short = False in_long = False  # period of Bollinger bands period = 3  last_time = \"\"  # main loop while True:     current_time = datetime.now()     # if current candlestick has closed and current time is not equal to the     # latest record (to avoid duplicated price records)     if current_time.minute % 5 == 0 and current_time.strftime('%Y-%m-%d %H:%M') != last_time:         last_time = current_time.strftime('%Y-%m-%d %H:%M')         # get latest price for the symbol         latest_price = client.futures_symbol_ticker(symbol=symbol)['price']         latest_price = float(latest_price)         prices.append(latest_price)              # print latest price with current time         print(current_time, latest_price)          # calculate moving average and deviation         ma = np.mean(prices[-period:])         moving_average_values.append(ma)          std = np.std(prices[-period:], ddof=1)          # calculate Bollinger bands         bb_high = ma + 2 * std         bb_low = ma - 2 * std          bollinger_band_high_values.append(bb_high)         bollinger_band_low_values.append(bb_low)<\/code><\/pre>\n<h3>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0445\u043e\u0434\u0430 (\u0432\u044b\u0445\u043e\u0434\u0430) \u0432 \u0441\u0434\u0435\u043b\u043a\u0438<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0438\u0439 \u0411\u043e\u043b\u043b\u0438\u043d\u0434\u0436\u0435\u0440\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0441\u0434\u0435\u043b\u043a\u0443:<\/p>\n<pre><code class=\"python\"># check if current closing price is higher than the upper band # but previous closing price is lower than the upper band # this indicates that the crossing occured on current candlestick if prices[-2] &lt; bollinger_band_high_values[-2] and prices[-1] > bollinger_band_high_values[-1]:     # if we are not in short position, open it     if not in_short:         short_open(symbol=symbol, quantity=1)         in_short = True  # check if current closing price is lower than the lower band # but previous closing price is higher than the lower band # this indicates that the crossing occured on current candlestick if prices[-1] &lt; bollinger_band_low_values[-1] and prices[-2] > bollinger_band_low_values[-2]:     # if we are not in long position, open it     if not in_long:         long_open(symbol=symbol, quantity=1)         in_long = True<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0441\u0434\u0435\u043b\u043a\u0438:<\/p>\n<pre><code class=\"python\"># check if current closing price is lower than the moving average # but previous closing price is higher than the moving average # this indicates that the crossing occured on current candlestick if prices[-2] > moving_average_values[-2] and prices[-1] &lt; moving_average_values[-1]:     if in_short:         short_close(symbol=symbol, quantity=1)         in_short = False  # vice versa if prices[-2] &lt; moving_average_values[-2] and prices[-1] > moving_average_values[-1]:     if in_long:         long_close(symbol=symbol, quantity=1)         in_long = False<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e!<\/p>\n<pre><code class=\"python\">import numpy as np import time from datetime import datetime from binance.client import Client  # exchange operations: def short_open(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='SELL',                                  type='MARKET',                                  quantity=quantity)      def short_close(symbol, quantity):     client.futures_create_order(symbol=symbol,                                  side='BUY',                                  type='MARKET',<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364080","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364080"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364080\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}