SHARE
TWEET

Untitled

a guest Dec 9th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. STEP_PRICE = 15
  2. STEP_PRICE2 = 40
  3. STEP_PRICE3 = 90
  4.  
  5. INIT_PRICE_2 = 4
  6. INIT_PRICE_3 = 7
  7.  
  8. TARGET = 5
  9.  
  10.  
  11.     def prepare_order(self, index):
  12.         """Create an order object."""
  13.  
  14.         acumulado = STEP_PRICE * abs(index)
  15.  
  16.         if abs(index) >= INIT_PRICE_2:
  17.             acumulado += (STEP_PRICE2 - STEP_PRICE) * (abs(index) - INIT_PRICE_2 + 1)
  18.  
  19.         if abs(index) >= INIT_PRICE_3:
  20.             acumulado += (STEP_PRICE3 - STEP_PRICE2) * (abs(index) - INIT_PRICE_3 + 1)
  21.  
  22.         price = int(self.ticker['sell']) - acumulado if index < 0 else int(self.ticker['buy']) + acumulado
  23.  
  24.         quantity = self.primeira_entrada + ((abs(index) - 1) * self.primeira_entrada)
  25.  
  26.         side = "Buy" if index < 0 else "Sell"
  27.  
  28.         return {'price': price, 'orderQty': quantity, 'side': "Buy" if index < 0 else "Sell",
  29.                 'text': '{} {}'.format(side, abs(index))}
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
 
Top