🛒 show button and place order
%binanceOrder=null
?order
%id=$.id %order
%replyMarkup={"inline_keyboard":[[{ "text": "Выставить ордера", "callback_data": "nid&orid=%id" } ]]}
%tgkeyboard={"text":"#%bot.symbol \n\n Покупка: %bot.price \n\n Таргеты: %ocoLimits \n\n Stop Loss: %bot.stopPrice","chat_id":"%sys.extuid","reply_markup":%replyMarkup}
$SYS.POST
?messageId
$.tgmessageid %order set(%messageId)
$.orders %trade add(%order)
%order=null
?orid
%symbol=$.orders[?(@.id==%orid)].symbol %trade
?symbol
%precision=$.orders[?(@.id==%orid)].precision %trade
?precision
map 💹 check current price
??symbolRate
%stopPrice=$.orders[?(@.id==%orid)].stopPrice %trade
?stopPrice
?symbolRate>%stopPrice
%takePrice=$.orders[?(@.id==%orid)].oco.0.price %trade
?symbolRate<%takePrice
%notification=Размещаю ордер %symbol
%notification=Can't fetch a %symbol priceRate from Binance
map ❌ delete message button
map ❌ delete message button
calc %signature=hash_hmac("SHA256","symbol=%symbol&side=%side&type=%type&timeInForce=GTC&quantity=%quantity&price=%price&recvWindow=50000×tamp=%time","%binanceSecretKey")
%price=$.orders[?(@.id==%orid)].price %trade
calc %quantity=%usdQuantity/%price
%type=LIMIT
%side=BUY
$SYS.POST
Content-Type: application/x-www-form-urlencoded
%originalQuantity=$.origQty %binanceOrder
%originalQuantity=null
NOmap 🚧 binance errors
$.orders[?(@.id==%orid)] %trade remove()
%notification=No stop price at OCO #
%notification=Ордер не может быть выполнен — курс превысил цену стопа, курс: %symbolRate #
%notification=Can't create Order #
%notification=Ордер отменен #
calc %quantity=intval(%quantity*%precision)/%precision
??originalQuantity
%symbol=null
%stopPrice=null
%price=null
X-MBX-APIKEY: %binanceKey
%id=null
QUESTION
%precision=null
recvWindow=50000
%notification=Can't get currency precision #
signature=%signature
ANSWER
%binanceOrder
QUESTION
%tgkeyboard
ANSWER
%messageId=result.message_id
timeInForce=GTC
quantity=%quantity
calc %time=round(%microtime*1000)
price=%price
%messageId=null
type=%type
%orid=null
timestamp=%time
$.pipeOrderId %binanceOrder set(%orid)
side=%side
symbol=%symbol
calc %symbolRate=intval(%symbolRate*%precision)/%precision
%answer
calc %microtime=microtime(1)
$.orders[?(@.id==%orid)].binance %trade set(%binanceOrder)
%replyMarkup=null
%tgkeyboard=null
%notification=Ордер не может быть выполнен — превышена цена тейка, курс: %symbolRate #
%notification=Ордер размещен, я сообщу об исполнении.
map ❌ delete message button
%orid=null
map 🛒 check status and place OCO order