Alphanume

Guide

TradeZero API Python Tutorial: From Stock Signals to Orders

Build a Python workflow using Alphanume stock rankings, TradeZero short locates and opening orders, with a downloadable starter and scheduled exits.

A trading API lets your Python program ask a broker for information and send orders. The harder part is connecting those requests into a complete day: choose stocks, check whether you can borrow them, enter orders, then account for every share when you exit.

This series builds that workflow around Alphanume's Pre-Market Drop Risk dataset and the TradeZero REST API. It is adapted from an Alphanume deployment, with a smaller public starter you can inspect and run. Start with a read-only preview; learn what each step returns before enabling writes.

This example requires an Alphanume API key with access to Pre-Market Drop Risk. TradeZero handles the account and execution; Alphanume supplies the ranked candidates. TradeZero's API can use other data, but this starter is built around Alphanume. See dataset access and plans.

Download the Python starter, Windows wrapper, and offline tests. Extract it before running commands. The ZIP includes setup instructions and the complete source.

What each service does

  • Alphanume supplies the morning's candidates, daily ranks, estimated drop probabilities and pre-market reference prices.
  • TradeZero supplies account information, borrow checks, locate inventory and order handling.
  • Massive supplies the fresh bid and ask used by this starter's exit. A delayed-data plan will not pass its freshness check.
  • Your computer runs Python, keeps local records and starts the jobs on schedule.

The dataset ranks the modeled chance of a decline of at least 5% from the open to the close. It does not predict the chance of touching a price at any time during the day. The example's 2 p.m. exit has a different holding period, so the dataset's close-based outcome is not a scorecard for that exit rule.

The day's workflow

  1. Fetch today's Alphanume rows with max_rank=5 and min_price=1.
  2. Divide your chosen reference budget among the eligible rows and round down to whole shares.
  3. Check easy-to-borrow status. For hard-to-borrow names, check inventory before requesting a paid locate.
  4. Build a short opening order using a route that supports the required order type and time in force.
  5. At 2 p.m. ET, start buying back recorded short positions with limit orders. On an early close, start one hour before the close.
  6. Read order status and positions again. A submitted order is not proof that the account is flat.

Five ranks do not promise five trades. A stock under the price floor, a costly locate, an existing position or a rejected order can reduce the basket. The starter leaves those skipped allocations unused. Its budget is an estimate based on a pre-market price; an opening market order can fill at a different price.

Run a preview

After the connection guide's setup, run these commands from the extracted folder. The $500 is fictional example input, not a suggested allocation. Both commands below make read-only requests.

.\.venv\Scripts\python.exe starter.py check
.\.venv\Scripts\python.exe starter.py entry --budget 500

The check prints the environment, available routes, position count and signal count. Entry prints proposed order bodies and borrow checks. It does not buy locates or place orders. An empty signal response produces no orders; the program never fills the gap with yesterday's names.

Choose your next guide

Common questions

Is this a finished unattended trading system?

It is a runnable educational starter with explicit live-write options. It does not provide alerts or broker supervision. Read its README for ownership rules, manual recovery and the differences from the private deployment.

Can I use TradeZero without Alphanume?

Yes. The brokerage API is independent. Alphanume is required for the signal selection demonstrated here and for the included starter, rather than for TradeZero access itself.

Does a high probability mean the trade will make money?

No. The modeled target excludes your locate bill, execution prices and exit timing. Evaluate the actual workflow and its costs separately.

Broker reference: TradeZero developer documentation. For the signal fields, see Alphanume API documentation.

API documentation checked September 27, 2026. Route availability and account access can change. Examples describe the included starter; they do not establish trading performance.