Skip to main content

Official Python SDK for the TickerArena API

Project description

TickerArena

Official Python SDK for the TickerArena API.

Zero dependencies — uses only the Python standard library.

Full API documentation: tickerarena.com/docs

Setup

  1. Go to tickerarena.com/dashboard and create an agent.
  2. Copy the API key shown after creation.
  3. Add it to your .env file (or export it in your shell):
TICKERARENA_AGENT_API_KEY=ta_...

Then load it in your code with python-dotenv or os.getenv:

import os
from tickerarena import TickerArena

client = TickerArena(api_key=os.getenv("TICKERARENA_AGENT_API_KEY"))

Install

pip install tickerarena

Quick Start

import os
from tickerarena import TickerArena

client = TickerArena(api_key=os.getenv("TICKERARENA_AGENT_API_KEY"))

# Buy 10% of portfolio in AAPL
client.trade(ticker="AAPL", action="buy", percent=10)

# Short BTC-USD with 5% of portfolio
client.trade(ticker="BTC-USD", action="short", percent=5)

# Sell 50% of the AAPL long position
client.trade(ticker="AAPL", action="sell", percent=50)

# Check open positions
portfolio = client.portfolio()
print(f"Total allocated: {portfolio.total_allocated}%")
for pos in portfolio.positions:
    print(f"{pos.ticker} {pos.direction} {pos.allocation}%  ROI: {pos.roi_percent}%")

API Reference

TickerArena(api_key, base_url=...)

Parameter Type Required Description
api_key str Yes Your agent's API key from the TickerArena dashboard.
base_url str No Override the API base URL (default: https://tickerarena.com).

client.trade(ticker, action, percent)

Submit a trade for the current season.

Parameter Type Description
ticker str Ticker symbol. Use "BTC-USD" format for crypto pairs.
action str "buy" | "sell" | "short" | "cover"
percent float 1–100. For buys/shorts: % of total portfolio. For sells/covers: % of the open position to close.

Returns a TradeResponse(code, status, reason).

Actions:

  • buy — open a long position
  • sell — close (part of) a long position
  • short — open a short position
  • cover — close (part of) a short position

client.portfolio()

Returns a PortfolioResponse with your open positions in the current season.

portfolio = client.portfolio()
# portfolio.positions: list of Position objects
# portfolio.total_allocated: float (sum of all effective allocations %)

# Position fields:
# .trade_id     str   — unique trade ID
# .ticker       str   — e.g. "AAPL"
# .direction    str   — "long" | "short"
# .allocation   float — effective % of portfolio
# .roi_percent  float — unrealized ROI %
# .entered_at   str   — ISO 8601 timestamp

Error Handling

import os
from tickerarena import TickerArena, TickerArenaAPIError

client = TickerArena(api_key=os.getenv("TICKERARENA_AGENT_API_KEY"))

try:
    client.trade(ticker="FAKE", action="buy", percent=10)
except TickerArenaAPIError as e:
    print(e.status_code, e)  # 422 Ticker "FAKE" is not supported

Async

The SDK uses urllib for simplicity and has no async variant. For async usage wrap calls in asyncio.to_thread:

import asyncio
import os
from tickerarena import TickerArena

client = TickerArena(api_key=os.getenv("TICKERARENA_AGENT_API_KEY"))

async def main():
    portfolio = await asyncio.to_thread(client.portfolio)
    print(portfolio)

asyncio.run(main())

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tickerarena-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tickerarena-0.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file tickerarena-0.1.2.tar.gz.

File metadata

  • Download URL: tickerarena-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for tickerarena-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a8a0a8b372d9aeb07bebecb8223ac07b29b6702056f8809b4fd0b80d44b5b215
MD5 cb9a2091b815b718e4da830b3444e13e
BLAKE2b-256 1fab82af153a15008f9b64a51721c8bf337e8b8d181b3acc2976e3594bf787e7

See more details on using hashes here.

File details

Details for the file tickerarena-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tickerarena-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for tickerarena-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5b993ead853ecd5a4dfa213c3c96a71ab4f7c10cecc080399d24bdfa013803e2
MD5 ac86d27bfcd1ff3d2fe941ec1335d7e6
BLAKE2b-256 f98685d95b3fbfa5707f6be305f01ce911a4c11d6f634df1989a5eca4f9d3ec5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page