SHARE
TWEET

Untitled

a guest Dec 12th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function getInterestRate() {
  2.     try {
  3.         var bitmexCurrentInterest = 0;
  4.         var bitmexNextInterest = 0;
  5.         var ftxFunding = 0;
  6.         var timetoBitmexFunding = 0;
  7.         var adjustedbitmexFunding = 0;
  8.         const result = await makeRequest('GET', 'instrument/active');
  9.         for (var i = 0; i< result.length; i++)
  10.         {
  11.             if(result[i].symbol == 'XBTUSD')
  12.             {
  13.                 timetoBitmexFunding = moment(result[i].fundingTimestamp).unix() - moment(moment().valueOf()).unix();
  14.                 bitmexCurrentInterest = result[i].fundingRate/8;
  15.                 bitmexNextInterest = result[i].indicativeFundingRate;
  16.             }
  17.         }  
  18.         const data = await ftx.request({
  19.             method: 'GET',
  20.             path: '/futures/BTC-PERP' + '/stats'
  21.         });
  22.         ftxFunding = data.result.nextFundingRate;
  23.         buyInterestAdjust = 0;
  24.         sellInterestAdjust = 0;
  25.         if (timetoBitmexFunding<1800)
  26.         {
  27.             adjustedbitmexFunding = bitmexCurrentInterest*8;
  28.         }
  29.         else if(timetoBitmexFunding<3600)
  30.         {
  31.             adjustedbitmexFunding = bitmexCurrentInterest*4;
  32.         }
  33.         else if(timetoBitmexFunding<7200)
  34.         {
  35.             adjustedbitmexFunding = bitmexCurrentInterest*2;
  36.         }      
  37.         else
  38.         {
  39.             adjustedbitmexFunding = bitmexCurrentInterest;
  40.         }
  41.  
  42.         if(ftxFunding < 0)
  43.         {
  44.             buyInterestAdjust = buyInterestAdjust + ftxFunding*2.5;
  45.             sellInterestAdjust = sellInterestAdjust - ftxFunding*2.5;  
  46.         }
  47.         if(ftxFunding >= 0)
  48.         {
  49.             buyInterestAdjust = buyInterestAdjust + ftxFunding*2.5;
  50.             sellInterestAdjust = sellInterestAdjust - ftxFunding*2.5;
  51.         }
  52.         if(adjustedbitmexFunding<0)
  53.         {
  54.             buyInterestAdjust = buyInterestAdjust + adjustedbitmexFunding;
  55.             sellInterestAdjust = sellInterestAdjust - adjustedbitmexFunding;                   
  56.         }
  57.         if(adjustedbitmexFunding>=0)
  58.         {
  59.             buyInterestAdjust = buyInterestAdjust + adjustedbitmexFunding;
  60.             sellInterestAdjust = sellInterestAdjust - adjustedbitmexFunding;
  61.         }
  62.     } catch (e) {
  63.         if (e.toString().includes('retry in', 0)) {
  64.             sleepforOneMinute('getPosition');
  65.         } else if (e.toString().includes('403 Forbidden', 0)) {
  66.             useProxy = true;
  67.         }
  68.         buyInterestAdjust = 0;
  69.         sellInterestAdjust = 0;
  70.         console.error('getInterestRate ' + e);
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top