-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloop.sh
More file actions
executable file
·61 lines (46 loc) · 1.61 KB
/
loop.sh
File metadata and controls
executable file
·61 lines (46 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# From argument or default to 0
delai=${1:-0}
identity=${2:-tx_sender}
echo "Starting random order generation loop..."
echo "Press Ctrl+C to stop the loop"
read -p "Press enter to start"
function tx {
echo "Next command: $@"
cargo run --bin tx_sender -F nonreproducible -- "$@"
}
# Function to generate random UUID
generate_uuid() {
cat /proc/sys/kernel/random/uuid
}
# Function to generate random number within bounds
random_between() {
local min=$1
local max=$2
echo $((RANDOM % (max - min + 1) + min))
}
mid_price=27500000000
# Loop with random parameters
while true; do
# Generate random parameters
order_id=$(generate_uuid)
side=$([ $((RANDOM % 2)) -eq 0 ] && echo "bid" || echo "ask")
# order_type=$([ $((RANDOM % 2)) -eq 0 ] && echo "limit" || echo "market")
order_type="limit"
# make the price of 1 USDT at each step
mid_price=$((mid_price + 100000))
quantity=$(random_between 10000 50000) # Bid quantity between 10k and 50k
price=$(random_between $((mid_price - 5000000000)) $((mid_price + 5000000000))) # Random price between 20k and 30k (in smallest units)
echo "Generating random order: side=$side, type=$order_type, quantity=$quantity, price=$price"
# Execute the transaction with random parameters
tx --identity $identity create-order \
--order-id $order_id \
--order-side $side \
--order-type $order_type \
--contract-name1 BTC \
--contract-name2 USDT \
--quantity $quantity \
--price $price
# Optional: Add a small delay between transactions
sleep $delai
done