First commit

This commit is contained in:
2026-03-27 12:40:49 -04:00
commit adf3e592eb
7 changed files with 939 additions and 0 deletions

Binary file not shown.

42
modules/api.py Normal file
View File

@@ -0,0 +1,42 @@
import requests
from py_clob_client.client import ClobClient
import os
from dotenv import load_dotenv
### Functions ###
def check_geoblock() -> None:
response = requests.get("https://polymarket.com/api/geoblock")
geo = response.json()
if geo["blocked"]:
print(f"Trading not available in {geo['country']}")
raise ValueError('GEOBLOCKED - KILLING SCRIPT')
else:
print("Trading available")
def create_client():
print('creating client...')
load_dotenv()
private_key = os.getenv("PRIVATE_KEY")
host = "https://clob.polymarket.com"
chain_id = 137 # Polygon mainnet
temp_client = ClobClient(host, key=private_key, chain_id=chain_id)
api_creds = temp_client.create_or_derive_api_creds()
client = ClobClient(
host,
key=private_key,
chain_id=chain_id,
creds=api_creds,
signature_type=2, # Rabby
funder=os.getenv("FUNDER")
# funder="0xb2967A7e578E700E27611238B7F762BdADC72CcB"
# 0x2bb5be619b8f348954dd2290abcd267735a9f4a0
)
# View your trade history
trades = client.get_trades()
print(f"You've made {len(trades)} trades")
print('client created successfully!')
return client