polytrader 0.1.0__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.
- polytrader-0.1.0/.gitignore +10 -0
- polytrader-0.1.0/.python-version +1 -0
- polytrader-0.1.0/.vscode/settings.json +14 -0
- polytrader-0.1.0/LICENSE +21 -0
- polytrader-0.1.0/PKG-INFO +20 -0
- polytrader-0.1.0/README.md +0 -0
- polytrader-0.1.0/code_formatter.sh +64 -0
- polytrader-0.1.0/mypy.ini +25 -0
- polytrader-0.1.0/pyproject.toml +42 -0
- polytrader-0.1.0/pytest.ini +5 -0
- polytrader-0.1.0/ruff.toml +40 -0
- polytrader-0.1.0/src/polytrader/__init__.py +85 -0
- polytrader-0.1.0/src/polytrader/client.py +554 -0
- polytrader-0.1.0/src/polytrader/constants.py +16 -0
- polytrader-0.1.0/src/polytrader/models.py +735 -0
- polytrader-0.1.0/src/polytrader/rpc.py +190 -0
- polytrader-0.1.0/src/polytrader/websocket.py +326 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_balance.yaml +111 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_current_updown_market.yaml +76 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_orders.yaml +112 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_positions.yaml +118 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_trades.yaml +1046 -0
- polytrader-0.1.0/tests/cassettes/test_client/test_get_updown_market.yaml +76 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_cancel_order.yaml +460 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_fak_order.yaml +347 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_fak_order_lifecycle.yaml +633 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_fok_order.yaml +347 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_get_order.yaml +460 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_gtc_order.yaml +456 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_gtd_order.yaml +458 -0
- polytrader-0.1.0/tests/cassettes/test_orders/test_market_order.yaml +346 -0
- polytrader-0.1.0/tests/conftest.py +107 -0
- polytrader-0.1.0/tests/fixtures/market_ws_messages.jsonl +12 -0
- polytrader-0.1.0/tests/fixtures/user_ws_messages.jsonl +4 -0
- polytrader-0.1.0/tests/test_client.py +152 -0
- polytrader-0.1.0/tests/test_orders.py +332 -0
- polytrader-0.1.0/tests/test_websocket.py +265 -0
- polytrader-0.1.0/uv.lock +1544 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
polytrader-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Omid Roshani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polytrader
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python trading client for Polymarket
|
|
5
|
+
Project-URL: Homepage, https://github.com/omidroshani/polytrader
|
|
6
|
+
Author: Omid Roshani
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: eth-abi>=5.0.0
|
|
14
|
+
Requires-Dist: eth-account>=0.13.0
|
|
15
|
+
Requires-Dist: eth-utils>=5.0.0
|
|
16
|
+
Requires-Dist: httpx>=0.28.1
|
|
17
|
+
Requires-Dist: py-builder-relayer-client>=0.0.1
|
|
18
|
+
Requires-Dist: py-clob-client>=0.34.6
|
|
19
|
+
Requires-Dist: python-dotenv>=1.2.2
|
|
20
|
+
Requires-Dist: websockets>=16.0
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Exit immediately if a command exits with non-zero status
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# Activate virtual environment if it exists
|
|
7
|
+
if [ -d "venv" ]; then
|
|
8
|
+
source venv/bin/activate
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Colors for output
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
BLUE='\033[0;34m'
|
|
16
|
+
NC='\033[0m' # No Color
|
|
17
|
+
|
|
18
|
+
# Function to print colored output
|
|
19
|
+
print_status() {
|
|
20
|
+
echo -e "${BLUE}🔄${NC} $1"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
print_success() {
|
|
24
|
+
echo -e "${GREEN}✅${NC} $1"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
print_error() {
|
|
28
|
+
echo -e "${RED}❌${NC} $1"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
echo -e "${YELLOW}🚀 Starting code quality checks...${NC}"
|
|
32
|
+
echo ""
|
|
33
|
+
|
|
34
|
+
# Run mypy for type checking
|
|
35
|
+
print_status "Running mypy type checker..."
|
|
36
|
+
if mypy .; then
|
|
37
|
+
print_success "mypy passed"
|
|
38
|
+
else
|
|
39
|
+
print_error "mypy failed"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
echo ""
|
|
43
|
+
|
|
44
|
+
# Run ruff for linting and auto-fix
|
|
45
|
+
print_status "Running ruff linter with auto-fix..."
|
|
46
|
+
if ruff check . --fix; then
|
|
47
|
+
print_success "ruff check passed"
|
|
48
|
+
else
|
|
49
|
+
print_error "ruff check failed"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
# Run ruff for code formatting
|
|
55
|
+
print_status "Running ruff formatter..."
|
|
56
|
+
if ruff format .; then
|
|
57
|
+
print_success "ruff format completed"
|
|
58
|
+
else
|
|
59
|
+
print_error "ruff format failed"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
echo ""
|
|
63
|
+
|
|
64
|
+
echo -e "${GREEN}🎉 All code quality checks completed successfully!${NC}"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
; https://mypy.readthedocs.io/en/stable/config_file.html
|
|
2
|
+
[mypy]
|
|
3
|
+
mypy_path = src
|
|
4
|
+
explicit_package_bases = True
|
|
5
|
+
disallow_untyped_defs = True
|
|
6
|
+
disallow_incomplete_defs = True
|
|
7
|
+
strict_equality = True
|
|
8
|
+
extra_checks = True
|
|
9
|
+
warn_unused_ignores = True
|
|
10
|
+
warn_return_any = True
|
|
11
|
+
warn_redundant_casts = True
|
|
12
|
+
show_error_codes = True
|
|
13
|
+
|
|
14
|
+
[mypy-py_clob_client.*]
|
|
15
|
+
ignore_missing_imports = True
|
|
16
|
+
|
|
17
|
+
[mypy-py_builder_relayer_client.*]
|
|
18
|
+
ignore_missing_imports = True
|
|
19
|
+
|
|
20
|
+
[mypy-py_builder_signing_sdk.*]
|
|
21
|
+
ignore_missing_imports = True
|
|
22
|
+
|
|
23
|
+
[mypy-tests.*]
|
|
24
|
+
disallow_untyped_defs = False
|
|
25
|
+
disallow_incomplete_defs = False
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "polytrader"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python trading client for Polymarket"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [{ name = "Omid Roshani" }]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"eth-abi>=5.0.0",
|
|
16
|
+
"eth-account>=0.13.0",
|
|
17
|
+
"eth-utils>=5.0.0",
|
|
18
|
+
"httpx>=0.28.1",
|
|
19
|
+
"py-builder-relayer-client>=0.0.1",
|
|
20
|
+
"py-clob-client>=0.34.6",
|
|
21
|
+
"python-dotenv>=1.2.2",
|
|
22
|
+
"websockets>=16.0",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/omidroshani/polytrader"
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["hatchling"]
|
|
30
|
+
build-backend = "hatchling.build"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = [
|
|
34
|
+
"mypy>=1.19.1",
|
|
35
|
+
"pytest>=9.0.2",
|
|
36
|
+
"pytest-asyncio>=1.3.0",
|
|
37
|
+
"pytest-recording>=0.13.4",
|
|
38
|
+
"python-dotenv>=1.2.2",
|
|
39
|
+
"rich>=14.3.3",
|
|
40
|
+
"ruff>=0.15.5",
|
|
41
|
+
"freezegun>=1.5.0",
|
|
42
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
line-length = 88
|
|
2
|
+
|
|
3
|
+
[lint]
|
|
4
|
+
select = [
|
|
5
|
+
"E", # pycodestyle errors
|
|
6
|
+
"F", # pyflakes
|
|
7
|
+
"I", # import sorting
|
|
8
|
+
"T20", # print statement usage (forbids print in production code)
|
|
9
|
+
"PIE", # flake8-pie: small code style improvements
|
|
10
|
+
"DTZ", # datetime-related errors (e.g., naive datetime usage)
|
|
11
|
+
"C4", # flake8-comprehensions: improve list/set/dict comprehensions
|
|
12
|
+
"UP", # pyupgrade: modern Python syntax
|
|
13
|
+
"SIM", # flake8-simplify: simplify if/else, loops, etc.
|
|
14
|
+
"RUF", # Ruff-specific enhancements
|
|
15
|
+
"ANN", # flake8-annotations: enforce type hints
|
|
16
|
+
"PL", # pylint-style rules: naming, style, structure
|
|
17
|
+
]
|
|
18
|
+
ignore = [
|
|
19
|
+
"E501", # line too long
|
|
20
|
+
"RUF012", # allow mutable class default values for dataclasses, pydantic etc.
|
|
21
|
+
"RUF022", # allow unsorted __all__ (we organize by category)
|
|
22
|
+
"ANN401", # allow typing.Any as return type
|
|
23
|
+
"PLR0912", # Too many branches
|
|
24
|
+
"PLR0915", # Too many statements
|
|
25
|
+
"PLR0911", # Too many return statements
|
|
26
|
+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
|
|
27
|
+
"PLR0913", # Too many arguments in function definition
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[lint.per-file-ignores]
|
|
31
|
+
"tests/**/*.py" = [
|
|
32
|
+
"ANN001", # Missing type annotation for function argument
|
|
33
|
+
"ANN201", # Missing return type annotation for function
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[format]
|
|
37
|
+
quote-style = "double"
|
|
38
|
+
indent-style = "space"
|
|
39
|
+
skip-magic-trailing-comma = false
|
|
40
|
+
docstring-code-format = true
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from polytrader.client import PolyTrader
|
|
2
|
+
from polytrader.models import (
|
|
3
|
+
Balance,
|
|
4
|
+
BestBidAsk,
|
|
5
|
+
Book,
|
|
6
|
+
Coin,
|
|
7
|
+
EventMessage,
|
|
8
|
+
LastTradePrice,
|
|
9
|
+
MakerOrder,
|
|
10
|
+
MarketEventType,
|
|
11
|
+
MarketResolved,
|
|
12
|
+
NewMarket,
|
|
13
|
+
OrderBookLevel,
|
|
14
|
+
OrderResult,
|
|
15
|
+
OrderResultStatus,
|
|
16
|
+
OrderSide,
|
|
17
|
+
OrderStatus,
|
|
18
|
+
OrderType,
|
|
19
|
+
Outcome,
|
|
20
|
+
PolymarketAuth,
|
|
21
|
+
PolymarketOrder,
|
|
22
|
+
PolymarketOrderType,
|
|
23
|
+
PolymarketPosition,
|
|
24
|
+
PolymarketTrade,
|
|
25
|
+
PriceChange,
|
|
26
|
+
PriceChangeItem,
|
|
27
|
+
TickSizeChange,
|
|
28
|
+
Timeframe,
|
|
29
|
+
TokenIdPair,
|
|
30
|
+
TraderSide,
|
|
31
|
+
TradeStatus,
|
|
32
|
+
UpDownMarket,
|
|
33
|
+
UpDownMarketToken,
|
|
34
|
+
UserEventType,
|
|
35
|
+
UserOrder,
|
|
36
|
+
UserTrade,
|
|
37
|
+
crypto_fee,
|
|
38
|
+
)
|
|
39
|
+
from polytrader.websocket import (
|
|
40
|
+
BasePolymarketWebSocket,
|
|
41
|
+
PolymarketMarketWebSocket,
|
|
42
|
+
PolymarketUserWebSocket,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"Balance",
|
|
47
|
+
"BasePolymarketWebSocket",
|
|
48
|
+
"BestBidAsk",
|
|
49
|
+
"Book",
|
|
50
|
+
"Coin",
|
|
51
|
+
"EventMessage",
|
|
52
|
+
"LastTradePrice",
|
|
53
|
+
"MakerOrder",
|
|
54
|
+
"MarketEventType",
|
|
55
|
+
"MarketResolved",
|
|
56
|
+
"NewMarket",
|
|
57
|
+
"OrderBookLevel",
|
|
58
|
+
"OrderResult",
|
|
59
|
+
"OrderResultStatus",
|
|
60
|
+
"OrderSide",
|
|
61
|
+
"OrderStatus",
|
|
62
|
+
"OrderType",
|
|
63
|
+
"Outcome",
|
|
64
|
+
"PolymarketAuth",
|
|
65
|
+
"PolymarketOrder",
|
|
66
|
+
"PolymarketOrderType",
|
|
67
|
+
"PolymarketPosition",
|
|
68
|
+
"PolymarketTrade",
|
|
69
|
+
"PolyTrader",
|
|
70
|
+
"PolymarketMarketWebSocket",
|
|
71
|
+
"PolymarketUserWebSocket",
|
|
72
|
+
"PriceChange",
|
|
73
|
+
"PriceChangeItem",
|
|
74
|
+
"TickSizeChange",
|
|
75
|
+
"Timeframe",
|
|
76
|
+
"TokenIdPair",
|
|
77
|
+
"TradeStatus",
|
|
78
|
+
"TraderSide",
|
|
79
|
+
"UpDownMarket",
|
|
80
|
+
"UpDownMarketToken",
|
|
81
|
+
"UserEventType",
|
|
82
|
+
"UserOrder",
|
|
83
|
+
"UserTrade",
|
|
84
|
+
"crypto_fee",
|
|
85
|
+
]
|