tradesquares (SDK)
Open-source Python SDK for building TradeSquares agents. It holds no data and no secrets: every call is an authenticated HTTPS request to the TradeSquares agent gateway, which does all checks.
pip install tradesquares
What is in this repo
| Path | What |
|---|---|
tradesquares/ |
The package published to PyPI |
examples/ |
Example agents (agent.yaml + agent.py) |
tests/ |
SDK tests; results in tests/results/ (not committed) |
The gateway and the sandbox server are private and live in tradesquares-agent-platform.
Settings
Copy .env.example to .env where you run your agent and fill in TS_BASE_URL,
TS_TIMEOUT_SECONDS and TS_API_KEY. Get an API key by signing up for a free trial (the gateway
emails a link that shows the key once); the key's agent has every public-data scope.
Writing an agent
from tradesquares import Agent, Context
agent = Agent()
@agent.on_schedule
async def run(ctx: Context) -> dict:
bars = await ctx.history.daily("SPY", "2026-10-01", "2026-10-30")
ema = await ctx.indicators.compute("SPY", "ema", [200], start="2026-10-01", end="2026-10-30")
cross = await ctx.indicators.evaluate("SPY", start="2026-06-01", end="2026-10-30",
condition="crossover(ema(9), ema(21))")
income = await ctx.fundamentals.periods("SPY", "income_statement", "2020-01-01", "2026-12-31", period="FY")
return {"close": bars[-1].close, "ema_200": ema.latest(), "crossed_on": cross.true_dates()}
asyncio.run(agent.run_once()) runs it once with public data. A full example is in
examples/ema_200/.
| Call | Scope | Returns |
|---|---|---|
ctx.history.daily(symbol, start, end, adjusted=True) |
history:read |
list of Bar |
ctx.indicators.compute(symbol, name, args, start=, end=, adjusted=True, src=None) |
indicators:read |
IndicatorSeries (.value, .outputs, .latest()) |
ctx.indicators.evaluate(symbol, start=, end=, value= or condition=) |
indicators:read |
EvaluatedSeries (.values, .true_dates()) — any one-line StratQL expression |
ctx.fundamentals.periods(symbol, type, start, end, period=None, as_of=None) |
fundamentals:read |
list of PeriodRow (.data) |
ctx.fundamentals.snapshots(symbol, type, start, end, as_of=None) |
fundamentals:read |
list of DatedRow |
ctx.fundamentals.events(symbol, type, start, end, as_of=None) |
fundamentals:read |
list of DatedRow |
Indicators are computed with StratQL, the same engine as TradeSquares backtests; the warm-up
before start is handled for you. as_of returns fundamentals as they were known at the end of
that day, so backtests do not see restated or later-filed numbers.
Fundamentals type values:
- periods:
income_statement,balance_sheet,cash_flow,income_statement_growth,balance_sheet_growth,cash_flow_growth,key_metrics,ratios,income_statement_as_reported,balance_sheet_as_reported,cash_flow_as_reported,revenue_by_product,revenue_by_region,insider_statistics - snapshots:
ratios_ttm,key_metrics_ttm,scores,dcf,peers,price_target_summary,analyst_consensus,etf_holdings,rating,analyst_grades,market_cap - events:
earnings,earnings_surprise,dividend,split,grade_change,price_target_change,insider_trade,employee_count,sec_filing,analyst_estimate_annual,analyst_estimate_quarter
Errors are subclasses of TradeSquaresError with the gateway's .code: AuthError,
ScopeError, PlanLimitError (e.g. a trial reading older than 30 days), AccountError,
RateLimitError, BadRequestError, NotFoundError, UnavailableError.
Customer data (ctx.orders, ctx.portfolio, ctx.report, agent.run_for_customers()) comes in
a later platform phase.
Releasing (maintainers)
From /Users/vivekren/BrokerApp/tradesquares-sdk:
- Raise
versioninpyproject.toml(PyPI never accepts the same version twice). python -m buildtwine check dist/*twine upload dist/tradesquares-<version>*
Tests
python3 -m venv .venv && source .venv/bin/activate
pip install -e . -r tests/requirements.txt
bash tests/run_tests.sh
Metadata
Release files for tradesquares 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tradesquares-0.2.0.tar.gz | 14.6 kB | Without provenance | Details for tradesquares-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tradesquares-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for tradesquares-0.2.0-py3-none-any.whl |
Total release size: 28.7 kB
Release files / tradesquares-0.2.0.tar.gz
| Download URL | tradesquares-0.2.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67f1371b7fc8cb3967f1cc03989b630ae060a98ebe339cde0db39273450e0ea2
|
|
BLAKE2b-256 checksum How to use checksums |
27f89e7695c0eee77c8def67c7ec49b47aff002464facebe20b3b6682d04fe9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / tradesquares-0.2.0-py3-none-any.whl
| Download URL | tradesquares-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe4712b95a70df43b1be2dde5ae51ed662fa18bdfe142acced4a62fc79571e6b
|
|
BLAKE2b-256 checksum How to use checksums |
ba035ebe26ec63ef9ec0eef28459f39d157c352b91a312530c9e1979e4089d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for tradesquares 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.