Building AI Agents from Scratch: Cloud, Local, and VPS Deployment for Stock Research
This article compares three ways to deploy an open-source AI agent platform—cloud hosting, local Docker deployment, and VPS self-hosting—and then presents a practical architecture for a stock research agent covering data access, RAG knowledge bases, analysis workflows, risk controls, and a staged rollout path.
Building AI Agents from Scratch: Cloud, Local, and VPS Deployment for Stock Research
In recent years, open-source AI application development platforms—often also called LLM application orchestration platforms—have significantly lowered the barrier to building AI agents. These platforms typically provide visual workflows, knowledge base retrieval, prompt orchestration, and Agent tool-calling capabilities, making it possible to build complex AI applications with little or no code. This article focuses on three core questions: how to choose a deployment method, how to design a stock research agent, and which pitfalls to avoid during implementation.
1. Comparing Three Deployment Options
1.1 Cloud Hosting: The Fastest Way to Start
The biggest advantage of the cloud version is that users can start immediately after registration. The platform provider hosts the service on its own infrastructure, so users do not need to manage operations, upgrades, or environment dependencies. This makes it suitable for individual developers validating prototypes.
However, convenience comes with limits and costs:
- Application limits: Free quotas usually allow only a small number of applications, commonly around five, which is not enough for parallel experiments across many scenarios.
- Collaboration limits: Free versions are often designed for a single account and single user, without team collaboration or permission management.
- Resource quotas: Model calls, vector storage capacity, and workflow execution frequency all have upper limits.
- Data boundaries: Data passes through a third-party cloud environment, which teams with compliance sensitivity need to evaluate.
If enterprises or teams decide to use a cloud solution, they generally need to upgrade to a paid plan to obtain higher quotas, member collaboration, and more complete support.
1.2 Local Deployment: Maximum Freedom
The standard approach for local deployment is to run the entire platform on container technology such as Docker. In a Windows environment, for example, users first install Docker Desktop and keep it running in the background, then pull the image, configure environment variables, and start the container according to the official process.
The core advantage of local deployment is that it removes cloud limits:
- The number of applications and workflow complexity are no longer constrained by a subscription plan.
- Data stays entirely local, which is suitable for sensitive data.
- Local models or privately deployed open-source models can be connected freely.
However, its runtime prerequisites also matter: the computer must be powered on and the Docker environment must be running before a workflow can be triggered. This means it is not suitable for 24/7 unattended tasks. In addition, the local machine’s CPU, memory, and GPU resources directly determine usability.
1.3 VPS Self-Hosting: A Balance Between Freedom and Stability
A third option is to purchase a VPS (Virtual Private Server) and install the platform on a remote server. This preserves the freedom of local deployment while providing always-on availability, making it suitable for scheduled tasks—such as fetching market data after the daily close and generating an analysis report—and lightweight external services.
General recommendations for selection:
- Prefer data centers close to the data source or user region to reduce latency.
- Confirm available memory and disk capacity, because containers, vector databases, and logs all consume resources.
- Configure HTTPS through a reverse proxy and expose only necessary ports.
- Back up workflow configurations and knowledge base data regularly.
- Disable SSH password login and use key authentication instead.
The user interface, parameter system, and operation methods of the three deployment options are basically the same, so the learning cost carries over: teams can practice on the cloud first and then migrate to local or VPS deployment with almost no relearning.
2. Using AI Agents for Stock Research: Architecture and Design
Using an agent for stock research essentially means building a pipeline: data acquisition → information processing → analysis and reasoning → report output. Below is a practical, general architecture.
2.1 Data Access Layer
The agent itself does not generate market data, so data sources must be addressed first:
- Market data: Obtain candlestick data, trading volume, and financial indicators through public market interfaces or third-party data service APIs.
- News data: Text inputs such as news, announcements, and research report summaries.
- Proprietary data: For example, your holdings records and trading logs, which can be uploaded as knowledge base documents.
From an engineering perspective, it is advisable to wrap data fetching as an independent Tool/Function and let the Agent call it on demand, rather than inserting raw data directly into the prompt.
# Pseudocode: wrap market data queries as a tooldef get_kline(symbol: str, period: str) -> dict:"""Query candlestick data for the specified symbol"""resp = request_market_api(symbol, period)return normalize(resp) # Standardize field names for downstream use
2.2 Knowledge Base and RAG Layer
Place investment research methodologies, company fundamentals, and historical review notes in the knowledge base, and use vector retrieval-augmented generation (RAG) so that answers are grounded in evidence. Key points:
- Split long documents reasonably, such as by chapter or paragraph, and preserve metadata such as stock code and report date.
- Apply time filtering during retrieval to avoid answering current questions with outdated research reports.
- In the prompt, require the model to cite sources so that humans can verify them.
2.3 Analysis Workflow Layer
A typical stock research workflow can be divided into several nodes:
- Data preprocessing: Clean missing values, unify the adjusted price basis, and calculate technical indicators such as moving averages, MACD, and RSI.
- Multi-factor extraction: Extract valuation, growth, momentum, volatility, and other factors from financial and price-volume data.
- Agent reasoning: Have the Agent combine the knowledge base and factor results to generate bull and bear case logic and scenario analysis.
- Report generation: Output a structured report containing the view, evidence, risk warnings, and trigger conditions.
2.4 Risk Control and Compliance Red Lines
This is the most easily overlooked but most critical part of stock market applications:
- AI output is not investment advice: Any generated analysis must include a disclaimer, and final decisions should be made by humans.
- Prevent overconfidence: Require the model to provide an evidence chain and explain uncertainty, avoiding single-point conclusions.
- Data timeliness: Delayed intraday data and lagging financial report updates can mislead the model, so data timestamps must be marked on the input side.
- Backtest is not live trading: Signal logic in the workflow should first go through historical backtesting, with attention to overfitting and look-ahead bias.
- Cost control: Long contexts and high-frequency calls quickly consume token quotas, so caching intermediate results is recommended.
3. Implementation Recommendations and Evolution Path
For teams trying this for the first time, the following evolution path is recommended:
- Prototype stage (cloud): Use the cloud version to validate prompts and workflow feasibility and quickly iterate on analysis logic.
- Private stage (local): Migrate to local deployment when sensitive data such as proprietary holdings and trading records are involved.
- Service stage (VPS): Migrate to a VPS when scheduled execution, continuous data collection, or multi-user access is needed, and add monitoring, backup, and alerting.
- Enhancement stage: Connect more tools such as market data APIs, financial databases, and notifications, and establish an evaluation set for regression testing of analysis quality.
Regardless of the deployment method chosen, remember: the platform is only an orchestration tool, and the value of the agent depends on data quality, the rigor of the analysis framework, and the design of risk constraints. Only when these three areas are solid, combined with an appropriate deployment form, can an AI agent truly become an efficiency amplifier in the investment research process rather than a “smart-looking” black box.
Summary: Cloud hosting wins on speed, local deployment wins on freedom, and VPS self-hosting wins on stable online availability. All three have consistent operations and support smooth migration. The success of a stock research agent depends on data access, RAG quality, and risk control design, and it should be advanced prudently under the principle of “assisted research, human decision-making.”
