mango-explorer/scripts/worlds-simplest-market-maker

20 lines
1011 B
Plaintext
Raw Normal View History

2021-06-25 02:33:40 -07:00
#!/usr/bin/env bash
MARKET=${1:-BTC-PERP}
FIXED_POSITION_SIZE=${2:-0.01}
FIXED_SPREAD=${3:-100}
SLEEP_BETWEEN_ORDER_PLACES=${4:-60}
2021-06-25 02:33:40 -07:00
printf "Running on market %s with position size %f and prices +/- %f from current price\nPress Control+C to stop...\n" $MARKET $FIXED_POSITION_SIZE $FIXED_SPREAD
2021-06-25 02:33:40 -07:00
while :
do
cancel-my-orders --market $MARKET --log-level ERROR
CURRENT_PRICE=$(fetch-price --provider serum --symbol $MARKET --log-level ERROR --cluster mainnet-beta | cut -d"'" -f 2 | sed 's/,//')
2021-06-25 02:33:40 -07:00
place-order --market $MARKET --order-type LIMIT --log-level ERROR \
--side BUY --quantity $FIXED_POSITION_SIZE --price $(echo "$CURRENT_PRICE - $FIXED_SPREAD" | bc)
2021-06-25 02:33:40 -07:00
place-order --market $MARKET --order-type LIMIT --log-level ERROR \
--side SELL --quantity $FIXED_POSITION_SIZE --price $(echo "$CURRENT_PRICE + $FIXED_SPREAD" | bc)
2021-06-25 02:33:40 -07:00
echo "Last ${MARKET} market-making action: $(date)" > /var/tmp/mango_healthcheck_worlds_simplest_market_maker
2021-06-25 02:33:40 -07:00
sleep $SLEEP_BETWEEN_ORDER_PLACES
done