Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STEP_PRICE = 15
- STEP_PRICE2 = 40
- STEP_PRICE3 = 90
- INIT_PRICE_2 = 4
- INIT_PRICE_3 = 7
- TARGET = 5
- def prepare_order(self, index):
- """Create an order object."""
- acumulado = STEP_PRICE * abs(index)
- if abs(index) >= INIT_PRICE_2:
- acumulado += (STEP_PRICE2 - STEP_PRICE) * (abs(index) - INIT_PRICE_2 + 1)
- if abs(index) >= INIT_PRICE_3:
- acumulado += (STEP_PRICE3 - STEP_PRICE2) * (abs(index) - INIT_PRICE_3 + 1)
- price = int(self.ticker['sell']) - acumulado if index < 0 else int(self.ticker['buy']) + acumulado
- quantity = self.primeira_entrada + ((abs(index) - 1) * self.primeira_entrada)
- side = "Buy" if index < 0 else "Sell"
- return {'price': price, 'orderQty': quantity, 'side': "Buy" if index < 0 else "Sell",
- 'text': '{} {}'.format(side, abs(index))}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement