|
| 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. |
0 commit comments