Build a Phone Controlled Trading Assistant
Create a safety first Telegram system that reads a paper portfolio, researches markets, produces reports and alerts, and prepares confirmed orders with persistent memory, risk limits, and an
Download the complete trading assistant blueprint
Build a Phone Controlled Trading Assistant
Connect paper trading, live market data, persistent memory, alerts, and Telegram without exposing your full portfolio.
What you will achieve
You will have a safety first blueprint for an AI assistant that can inspect a paper portfolio, produce market reports, send alerts, and prepare or submit trades from Telegram.
Who this is for
Technically comfortable investors and traders who can configure APIs, run a coding agent, and supervise automated actions.
Difficulty: Intermediate
Short tutorial
Connect paper trading, live market data, persistent memory, alerts, and Telegram without exposing your full portfolio.
Guide: Build a Phone Controlled AI Trading Assistant
Time: 60-90 minutes
This tutorial shows you how to assemble a mobile portfolio assistant from five parts: an AI runtime, a broker or exchange connector, financial data sources, a persistent memory folder, and a Telegram bot.
Start with paper trading. Build read and reporting functions first, add alerts next, and enable order submission only after testing every action. This is an experimental system, not financial advice, and it should never receive unrestricted access to your entire portfolio.
Understand the architecture
The complete message flow is:
Telegram on your phone
↓
Always available AI runtime
↓
Memory folder + financial data connectors
↓
Paper broker or exchange API
↓
Report, alert, or proposed order returned to TelegramThe source implementation uses Claude Code as the runtime, but a comparable coding agent such as Codex can serve the same role if it supports the required connectors and local files.
| Layer | Purpose | Options described in the source |
|---|---|---|
| Runtime | Interprets requests and coordinates tools | Claude Code or Codex |
| Compute | Keeps the complete bot available | Mac mini, desktop, old computer, or remote server |
| Equities execution | Reads positions and submits orders | Alpaca, with paper trading recommended |
| Crypto execution | Reads positions and submits orders | Bybit MCP, testnet or isolated subaccount recommended |
| Market data | Supplies current financial information | FMP, Quiver, Massive |
| Memory | Stores strategy, preferences, and trade history | Local folder accessible to the runtime |
| Mobile interface | Sends commands and receives alerts | Telegram bot |
The transcript calls the low cost remote compute option a “VPN,” but its description resembles a VPS or another always available remote server. Confirm the intended service before purchasing anything.
1. Establish nonnegotiable safety controls
Use these rules before connecting any account:
- Begin with paper trading or testnet funds.
- If paper trading is unavailable, use a separate subaccount containing only a small test amount.
- Disable withdrawals on every trading API key.
- Enable two factor authentication on the broker, exchange, Telegram, and hosting accounts.
- Do not connect the assistant to your entire net worth.
- Use separate API credentials for testing and production.
- Start with read access, then allow paper orders, then consider limited live orders.
- Require a fresh account query immediately before any order.
- Require an explicit confirmation message before submission.
- Record every request, proposed action, broker response, error, and final status.
A sensible permission sequence is:
Stage 1: Read portfolio and market data only Stage 2: Generate proposed paper orders Stage 3: Submit paper orders after explicit confirmation Stage 4: Use a limited live subaccount only after sustained testing
2. Prepare the runtime
For the full Telegram and local memory design, the runtime must remain available. If the machine shuts down, the bot cannot reach its local files or process Telegram requests.
Choose one option:
- A dedicated desktop or Mac mini that remains powered on.
- An old computer that can run the coding agent reliably.
- A remote server with internet access and enough capacity to run the terminal based agent.
Alpaca exposes a cloud API, so some integrations can operate without a personal computer remaining on. The complete design in this tutorial still needs an available runtime somewhere to process Telegram messages, schedules, and memory files.
Verify that the machine can:
- Maintain internet access.
- Run your chosen coding agent.
- Read and write the memory folder.
- Reach broker and data APIs.
- Restart the bot after a reboot or process failure.
3. Create the persistent memory folder
Create one folder that both the assistant and bot process can access:
trading-assistant/
memory/
investor-profile.md
strategy.md
risk-rules.md
watchlist.md
learnings.md
ledger/
trades.csv
bot-events.log
reports/
app/
.envDo not commit .env, API tokens, or account credentials to a public repository.
Investor profile template
Save this as memory/investor-profile.md:
# Investor profile ## Account mode Paper trading only ## Objectives Primary objective: [capital growth, income, preservation, or other] Time horizon: [time period] ## Risk context Maximum acceptable portfolio drawdown: [percentage] Maximum position size: [percentage] Maximum daily order value: [amount] Assets I will not trade: [list] ## Portfolio context Accounts connected: [paper accounts only at first] Existing concentration concerns: [details] Liquidity needs: [details] ## Preferences Preferred sectors or assets: [list] Restricted sectors or assets: [list] Reporting currency: [currency] Time zone: [time zone] ## Approval policy The assistant may analyze and propose actions. The assistant must not submit an order without an explicit confirmation message containing the order identifier.
Strategy and risk template
Save this as memory/strategy.md:
# Trading strategy ## Universe Allowed instruments: [list] Allowed account: [paper account identifier] ## Entry conditions 1. [condition] 2. [condition] 3. [condition] ## Exit conditions 1. [condition] 2. [condition] 3. [condition] ## Position sizing Sizing method: [fixed value, portfolio percentage, or other] Maximum single position: [percentage] Maximum sector allocation: [percentage] ## Execution Allowed order types: [list] Allowed trading hours: [times] Orders require confirmation: Yes ## Prohibited behavior Do not infer missing quantities, symbols, prices, or account identifiers. Do not submit an order when account data is stale or unavailable. Do not submit an order when a risk rule would be violated. Do not enable or request withdrawals.
Save hard limits separately in memory/risk-rules.md. Keeping them separate makes them easier to audit and harder to confuse with descriptive preferences.
Trade ledger
Initialize ledger/trades.csv with:
timestamp,environment,request_id,symbol,side,quantity,notional,order_type,status,broker_order_id,rationale,error,review_notes
The ledger should capture rejected and failed requests as well as completed orders. Those records let you diagnose what went wrong and add lessons to memory/learnings.md.
4. Connect one paper execution account
Do not connect multiple brokers during the first build. Choose one path and prove the workflow end to end.
Equities path
The source recommends Alpaca for beginners because paper trading is available within the account. Paper and live modes use different settings, and live access requires the broker’s identity verification process.
- Create or select the paper trading environment.
- Generate credentials for that environment only.
- Add the Alpaca MCP or API integration supported by your coding agent.
- Confirm that the endpoint or account mode is paper trading.
- Test account and position reads before testing orders.
Crypto path
The source uses Bybit through its official MCP connection.
- Use testnet if available for your intended workflow, or create an isolated subaccount.
- Generate an API key with only the permissions required for testing.
- Keep withdrawal permission disabled.
- Connect the key through the supported Bybit MCP setup.
- Test balances and positions before any paper or limited order action.
The source does not provide exact MCP installation commands. Connector commands and authentication fields can change, so use the current instructions shown by the selected connector rather than guessing package names or command syntax.
5. Add financial data connectors
Broker data tells the assistant what you own. Dedicated market data connectors provide the context needed to analyze it.
The source describes these options:
- FMP: A practical first connector for stock data, filings, and crypto prices.
- Quiver: Additional information such as insider transactions, congressional filings, and hedge fund positioning.
- Massive: Named as a third data source, although its specific role is not detailed in the source.
Start with FMP. Add Quiver only after basic portfolio queries work.
For Claude, the described path is Settings, then Connectors, then locate FMP. Quiver requires an account and API key, which the coding runtime can use to establish the connection.
Run these validation requests before moving on:
Query the connected financial data source for the latest available price and timestamp for [SYMBOL]. Identify the source and clearly state whether the result is delayed or real time. Do not use general web search as a substitute.
Retrieve the latest available filing data for [SYMBOL]. Return the filing type, filing date, source connector, and a concise factual summary. If the connector returns nothing, say so without filling gaps from memory.
Using the connected account, list current positions and portfolio weights. Then compare the totals with the account equity. Flag discrepancies instead of estimating missing values.
6. Create the Telegram interface
Telegram is the mobile command and notification layer. The analysis and execution still happen on the runtime machine.
- Open Telegram and start a conversation with BotFather.
- Create a new bot and copy the token it provides.
- Store the token as a secret available to the bot process.
- Configure the application to accept messages only from your approved Telegram user or chat identifier.
- Send a test message and confirm that the runtime returns a response.
- Restart the runtime and verify that the bot reconnects automatically.
Treat the bot token like a password. If it is exposed, rotate it through BotFather.
For voice input, the source recommends transcribing speech into text on the phone before sending it. It reports that raw text is faster and more reliable than sending voice notes for server side transcription. A phone transcription tool such as Whisper Flow was used in the source implementation.
7. Give the coding agent a complete build specification
Paste the following prompt into your coding agent after creating the folder and obtaining paper credentials. Replace bracketed values before use.
Build a Telegram based portfolio assistant in the current project folder. Environment: 1. The execution account is [ALPACA PAPER or BYBIT TESTNET]. 2. Use paper or test funds only. 3. The memory folder is ./memory. 4. Write trade records to ./ledger/trades.csv. 5. Write bot activity and errors to ./ledger/bot-events.log. 6. Use the connected financial data tools when current market data is required. Required functions: 1. Read account equity, cash, positions, open orders, and recent transactions. 2. Calculate portfolio allocation by position and sector when sector data is available. 3. Generate a morning portfolio report and save a copy under ./reports. 4. Evaluate configurable price, position, and data alerts. 5. Research a symbol using connected data sources and cite the source and timestamp. 6. Create proposed orders, but do not submit them immediately. 7. Return every proposed order with a unique request ID, symbol, side, quantity or notional value, order type, estimated portfolio impact, and risk rule checks. 8. Submit an order only when I send: CONFIRM [request ID]. 9. Reject expired confirmations and confirmations from unapproved Telegram users. 10. Query the account again immediately before submission. 11. Refuse any order that violates ./memory/risk-rules.md. 12. Append all proposals, confirmations, submissions, rejections, broker responses, and errors to the logs. Security requirements: 1. Load secrets from environment variables. Never print secrets or write them to logs. 2. Accept Telegram commands only from the approved chat ID [CHAT ID]. 3. Never request or enable withdrawal permission. 4. Never switch from paper to live mode automatically. 5. Redact account identifiers in Telegram responses. 6. Default to no action when data, authorization, or intent is ambiguous. Implementation process: 1. Inspect the project and available connectors. 2. Tell me which credentials and settings are required, without asking me to paste secrets into chat. 3. Implement read only account queries first. 4. Add automated tests using mocked broker responses. 5. Add paper order proposals and confirmation handling. 6. Add reports and alerts last. 7. Provide commands for starting, stopping, testing, and checking logs. 8. Stop and ask me for clarification if connector names, endpoints, or account modes cannot be verified. Do not place any order during setup. Finish by giving me a paper trading acceptance checklist.
8. Configure reports and alerts
Begin with informational alerts. Do not make an alert trigger an automatic trade.
Morning report prompt
Generate my morning portfolio report using the connected paper account and financial data sources. Include: 1. Timestamp and data sources. 2. Account equity, cash, and daily change when available. 3. Positions and portfolio weights. 4. Sector allocation when classification data is available. 5. Open orders. 6. Major overnight headlines that may affect current holdings. 7. New filings or insider activity relevant to current holdings, when available through connected tools. 8. Risk rule violations or unusual account changes. Separate verified account facts from analysis. Do not recommend or place a trade. Send the concise report to Telegram and save the full report in ./reports.
Position movement alert
The source gives a 5 percent daily decline as an example:
Check my positions on the configured schedule. Notify me in Telegram when a position has fallen more than 5 percent during the current trading day. Include the symbol, percentage move, position weight, data timestamp, and source. Do not submit a trade.
Insider activity alert
Using the connected insider transaction data, notify me when a semiconductor company meets my configured threshold for major insider accumulation. Include the company, symbol, transaction dates, insider roles, transaction values when available, source, and retrieval time. Do not label the event bullish or place a trade.
Define what “major” means in your own risk rules. Without a numeric threshold, the assistant may interpret the term inconsistently.
9. Test phone commands in increasing order of risk
Read only queries
Break down my paper portfolio by position and sector. Show allocation percentages, source timestamps, and any positions you could not classify.
Which companies in the connected data set currently show three or more insiders buying? State the time window used and return source records rather than an investment recommendation.
For Nvidia, retrieve any available congressional updates, filings, or insider transactions that may be relevant to my research. Separate facts from interpretation and include dates and sources.
Proposed paper order
Using the paper account only, prepare a proposal to buy $100 of Nvidia. Check the latest account data and my risk rules. Do not submit it. Return the request ID, estimated quantity, order type, estimated portfolio weight after the order, and confirmation syntax.
A safe response should resemble:
PROPOSED PAPER ORDER Request ID: P-1042 Symbol: NVDA Side: Buy Notional: $100 Order type: Market Risk checks: Passed Status: Awaiting confirmation To submit: CONFIRM P-1042
Do not confirm until the symbol, account mode, side, value, and order type are correct.
Rebalancing proposal
Using the paper account only, prepare a proposal to reduce my equities exposure by 5 percent and allocate the proceeds equally between my permitted gold instrument and permitted US Treasury bill instrument. Do not choose instruments that are absent from my allowed universe. Show every proposed order, allocation before and after, timing assumptions, and risk checks. Do not submit anything.
This wording prevents the assistant from inventing tradable instruments when your strategy file has not defined them.
10. Complete acceptance testing
Do not consider the assistant ready until all of these pass:
- [ ] Telegram rejects a message from an unauthorized account.
- [ ] The broker connection clearly reports paper or test mode.
- [ ] Portfolio totals match the broker interface.
- [ ] Market data responses include source timestamps.
- [ ] Missing data produces an error or uncertainty statement, not an estimate.
- [ ] A proposed order does not execute without confirmation.
- [ ] An incorrect or expired request ID is rejected.
- [ ] A risk limit violation blocks the order.
- [ ] Every attempted action appears in the ledger or event log.
- [ ] API secrets never appear in Telegram, reports, or logs.
- [ ] Withdrawal permission is disabled.
- [ ] Two factor authentication is enabled.
- [ ] The bot reconnects safely after a runtime restart.
- [ ] Reports and alerts do not trigger trades automatically.
Run the system with paper funds until its account calculations, confirmation behavior, alerts, failure handling, and logs are consistently correct. If you later introduce live funds, use a separate limited account and retain the same confirmation and risk controls.