-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_examples.py
More file actions
65 lines (53 loc) · 1.96 KB
/
async_examples.py
File metadata and controls
65 lines (53 loc) · 1.96 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import time
from lighter.lighter_client import Client
import os
from lighter.modules.blockchain import OrderSide
private_key = os.environ.get("TEST_SOURCE_PRIVATE_KEY") or "xxx"
api_auth = os.environ.get("TEST_API_AUTH") or "xxx"
# You don't need to provide private key if you only want to use the api module.
client = Client(
private_key=private_key, api_auth=api_auth, web3_provider_url="ALCHEMY_URL"
)
async def main():
client.async_blockchain
sizes = ["0.0001"]
prices = ["100000"]
sides = [OrderSide.SELL]
print(await client.async_api.get_blockchains())
print(await client.async_api.get_orderbook("WETH_USDC"))
print(client.api.get_orderbook("WETH_USDC"))
print(
client.api.get_candles(
orderbook_symbol="WETH_USDC",
resolution=60,
timestamp_start=int(time.time()) - 60 * 60 * 60 * 24,
timestamp_end=int(time.time()),
)
)
tx_hash = await client.async_blockchain.create_limit_order_batch(
"WETH_USDC", sizes, prices, sides
)
# tx_hash = await client.async_blockchain.cancel_limit_order_batch(
# "WETH_USDC", [24989]
# )
# tx_hash = await client.async_blockchain.update_limit_order_batch(
# "WETH_USDC", [24991], ["0.0001"], ["100"], [OrderSide.BUY]
# )
# tx_hash = await client.async_blockchain.create_market_order(
# "WETH_USDC", "0.0001", "100", OrderSide.SELL
# )
result = await client.async_blockchain.get_create_order_transaction_result(
tx_hash, "WETH_USDC"
)
# result = await client.async_blockchain.get_limit_order_canceled_transaction_result(
# tx_hash, "WETH_USDC"
# )
# result = await client.async_blockchain.get_update_limit_order_transaction_result(
# tx_hash, "WETH_USDC"
# )
print(result)
await client.async_api.close_connection()
if __name__ == "__main__":
import asyncio
loop = asyncio.get_event_loop()
loop.run_until_complete(main())