34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from py_clob_client import OrderArgs, OrderType, BalanceAllowanceParams, AssetType
|
|
from py_clob_client.client import ClobClient
|
|
|
|
|
|
# 使用代理钱包
|
|
client = ClobClient(
|
|
host="https://clob.polymarket.com",
|
|
key="0x78517b3a088e693e558177c19466c7fdad0458752618c306afcca8e440964a8a", # 你的主钱包私钥
|
|
chain_id=137,
|
|
signature_type=1, # Magic/Email 登录使用 1
|
|
funder="0xc859c04b0978Af007AcFD7178121E1666C8eB646" # 你的代理钱包地址
|
|
)
|
|
|
|
# 设置 API 凭据
|
|
client.set_api_creds(client.create_or_derive_api_creds())
|
|
|
|
params = BalanceAllowanceParams(
|
|
asset_type=AssetType.COLLATERAL,
|
|
signature_type=1,
|
|
)
|
|
print(client.get_balance_allowance(params))
|
|
|
|
|
|
# # 获取所有活跃市场
|
|
# markets = client.get_markets()
|
|
|
|
# # 搜索特定主题
|
|
# for market in markets["data"]:
|
|
# print(market)
|
|
# if "Trump" in market['question']:
|
|
# print(f"市场:{market['question']}")
|
|
# print(f"Token ID (Yes): {market['tokens'][0]['token_id']}")
|
|
# print(f"Token ID (No): {market['tokens'][1]['token_id']}")
|