Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mavera.io/llms.txt

Use this file to discover all available pages before exploring further.

Scenario

Your sales team targets multiple verticals but can’t pursue all equally. Alpha Vantage’s SECTOR function returns real-time and historical performance by sector. This job maps sector momentum to marketing effort — invest messaging resources in growing sectors, adopt defensive positioning in declining ones, and generate vertical-specific campaign copy for the top priorities. Flow: Alpha Vantage GET ?function=SECTOR → Rank by performance → Mavera POST /mave/chat + POST /generations → Vertical priority matrix + copy

Code

import os, requests, time

AV_KEY = os.environ["ALPHA_VANTAGE_KEY"]
AV_BASE = "https://www.alphavantage.co/query"
MV = os.environ["MAVERA_API_KEY"]
MV_BASE = "https://app.mavera.io/api/v1"
MV_H = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}

PRODUCT = "marketing analytics platform"

# 1. Fetch sector performance
r = requests.get(AV_BASE, params={"function": "SECTOR", "apikey": AV_KEY})
r.raise_for_status()
sector_data = r.json()

timeframes = {
    "1 Day": "Rank A: Real-Time Performance",
    "1 Month": "Rank D: Month Performance",
    "3 Months": "Rank E: Quarter Performance",
    "1 Year": "Rank G: Year Performance",
}

sector_summary = []
for label, key in timeframes.items():
    data = sector_data.get(key, {})
    sorted_sectors = sorted(data.items(), key=lambda x: float(x[1].replace("%","")), reverse=True)
    sector_summary.append(f"\n**{label}:**")
    for sector, perf in sorted_sectors:
        sector_summary.append(f"  {sector}: {perf}")

performance_text = "\n".join(sector_summary)
print(f"Sector data retrieved across {len(timeframes)} timeframes")

# 2. Mave prioritization
priority = requests.post(f"{MV_BASE}/mave/chat", headers=MV_H, json={
    "message": f"Marketing strategist. We sell a {PRODUCT}.\n\n"
        f"SECTOR PERFORMANCE:\n{performance_text}\n\n"
        "Create a VERTICAL PRIORITIZATION MATRIX:\n\n"
        "For each sector:\n"
        "1. **Momentum Score** (1-10) — based on recent vs long-term performance\n"
        "2. **Marketing Investment** — Increase / Maintain / Decrease\n"
        "3. **Messaging Strategy** — Growth narrative vs efficiency narrative vs stability narrative\n"
        "4. **Key Angle** — One sentence positioning for this vertical\n"
        "5. **Budget Recommendation** — % of total marketing budget\n\n"
        "Rank by priority. Top 3 get detailed campaign angles."
}).json()
print(f"\n{priority.get('content', '')[:2000]}")

# 3. Generate copy for top sector
gen = requests.post(f"{MV_BASE}/generations", headers=MV_H, json={
    "prompt": f"Based on this vertical prioritization:\n\n{priority.get('content','')[:2000]}\n\n"
        f"Generate campaign copy for the TOP-RANKED sector targeting our {PRODUCT}.\n\n"
        "Include:\n"
        "1. Landing page headline + subheadline\n"
        "2. Three value propositions (sector-specific)\n"
        "3. Email subject line + preview text for outbound\n"
        "4. LinkedIn ad (headline + body + CTA)\n"
        "5. Case study headline template\n\n"
        "Reference sector momentum. Make the copy feel industry-native.",
}).json()
print(f"\n{'='*60}\nTOP SECTOR CAMPAIGN COPY\n{'='*60}")
print(gen.get("output", gen.get("content", ""))[:1500])

Example Output

Sector data across 4 timeframes

VERTICAL PRIORITIZATION MATRIX:
| Sector | Momentum | Investment | Strategy | Budget |
|--------|----------|------------|----------|--------|
| Technology | 9/10 | Increase | Growth narrative | 30% |
| Healthcare | 7/10 | Increase | Efficiency | 20% |
| Energy | 6/10 | Maintain | Stability | 15% |
| Financials | 5/10 | Maintain | Efficiency | 15% |
| Real Estate | 3/10 | Decrease | Survival | 5% |

TOP SECTOR CAMPAIGN COPY (Technology)
============================================================
1. HEADLINE: Marketing Analytics Built for Tech's Growth Pace
   SUB: When your sector grows 18% YoY, your analytics can't lag.

2. VALUE PROPS:
   • Ship campaigns at sprint speed — not quarterly planning cycles
   • Attribution for PLG funnels — track product-led → sales-assisted
   • Benchmark against 200+ SaaS companies in our index

3. EMAIL: "Your sector grew 18% — did your pipeline keep up?"
   Preview: Tech marketing leaders are outpacing revenue growth. Here's how.

4. LINKEDIN: "Tech is outperforming every sector by 2x this quarter.
   Is your marketing analytics keeping pace?" → See the benchmark →

Error Handling

Alpha Vantage uses SEC sector names (e.g., “Information Technology” not “Tech”). Map to your internal vertical names before generating copy.
The SECTOR function returns all timeframes in one call — only 1 of your 25 daily free calls. Cache the response for the full day.
Sectors with negative returns need defensive messaging, not growth messaging. The Mave prompt handles this via the “stability narrative” strategy option.