Building Your Financial Environment Module
Throughout this section, we'll only share key code snippets to help you understand the core concepts. Use the financial environment module repository to follow along and for a complete code reference implementation.
Project Setup
First, let's set up our development environment using the recommended module template:
Defining Our State Schema
Our environment module needs to track and define schemas for:
- Current workflow stage (analysis/research/report)
- Stock tickers under analysis
- Financial analysis results
- Market research findings
- Final generated reports
Let's implement our state schemas in schemas.py
:
Configuration Management
We also need to update the deployment.json
file contains the deployment configuration for our environment module.
Core Environment Implementation
Our environment class inherits from Naptha's base Environment class and implements key state management methods:
- get_global_state(): Retrieves current analysis state
- reset(): Clears environment state
- close(): Cleanup resources (future-proofing)
All these will be implemented in the run.py
file.
Run Function Implementation
The run function serves as the main entry point for our environment module:
Example Usage Implementation
We will also be adding an usage implementation that loads our environment deployment configuration and conducts an hypothetical run of our environment module.
Need help with implementation? Join our community