2021-06-25 02:33:40 -07:00
#!/usr/bin/env bash
2021-06-30 06:08:37 -07:00
MARKET=${1:-BTC-PERP}
2021-07-13 12:01:32 -07:00
FIXED_POSITION_SIZE=${2:-0.01}
FIXED_SPREAD=${3:-100}
SLEEP_BETWEEN_ORDER_PLACES=${4:-60}
2021-07-14 06:39:09 -07:00
ORACLE_MARKET=${MARKET//\-PERP/\/USDC}
2021-06-25 02:33:40 -07:00
2021-07-13 12:01:32 -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
2021-08-09 08:39:40 -07:00
cancel-my-orders --name "WSMM ${MARKET} (cancel)" --market $MARKET --log-level ERROR
2021-06-25 02:33:40 -07:00
2021-08-26 02:31:02 -07:00
CURRENT_PRICE=$(fetch-price --provider serum --symbol $ORACLE_MARKET --log-level ERROR --cluster-name mainnet | cut -d"'" -f 2 | sed 's/,//')
2021-08-09 08:39:40 -07:00
place-order --name "WSMM ${MARKET} (buy)" --market $MARKET --order-type LIMIT \
--log-level ERROR --side BUY --quantity $FIXED_POSITION_SIZE --price $(echo "$CURRENT_PRICE - $FIXED_SPREAD" | bc)
place-order --name "WSMM ${MARKET} (sell)" --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
2021-07-14 06:17:14 -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