SHELDON: 'Stock Handling and Evaluation Library for Data Operations and Navigation'
SHELDON is a command-line interface (CLI) tool aimed at helping users analyze, manage, and navigate financial data. It supports tasks like:
- Fetching and analyzing stock prices.
- Evaluating portfolio performance.
- Navigating datasets or APIs related to financial markets.
- Performing computations like ROI, CAGR, or risk assessment.
- Query stock prices for any publicly traded company by its symbol.
- Output data in JSON format for easy integration or further analysis.
- Modular design for future extensibility (e.g., scheduled queries, database integrations).
- Go (version 1.17 or later)
- An Alpha Vantage API key
- Internet connection
-
Clone the repository:
git clone [email protected]:Cesarec88/sheldon.git cd sheldon
-
Install dependencies:
go mod tidy
-
Set up your
.env
file: Create a.env
file in the project root and add your API key and the base URL:ALPHA_VANTAGE_API_KEY=your_api_key_here BASE_URL=https://www.alphavantage.co/query
-
Build the application:
go build -o sheldon main.go
Sheldon uses the Cobra CLI framework to provide a modular and extensible command-line interface.
fetch
: Fetch stock data (latest or historical).- Flags:
--ticker
: The stock ticker to query (required).--limit
: Number of historical elements to return (default: 1 for the latest data).--delta
: Time interval for historical data (e.g.,1min
,daily
,weekly
,monthly
).
- Flags:
-
Fetch the latest stock quote:
./sheldon fetch --ticker=IBM
Output:
{ "Global Quote": { "01. symbol": "IBM", "05. price": "123.45" } }
-
Fetch historical data for a stock:
./sheldon fetch --ticker=IBM --limit=5 --delta=daily
Output: JSON containing 5 daily historical entries.
Run the unit tests:
go test ./...
Expected output:
ok sheldon/internal/config 0.XXXs
ok sheldon/internal/api 0.XXXs
ok sheldon/internal/handler 0.XXXs
sheldon/
│
├── cmd/ # Cobra commands
│ ├── root.go # Root command for the CLI
│ └── fetch.go # Fetch command implementation
│
├── internal/ # Internal packages
│ ├── api/ # API client implementations
│ │ └── client.go # Core API client logic
| | └── client_test.go # Test Core API client logic
│ │
│ ├── config/ # Configuration management
│ │ └── config.go # Loads environment variables and settings
│ │ └── config_test.go # Test Loads environment variables and settings
│ │
│ └── handler/ # Query handling logic
│ └── query_handler.go # Processes stock queries
│ └── query_handler_test.go # Test Processes stock queries
│
├── .env # Environment file for sensitive settings
├── go.mod # Go module definition
├── go.sum # Dependency tracking
└── README.md # Project documentation
Sheldon uses the Cobra framework for building its command-line interface.
- Modular Design: Easy to add new commands.
- Built-in Help: Automatically generates
help
commands for users. - Community Support: A popular framework in the Go ecosystem.
To add a new subcommand:
- Use the
cobra-cli
tool:cobra-cli add <command-name>
- Implement the command logic in the generated file (e.g.,
cmd/<command-name>.go
). - Register the command in
cmd/root.go
withrootCmd.AddCommand(<command-name>)
.
- Scheduled Queries: Add a feature to fetch stock data periodically.
- Multiple Stock Support: Query multiple stocks at once.
- Output Options: Save results to a file (JSON, CSV) or database.
- Web Interface: Expand to a web application for broader accessibility.
This project is licensed under the MIT License. See the LICENSE
file for details.
Contributions are welcome! Feel free to open issues or submit pull requests to improve this project.
- Alpha Vantage for providing the stock market data API.
- Go for powering this application.
- Cobra for its robust CLI framework.