This repository is a small, copyable Python quickstart for interacting with Pascal's public API.
It is not the Pascal Python SDK. The SDK will eventually provide a polished package, typed models, stable client APIs, and stronger abstractions. This quickstart should stay close to the wire format so integrators can see exactly how request signing, order placement, and cancellation work.
Public API reference: https://docs.pascal.trade/
Clone the repository and install dependencies:
git clone https://github.com/Pascal-Research-Inc/pascal-python-quickstart.git
cd pascal-python-quickstart
uv syncRun a read-only market data example:
uv run python examples/01_market_context.pyBefore placing orders, choose exactly one onboarding path:
- Use docs/onboarding_web_app.md if you are connecting a wallet in the Pascal web app and generating a trading key there.
- Use docs/onboarding_solana_key.md if you already have a Solana private key and want to register the deposit address and trading key from the command line.
Both paths end with the same .env shape:
PASCAL_OWNER_PUBLIC_KEY=<owner-wallet-public-key>
PASCAL_TRADING_PRIVATE_KEY=<authorized-trading-private-key>Do not use your owner wallet private key as PASCAL_TRADING_PRIVATE_KEY.
Order and cancel requests are signed by a separate trading key. The owner
wallet key is only for owner-wallet actions such as registering a deposit
address, registering trading keys, or withdrawing.
After either onboarding path, verify the configured signer:
uv run pytest tests/test_signing_vectors.py
uv run python examples/07_check_trading_key.pyIf you are writing your own signing code, use the test signing vectors to verify its correctness.
Build a signed order request. By default this prints the JSON request without sending it.
uv run python examples/02_place_order.pyThe example defaults to prod, selects the first available market if you do
not pass --symbol, uses 123 as the default client_order_id, and builds a
one-contract post-only bid. Use --help to see the fields you can override.
Send the order only when you are ready to place the order:
uv run python examples/02_place_order.py --sendCancel the order by client_order_id:
uv run python examples/03_cancel_order.py --sendThe cancel example uses 123 as the default client_order_id, matching the
place example. You can also pass --client-order-id or --order-id
explicitly.
The same order example can attach a builder fee. Set BUILDER_PUBKEY to the
builder account's wallet public key, not its trading key. The builder must be a
registered Pascal account other than the trader's own account and must have at
least $100 of free collateral when the order is placed.
export BUILDER_PUBKEY="YOUR_BUILDER_WALLET_PUBLIC_KEY"
uv run python examples/02_place_order.py \
--symbol ME_SEN_2026.REP --side BID --price 0.500000 --size 100 \
--builder-pubkey "$BUILDER_PUBKEY" --builder-fee-rate 0.010000This prints a signed request without sending it. Add --send only when you are
ready to place the order. If all 100 contracts fill at $0.50, the 1% builder
rate pays the builder 100 * 0.50 * (1 - 0.50) * 0.01 = $0.25, in addition to
any venue fees. Rates are decimal strings, not percentages: 0.010000 is 1%,
and the maximum rate is 0.100000 (10%).
In Python, pass builder_pubkey and builder_fee_rate together to
signed_place_order_request() (or place_order_message() for raw permit
bytes). The request helper adds:
{
"builder_info": {
"builder_pubkey": "<builder-wallet-public-key>",
"builder_fee_rate": "0.010000"
}
}Both fields are included in the signed permit, so do not append or change
builder_info after signing. No separate builder approval signature is needed.
Omit both arguments for orders without a builder. To stop paying a builder on
future fills, cancel any open orders naming it and omit the builder on new
orders. See the builder code rules.
The repo also includes a small discoverable CLI for agents and operators. From
the project root, run the committed ./cli shim or the equivalent
uv run cli project script.
./cli
./cli markets
./cli limit-orderRunning ./cli lists commands. Running a read-only command such as
./cli positions executes it with .env defaults; use ./cli <command> --help
to see that command's arguments and examples. Write commands remain dry-run by
default, print the exact request JSON, and only post when --send is present.
The CLI covers market lists, top of book, open orders, positions, deposit
addresses, fills/transfers/position-resolution history, PnL, simple limit or
market orders, and batch order placement from an unsigned JSON array.
History-like commands print rows by default; pass --json for the full
response.
./cli markets
./cli markets --limit 10
./cli book ME_SEN_2026.REP
./cli orders --symbol ME_SEN_2026.REP
./cli positions
./cli deposit-address
./cli history --limit 5
./cli history --kind fills --symbol ME_SEN_2026.REP --limit 25 --json
./cli pnl
./cli limit-order --symbol ME_SEN_2026.REP --side BID --price 0.450000 --size 1
./cli market-order --symbol ME_SEN_2026.REP --side BID --size 1
./cli batch-orders orders.json
./cli cancel-order --client-order-id 1783261000000 1783261000001Batch order input is a JSON array of unsigned order specs. Omit
client_order_id to generate timestamp-based ids:
[
{"symbol": "ME_SEN_2026.REP", "side": "BID", "price": "0.450000", "size": 1},
{"type": "MARKET", "symbol": "ME_SEN_2026.REP", "side": "ASK", "size": 1}
]-
See
examples/04_simple_market_maker.pyfor a looped market maker. It picks a market, fetches account state and the order book once per second, maintains three post-only bid and ask levels sized1,3, and5contracts, bounds exposure to+/-10contracts by default, and cancels its open orders when interrupted withCtrl+C. -
See
examples/05_register_deposit_address.pyandexamples/06_register_trading_key.pyfor the owner-wallet flow that registers a deposit address, waits for funding, then registers a trading key. -
See
examples/07_check_trading_key.pyfor a read-only check that derives the configured trading key's public key and confirms it is active for the configured owner. -
See
examples/08_trade_history_pagination.pyfor a read-only example that pages through historical trades using the correct cursor parameter.
Historical endpoints return data.next_cursor in the response. To fetch the
next older page, send that value back as before_cursor.
GET /api/v1/trades?symbols=ME_SEN_2026.REP&limit=5
# response data.next_cursor = 00000000000000737841:0000000000
GET /api/v1/trades?symbols=ME_SEN_2026.REP&limit=5&before_cursor=00000000000000737841:0000000000Do not send cursor=<next_cursor>; next_cursor is the response field,
while before_cursor is the query parameter for the next older page.
Run the Python example:
uv run python examples/08_trade_history_pagination.py --symbol ME_SEN_2026.REP --limit 5 --pages 3unauthorized_signer usually means the request's auth.signer is not an
active trading key for the request's auth.owner in that environment. First
verify that your local signing code still matches Pascal's public API examples:
uv run pytest tests/test_signing_vectors.pyThen confirm your configured private key derives to one of the owner's active trading keys:
uv run python examples/07_check_trading_key.pyIf the derived signer is missing from the active trading-key list, use the
private key that matches an active trading key, register the configured key with
examples/06_register_trading_key.py, or confirm that --env and
PASCAL_OWNER_PUBLIC_KEY refer to the same account.
A TRADING_KEY_NAME_ALREADY_USED response means the label is already taken; it
does not prove that the private key in .env matches that registered signer.
Run checks:
uv run ruff format --check .
uv run ruff check .
uv run basedpyright
uv run pytest