hyperquant 1.56__tar.gz → 1.58__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hyperquant-1.56 → hyperquant-1.58}/PKG-INFO +1 -1
- {hyperquant-1.56 → hyperquant-1.58}/pyproject.toml +1 -1
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/polymarket.py +264 -26
- {hyperquant-1.56 → hyperquant-1.58}/uv.lock +1 -1
- {hyperquant-1.56 → hyperquant-1.58}/.gitignore +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/README.md +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/requirements-dev.lock +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/requirements.lock +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/__init__.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/auth.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/bitget.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/bitmart.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/coinw.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/deepcoin.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/edgex.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/hyperliquid.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lbank.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/edgex_sign.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/hpstore.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/hyper_types.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/polymarket/ctfAbi.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/polymarket/safeAbi.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lib/util.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/lighter.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/apexpro.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/bitget.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/bitmart.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/coinw.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/deepcoin.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/edgex.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/hyperliquid.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/lbank.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/lighter.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/ourbit.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/models/polymarket.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/ourbit.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/broker/ws.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/core.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/datavison/_util.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/datavison/binance.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/datavison/coinglass.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/datavison/okx.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/db.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/draw.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/logkit.py +0 -0
- {hyperquant-1.56 → hyperquant-1.58}/src/hyperquant/notikit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyperquant
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.58
|
|
4
4
|
Summary: A minimal yet hyper-efficient backtesting framework for quantitative trading
|
|
5
5
|
Project-URL: Homepage, https://github.com/yourusername/hyperquant
|
|
6
6
|
Project-URL: Issues, https://github.com/yourusername/hyperquant/issues
|
|
@@ -8,7 +8,7 @@ from functools import lru_cache
|
|
|
8
8
|
import os
|
|
9
9
|
import time
|
|
10
10
|
from typing import Any, Awaitable, Callable, Iterable, Iterator, Literal, Mapping, Sequence
|
|
11
|
-
from urllib.parse import urlsplit, urlunsplit
|
|
11
|
+
from urllib.parse import urlencode, urlsplit, urlunsplit
|
|
12
12
|
|
|
13
13
|
import json
|
|
14
14
|
|
|
@@ -232,7 +232,8 @@ class Polymarket:
|
|
|
232
232
|
private_key: str | None = None,
|
|
233
233
|
chain_id: int | None = None,
|
|
234
234
|
signature_type: int | None = None,
|
|
235
|
-
funder: str | None = None
|
|
235
|
+
funder: str | None = None,
|
|
236
|
+
forward_url: str | None = None, # geoblock转发
|
|
236
237
|
) -> None:
|
|
237
238
|
# Logger (per-class, safe default)
|
|
238
239
|
self.logger = logging.getLogger(f"{API_NAME}.{self.__class__.__name__}")
|
|
@@ -247,6 +248,7 @@ class Polymarket:
|
|
|
247
248
|
self.client = client
|
|
248
249
|
self.rest_api = (rest_api or DEFAULT_REST_ENDPOINT).rstrip("/")
|
|
249
250
|
self.ws_public = ws_public or DEFAULT_WS_ENDPOINT
|
|
251
|
+
self.forward_url = forward_url
|
|
250
252
|
|
|
251
253
|
self.chain_id = chain_id or 137
|
|
252
254
|
# Default to POLY_GNOSIS_SAFE (2) to match common proxy flows used in examples/tests.
|
|
@@ -315,7 +317,7 @@ class Polymarket:
|
|
|
315
317
|
concurrency: int = 5,
|
|
316
318
|
callback: Callable[[dict[str, Any]], Awaitable[None] | None] | None = None,
|
|
317
319
|
) -> None:
|
|
318
|
-
"""Mount forward execution for
|
|
320
|
+
"""Mount forward execution for order placement and cancellation endpoints."""
|
|
319
321
|
cfg = {
|
|
320
322
|
"mode": mode,
|
|
321
323
|
"url": url,
|
|
@@ -802,13 +804,19 @@ class Polymarket:
|
|
|
802
804
|
|
|
803
805
|
async def create_api_key(self, nonce: int | None = None) -> dict[str, Any]:
|
|
804
806
|
params = {"nonce": nonce} if nonce is not None else None
|
|
805
|
-
|
|
807
|
+
if self.forward_url:
|
|
808
|
+
data = await self._forward_l1_auth_request("POST", "/auth/api-key", params=params)
|
|
809
|
+
else:
|
|
810
|
+
data = await self._rest("POST", "/auth/api-key", params=params)
|
|
806
811
|
self._store_api_creds(data)
|
|
807
812
|
return data
|
|
808
813
|
|
|
809
814
|
async def derive_api_key(self, nonce: int | None = None) -> dict[str, Any]:
|
|
810
815
|
params = {"nonce": nonce} if nonce is not None else None
|
|
811
|
-
|
|
816
|
+
if self.forward_url:
|
|
817
|
+
data = await self._forward_l1_auth_request("GET", "/auth/derive-api-key", params=params)
|
|
818
|
+
else:
|
|
819
|
+
data = await self._rest("GET", "/auth/derive-api-key", params=params)
|
|
812
820
|
self._store_api_creds(data)
|
|
813
821
|
return data
|
|
814
822
|
|
|
@@ -1506,6 +1514,135 @@ class Polymarket:
|
|
|
1506
1514
|
"Content-Type": "application/json",
|
|
1507
1515
|
}
|
|
1508
1516
|
|
|
1517
|
+
def _build_l1_signed_headers(self, *, nonce: int = 0) -> dict[str, str]:
|
|
1518
|
+
from eth_account import Account as _A
|
|
1519
|
+
try:
|
|
1520
|
+
from eth_account.messages import encode_typed_data as _enc
|
|
1521
|
+
except ImportError:
|
|
1522
|
+
from eth_account.messages import encode_structured_data as _enc
|
|
1523
|
+
|
|
1524
|
+
private_key, _, signer_addr = self._get_signing_context()
|
|
1525
|
+
timestamp = int(time.time())
|
|
1526
|
+
typed_data = {
|
|
1527
|
+
"types": {
|
|
1528
|
+
"EIP712Domain": [
|
|
1529
|
+
{"name": "name", "type": "string"},
|
|
1530
|
+
{"name": "version", "type": "string"},
|
|
1531
|
+
{"name": "chainId", "type": "uint256"},
|
|
1532
|
+
],
|
|
1533
|
+
"ClobAuth": [
|
|
1534
|
+
{"name": "address", "type": "address"},
|
|
1535
|
+
{"name": "timestamp", "type": "string"},
|
|
1536
|
+
{"name": "nonce", "type": "uint256"},
|
|
1537
|
+
{"name": "message", "type": "string"},
|
|
1538
|
+
],
|
|
1539
|
+
},
|
|
1540
|
+
"domain": {
|
|
1541
|
+
"name": "ClobAuthDomain",
|
|
1542
|
+
"version": "1",
|
|
1543
|
+
"chainId": int(self.chain_id),
|
|
1544
|
+
},
|
|
1545
|
+
"primaryType": "ClobAuth",
|
|
1546
|
+
"message": {
|
|
1547
|
+
"address": signer_addr,
|
|
1548
|
+
"timestamp": str(timestamp),
|
|
1549
|
+
"nonce": int(nonce),
|
|
1550
|
+
"message": "This message attests that I control the given wallet",
|
|
1551
|
+
},
|
|
1552
|
+
}
|
|
1553
|
+
encoded = _enc(full_message=typed_data)
|
|
1554
|
+
signature = _A.sign_message(encoded, private_key).signature.hex()
|
|
1555
|
+
if not signature.startswith("0x"):
|
|
1556
|
+
signature = f"0x{signature}"
|
|
1557
|
+
return {
|
|
1558
|
+
"POLY_ADDRESS": signer_addr,
|
|
1559
|
+
"POLY_SIGNATURE": signature,
|
|
1560
|
+
"POLY_TIMESTAMP": str(timestamp),
|
|
1561
|
+
"POLY_NONCE": str(int(nonce)),
|
|
1562
|
+
"Content-Type": "application/json",
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
async def _forward_l1_auth_request(
|
|
1566
|
+
self,
|
|
1567
|
+
method: str,
|
|
1568
|
+
path: str,
|
|
1569
|
+
*,
|
|
1570
|
+
params: Mapping[str, Any] | None = None,
|
|
1571
|
+
) -> dict[str, Any]:
|
|
1572
|
+
session: aiohttp.ClientSession = getattr(self.client, "_session", None)
|
|
1573
|
+
if session is None:
|
|
1574
|
+
raise RuntimeError("pybotters client session missing")
|
|
1575
|
+
if not self.forward_url:
|
|
1576
|
+
raise RuntimeError("forward_url is required for forward auth request")
|
|
1577
|
+
|
|
1578
|
+
nonce = 0
|
|
1579
|
+
if params and "nonce" in params:
|
|
1580
|
+
try:
|
|
1581
|
+
nonce = int(params["nonce"])
|
|
1582
|
+
except (TypeError, ValueError):
|
|
1583
|
+
nonce = 0
|
|
1584
|
+
|
|
1585
|
+
query = urlencode(dict(params), doseq=True) if params else ""
|
|
1586
|
+
url = f"{self.rest_api.rstrip('/')}{path}"
|
|
1587
|
+
if query:
|
|
1588
|
+
url = f"{url}?{query}"
|
|
1589
|
+
req = {
|
|
1590
|
+
"method": method.upper(),
|
|
1591
|
+
"url": url,
|
|
1592
|
+
"headers": self._build_l1_signed_headers(nonce=nonce),
|
|
1593
|
+
"body": None,
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
endpoint = self._normalize_forward_batch_url(self.forward_url)
|
|
1597
|
+
async with session.post(endpoint, json={"requests": [req]}) as resp:
|
|
1598
|
+
if resp.status >= 400:
|
|
1599
|
+
text = await resp.text()
|
|
1600
|
+
raise RuntimeError(f"Forward auth request failed: {resp.status} {text}")
|
|
1601
|
+
payload = await resp.json(content_type=None)
|
|
1602
|
+
|
|
1603
|
+
first: Any
|
|
1604
|
+
if isinstance(payload, list):
|
|
1605
|
+
first = payload[0] if payload else {}
|
|
1606
|
+
elif isinstance(payload, dict):
|
|
1607
|
+
for key in ("responses", "results", "data"):
|
|
1608
|
+
value = payload.get(key)
|
|
1609
|
+
if isinstance(value, list):
|
|
1610
|
+
first = value[0] if value else {}
|
|
1611
|
+
break
|
|
1612
|
+
else:
|
|
1613
|
+
first = payload
|
|
1614
|
+
else:
|
|
1615
|
+
raise RuntimeError(f"Unexpected forward response: {payload!r}")
|
|
1616
|
+
|
|
1617
|
+
def _parse_maybe_json(data: Any) -> Any:
|
|
1618
|
+
if isinstance(data, str):
|
|
1619
|
+
text = data.strip()
|
|
1620
|
+
try:
|
|
1621
|
+
return json.loads(text)
|
|
1622
|
+
except Exception:
|
|
1623
|
+
return text
|
|
1624
|
+
return data
|
|
1625
|
+
|
|
1626
|
+
if isinstance(first, dict):
|
|
1627
|
+
# worker forwarder shape: { ok, status, bodyPreview }
|
|
1628
|
+
if first.get("ok") is False or int(first.get("status", 200)) >= 400:
|
|
1629
|
+
detail = _parse_maybe_json(first.get("bodyPreview") or first.get("body") or first)
|
|
1630
|
+
raise RuntimeError(
|
|
1631
|
+
f"Forward upstream auth failed: status={first.get('status')} detail={detail!r}"
|
|
1632
|
+
)
|
|
1633
|
+
|
|
1634
|
+
body = _parse_maybe_json(first.get("body"))
|
|
1635
|
+
if isinstance(body, dict):
|
|
1636
|
+
return body
|
|
1637
|
+
|
|
1638
|
+
preview = _parse_maybe_json(first.get("bodyPreview"))
|
|
1639
|
+
if isinstance(preview, dict):
|
|
1640
|
+
return preview
|
|
1641
|
+
|
|
1642
|
+
if all(k in first for k in ("apiKey", "secret", "passphrase")):
|
|
1643
|
+
return first
|
|
1644
|
+
raise RuntimeError(f"Forward response missing auth body: {payload!r}")
|
|
1645
|
+
|
|
1509
1646
|
async def _submit_forward_requests(self, requests_payload: Sequence[Mapping[str, Any]]) -> Any:
|
|
1510
1647
|
cfg = self._forward_orders_cfg
|
|
1511
1648
|
if not cfg:
|
|
@@ -1549,6 +1686,33 @@ class Polymarket:
|
|
|
1549
1686
|
"count": len(requests_payload),
|
|
1550
1687
|
}
|
|
1551
1688
|
|
|
1689
|
+
def _build_forward_signed_request(
|
|
1690
|
+
self,
|
|
1691
|
+
*,
|
|
1692
|
+
method: str,
|
|
1693
|
+
path: str,
|
|
1694
|
+
payload: Any,
|
|
1695
|
+
signer_addr: str,
|
|
1696
|
+
api_key: str,
|
|
1697
|
+
api_secret: str,
|
|
1698
|
+
api_passphrase: str,
|
|
1699
|
+
) -> dict[str, Any]:
|
|
1700
|
+
headers = self._build_l2_signed_headers(
|
|
1701
|
+
signer_addr=signer_addr,
|
|
1702
|
+
api_key=api_key,
|
|
1703
|
+
api_secret=api_secret,
|
|
1704
|
+
api_passphrase=api_passphrase,
|
|
1705
|
+
method=method,
|
|
1706
|
+
path=path,
|
|
1707
|
+
payload=payload,
|
|
1708
|
+
)
|
|
1709
|
+
return {
|
|
1710
|
+
"method": method.upper(),
|
|
1711
|
+
"url": f"{self.rest_api.rstrip('/')}{path}",
|
|
1712
|
+
"headers": headers,
|
|
1713
|
+
"body": payload,
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1552
1716
|
async def post_orders(
|
|
1553
1717
|
self,
|
|
1554
1718
|
orders: Iterable[tuple[Mapping[str, Any], str]],
|
|
@@ -1679,7 +1843,35 @@ class Polymarket:
|
|
|
1679
1843
|
"""
|
|
1680
1844
|
{'not_canceled': {}, 'canceled': ['0xb3507e9fda9541c3e038afcb4f24b96efcfa667d46cf5e9e52c41620711818df', '0x4b9c3ee4dee8653f15f716653e8ac83f0a086a38597e6ec4b72be2389c79b8b4']}
|
|
1681
1845
|
"""
|
|
1682
|
-
|
|
1846
|
+
payload = {"orderID": order_id}
|
|
1847
|
+
if self._forward_orders_cfg:
|
|
1848
|
+
session: aiohttp.ClientSession = getattr(self.client, "_session", None)
|
|
1849
|
+
if session is None:
|
|
1850
|
+
raise RuntimeError("pybotters client session missing")
|
|
1851
|
+
creds = getattr(session, "_polymarket_api_creds", None)
|
|
1852
|
+
if not creds:
|
|
1853
|
+
raise RuntimeError("Polymarket API creds missing; call create_or_derive_api_creds")
|
|
1854
|
+
api_key = creds.get("api_key")
|
|
1855
|
+
api_secret = creds.get("api_secret")
|
|
1856
|
+
api_passphrase = creds.get("api_passphrase")
|
|
1857
|
+
if not (api_key and api_secret and api_passphrase):
|
|
1858
|
+
raise RuntimeError("Polymarket API creds incomplete")
|
|
1859
|
+
|
|
1860
|
+
_, _, signer_addr = self._get_signing_context()
|
|
1861
|
+
requests_payload = [
|
|
1862
|
+
self._build_forward_signed_request(
|
|
1863
|
+
method="DELETE",
|
|
1864
|
+
path="/order",
|
|
1865
|
+
payload=payload,
|
|
1866
|
+
signer_addr=signer_addr,
|
|
1867
|
+
api_key=api_key,
|
|
1868
|
+
api_secret=api_secret,
|
|
1869
|
+
api_passphrase=api_passphrase,
|
|
1870
|
+
)
|
|
1871
|
+
]
|
|
1872
|
+
return await self._submit_forward_requests(requests_payload)
|
|
1873
|
+
|
|
1874
|
+
return await self._signed_request_via_session("DELETE", "/order", payload)
|
|
1683
1875
|
|
|
1684
1876
|
async def cancel_orders(
|
|
1685
1877
|
self,
|
|
@@ -1703,22 +1895,16 @@ class Polymarket:
|
|
|
1703
1895
|
raise RuntimeError("Polymarket API creds incomplete")
|
|
1704
1896
|
|
|
1705
1897
|
_, _, signer_addr = self._get_signing_context()
|
|
1706
|
-
headers = self._build_l2_signed_headers(
|
|
1707
|
-
signer_addr=signer_addr,
|
|
1708
|
-
api_key=api_key,
|
|
1709
|
-
api_secret=api_secret,
|
|
1710
|
-
api_passphrase=api_passphrase,
|
|
1711
|
-
method="DELETE",
|
|
1712
|
-
path="/orders",
|
|
1713
|
-
payload=payload,
|
|
1714
|
-
)
|
|
1715
1898
|
requests_payload = [
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
"
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1899
|
+
self._build_forward_signed_request(
|
|
1900
|
+
method="DELETE",
|
|
1901
|
+
path="/orders",
|
|
1902
|
+
payload=payload,
|
|
1903
|
+
signer_addr=signer_addr,
|
|
1904
|
+
api_key=api_key,
|
|
1905
|
+
api_secret=api_secret,
|
|
1906
|
+
api_passphrase=api_passphrase,
|
|
1907
|
+
)
|
|
1722
1908
|
]
|
|
1723
1909
|
return await self._submit_forward_requests(requests_payload)
|
|
1724
1910
|
|
|
@@ -1728,10 +1914,65 @@ class Polymarket:
|
|
|
1728
1914
|
"""
|
|
1729
1915
|
{'not_canceled': {}, 'canceled': ['0xb3507e9fda9541c3e038afcb4f24b96efcfa667d46cf5e9e52c41620711818df', '0x4b9c3ee4dee8653f15f716653e8ac83f0a086a38597e6ec4b72be2389c79b8b4']}
|
|
1730
1916
|
"""
|
|
1731
|
-
|
|
1917
|
+
payload = None
|
|
1918
|
+
if self._forward_orders_cfg:
|
|
1919
|
+
session: aiohttp.ClientSession = getattr(self.client, "_session", None)
|
|
1920
|
+
if session is None:
|
|
1921
|
+
raise RuntimeError("pybotters client session missing")
|
|
1922
|
+
creds = getattr(session, "_polymarket_api_creds", None)
|
|
1923
|
+
if not creds:
|
|
1924
|
+
raise RuntimeError("Polymarket API creds missing; call create_or_derive_api_creds")
|
|
1925
|
+
api_key = creds.get("api_key")
|
|
1926
|
+
api_secret = creds.get("api_secret")
|
|
1927
|
+
api_passphrase = creds.get("api_passphrase")
|
|
1928
|
+
if not (api_key and api_secret and api_passphrase):
|
|
1929
|
+
raise RuntimeError("Polymarket API creds incomplete")
|
|
1930
|
+
|
|
1931
|
+
_, _, signer_addr = self._get_signing_context()
|
|
1932
|
+
requests_payload = [
|
|
1933
|
+
self._build_forward_signed_request(
|
|
1934
|
+
method="DELETE",
|
|
1935
|
+
path="/cancel-all",
|
|
1936
|
+
payload=payload,
|
|
1937
|
+
signer_addr=signer_addr,
|
|
1938
|
+
api_key=api_key,
|
|
1939
|
+
api_secret=api_secret,
|
|
1940
|
+
api_passphrase=api_passphrase,
|
|
1941
|
+
)
|
|
1942
|
+
]
|
|
1943
|
+
return await self._submit_forward_requests(requests_payload)
|
|
1944
|
+
|
|
1945
|
+
return await self._signed_request_via_session("DELETE", "/cancel-all", payload)
|
|
1732
1946
|
|
|
1733
1947
|
async def cancel_market_orders(self, market: str = "", asset_id: str = "") -> Any:
|
|
1734
1948
|
body = {"market": market, "asset_id": asset_id}
|
|
1949
|
+
if self._forward_orders_cfg:
|
|
1950
|
+
session: aiohttp.ClientSession = getattr(self.client, "_session", None)
|
|
1951
|
+
if session is None:
|
|
1952
|
+
raise RuntimeError("pybotters client session missing")
|
|
1953
|
+
creds = getattr(session, "_polymarket_api_creds", None)
|
|
1954
|
+
if not creds:
|
|
1955
|
+
raise RuntimeError("Polymarket API creds missing; call create_or_derive_api_creds")
|
|
1956
|
+
api_key = creds.get("api_key")
|
|
1957
|
+
api_secret = creds.get("api_secret")
|
|
1958
|
+
api_passphrase = creds.get("api_passphrase")
|
|
1959
|
+
if not (api_key and api_secret and api_passphrase):
|
|
1960
|
+
raise RuntimeError("Polymarket API creds incomplete")
|
|
1961
|
+
|
|
1962
|
+
_, _, signer_addr = self._get_signing_context()
|
|
1963
|
+
requests_payload = [
|
|
1964
|
+
self._build_forward_signed_request(
|
|
1965
|
+
method="DELETE",
|
|
1966
|
+
path="/cancel-market-orders",
|
|
1967
|
+
payload=body,
|
|
1968
|
+
signer_addr=signer_addr,
|
|
1969
|
+
api_key=api_key,
|
|
1970
|
+
api_secret=api_secret,
|
|
1971
|
+
api_passphrase=api_passphrase,
|
|
1972
|
+
)
|
|
1973
|
+
]
|
|
1974
|
+
return await self._submit_forward_requests(requests_payload)
|
|
1975
|
+
|
|
1735
1976
|
return await self._signed_request_via_session("DELETE", "/cancel-market-orders", body)
|
|
1736
1977
|
|
|
1737
1978
|
async def get_order(self, order_id: str) -> Any:
|
|
@@ -2711,10 +2952,7 @@ class Polymarket:
|
|
|
2711
2952
|
self.auth = True
|
|
2712
2953
|
|
|
2713
2954
|
@staticmethod
|
|
2714
|
-
def load_poly_api():
|
|
2715
|
-
from dotenv import load_dotenv
|
|
2716
|
-
|
|
2717
|
-
load_dotenv()
|
|
2955
|
+
def load_poly_api() -> list[Any]:
|
|
2718
2956
|
pk = os.getenv("PK")
|
|
2719
2957
|
api_key = os.getenv("CLOB_API_KEY")
|
|
2720
2958
|
api_secret = os.getenv("CLOB_API_SECRET")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|