Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. ftxFix.on('error', async err => {
  2. console.error(err)
  3. console.log('try to reconnect Ftx Fix Server later..')
  4. utils.sleep(3000)
  5. ftxFix.reconnect()
  6. })
  7.  
  8. async function connectFix() {
  9. ftxFix.connect(err => {
  10. if (err) {
  11. throw err
  12. } else {
  13. console.log('FTX FIX connect success')
  14. }
  15. })
  16. await utils.sleep(5000);
  17. if (ftxFix.connected && ftxFix.authenticated) {
  18. ftxFix.subscribeReport(report => {
  19. console.debug(report)
  20. })
  21. }
  22.  
  23. }
  24.  
  25. connectFix()
  26.  
  27. async function FIXSendOrder(future, side, price, size, ioc, clientID) {
  28. if (ftxFix.connected && ftxFix.authenticated) {
  29. ftxFix.newOrder(
  30. {
  31. ClOrdID: clientID,
  32. Symbol: future,
  33. OrdType: '2',
  34. OrderQty: size,
  35. Price: price,
  36. Side: side,
  37. TimeInForce: ioc
  38. },
  39. (err, msg) => {
  40. console.debug(msg)
  41. }
  42. )
  43. }
  44. await utils.sleep(1500);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement