I know this question has been asked several times but I cant solve it in my project structure.
I have 3 files:
new_order.js
binance.js
advance.js
new_order.js
is responsible for initializing values and passing it to binance.js
to execute an order.
binance.js
then executes a the order and has a websocket running at all times to wait for the event where the order is filled. Because I can't return values in websockets, I call advance.js
right after the order has been filled.
advance.js
has advance functions like having a stoploss/take profit. The problem I am having is, once the price reaches the stoploss/take profit level, I have to call binance.js
again to execute a sell order.
My flow is new_order.js
-> binance.js
<-> advance.js
.. how can I overcome this issue, and also is it possible to return a value from binance.js
back to new_order.js
from a fulltime running websocket?