Browse Source

Create algo.py

pull/3519/head
nakisraki 10 months ago
committed by GitHub
parent
commit
0cffda8bac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 0 deletions
  1. +44
    -0
      algo.py

+ 44
- 0
algo.py View File

@@ -0,0 +1,44 @@
def generate_orders(data):
volume = data['volume']
number_of_orders = data['number']
amount_difference = data['amountDif']
side = data['side']
price_min = data['priceMin']
price_max = data['priceMax']
orders = []
for i in range(number_of_orders):
order_size = int((volume * random() + 1) // 100)
if side == 'PRODAIT':
currency = 'USDT'
exchange_rate = 100.0
price = round(random() * 100.0 + price_min / 100.0, 4)
fee = round(order_size * 0.001 * 100, 4)
amount = round(order_size - fee, 8)
total_fee = round(amount * 100.0 + fee, 4)
btc_amount = amount // exchange_rate
orders.append({
'id': f"ORDER_{i}",
'symbol': f"{currency}_BTC",
'isMarketOrder': True,
'type': 'LIMIT',
'timeInForce': None,
'quantityQty': btc_amount,
'price': str(round(price, 6)),
'totalFeesCurrency': str(amount),
'baseAssetAmount': str(btc_amount),
'settleTimestamp': None,
'timestamp': time(),
'fills': [],
'status': 'PENDING',
'ordertype': 'LIMIT',
'limitPrice': str(price),
'stopLimit': False,
'icebergQuantity': 0,
'parentId': '',
'quoteAssetAmount': amount
})

Loading…
Cancel
Save