-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathGTD_order.py
39 lines (30 loc) · 1.03 KB
/
GTD_order.py
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
import os
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds, OrderArgs, OrderType
from dotenv import load_dotenv
from py_clob_client.constants import AMOY
from py_clob_client.order_builder.constants import BUY
load_dotenv()
def main():
host = "http://localhost:8080"
key = os.getenv("PK")
creds = ApiCreds(
api_key=os.getenv("CLOB_API_KEY"),
api_secret=os.getenv("CLOB_SECRET"),
api_passphrase=os.getenv("CLOB_PASS_PHRASE"),
)
chain_id = AMOY
client = ClobClient(host, key=key, chain_id=chain_id, creds=creds)
# Create and sign a limit order buying 100 YES tokens for 0.50c each
order_args = OrderArgs(
price=0.50,
size=100.0,
side=BUY,
token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563",
expiration="1000000000000",
)
signed_order = client.create_order(order_args)
resp = client.post_order(signed_order, OrderType.GTD)
print(resp)
print("Done!")
main()