Documentation Index
Fetch the complete documentation index at: https://scalarfield.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
Python module: from scalarlib import venue (alias: from scalarlib import brokerage)
Venue Registry
Scalar Field connects to multiple trading venues organized by asset class. You can view portfolios, place trades, and run automated strategies on any active venue.
| Venue | Asset Class | Mode | Status | Capabilities |
|---|
| Alpaca Paper | US Equities | Paper | Active | Trade, read positions, order history |
| Alpaca Live | US Equities | Live | Coming soon | Trade, read positions, order history |
| Public.com | US Equities | Live | Coming soon | Trade, read positions, order history |
| Webull | US Equities | Live | Coming soon | Trade, read positions, order history |
| Polymarket | Prediction Markets | Live | Active | Trade, read positions, order history |
| Jupiter DEX | Tokenized Assets (Solana) | Live | Active | Trade, read positions, order history |
| Robinhood | US Equities | Live | Read-only | View portfolio and holdings |
| Interactive Brokers | US Equities | Live | Read-only | View portfolio and holdings |
| Fidelity | US Equities | Live | Read-only | View portfolio and holdings |
Asset-Class Groups
Venues are organized into compatibility groups by the instruments they trade. Strategies are compatible with any venue in the same group — for example, a US equities strategy can run on Alpaca Paper today and migrate to Alpaca Live, Public.com, or Webull when those venues launch.
| Group | Currency | Venues |
|---|
| US Equities | USD | Alpaca Paper, Alpaca Live, Public.com, Webull, Robinhood, Interactive Brokers, Fidelity |
| Prediction Markets | USDC.e | Polymarket |
| Tokenized Assets | USDC | Jupiter DEX (Solana) |
Connecting a Venue
- Alpaca: OAuth flow — click “Connect” on the Portfolio page, authorize with your Alpaca account, and you are linked immediately.
- Polymarket: Wallet-based — Scalar Field provisions a managed wallet on Polygon. Fund it with USDC to start trading. No external wallet connection required.
- Jupiter DEX: Wallet-based — Scalar Field provisions a managed Solana wallet. Fund it with USDC to trade tokenized equities (xStocks) and any verified Solana token.
- Read-only venues (Robinhood, Interactive Brokers, Fidelity): Linked via Plaid for portfolio viewing. No trade execution.
Venue Functions Reference
The venue module provides functions for account data, positions, balances, trade history, and order placement. These functions are available in chat code execution. For automated strategy agents, use the strategy module instead (see Strategies).
venue.account()
Returns a snapshot of all connected venues with balances, positions, and metadata.
from scalarlib import venue
# All connected venues
data = venue.account()
for acct in data["accounts"]:
print(acct["name"], acct.get("portfolio_value"))
# Single venue
data = venue.account(account="Alpaca Paper")
alpaca = data["accounts"][0]
print(alpaca["cash"], alpaca["buying_power"])
Parameters
| Parameter | Type | Required | Description |
|---|
account | str | No | Filter by venue name (e.g. "Alpaca Paper", "Polymarket", "wallet_sol"). Returns all venues if omitted. |
Return Schema
Returns {"accounts": [...]} where each account contains fields relevant to its type:
Brokerage accounts (Alpaca):
| Field | Type | Description |
|---|
name | string | Venue name (e.g. "Alpaca Paper") |
type | string | "brokerage" |
cash | float | Available cash balance (USD) |
buying_power | float | Total buying power |
portfolio_value | float | Total account value |
positions | list | Open positions (see position fields below) |
Exchange accounts (Polymarket):
| Field | Type | Description |
|---|
name | string | "Polymarket" |
type | string | "exchange" |
positions | list | Open prediction market positions with token_id, title, outcome, qty, avg_price, price, market_value, unrealized_pnl |
Wallet accounts (Jupiter DEX / Solana):
| Field | Type | Description |
|---|
name | string | "wallet_sol" |
type | string | "wallet" |
chain | string | "solana" |
cash | float | USDC balance |
portfolio_value | float | Total value of all holdings |
positions | list | Tokenized equity positions with symbol (e.g. "T:AAPLX"), qty, avg_price, price, market_value, unrealized_pnl |
Position fields (common across venue types):
| Field | Type | Description |
|---|
symbol | string | Ticker symbol (equities) or token identifier |
qty | float | Number of shares/tokens held |
avg_price | float | Average entry price |
price | float | Current market price |
market_value | float | Current position value |
cost_basis | float | Total cost of the position |
unrealized_pnl | float | Unrealized profit/loss |
venue.positions()
Returns a flat list of all positions across all venues, each tagged with its venue name.
from scalarlib import venue
# All positions across all venues
all_pos = venue.positions()
for p in all_pos:
print(p["venue"], p["symbol"], p["qty"], p["unrealized_pnl"])
# Positions for a specific venue
poly_pos = venue.positions(account="Polymarket")
jupiter_pos = venue.positions(account="wallet_sol")
Parameters
| Parameter | Type | Required | Description |
|---|
account | str | No | Filter by venue name. Returns all venues if omitted. |
Return Schema
Returns a list of position dicts. Each position includes a venue field plus the standard position fields (symbol, qty, avg_price, price, market_value, cost_basis, unrealized_pnl). Polymarket positions additionally include token_id, title, outcome, and slug.
venue.balances()
Returns cash and token balances across venues.
from scalarlib import venue
# All balances
all_bal = venue.balances()
# Filter by asset (USDC also matches USDC.E)
usdc = venue.balances(asset="USDC")
Parameters
| Parameter | Type | Required | Description |
|---|
account | str | No | Filter by venue name. |
asset | str | No | Filter by asset symbol (e.g. "USD", "USDC", "POL"). "USDC" also matches "USDC.E". |
Return Schema
Returns a list of balance dicts:
| Field | Type | Description |
|---|
venue | string | Venue name |
asset | string | Asset symbol (e.g. "USD", "USDC") |
amount | float | Balance amount |
usd_value | float | USD equivalent |
Exchange accounts (Polymarket) are skipped — they hold positions, not fungible balances. Polymarket funds live in the wallet_pol wallet.
venue.history()
Returns unified financial history across all venues — trades, transfers, dividends, and fees — sorted newest first.
from scalarlib import venue
# Recent activity
all_activity = venue.history(limit=50)
# Trades only on Alpaca
trades = venue.history(category="trade", account="Alpaca Paper")
# Wallet transfers
transfers = venue.history(category="transfer", account="wallet_pol")
# Jupiter trades for a specific symbol
jupiter = venue.history(symbol="T:AAPLX", account="wallet_sol")
Parameters
| Parameter | Type | Required | Description |
|---|
symbol | str | No | Filter by symbol (ticker, token ID, or tokenized asset symbol). |
start | str | No | Start date ("YYYY-MM-DD", New York time). |
end | str | No | End date (same format). |
limit | int | No | Maximum number of records to return. |
offset | int | No | Pagination offset. |
account | str | No | Filter by venue name. |
category | str | No | "trade" (buys/sells only), "transfer" (wallet transfers only), or None (all categories). |
Return Schema
Returns a list of history dicts:
| Field | Type | Description |
|---|
venue | string | Venue name |
category | string | "trade", "transfer", "dividend", or "fee" |
side | string | "buy", "sell", "send", or "receive" |
symbol | string | Ticker or token symbol (null for transfers) |
qty | float | Quantity traded (null for transfers) |
price | float | Execution price (null for transfers) |
amount | float | Transfer amount in asset units (null for trades) |
fees | float | Fees charged on this transaction |
tx_hash | string | Blockchain transaction hash (on-chain venues only) |
status | string | Transaction status (e.g. "SUCCESS", "confirmed") |
ts | string | Timestamp in New York time ("YYYY-MM-DD HH:MM:SS") |
venue.trade()
Places a buy or sell order on a connected venue. Direct execution — no approval workflow.
from scalarlib import venue
# Buy equities on Alpaca
resp = venue.trade("buy", "AAPL", 5)
resp = venue.trade("sell", "MSFT", 10, account="Alpaca Paper")
# Buy prediction market tokens on Polymarket
from scalarlib import screenPolymarkets
markets = screenPolymarkets(query="bitcoin", closed=False)
token_id = markets.iloc[0]["token_ids"][0]
resp = venue.trade("buy", token_id, 100, account="Polymarket")
# Buy tokenized equities on Jupiter DEX
resp = venue.trade("buy", "T:AAPLX", 5, account="wallet_sol")
resp = venue.trade("sell", "T:AAPLX", 2.5, account="wallet_sol", slippage_bps=100)
# Trade any Solana token by mint address
from scalarlib import searchJupiterTokens
tokens = searchJupiterTokens("bonk")
mint = tokens.iloc[0]["mint_address"]
resp = venue.trade("buy", f"T:{mint}", 1000000, account="wallet_sol")
Parameters
| Parameter | Type | Required | Description |
|---|
action | str | Yes | "buy" or "sell" |
symbol | str | Yes | Ticker for equities (e.g. "AAPL"), outcome token ID for Polymarket, or "T:<symbol>" / "T:<mint_address>" for Jupiter. |
qty | float | Yes | Number of shares/tokens to buy or sell. Fractional quantities are supported on all venues. |
account | str | No | Venue name (e.g. "Alpaca Paper", "Polymarket", "wallet_sol"). Auto-selected when only one writable venue exists. |
slippage_bps | int | No | Slippage tolerance in basis points. Default: 50 bps (0.5%) for Jupiter, 500 bps (5%) for Polymarket. Ignored for Alpaca. |
Return Schema
| Field | Type | Description |
|---|
status | string | "FILLED", "PARTIALLY_FILLED", "PENDING", "REJECTED", or "FAILED" |
symbol | string | The traded symbol |
action | string | "buy" or "sell" |
qty | float | Requested quantity |
filled_qty | float | Actual quantity filled (may differ due to slippage) |
avg_price | float | Average fill price |
broker_order_id | string | Broker/venue order identifier |
fee_bps | int or null | Platform fee rate in basis points (null when 0) |
fee_amount | float or null | Platform fee amount (null when 0) |
reason | string or null | Rejection/failure reason |
ts | string | Execution timestamp in New York time |
Alpaca orders may return "PENDING" — the order is submitted but not yet filled. Jupiter and Polymarket orders are synchronous and always block until the fill completes.
Important Notes
- Fractional shares: All venues support fractional orders. When computing quantity from a dollar budget, use
round(budget / price, 2) — never int(), which floors to 0 when the budget is less than one share price.
- Dust positions: On Jupiter and Polymarket, selling an entire position may leave a tiny residual quantity due to rounding (e.g. 0.0001 tokens worth 0.02).Treatanypositionwith‘abs(marketvalue)<0.10` as effectively closed.
- Settlement delay: After a Jupiter or Polymarket trade, positions and balances may take a moment to reflect the fill due to on-chain settlement. Allow a brief delay before re-querying.
searchJupiterTokens()
Search for verified tokens tradeable on Jupiter DEX by name, symbol, or mint address.
from scalarlib import searchJupiterTokens
tokens = searchJupiterTokens("bonk")
print(tokens[["symbol", "name", "mint_address", "price"]])
# Trade the first result
mint = tokens.iloc[0]["mint_address"]
resp = venue.trade("buy", f"T:{mint}", 1000000, account="wallet_sol")
Parameters
| Parameter | Type | Required | Description |
|---|
query | str | Yes | Search string (token name, symbol, or mint address). |
limit | int | No | Maximum results (default 20). |
Return Schema
Returns a pandas DataFrame:
| Column | Type | Description |
|---|
mint_address | string | Solana mint address — use with venue.trade() as "T:<mint_address>" |
symbol | string | Token symbol (e.g. "BONK", "JUP") |
name | string | Token name |
decimals | int | Token decimal places |
price | float | Current USD price |
mcap | float | Market capitalization |
volume_24h | float | 24-hour trading volume |
liquidity | float | Available liquidity |
holder_count | int | Number of token holders |