{"id":326468,"date":"2021-07-15T09:00:15","date_gmt":"2021-07-15T09:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326468"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326468","title":{"rendered":"\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0441\u0441\u0438\u0432\u043d\u044b\u0439 \u0434\u043e\u0445\u043e\u0434: \u041f\u0438\u0448\u0435\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0434 \u0431\u043e\u0442\u0430 \u043d\u0430 JS (\u0447\u0430\u0441\u0442\u044c 2)"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439. \u041a\u0442\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u043b &#8212; \u043f\u0440\u043e\u0448\u0443 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/post\/562496\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u0418\u0442\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c. \u0411\u044b\u0441\u0442\u0440\u0435\u043d\u044c\u043a\u043e \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0438\u0440\u0436\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u043b\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u043b\u0438\u043c\u0438\u0442\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. <\/p>\n<pre><code class=\"javascript\">const MAX_QUERY_PER_SECOND = 4;  class ApiQueueService {   constructor() {     this.queue = [];     this.executeHistory = [];     this.isRun = false;   }    executeInQueue(method, ...data) {     return new Promise((resolve, reject) =&gt; {       this.addToQueue(method, data, ({ err, data }) =&gt; {         if (err) {           return reject(err);         }         return resolve(data);       });     });   }    addToQueue(method, data, cb) {     this.queue.push({ method, data, cb });     this.run();   }    run(force = false) {     if (this.isRun &amp;&amp; !force) {       return;     }     this.isRun = true;     if (this.isBusy()) {       const timer = setTimeout(() =&gt; {         clearTimeout(timer);         this.run(true);       }, 100);       return;     }     const q = this.getFirst();     if (!q) {       this.isRun = false;       return;     }     this.execute(q).finally(() =&gt; {       this.removeFirst();       if (this.queue.length === 0) {         this.isRun = false;         return;       }       this.run(true);     });   }    getFirst() {     return this.queue &amp;&amp; this.queue[0];   }    removeFirst() {     this.queue.splice(0, 1);   }    isBusy() {     return this.getCountQueryInLastSecond() &gt;= MAX_QUERY_PER_SECOND;   }    getCountQueryInLastSecond() {     const currentTime = +new Date();     this.executeHistory = this.executeHistory.filter((d) =&gt; d.time &gt; (currentTime - 1000));     return this.executeHistory.length;   }    execute(q) {     this.executeHistory.push({ time: +new Date() });     return q.method(...(q.data || [])).then((data) =&gt; {       q.cb({ data });     }).catch((err) =&gt; {       q.cb({ err });     });    } } module.exports = new ApiQueueService();<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>module.exports = new ApiQueueService();<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u0441\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<pre><code class=\"javascript\">const apiQueue = require('.\/services\/copy\/ApiQueueService'); const apiQueue2 = require('.\/services\/copy\/ApiQueueService'); const apiQueue3 = require('.\/services\/copy\/ApiQueueService');  const wait = (t) =&gt; new Promise((resolve) =&gt; setTimeout(() =&gt; resolve(), t));  const testAsync = async (d) =&gt; {   const { t, ...other } = d;   await wait(t);   return other; };  (async () =&gt; {   for (let i = 0; i &lt; 100; i++) {     apiQueue.executeInQueue(testAsync, { t: 100, index: i, fromFile: 1 }).then((d) =&gt; console.log(d));     apiQueue2.executeInQueue(testAsync, { t: 100, index: i, fromFile: 2 }).then((d) =&gt; console.log(d));     apiQueue3.executeInQueue(testAsync, { t: 100, index: i, fromFile: 3 }).then((d) =&gt; console.log(d));   }  })();<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ecd\/cc2\/66f\/ecdcc266f68701736f64b0bd261ad817.gif\" width=\"640\" height=\"769\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u043d\u0430\u0448\u0438\u0445 \u043e\u0440\u0434\u0435\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u043e\u043a\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0438\u0440\u0436\u0435\u0439 \u043f\u043e API \u043a\u043b\u044e\u0447\u0430\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u043b\u043e\u0432\u0438\u0442\u044c \u0438\u0432\u0435\u043d\u0442\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0434\u0435\u0440\u043e\u0432. \u0411\u0438\u043d\u0430\u043d\u0441 \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442:<\/p>\n<pre><code class=\"javascript\">this.api.websockets.userFutureData(       this.marginCallCallback,       this.accountUpdateCallback,       this.orderUpdateCallback,       this.subscribedCallback,       this.accountConfigUpdateCallback, )<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435  <code>orderUpdateCallback<\/code> . \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 &#8212; \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u0440\u0434\u0435\u0440. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441 \u0432 \u0431\u0430\u0437\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0438 &#8212; \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">checkOrder = async (data)=&gt;{     if (data &amp;&amp; data.order) {       try {         const { order } = data         if (order &amp;&amp; order.orderId &amp;&amp; order.orderStatus &amp;&amp; order.executionType === 'TRADE') {           const o = await orderProvider.getOrder(order)           if (o &amp;&amp; o.status !== order.orderStatus) {             o.status = order.orderStatus             await orderProvider.updateOrderCommission(o, order)           }         }       } catch (e) {         this.error('executionTRADE error', e)       }     }   }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c  \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438. \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 <code>WAIT_ENTRY_POINT<\/code> ,<code>IN_PROGRESS<\/code> , <code>COMPLETED<\/code> . \u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><code>WAIT_ENTRY_POINT<\/code>  &#8212; \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u0435\u0447\u0438, \u043f\u0430\u0442\u0435\u0440\u043d\u044b, \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u044b (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438) \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0440\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u043b\u043e\u043d\u0433\/\u0448\u043e\u0440\u0442. \u041f\u043e\u043a\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0432 \u044d\u0442\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 (\u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u043e\u0440\u0434\u0435\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435)<\/p>\n<\/li>\n<li>\n<p><code>IN_PROGRESS<\/code>  &#8212; \u0432 \u044d\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0436\u0435 \u0432 &#171;\u043f\u043e\u0437\u0438\u0446\u0438\u0438&#187; (\u043e\u0440\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u043b\u043e\u043d\u0433\/\u0448\u043e\u0440\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438). \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441 \u0443\u0440\u043e\u0432\u043d\u044f\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0440\u0434\u0435\u0440\u043e\u043c \u0441\u0442\u043e\u043f \u043b\u043e\u0441\u0441. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043e\u0440\u0434\u0435\u0440\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><code>COMPLETED<\/code> &#8212; \u0432 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0418\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0447\u0435\u0442 \u043f\u0440\u0438\u0431\u044b\u043b\u0438\/\u0443\u0431\u044b\u0442\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c <code>WAIT_ENTRY_POINT<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u041f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044e, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>checkStrategy<\/code> \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. <code>Complete<\/code> \u0443 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439, \u0430 \u0432\u043e\u0442 <code>wait<\/code> \u0438 <code>progress<\/code> &#8212; \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0418 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u044b <code>wait<\/code> \u0438 <code>progress<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">class Strategy extends BaseApiService{   constructor(params) {     const { symbol, user, positionSide } = params     super(user.binanceApiKey, user.binanceApiSecret)     this.symbol = symbol     this.user = user     this.positionSide = positionSide   }    async init() {     await this.loadStrategy()     await this.checkStrategy()   }    async checkStrategy() {     await this.loadStrategy()     if (this.strategy.status === STRATEGY.STATUS.WAIT_ENTRY_POINT) {       await this.wait()     } else if (this.strategy.status === STRATEGY.STATUS.IN_PROGRESS) {       await this.progress()     } else if (this.strategy.status === STRATEGY.STATUS.COMPLETED) {       await this.complete()     }   }    async wait() {     \/\/ this should be implemented in parent strategy class   }    async progress() {     \/\/ this should be implemented in parent strategy class   }    async cancelAllOrders() {     if (this.strategy.orders &amp;&amp; Array.isArray(this.strategy.orders)) {       const prs = []       for (const order of this.strategy.orders) {         if (order &amp;&amp; order.orderId &amp;&amp;           ![ORDER.STATUS.FILLED, ORDER.STATUS.CANCELED, ORDER.STATUS.EXPIRED].includes(order.status)) {           prs.push(this.cancelDBOrder(order))         }       }       if (prs.length &gt; 0) {         await Promise.all(prs)       }     }   }    async addOrderToStrategy(order) {     return orderProvider.createOrder({       ...order,       userId: this.user.id,       strategyId: this.strategy.id,     })   }    async complete() {     this.strategy.status = STRATEGY.STATUS.COMPLETED     await this.cancelAllOrders()     await this.strategy.save()     await this.loadStrategy()   }    async loadStrategy() {     this.strategy = await strategyProvider.getCurrentStrategy({       symbol: this.symbol,       userId: this.user.id,       positionSide: this.positionSide,     })     if (!(this.strategy &amp;&amp; this.strategy.id)) {       this.strategy = await strategyProvider.create({         symbol: this.symbol,         userId: this.user.id,         positionSide: this.positionSide,         status: STRATEGY.STATUS.WAIT_ENTRY_POINT,       })     }   } }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0440\u0435\u0439\u0434 \u0431\u043e\u0442\u0430. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0430\u043b\u0437\u0438\u0443\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e. \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 binance \u043a\u0430\u043a \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043e\u0440\u0434\u0435\u0440\u0430 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d \u0440\u0435\u0436\u0438\u043c\u0435<\/p>\n<p><a href=\"https:\/\/github.com\/avkos\/bot\" rel=\"noopener noreferrer nofollow\"><strong>\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 <\/strong><\/a><\/p>\n<\/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\/post\/567836\/\"> https:\/\/habr.com\/ru\/post\/567836\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439. \u041a\u0442\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u043b &#8212; \u043f\u0440\u043e\u0448\u0443 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/post\/562496\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u0418\u0442\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c. \u0411\u044b\u0441\u0442\u0440\u0435\u043d\u044c\u043a\u043e \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0438\u0440\u0436\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u043b\u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u043b\u0438\u043c\u0438\u0442\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. <\/p>\n<pre><code class=\"javascript\">const MAX_QUERY_PER_SECOND = 4;  class ApiQueueService {   constructor() {     this.queue = [];     this.executeHistory = [];     this.isRun = false;   }    executeInQueue(method, ...data) {     return new Promise((resolve, reject) =&gt; {       this.addToQueue(method, data, ({ err, data }) =&gt; {         if (err) {           return reject(err);         }         return resolve(data);       });     });   }    addToQueue(method, data, cb) {     this.queue.push({ method, data, cb });     this.run();   }    run(force = false) {     if (this.isRun &amp;&amp; !force) {       return;     }     this.isRun = true;     if (this.isBusy()) {       const timer = setTimeout(() =&gt; {         clearTimeout(timer);         this.run(true);       }, 100);       return;     }     const q = this.getFirst();     if (!q) {       this.isRun = false;       return;     }     this.execute(q).finally(() =&gt; {       this.removeFirst();       if (this.queue.length === 0) {         this.isRun = false;         return;       }       this.run(true);     });   }    getFirst() {     return this.queue &amp;&amp; this.queue[0];   }    removeFirst() {     this.queue.splice(0, 1);   }    isBusy() {     return this.getCountQueryInLastSecond() &gt;= MAX_QUERY_PER_SECOND;   }    getCountQueryInLastSecond() {     const currentTime = +new Date();     this.executeHistory = this.executeHistory.filter((d) =&gt; d.time &gt; (currentTime - 1000));     return this.executeHistory.length;   }    execute(q) {     this.executeHistory.push({ time: +new Date() });     return q.method(...(q.data || [])).then((data) =&gt; {       q.cb({ data });     }).catch((err) =&gt; {       q.cb({ err });     });    } } module.exports = new ApiQueueService();<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>module.exports = new ApiQueueService();<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u0441\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438:<\/p>\n<pre><code class=\"javascript\">const apiQueue = require('.\/services\/copy\/ApiQueueService'); const apiQueue2 = require('.\/services\/copy\/ApiQueueService'); const apiQueue3 = require('.\/services\/copy\/ApiQueueService');  const wait = (t) =&gt; new Promise((resolve) =&gt; setTimeout(() =&gt; resolve(), t));  const testAsync = async (d) =&gt; {   const { t, ...other } = d;   await wait(t);   return other; };  (async () =&gt; {   for (let i = 0; i &lt; 100; i++) {     apiQueue.executeInQueue(testAsync, { t: 100, index: i, fromFile: 1 }).then((d) =&gt; console.log(d));     apiQueue2.executeInQueue(testAsync, { t: 100, index: i, fromFile: 2 }).then((d) =&gt; console.log(d));     apiQueue3.executeInQueue(testAsync, { t: 100, index: i, fromFile: 3 }).then((d) =&gt; console.log(d));   }  })();<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u043d\u0430\u0448\u0438\u0445 \u043e\u0440\u0434\u0435\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u043e\u043a\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0438\u0440\u0436\u0435\u0439 \u043f\u043e API \u043a\u043b\u044e\u0447\u0430\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u043b\u043e\u0432\u0438\u0442\u044c \u0438\u0432\u0435\u043d\u0442\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0434\u0435\u0440\u043e\u0432. \u0411\u0438\u043d\u0430\u043d\u0441 \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442:<\/p>\n<pre><code class=\"javascript\">this.api.websockets.userFutureData(       this.marginCallCallback,       this.accountUpdateCallback,       this.orderUpdateCallback,       this.subscribedCallback,       this.accountConfigUpdateCallback, )<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435  <code>orderUpdateCallback<\/code> . \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 &#8212; \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u0440\u0434\u0435\u0440. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441 \u0432 \u0431\u0430\u0437\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0438 &#8212; \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">checkOrder = async (data)=&gt;{     if (data &amp;&amp; data.order) {       try {         const { order } = data         if (order &amp;&amp; order.orderId &amp;&amp; order.orderStatus &amp;&amp; order.executionType === 'TRADE') {           const o = await orderProvider.getOrder(order)           if (o &amp;&amp; o.status !== order.orderStatus) {             o.status = order.orderStatus             await orderProvider.updateOrderCommission(o, order)           }         }       } catch (e) {         this.error('executionTRADE error', e)       }     }   }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c  \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438. \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 <code>WAIT_ENTRY_POINT<\/code> ,<code>IN_PROGRESS<\/code> , <code>COMPLETED<\/code> . \u0418 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><code>WAIT_ENTRY_POINT<\/code>  &#8212; \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u0435\u0447\u0438, \u043f\u0430\u0442\u0435\u0440\u043d\u044b, \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u044b (\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438) \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0440\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u043b\u043e\u043d\u0433\/\u0448\u043e\u0440\u0442. \u041f\u043e\u043a\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0432 \u044d\u0442\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 (\u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u043e\u0440\u0434\u0435\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435)<\/p>\n<\/li>\n<li>\n<p><code>IN_PROGRESS<\/code>  &#8212; \u0432 \u044d\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0436\u0435 \u0432 &#171;\u043f\u043e\u0437\u0438\u0446\u0438\u0438&#187; (\u043e\u0440\u0434\u0435\u0440\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u043b\u043e\u043d\u0433\/\u0448\u043e\u0440\u0442 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438). \u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441 \u0443\u0440\u043e\u0432\u043d\u044f\u043c\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0440\u0434\u0435\u0440\u043e\u043c \u0441\u0442\u043e\u043f \u043b\u043e\u0441\u0441. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043e\u0440\u0434\u0435\u0440\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p><code>COMPLETED<\/code> &#8212; \u0432 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u0418\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0447\u0435\u0442 \u043f\u0440\u0438\u0431\u044b\u043b\u0438\/\u0443\u0431\u044b\u0442\u043a\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c <code>WAIT_ENTRY_POINT<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u041f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044e, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>checkStrategy<\/code> \u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. <code>Complete<\/code> \u0443 \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439, \u0430 \u0432\u043e\u0442 <code>wait<\/code> \u0438 <code>progress<\/code> &#8212; \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430. \u0418 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u044b <code>wait<\/code> \u0438 <code>progress<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">class Strategy extends BaseApiService{   constructor(params) {     const { symbol, user, positionSide } = params     super(user.binanceApiKey, user.binanceApiSecret)     this.symbol = symbol     this.user = user     this.positionSide = positionSide   }    async init() {     await this.loadStrategy()     await this.checkStrategy()   }    async checkStrategy() {     await this.loadStrategy()     if (this.strategy.status === STRATEGY.STATUS.WAIT_ENTRY_POINT) {       await this.wait()     } else if (this.strategy.status === STRATEGY.STATUS.IN_PROGRESS) {       await this.progress()     } else if (this.strategy.status === STRATEGY.STATUS.COMPLETED) {       await this.complete()     }   }    async wait() {     \/\/ this should be implemented in parent strategy class   }    async progress() {     \/\/ this should be implemented in parent strategy class   }    async cancelAllOrders() {     if (this.strategy.orders &amp;&amp; Array.isArray(this.strategy.orders)) {       const prs = []       for (const order of this.strategy.orders) {         if (order &amp;&amp; order.orderId &amp;&amp;           ![ORDER.STATUS.FILLED, ORDER.STATUS.CANCELED, ORDER.STATUS.EXPIRED].includes(order.status)) {           prs.push(this.cancelDBOrder(order))         }       }       if (prs.length &gt; 0) {         await Promise.all(prs)       }     }   }    async addOrderToStrategy(order) {     return orderProvider.createOrder({       ...order,       userId: this.user.id,       strategyId: this.strategy.id,     })   }    async complete() {     this.strategy.status = STRATEGY.STATUS.COMPLETED     await this.cancelAllOrders()     await this.strategy.save()     await this.loadStrategy()   }    async loadStrategy() {     this.strategy = await strategyProvider.getCurrentStrategy({       symbol: this.symbol,       userId: this.user.id,       positionSide: this.positionSide,     })     if (!(this.strategy &amp;&amp; this.strategy.id)) {       this.strategy = await strategyProvider.create({         symbol: this.symbol,         userId: this.user.id,         positionSide: this.positionSide,         status: STRATEGY.STATUS.WAIT_ENTRY_POINT,       })     }   } }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0440\u0435\u0439\u0434 \u0431\u043e\u0442\u0430. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0430\u043b\u0437\u0438\u0443\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e. \u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435 binance \u043a\u0430\u043a \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043e\u0440\u0434\u0435\u0440\u0430 \u0432 \u043e\u043d\u043b\u0430\u0439\u043d \u0440\u0435\u0436\u0438\u043c\u0435<\/p>\n<p><a href=\"https:\/\/github.com\/avkos\/bot\" rel=\"noopener noreferrer nofollow\"><strong>\u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 <\/strong><\/a><\/p>\n<\/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\/post\/567836\/\"> https:\/\/habr.com\/ru\/post\/567836\/<\/a><br \/><\/br><\/br><\/p>\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-326468","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326468","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=326468"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326468\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}