Skip to main content

Overview

The terminal uses a local SQLite database (apeindex_bot.db). All tables are created automatically on first launch with forward-compatible ALTER TABLE migration for new columns.
The database is single-node SQLite. For multi-user horizontal scaling, migration to PostgreSQL would be required.

Tables

users

Stores per-user configuration, API credentials, and monitoring state.
ColumnTypeDescription
user_idINTEGERTelegram user ID (primary key)
encrypted_api_keysTEXTAES-encrypted CLOB API key pair
monitoring_activeBOOLEANWhether monitoring task is running
trading_modeTEXTmanual or auto
risk_levelTEXTlow, medium, or high
min_trade_amountREALMinimum trade size in USD
max_trade_amountREALMaximum trade size in USD
timezoneTEXTUser’s local timezone for digest
created_atDATETIMEAccount creation timestamp

positions

All open and closed positions with P&L tracking.
ColumnTypeDescription
idINTEGERAuto-increment primary key
user_idINTEGERFK → users
market_idTEXTPolymarket market conditionId
outcomeTEXTYes or No
entry_priceREALPrice at time of execution
current_priceREALLast fetched market price
sizeREALUSD amount invested
stop_lossREALConfigured SL level
take_profitREALConfigured TP level
statusTEXTopen or closed
exit_priceREALPrice at exit (null if open)
pnlREALRealised P&L in USD
opened_atDATETIMETrade execution timestamp
closed_atDATETIMEExit timestamp (null if open)

signal_history

All signals that have fired, used for the daily digest and analytics.
ColumnTypeDescription
idINTEGERAuto-increment primary key
user_idINTEGERFK → users
patternTEXTWhich of the 5 patterns fired
market_idTEXTPolymarket market ID
market_questionTEXTHuman-readable market question
outcomeTEXTSuggested direction
scoreINTEGERComposite score 1–100
fired_atDATETIMESignal timestamp
resolvedBOOLEANWhether market has resolved

watchlist

User-specific market watchlist with entry price tracking.
ColumnTypeDescription
idINTEGERAuto-increment primary key
user_idINTEGERFK → users
market_idTEXTPolymarket market ID
market_questionTEXTHuman-readable question
entry_priceREALYes price at time of addition
added_atDATETIMEAddition timestamp

followed_wallets

Whale wallet addresses tracked per user.
ColumnTypeDescription
idINTEGERAuto-increment primary key
user_idINTEGERFK → users
wallet_addressTEXTPolygon wallet address
labelTEXTOptional user-defined label
added_atDATETIMEAddition timestamp