-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Louis Tao
committed
Feb 23, 2024
1 parent
84b854f
commit ef147ea
Showing
5 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import time | ||
|
||
from hyperliquid.utils import constants | ||
from hyperliquid.utils.signing import get_timestamp_ms | ||
import example_utils | ||
|
||
|
||
def main(): | ||
address, info, exchange = example_utils.setup(base_url=constants.TESTNET_API_URL, skip_ws=True) | ||
|
||
# Place an order that should rest by setting the price very low | ||
order_result = exchange.order("ETH", True, 0.2, 1100, {"limit": {"tif": "Gtc"}}) | ||
print(order_result) | ||
|
||
# Query the order status by oid | ||
if order_result["status"] == "ok": | ||
status = order_result["response"]["data"]["statuses"][0] | ||
if "resting" in status: | ||
order_status = info.query_order_by_oid(address, status["resting"]["oid"]) | ||
print("Order status by oid:", order_status) | ||
|
||
# Schedule cancel | ||
cancel_time = get_timestamp_ms() + 10000 # 10 seconds from now | ||
print(exchange.schedule_cancel(cancel_time)) | ||
|
||
time.sleep(10) | ||
print("open orders:", info.open_orders(address)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "hyperliquid-python-sdk" | ||
version = "0.2.2" | ||
version = "0.2.3" | ||
description = "SDK for Hyperliquid API trading with Python." | ||
readme = "README.md" | ||
authors = ["Hyperliquid <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters