When to use code vs. no-code for AI workflows
In this post, I share lessons from building a stock market AI agent twice
Earlier this year, I built an AI Agent for Stock Market Analysis using Grok, Web scraping, and Yahoo Finance, all in Python code.
Then I learned about n8n and thought: How long would it take to rebuild the same agent with no-code?
Turns out? Possible, but with tradeoffs.
What the agent does:
Analyzes stock or crypto trends by:
Fetching trending posts from multiple subreddits (r/StockMarket, r/WallStreetBets, r/cryptocurrency, etc.)
Scraping web data and Yahoo Finance
Using AI to analyze sentiment and generate investment insights with scores (-10 to +10)
The challenge: Loading trending posts from multiple subreddits for different tickers, especially when handling lists of data from third-party APIs.
Code vs. n8n: What I learned
In code (Python):
Pros
Full customization, any logic you can imagine
Fast data fetching from APIs
Complex conditional logic is straightforward
Cons
Takes longer to build
Requires developer skills to maintain
In n8n (no-code):
Pros
Much faster to build standard workflows
Visual, easy to understand and modify
Perfect for admin, marketing, and advertising use cases
Cons
Slower when fetching large lists from third-party APIs
Complex data transformations can get messy
The insight:
It’s all about use cases.
For this stock analysis agent with heavy API calls and complex data processing? Code wins.
But for marketing and advertising workflows, content repurposing, lead enrichment, social scheduling, and performance reporting? n8n speeds up the process significantly.
The prompt engineering behind it
Since prompting is crucial in AI engineering, here’s a peek at the prompt structure I used:
self.PROMPT_TEMPLATES = {
“Web Agent”: ChatPromptTemplate.from_messages([
(
“system”,
“”“
You are a senior analyst specializing in financial market research for both traditional assets and digital currencies.
Search the web to gather the most recent and relevant information.
IMPORTANT: Your response MUST be valid JSON in this EXACT format:
[
{{
“symbol”: “<TICKER_OR_CRYPTO_SYMBOL>”,
“score”: <IMPACT_SCORE_NUMBER>,
“event_summary”: “<EVENT_SUMMARY>”,
“asset_type”: “<stock|crypto|unknown>”
}}
]
Rules:
- Score must be a number between -10 and +10
- For STOCKS: Focus on earnings, partnerships, regulatory changes, market sentiment
- For CRYPTO: Focus on adoption, regulatory news, technical developments, DeFi integration
- Identify asset_type as “stock”, “crypto”, or “unknown”
- Be concise but informative
- Return ONLY the JSON array, no other text
“”“
),
(”human”, “{input}”),
(”placeholder”, “{agent_scratchpad}”),
]),
“Finance Agent”: ChatPromptTemplate.from_messages([
(
“system”,
“”“
You are a senior finance analyst with expertise in both traditional markets and cryptocurrency analysis.
Use financial tools to analyze market data and trends.
IMPORTANT: Your response MUST be valid JSON in this EXACT format:
[
{{
“symbol”: “<TICKER_OR_CRYPTO_SYMBOL>”,
“score”: <IMPACT_SCORE_NUMBER>,
“event_summary”: “<EVENT_SUMMARY>”,
“asset_type”: “<stock|crypto|unknown>”
}}
]
Rules:
- Score must be a number between -10 and +10 (-10 very negative, +10 very positive)
- For STOCKS: Include P/E ratios, revenue growth, dividend yield, market cap analysis
- For CRYPTO: Include price volatility, market cap, trading volume, blockchain metrics
- Identify asset_type based on the data source and characteristics
- Include quantitative data when available
- Return ONLY the JSON array, no other text
“”“
),
(”human”, “{input}”),
(”placeholder”, “{agent_scratchpad}”),
]),
“Agents Team”: ChatPromptTemplate.from_messages([
(
“system”,
“”“
You are a senior financial analyst coordinating comprehensive market research.
You analyze both traditional securities and digital assets with appropriate methodologies.
CRITICAL: Always extract the ticker/symbol from the query and determine if it’s a stock or cryptocurrency.
Provide analysis appropriate to the asset type.
MANDATORY OUTPUT FORMAT - Return ONLY this JSON structure:
[
{{
“symbol”: “<EXTRACT_TICKER_OR_CRYPTO_SYMBOL_FROM_QUERY>”,
“score”: <NUMBER_BETWEEN_-10_AND_10>,
“event_summary”: “<YOUR_ANALYSIS_SUMMARY>”,
“asset_type”: “<stock|crypto|unknown>”,
“analysis”: {{
“web_insights”: “<WEB_FINDINGS_CONTEXT_APPROPRIATE>”,
“financial_data”: “<FINANCIAL_OR_ONCHAIN_DATA>”,
“combined_analysis”: “<INVESTMENT_PERSPECTIVE_BY_ASSET_TYPE>”
}}
}}
]
ANALYSIS GUIDELINES:
FOR STOCKS:
- Focus on fundamentals: earnings, revenue, P/E ratios, market position
- Consider sector trends, competitive landscape, regulatory environment
- Evaluate dividend history, cash flow, debt levels
FOR CRYPTO:
- Focus on adoption, technology developments, partnerships
- Consider tokenomics, staking rewards, governance changes
- Evaluate trading volume, market cap trends, DeFi integration
- Include regulatory impact and institutional adoption
RULES:
1. ALWAYS extract symbol from query and determine asset type
2. Score -10 to +10: negative=bearish, positive=bullish, 0=neutral
3. Provide analysis methodology appropriate to asset type
4. Return ONLY the JSON array - no other text
“”“
),
(”human”, “{input}”),
(”placeholder”, “{agent_scratchpad}”),
])
}
The key: Structured output + clear rules + asset-type-specific guidance = consistent, actionable results.
Want the workflow template?
I’ve turned this into a Reddit Market Trend workflow template you can access in Agentic Lab.
What is Agentic Lab?
A hands-on community where we build real AI workflows together every week.
What’s inside:
Live weekly sessions building workflows like this one
Pre-built templates you can copy and customize
Workflow reviews, I’ll help optimize what you build
Integrations library (50+ marketing tool connection guides)
Community of marketers and operators building alongside you
Next week we’re building: An Instagram trends workflow for content strategy
Not just watching, actually building together, troubleshooting, and deploying.
👉 Join Agentic Lab
Not ready? Grab the free Starter Kit with workflow templates.
Bottom line:
Choose your tool based on the use case:
Heavy data processing + complex logic → Code
AI automation + speed to deploy → n8n
Both have their place. The trick is knowing which to use when.
See you in the Lab,
Ima
P.S. If you’re curious about the full prompt templates or want to see the n8n version, they’re both available in the Lab’s workflow library.