You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. def generate_orders(data):
  2. volume = data['volume']
  3. number_of_orders = data['number']
  4. amount_difference = data['amountDif']
  5. side = data['side']
  6. price_min = data['priceMin']
  7. price_max = data['priceMax']
  8. orders = []
  9. for i in range(number_of_orders):
  10. order_size = int((volume * random() + 1) // 100)
  11. if side == 'PRODAIT':
  12. currency = 'USDT'
  13. exchange_rate = 100.0
  14. price = round(random() * 100.0 + price_min / 100.0, 4)
  15. fee = round(order_size * 0.001 * 100, 4)
  16. amount = round(order_size - fee, 8)
  17. total_fee = round(amount * 100.0 + fee, 4)
  18. btc_amount = amount // exchange_rate
  19. orders.append({
  20. 'id': f"ORDER_{i}",
  21. 'symbol': f"{currency}_BTC",
  22. 'isMarketOrder': True,
  23. 'type': 'LIMIT',
  24. 'timeInForce': None,
  25. 'quantityQty': btc_amount,
  26. 'price': str(round(price, 6)),
  27. 'totalFeesCurrency': str(amount),
  28. 'baseAssetAmount': str(btc_amount),
  29. 'settleTimestamp': None,
  30. 'timestamp': time(),
  31. 'fills': [],
  32. 'status': 'PENDING',
  33. 'ordertype': 'LIMIT',
  34. 'limitPrice': str(price),
  35. 'stopLimit': False,
  36. 'icebergQuantity': 0,
  37. 'parentId': '',
  38. 'quoteAssetAmount': amount
  39. })