demo and fix python
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
21b27feef6
commit
7830496938
|
@ -12,6 +12,7 @@ Directory structure
|
|||
.
|
||||
├── README.md
|
||||
├── mango-service-v3 - REST API Service for mango markets version 3
|
||||
├── mango-vial - WEBSOCKET API Service for L1, L2 orderbook data for mango markets version 3
|
||||
└── py - python3 client for above REST API Service
|
||||
```
|
||||
# Todos
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "cancel all orders"
|
||||
echo "curl --location --request DELETE 'http://localhost:3000/api/orders'"
|
||||
|
||||
curl --location --request DELETE 'http://localhost:3000/api/orders'
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
./get_balances.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./get_candles.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./get_coins.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./get_markets.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./get_orders.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./cancel_all_orders.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./post_order.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
||||
|
||||
./get_orders.sh
|
||||
echo "\n\n"
|
||||
sleep 1
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show USDC balance for user"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/wallet/balances' \
|
||||
--data-raw '' | jq '.result[8]'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/wallet/balances' \
|
||||
--data-raw '' | jq '.result[8]'
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show candles for a BTC-PERP"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/candles?resolution=60&start_time=1625922900&end_time=1631214960' | jq '.result[8]'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/candles?resolution=60&start_time=1625922900&end_time=1631214960' | jq '.result[8]'
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show a random coin availbale to trade"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/coins' \
|
||||
--data-raw '' | jq '.result[8]'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/coins' \
|
||||
--data-raw '' | jq '.result[8]'
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show BTC-PERP market"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP' | jq '.result'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP' | jq '.result'
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show orderbook"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/orderbook?depth=30' | jq '.result.asks[0]"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/orderbook?depth=30' | jq '.result.asks[0]
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show all orders"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/orders' \
|
||||
--data-raw '' | jq '.result'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/orders' \
|
||||
--data-raw '' | jq '.result'
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show all positions"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/positions' \
|
||||
--data-raw '' | jq '.result[0]'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/positions' \
|
||||
--data-raw '' | jq '.result[0]'
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "show a random trade"
|
||||
echo "curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/trades' | jq '.result[0]'"
|
||||
|
||||
curl -s --location --request GET 'http://localhost:3000/api/markets/BTC-PERP/trades' | jq '.result[0]'
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
echo "place order"
|
||||
cat << EOF
|
||||
curl -s --location --request POST 'http://localhost:3000/api/orders' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"market": "BTC-PERP",
|
||||
"side": "buy",
|
||||
"price": 20000,
|
||||
"type": "limit",
|
||||
"size": 0.0001,
|
||||
"reduceOnly": false,
|
||||
"ioc": false,
|
||||
"postOnly": false,
|
||||
"clientId": "870"
|
||||
}
|
||||
' | jq .
|
||||
EOF
|
||||
|
||||
curl -s --location --request POST 'http://localhost:3000/api/orders' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"market": "BTC-PERP",
|
||||
"side": "buy",
|
||||
"price": 20000,
|
||||
"type": "limit",
|
||||
"size": 0.0001,
|
||||
"reduceOnly": false,
|
||||
"ioc": false,
|
||||
"postOnly": false,
|
||||
"clientId": "870"
|
||||
}
|
||||
'
|
|
@ -33,7 +33,7 @@ def delayed(seconds):
|
|||
|
||||
|
||||
class MangoServiceV3Client:
|
||||
def __init__(self, base_url, timeout):
|
||||
def __init__(self, base_url=None, timeout=None):
|
||||
self.timeout = timeout if timeout else 10.0
|
||||
if base_url:
|
||||
self.BASE_URL = base_url
|
||||
|
|
Loading…
Reference in New Issue