Can you provide a llm prompt that can get me started with alpaca? I'm using copilot in visual studio and would like for the prompt to review the work I have already done and add to these goals.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here's a comprehensive LLM prompt you can use with Copilot in Visual Studio to get started with Alpaca integration:
code
You are an expert Python developer specializing in financial applications and trading APIs. I'm building a modern investment tracking and trading application for retail investors and active traders using the Alpaca API.
CONTEXT:
Please review my existing codebase and help me integrate Alpaca's trading API to achieve the following goals:
CORE REQUIREMENTS:
1. Connect to Alpaca's REST API and WebSocket streaming
2. Implement portfolio holdings retrieval and display
3. Add trade execution capabilities (market, limit, stop-loss, bracket, trailing stop orders)
4. Create performance analysis and tracking features
5. Implement paper trading mode for backtesting
6. Add real-time market data streaming
7. Build order management system with custom order types
TECHNICAL SPECIFICATIONS:
- Use Alpaca's official Python SDK (alpaca-trade-api)
- Implement proper error handling and rate limiting
- Follow async/await patterns where appropriate for real-time data
- Include comprehensive logging for debugging
- Implement secure credential management (environment variables)
- Add data validation for all API requests/responses
- Create modular, testable code structure
ALPACA API FEATURES TO IMPLEMENT:
- Account information and buying power
- Portfolio positions and P&L tracking
- Order placement, modification, and cancellation
- Real-time market data via WebSocket
- Historical data retrieval for backtesting
- Paper trading environment setup
- Asset search and market hours checking
CODE STRUCTURE PREFERENCES:
- Create separate modules for: API client, order management, portfolio tracking, data streaming
- Use dataclasses or Pydantic models for data structures
- Implement proper exception handling with custom exception classes
- Add type hints throughout
- Include docstrings following Google/NumPy style
- Create configuration management for API keys and settings
SPECIFIC TASKS:
1. Review my existing code and identify integration points
2. Set up Alpaca API client with proper authentication
3. Create base classes for portfolio, orders, and market data
4. Implement WebSocket connection for real-time data streaming
5. Add paper trading toggle functionality
6. Create order validation and risk management checks
7. Build data persistence layer (if not already present)
8. Add comprehensive error handling and logging
EXAMPLE FEATURES TO IMPLEMENT:
- Real-time portfolio value updates
- Stop-loss and take-profit order automation
- Position sizing calculations
- Performance metrics (Sharpe ratio, max drawdown, etc.)
- Trade history and analytics
- Market data caching and optimization
Please analyze my existing code structure and provide:
1. Integration recommendations based on my current architecture
2. Code examples for core Alpaca API functionality
3. Suggestions for improving existing code to work with Alpaca
4. Best practices for handling real-time data and order management
5. Testing strategies for both paper and live trading modes
Focus on production-ready, scalable code that follows financial industry best practices for security and reliability.
This prompt will help Copilot:
Understand your context - It knows you're building a trading app with specific goals
Review existing code - It will analyze what you already have and suggest integration points
Provide targeted solutions - Focused on Alpaca API specifically with your requirements
Follow best practices - Emphasizes security, error handling, and production-ready code
Create modular code - Suggests proper architecture for scalability
You can also add this follow-up prompt after Copilot reviews your code:
code
Based on your analysis of my existing code, please:
1. Create a step-by-step implementation plan prioritized by importance
2. Identify any potential conflicts or refactoring needed in my current code
3. Provide specific code examples for the top 3 most critical integrations
4. Suggest a testing strategy that works with my current setup
5. Recommend any additional dependencies or tools I should consider
Please start with the most essential Alpaca integration that will give me immediate functionality, then build from there.
This approach will give you a tailored response that builds on your existing work rather than starting from scratch, which should accelerate your development significantly.