-
Notifications
You must be signed in to change notification settings - Fork 505
Expand file tree
/
Copy pathbasic_vault.py
More file actions
27 lines (19 loc) · 916 Bytes
/
basic_vault.py
File metadata and controls
27 lines (19 loc) · 916 Bytes
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
import example_utils
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants
def main():
address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True)
# Change this address to a vault that you lead or a subaccount that you own
vault = "0x1719884eb866cb12b2287399b15f7db5e7d775ea"
# Place an order that should rest by setting the price very low
exchange = Exchange(exchange.wallet, exchange.base_url, vault_address=vault)
order_result = exchange.order("ETH", True, 0.2, 1100, {"limit": {"tif": "Gtc"}})
print(order_result)
# Cancel the order
if order_result["status"] == "ok":
status = order_result["response"]["data"]["statuses"][0]
if "resting" in status:
cancel_result = exchange.cancel("ETH", status["resting"]["oid"])
print(cancel_result)
if __name__ == "__main__":
main()