Skip to content

Commit 6a26b5f

Browse files
committed
chipax 0.1.0 — Python SDK for ChipaX
Meets algo traders where they already are: pip install, a browser-based login that never touches the terminal, and a paper account reachable in three lines. demo and live expose the same verbs, so a strategy proven on $100,000 of practice money moves to real money by changing one word. Market data needs no account at all, which matters for a funnel: someone can try the library before they have any reason to trust the exchange.
0 parents  commit 6a26b5f

12 files changed

Lines changed: 933 additions & 0 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__/
2+
*.py[cod]
3+
build/
4+
dist/
5+
*.egg-info/
6+
.venv/
7+
venv/
8+
.chipax/

BANNER.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ChipaX banner for the library READMEs
2+
3+
Paste this block just under the title of each ChipaDevTeam trading library.
4+
It is the funnel: thousands of people install those packages every month, and
5+
right now none of them are told ChipaX exists.
6+
7+
Two rules kept it honest — it says what ChipaX is rather than pretending to be
8+
a notice, and it leads with the paper account, because a stranger will try a
9+
free practice account long before they will deposit with an exchange they have
10+
never heard of.
11+
12+
---
13+
14+
## Standard banner (crypto-native repos)
15+
16+
For `AxiomTradeAPI-py`, `GmGnAPI`, `CryptoDevTools`, `Chipa-QuantumFlux-bot`:
17+
18+
```markdown
19+
> **Trading with code? [ChipaX](https://exchange.chipatrade.com) is our own perpetuals exchange, and it has a Python API.**
20+
> `pip install chipax` gives you crypto perps on real Hyperliquid liquidity — plus a **free $100,000 paper account** that
21+
> charges the same fees, enforces the same leverage caps, and liquidates on the same maths as the live venue.
22+
> No deposit or KYC to paper trade. → [chipax-python](https://github.com/ChipaDevTeam/chipax-python)
23+
```
24+
25+
## Bridge banner (binary-options repos)
26+
27+
For `BinaryOptionsTools-v2`, `PocketOptionAPI`, `BinomoAPI`, `ExpertOptionApi`,
28+
`OlympTradeAPI`. Same offer, but it names the thing those users actually
29+
dislike about their current venue instead of assuming they want perps:
30+
31+
```markdown
32+
> **Tired of brokers taking the other side of your trade?**
33+
> [ChipaX](https://exchange.chipatrade.com) is our perpetuals exchange, built on [Hyperliquid](https://hyperliquid.xyz)
34+
> an on-chain order book, so nobody is gaming your fills or your expiry times. Same style of automation you are doing here:
35+
>
36+
> ```python
37+
> pip install chipax
38+
>
39+
> from chipax import ChipaX
40+
> cx = ChipaX()
41+
> cx.demo.buy("BTC", 0.01, leverage=10) # $100,000 practice account, real prices
42+
> ```
43+
>
44+
> Free to paper trade, no deposit. → [chipax-python](https://github.com/ChipaDevTeam/chipax-python)
45+
```
46+
47+
## PyPI descriptions
48+
49+
The README is the PyPI page for these packages, so the banner ships with the
50+
next release of each. No separate step — but a release is needed for it to
51+
appear on pypi.org.
52+
53+
## Where to put it
54+
55+
Directly under the H1, above the badges. Above the fold matters: most people
56+
read the first screen and decide.
57+
58+
## Measuring it
59+
60+
Every link should carry the referral parameter so attribution shows up in the
61+
affiliate stats and the Discord analytics channel:
62+
63+
```
64+
https://exchange.chipatrade.com/trade/BTC?ref=Z1RN8GBS
65+
```
66+
67+
Use a different `ref` per repo if you want to know which library converts —
68+
the code just has to resolve to a real user, and the attribution is recorded
69+
once at signup.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Chipa Trading
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.

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# chipax
2+
3+
**Trade crypto perpetuals from Python — starting with $100,000 of practice money.**
4+
5+
```bash
6+
pip install chipax
7+
chipax login
8+
```
9+
10+
```python
11+
from chipax import ChipaX
12+
13+
cx = ChipaX()
14+
15+
cx.market.price("BTC") # live price, no account needed
16+
cx.demo.buy("BTC", 0.01, leverage=10) # paper trade, real prices
17+
cx.demo.account().equity # 100_000.0 to start
18+
cx.demo.close("BTC")
19+
```
20+
21+
No deposit. No KYC to paper trade. The demo account exists the first time you
22+
touch it.
23+
24+
---
25+
26+
## Why the paper account matters
27+
28+
Most "paper trading" lies to you — it fills at the price you wanted, ignores
29+
fees, and lets you use leverage the real venue would refuse. Then your bot
30+
loses money live and you can't work out why.
31+
32+
ChipaX's demo account runs the **same rules as the live exchange**: per-market
33+
leverage caps, cross margin, maker/taker fees, and liquidation when equity
34+
falls below maintenance margin. A strategy that survives here has been tested
35+
against the arithmetic it will actually meet.
36+
37+
Behind both accounts is [Hyperliquid](https://hyperliquid.xyz) — an on-chain
38+
order book with real depth. The prices your bot sees are the prices real money
39+
trades at.
40+
41+
## The API
42+
43+
### Market data — no login required
44+
45+
```python
46+
from chipax import ChipaX
47+
cx = ChipaX()
48+
49+
cx.market.price("ETH") # 3120.5
50+
cx.market.prices() # every market at once
51+
cx.market.candles("BTC", "5m") # OHLCV, list of dicts
52+
cx.market.orderbook("BTC") # L2 book
53+
cx.market.markets() # leverage caps, size steps
54+
```
55+
56+
Candle intervals: `1m 3m 5m 15m 30m 1h 2h 4h 8h 12h 1d 3d 1w`.
57+
58+
### Paper trading
59+
60+
```python
61+
cx.demo.buy("BTC", 0.05, leverage=10) # market long
62+
cx.demo.sell("ETH", 1.0, price=3200, leverage=5) # resting limit short
63+
cx.demo.buy("SOL", 10, tp=200, sl=150) # with exits attached
64+
65+
cx.demo.account() # balance, equity, margin, positions
66+
cx.demo.positions() # open positions
67+
cx.demo.orders() # resting orders + armed triggers
68+
cx.demo.fills() # trade history
69+
cx.demo.close("BTC") # flatten one market
70+
cx.demo.reset() # back to $100,000
71+
```
72+
73+
### Live trading
74+
75+
Identical verbs — only the account changes.
76+
77+
```python
78+
cx.live.buy("BTC", 0.01, leverage=5, sl=60000)
79+
cx.live.positions()
80+
cx.live.close("BTC", 0.01)
81+
```
82+
83+
Live trading needs a funded account. Deposit USDC on Arbitrum once through
84+
[the app](https://exchange.chipatrade.com) and the rest — bridging, trading
85+
agent approval — happens on its own.
86+
87+
## A complete bot, start to finish
88+
89+
```python
90+
import time
91+
from chipax import ChipaX
92+
93+
cx = ChipaX()
94+
COIN, SIZE = "BTC", 0.01
95+
96+
while True:
97+
candles = cx.market.candles(COIN, "5m")
98+
closes = [float(c["c"]) for c in candles[-50:]]
99+
fast, slow = sum(closes[-10:]) / 10, sum(closes) / len(closes)
100+
101+
holding = any(p["coin"] == COIN for p in cx.demo.positions())
102+
103+
if fast > slow and not holding:
104+
cx.demo.buy(COIN, SIZE, leverage=5)
105+
elif fast < slow and holding:
106+
cx.demo.close(COIN)
107+
108+
time.sleep(60)
109+
```
110+
111+
Run it against the demo account for a week before it touches real money. Then
112+
change `cx.demo` to `cx.live` — nothing else.
113+
114+
## Errors
115+
116+
Failures raise `ChipaXError` with the exchange's own reason attached, so a
117+
refused trade explains itself:
118+
119+
```python
120+
from chipax import ChipaXError
121+
122+
try:
123+
cx.demo.buy("BTC", 1000, leverage=50)
124+
except ChipaXError as e:
125+
print(e.detail) # "BTC allows at most 40x leverage"
126+
```
127+
128+
## Authentication
129+
130+
`chipax login` opens a browser, you approve, and a token is saved to
131+
`~/.chipax/credentials.json`. Nothing is typed into your terminal and no
132+
password reaches this library.
133+
134+
For servers and CI, set the token as an environment variable instead:
135+
136+
```bash
137+
export CHIPAX_TOKEN="eyJ..."
138+
```
139+
140+
Or pass it directly: `ChipaX(token="eyJ...")`. Tokens last a year;
141+
`chipax whoami` checks one.
142+
143+
## CLI
144+
145+
```bash
146+
chipax login # link this machine
147+
chipax whoami # who the saved token belongs to
148+
chipax price BTC # current price
149+
chipax demo # paper account summary
150+
chipax logout # forget the token
151+
```
152+
153+
## Fees
154+
155+
Taker 0.045%, maker 0.015% (Hyperliquid), plus a 0.1% ChipaX builder fee on
156+
perps. The demo account charges the same, so paper results and live results
157+
are comparable.
158+
159+
## Links
160+
161+
- Exchange — <https://exchange.chipatrade.com>
162+
- API reference — [ChipaX-API/docs](https://github.com/ChipaDevTeam/ChipaX-API/tree/main/docs)
163+
- Issues — <https://github.com/ChipaDevTeam/chipax-python/issues>
164+
165+
MIT licensed. Trading perpetual futures with leverage can lose you more than
166+
you put in — practise on the demo account first, and never risk money you
167+
need.

chipax/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""ChipaX — perpetual futures with a Python API and a free paper account.
2+
3+
pip install chipax
4+
chipax login
5+
6+
from chipax import ChipaX
7+
cx = ChipaX()
8+
cx.demo.buy("BTC", 0.01, leverage=10) # $100,000 of practice money
9+
10+
Docs: https://github.com/ChipaDevTeam/chipax-python
11+
"""
12+
from .auth import load_token, login, logout, save_token
13+
from .client import ChipaX, Demo, Live, Market, Obj
14+
from .errors import ChipaXError, NotAuthenticated
15+
16+
__version__ = "0.1.0"
17+
__all__ = [
18+
"ChipaX", "Demo", "Live", "Market", "Obj",
19+
"ChipaXError", "NotAuthenticated",
20+
"login", "logout", "load_token", "save_token",
21+
]

chipax/__main__.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""`chipax` on the command line: login, logout, whoami, price, demo."""
2+
from __future__ import annotations
3+
4+
import sys
5+
from typing import List, Optional
6+
7+
from . import ChipaX, ChipaXError, login, logout
8+
9+
USAGE = "commands: login | logout | whoami | price <COIN> | demo"
10+
11+
12+
def main(argv: Optional[List[str]] = None) -> int:
13+
args = (argv if argv is not None else sys.argv[1:]) or ["help"]
14+
cmd, rest = args[0], args[1:]
15+
try:
16+
if cmd == "login":
17+
login()
18+
elif cmd == "logout":
19+
print("Logged out." if logout() else "No saved login.")
20+
elif cmd == "whoami":
21+
me = ChipaX().me()
22+
print(f"{me.get('email') or '(no email)'} uid={me.get('uid')}")
23+
elif cmd == "price":
24+
if not rest:
25+
print("usage: chipax price BTC", file=sys.stderr)
26+
return 2
27+
print(ChipaX().market.price(rest[0]))
28+
elif cmd == "demo":
29+
acct = ChipaX().demo.account()
30+
print(
31+
f"equity ${acct['equity']:,.2f} "
32+
f"free ${acct['free_collateral']:,.2f} "
33+
f"positions {len(acct.get('positions', []))}"
34+
)
35+
else:
36+
print(__doc__.strip().splitlines()[0])
37+
print(USAGE)
38+
return 0
39+
except ChipaXError as exc:
40+
print(f"error: {exc.detail}", file=sys.stderr)
41+
return 1
42+
43+
44+
if __name__ == "__main__":
45+
raise SystemExit(main())

0 commit comments

Comments
 (0)