Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

feat: Add 19 new data source Rust bridges

tilakpatel2249b935a7d939
diff --git a/docs/ADD_NEW_DATA_SOURCE.md b/docs/ADD_NEW_DATA_SOURCE.md
new file mode 100644
index 000000000..4bf51b7aa
--- /dev/null
+++ b/docs/ADD_NEW_DATA_SOURCE.md
@@ -0,0 +1,195 @@
+# Add New Python Data Source
+
+## Quick Guide for Adding Financial APIs
+
+### Step 1: Choose Your Data Source
+
+**Good options for beginners:**
+- Alpha Vantage (stocks, forex)
+- Twelve Data (stocks, crypto)
+- Financial Modeling Prep (stocks, financials)
+- CoinGecko (cryptocurrency)
+- FRED (economic data)
+
+### Step 2: Create Your Data Source File
+
+1. Navigate to: `fincept_terminal/Agents/src/tools/`
+2. Create new file: `your_source_name.py`
+3. Use this template:
+
+```python
+"""
+Your Source Name Data Fetcher
+Fetches data from [API Name]
+Returns structured data for analysis
+"""
+
+import requests
+import os
+from typing import Dict, Any, List
+from .api import get_financial_data
+
+# ===== DATA SOURCES REQUIRED =====
+# INPUT:
+# - ticker symbols (array)
+# - API_KEY (environment variable)
+# - data_type (string): "quote", "historical", etc.
+#
+# OUTPUT:
+# - Financial data (prices, volume, etc.)
+# - Analysis results (metrics, indicators)
+#
+# PARAMETERS:
+# - period: "daily", "weekly", "monthly"
+# - limit: Number of records to fetch
+
+API_KEY = os.environ.get('YOUR_SOURCE_API_KEY', '')
+BASE_URL = "https://api.example.com"
+
+def fetch_stock_data(symbol: str, data_type: str = "quote") -> Dict[str, Any]:
+ """Fetch stock data from API"""
+
+ if not API_KEY:
+ return {"error": "API key not configured"}
+
+ try:
+ # Make API request
+ url = f"{BASE_URL}/stock/{data_type}"
+ params = {
+ "symbol": symbol,
+ "apikey": API_KEY
+ }
+
+ response = requests.get(url, params=params, timeout=10)
+ response.raise_for_status()
+
+ data = response.json()
+
+ # Format the response
+ return {
+ "symbol": symbol,
+ "price": data.get("price", 0),
+ "volume": data.get("volume", 0),
+ "change": data.get("change", 0),
+ "timestamp": data.get("timestamp")
+ }
+
+ except requests.exceptions.RequestException as e:
+ return {"error": f"Network error: {str(e)}"}
+ except Exception as e:
+ return {"error": str(e)}
+
+def get_multiple_symbols(symbols: List[str]) -> Dict[str, Any]:
+ """Fetch data for multiple symbols"""
+ results = {}
+
+ for symbol in symbols:
+ data = fetch_stock_data(symbol)
+ results[symbol] = data
+
+ return results
+```
+
+### Step 3: Test Your Code
+
+```python
+# Test with a single symbol
+result = fetch_stock_data("AAPL")
+print(result)
+
+# Test with multiple symbols
+symbols = ["AAPL", "GOOGL", "MSFT"]
+results = get_multiple_symbols(symbols)
+print(results)
+```
+
+### Step 4: Add Documentation
+
+Add to your file:
+- What API it connects to
+- How to get API key
+- Available data types
+- Example usage
+
+### Step 5: Update Agent Files
+
+Add your new data source to relevant agents:
+
+```python
+# In agent files like warren_buffett_agent.py
+from .tools.your_source_name import fetch_stock_data
+
+# Use in analysis
+data = fetch_stock_data(ticker)
+```
+
+### Step 6: Create Pull Request
+
+1. **Commit your changes:**
+```bash
+git add your_source_name.py
+git commit -m "Add [API Name] data source"
+```
+
+2. **Push and create PR:**
+```bash
+git push origin main
+# Go to GitHub and create Pull Request
+```
+
+### PR Template:
+
+```markdown
+## Description
+Add [API Name] data source for [type of data]
+
+## Data Source Information
+- **API Provider**: [Company Name]
+- **Free Tier**: Yes/No (describe limits)
+- **Documentation**: [link to docs]
+- **Data Types**: [list what you implemented]
+
+## Testing
+- [x] Tested with valid symbols
+- [x] Tested error handling
+- [x] Verified output format
+
+## Usage Example
+```python
+from your_source_name import fetch_stock_data
+result = fetch_stock_data("AAPL")
+```
+```
+
+## Requirements Checklist
+
+- [ ] File created in `Agents/src/tools/`
+- [ ] API key uses environment variable
+- [ ] Error handling implemented
+- [ ] Data returned in consistent format
+- [ ] Documentation added
+- [ ] Code tested successfully
+- [ ] Pull request created
+
+## Need Help?
+
+- Check existing files for examples
+- Ask in GitHub Issues
+- Include your code and error messages
+
+## Common API Sources
+
+**Stock Market Data:**
+- Alpha Vantage: Free 500 calls/day
+- Twelve Data: Free 800 calls/day
+- Financial Modeling Prep: Free 250 calls/day
+
+**Cryptocurrency:**
+- CoinGecko: No API key needed
+- CoinMarketCap: Free tier available
+
+**Economic Data:**
+- FRED: Federal Reserve data
+- World Bank: Global economic indicators
+
+Start with a simple API that doesn't require complex authentication. Build confidence, then tackle more complex data sources!
\ No newline at end of file
diff --git a/docs/PYTHON_CONTRIBUTOR_GUIDE.md b/docs/PYTHON_CONTRIBUTOR_GUIDE.md
index 334638a09..e37a95641 100644
--- a/docs/PYTHON_CONTRIBUTOR_GUIDE.md
+++ b/docs/PYTHON_CONTRIBUTOR_GUIDE.md
@@ -1,936 +1,212 @@
-# Python Developer Intern Guide
-## Fincept Terminal - Building Financial Data API Wrappers
+# Python Contributor Guide for Fincept Terminal
-Welcome to the Fincept Terminal Python development team! This guide will help you contribute to building API wrappers for financial data sources, even if you're completely new to the project.
+## Quick Start Guide for Absolute Beginners
----
-
-## 📋 Table of Contents
-
-1. [What You'll Be Building](#what-youll-be-building)
-2. [Getting Started](#getting-started)
-3. [Understanding the Project](#understanding-the-project)
-4. [Your First Contribution](#your-first-contribution)
-5. [API Wrapper Development Guide](#api-wrapper-development-guide)
-6. [Finding Financial APIs to Integrate](#finding-financial-apis-to-integrate)
-7. [Code Standards & Best Practices](#code-standards--best-practices)
-8. [Testing Your Code](#testing-your-code)
-9. [Submitting Your Work](#submitting-your-work)
-10. [Resources & Learning](#resources--learning)
+Welcome! This guide helps you contribute Python code to Fincept Terminal, even if you're new to programming.
---
-## 🎯 What You'll Be Building
-
-As a Python developer intern, your primary role is to **create API wrappers** that connect Fincept Terminal to various financial data sources. Think of yourself as building bridges between the terminal and the vast world of financial data.
-
-### What are API Wrappers?
-
-API wrappers are Python scripts that:
-- Connect to financial data providers (like Yahoo Finance, Polygon.io, FRED, etc.)
-- Fetch data (stock prices, economic indicators, news, etc.)
-- Format the data in a standardized JSON format
-- Return clean, usable data to the Fincept Terminal
-
-### Why This Matters
+## 📋 Table of Contents
-Your work directly enables financial professionals to access and analyze data from hundreds of sources in one unified platform. Each wrapper you create adds immense value to the terminal!
+1. [What You Need](#what-you-need)
+2. [Project Structure](#project-structure)
+3. [Your First Contribution](#your-first-contribution)
+4. [Python Basics](#python-basics)
+5. [How to Test](#how-to-test)
+6. [Common Tasks](#common-tasks)
+7. [Get Help](#get-help)
---
-## 🚀 Getting Started
-
-### Prerequisites
-
-You need:
-- **Python 3.8+** installed on your computer
-- **Git** for version control
-- A **code editor** (VS Code, PyCharm, or any you prefer)
-- **Basic Python knowledge** (functions, dictionaries, error handling)
+## What You Need
-### Setup Instructions
+### Essential Tools:
+- **Python 3.8+** - Download from python.org
+- **Code Editor** - VS Code (recommended) or PyCharm
+- **Git** - Download from git-scm.com
-1. **Fork and Clone the Repository**
+### Setup:
```bash
-# Fork the repo on GitHub first, then:
-git clone https://github.com/YOUR_USERNAME/FinceptTerminal.git
-cd FinceptTerminal
-```
-
-2. **Navigate to the Python Scripts Directory**
-```bash
-cd fincept-terminal-desktop/src-tauri/resources/scripts
-```
-
-3. **Set Up Python Environment** (Recommended)
-```bash
-# Create virtual environment
-python -m venv venv
-
-# Activate it
-# On Windows:
-venv\Scripts\activate
-# On Mac/Linux:
-source venv/bin/activate
+# Install Python packages
+pip install requests pandas
-# Install common dependencies
-pip install requests pandas yfinance aiohttp
-```
-
-4. **Test Existing Scripts**
-```bash
-# Test Yahoo Finance wrapper
-python yfinance_data.py quote AAPL
-
-# Test FRED wrapper (requires API key in environment)
-set FRED_API_KEY=your_key_here # Windows
-export FRED_API_KEY=your_key_here # Mac/Linux
-python fred_data.py series GDP
+# Clone the project
+git clone [project-url]
+cd fincept_terminal
```
---
-## 🏗️ Understanding the Project
-
-### Project Architecture Overview
-
-```
-Fincept Terminal
-├── Frontend (React/TypeScript) - User interface
-│ └── Makes requests to backend
-│
-├── Backend (Rust/Tauri) - Native app framework
-│ └── Calls Python scripts via command line
-│
-└── Python Scripts (YOU ARE HERE!)
- └── Fetch data from external APIs
- └── Return JSON to backend
-```
-
-### Your Python Scripts Location
+## Project Structure
-All your work will be in:
```
-fincept-terminal-desktop/src-tauri/resources/scripts/
+fincept_terminal/
+├── Agents/ # AI hedge fund agents
+│ ├── Trader_Investors_agent/ # Famous investor strategies
+│ └── src/ # Shared utilities
+├── Analytics/economics/ # Economic analysis tools
+└── docs/ # Documentation (you're here!)
```
-Current example scripts:
-- `polygon_data.py` - Polygon.io API wrapper
-- `yfinance_data.py` - Yahoo Finance wrapper
-- `fred_data.py` - Federal Reserve Economic Data
-- `econdb_data.py` - Economic indicators database
+**Where you'll work:** `Agents/` folder, adding comments and simple functions.
---
-## 🎓 Your First Contribution
-
-Let's build your first API wrapper step-by-step! We'll create a simple wrapper for **Alpha Vantage** stock data.
-
-### Step 1: Research the API
-
-1. Go to https://www.alphavantage.co/
-2. Sign up for a free API key
-3. Read the documentation for their "Quote Endpoint"
-4. Test the API in your browser or Postman
-
-Example API call:
-```
-https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=AAPL&apikey=YOUR_KEY
-```
+## Your First Contribution
-### Step 2: Create Your Wrapper File
+### Easy Start: Add Comments
-Create `alphavantage_data.py` in the scripts directory:
+1. **Pick a file** in `Agents/Trader_Investors_agent/`
+2. **Add data source comments** at the top:
```python
-"""
-Alpha Vantage Data Fetcher
-Fetches stock quotes and data from Alpha Vantage API
-Returns JSON output for Rust integration
-"""
-
-import sys
-import json
-import os
-import requests
-from typing import Optional, Dict, Any
-
-# API Configuration
-API_KEY = os.environ.get('ALPHAVANTAGE_API_KEY', '')
-BASE_URL = "https://www.alphavantage.co/query"
-
-def get_quote(symbol: str) -> Dict[str, Any]:
- """
- Fetch real-time quote for a stock symbol
-
- Args:
- symbol: Stock ticker symbol (e.g., 'AAPL', 'MSFT')
-
- Returns:
- Dictionary with quote data or error
- """
- try:
- # Check if API key is configured
- if not API_KEY:
- return {"error": "Alpha Vantage API key not configured"}
-
- # Build API request
- params = {
- 'function': 'GLOBAL_QUOTE',
- 'symbol': symbol,
- 'apikey': API_KEY
- }
-
- # Make request with timeout
- response = requests.get(BASE_URL, params=params, timeout=10)
- response.raise_for_status()
-
- # Parse JSON response
- data = response.json()
-
- # Check for API errors
- if 'Error Message' in data:
- return {"error": data['Error Message'], "symbol": symbol}
-
- if 'Note' in data:
- return {"error": "API rate limit exceeded", "symbol": symbol}
-
- # Extract quote data
- if 'Global Quote' not in data:
- return {"error": "No data returned for symbol", "symbol": symbol}
-
- quote = data['Global Quote']
-
- # Format standardized response
- result = {
- "symbol": symbol,
- "price": float(quote.get('05. price', 0)),
- "change": float(quote.get('09. change', 0)),
- "change_percent": float(quote.get('10. change percent', '0').replace('%', '')),
- "volume": int(quote.get('06. volume', 0)),
- "high": float(quote.get('03. high', 0)),
- "low": float(quote.get('04. low', 0)),
- "open": float(quote.get('02. open', 0)),
- "previous_close": float(quote.get('08. previous close', 0)),
- "trading_day": quote.get('07. latest trading day', '')
- }
-
- return result
-
- except requests.exceptions.RequestException as e:
- return {"error": f"Network error: {str(e)}", "symbol": symbol}
- except Exception as e:
- return {"error": str(e), "symbol": symbol}
-
-
-def main():
- """Main CLI entry point"""
- if len(sys.argv) < 2:
- print(json.dumps({
- "error": "Usage: python alphavantage_data.py <command> <args>",
- "commands": ["quote <symbol>"]
- }))
- sys.exit(1)
-
- command = sys.argv[1]
-
- if command == "quote":
- if len(sys.argv) < 3:
- print(json.dumps({"error": "Usage: python alphavantage_data.py quote <symbol>"}))
- sys.exit(1)
-
- symbol = sys.argv[2]
- result = get_quote(symbol)
- print(json.dumps(result, indent=2))
-
- else:
- print(json.dumps({"error": f"Unknown command: {command}"}))
- sys.exit(1)
-
-
-if __name__ == "__main__":
- main()
-```
+# ===== DATA SOURCES REQUIRED =====
+# INPUT:
+# - ticker symbols (array)
+# - end_date (string)
+# - API_KEY (string)
-### Step 3: Test Your Wrapper
+# OUTPUT:
+# - Financial metrics (ROE, P/E ratio, etc.)
+# - Analysis results (signals, confidence)
-```bash
-# Set your API key
-set ALPHAVANTAGE_API_KEY=your_actual_key # Windows
-export ALPHAVANTAGE_API_KEY=your_actual_key # Mac/Linux
-
-# Test the wrapper
-python alphavantage_data.py quote AAPL
-
-# Expected output:
-{
- "symbol": "AAPL",
- "price": 175.43,
- "change": 2.34,
- "change_percent": 1.35,
- "volume": 45200000,
- ...
-}
+# PARAMETERS:
+# - period: "annual" or "quarterly"
+# - limit: Number of years of data
```
-### Step 4: Document Your Wrapper
+3. **Save the file** (Ctrl+S)
-Add a README section or comments explaining:
-- What API it connects to
-- How to get an API key
-- What commands are available
-- Example usage
+That's it! You've made your first contribution.
---
-## 📚 API Wrapper Development Guide
-
-### Standard Architecture Pattern
-
-Every API wrapper should follow this structure:
+## Python Basics
+### Comments (Explain Your Code)
```python
-"""
-[API NAME] Data Fetcher
-[Brief description of what this wrapper does]
-Returns JSON output for Rust integration
-"""
-
-import sys
-import json
-import os
-import requests # or other HTTP libraries
-from typing import Optional, Dict, Any, List
-
-# 1. CONFIGURATION
-API_KEY = os.environ.get('API_NAME_KEY', '')
-BASE_URL = "https://api.example.com"
-
-# 2. CORE FUNCTIONS
-def get_data_type_1(param1: str, param2: Optional[str] = None) -> Dict[str, Any]:
- """
- Fetch [data type 1]
-
- Args:
- param1: Description
- param2: Optional description
-
- Returns:
- Dictionary with data or error
- """
- try:
- # API call logic
- # Error handling
- # Data formatting
- return formatted_result
- except Exception as e:
- return {"error": str(e)}
-
-def get_data_type_2(params) -> Dict[str, Any]:
- """Another data fetching function"""
- pass
-
-# 3. CLI INTERFACE
-def main():
- """Main CLI entry point"""
- if len(sys.argv) < 2:
- print(json.dumps({"error": "Usage information"}))
- sys.exit(1)
-
- command = sys.argv[1]
-
- # Route commands to functions
- if command == "command1":
- result = get_data_type_1(sys.argv[2])
- print(json.dumps(result, indent=2))
- elif command == "command2":
- result = get_data_type_2(sys.argv[2])
- print(json.dumps(result, indent=2))
- else:
- print(json.dumps({"error": f"Unknown command: {command}"}))
- sys.exit(1)
-
-if __name__ == "__main__":
- main()
-```
-
-### Standardized Response Format
-
-Always return JSON in this format:
-
-**Success Response:**
-```json
-{
- "symbol": "AAPL",
- "data_field1": value1,
- "data_field2": value2,
- "timestamp": 1234567890
-}
+# This is a single-line comment
+'''
+This is a multi-line comment
+Can span multiple lines
+'''
```
-**Error Response:**
-```json
-{
- "error": "Descriptive error message",
- "symbol": "AAPL" // Include context if applicable
-}
-```
-
-### Common Commands to Implement
-
-Most financial APIs should support these commands:
-
-1. **quote** - Get current price/quote for a symbol
-2. **historical** - Get historical data for a date range
-3. **info** - Get detailed information about a symbol
-4. **search** - Search for symbols/securities
-5. **batch** - Fetch multiple symbols at once
-
----
-
-## 🔍 Finding Financial APIs to Integrate
-
-### Where to Find APIs
-
-1. **Financial Data Aggregators**
- - Alpha Vantage (https://www.alphavantage.co/)
- - Twelve Data (https://twelvedata.com/)
- - Financial Modeling Prep (https://financialmodelingprep.com/)
- - Finnhub (https://finnhub.io/)
- - IEX Cloud (https://iexcloud.io/)
-
-2. **Cryptocurrency**
- - CoinGecko (https://www.coingecko.com/en/api)
- - CoinMarketCap (https://coinmarketcap.com/api/)
- - Binance API (https://binance-docs.github.io/apidocs/)
- - Kraken (https://www.kraken.com/features/api)
-
-3. **Economic Data**
- - World Bank API (https://datahelpdesk.worldbank.org/knowledgebase/topics/125589)
- - IMF Data (https://data.imf.org/)
- - OECD Data (https://data.oecd.org/)
- - Bureau of Labor Statistics (https://www.bls.gov/developers/)
-
-4. **Alternative Data**
- - Quandl (https://www.quandl.com/)
- - Intrinio (https://intrinio.com/)
- - Tiingo (https://www.tiingo.com/)
- - NewsAPI (https://newsapi.org/)
-
-5. **Specialized Sources**
- - Options data (CBOE, tradier)
- - Fundamental data (Seeking Alpha, SimFin)
- - ESG data (Sustainalytics, MSCI)
- - Real estate (Zillow, Redfin APIs)
-
-### How to Choose APIs
-
-**Good APIs for beginners:**
-- ✅ Free tier available
-- ✅ Good documentation
-- ✅ Simple authentication (API key)
-- ✅ RESTful JSON responses
-- ✅ No rate limit issues
-
-**Ask yourself:**
-1. Does this API provide unique value?
-2. Is it reliable and well-maintained?
-3. Can financial professionals use this data?
-4. Does it fit into Fincept Terminal's vision?
-
-### Research Process
-
-1. **Find a tool financial professionals use**
- - LinkedIn: Ask "What tools do you use for market research?"
- - Reddit: r/algotrading, r/finance, r/investing
- - Twitter: Follow fintwit traders
-
-2. **Check if they have an API**
- - Google: "[platform name] API documentation"
- - Look for developer portals
-
-3. **Evaluate the API**
- - Sign up for API access
- - Read documentation
- - Test endpoints
- - Check rate limits and pricing
-
-4. **Propose integration**
- - Create GitHub issue describing the API
- - Explain the value it brings
- - Get feedback before building
-
----
-
-## ✅ Code Standards & Best Practices
-
-### 1. Error Handling
-
-Always wrap API calls in try-except blocks:
-
+### Variables (Store Data)
```python
-def get_data(symbol):
- try:
- response = requests.get(url, timeout=10)
- response.raise_for_status()
- return response.json()
- except requests.exceptions.Timeout:
- return {"error": "Request timed out"}
- except requests.exceptions.HTTPError as e:
- return {"error": f"HTTP error: {e.response.status_code}"}
- except requests.exceptions.RequestException as e:
- return {"error": f"Network error: {str(e)}"}
- except Exception as e:
- return {"error": str(e)}
+agent_name = "Warren Buffett"
+confidence = 85.5
+is_bullish = True
```
-### 2. API Key Management
-
-Never hardcode API keys:
-
+### Functions (Reusable Code)
```python
-# ❌ BAD
-API_KEY = "abc123xyz"
-
-# ✅ GOOD
-API_KEY = os.environ.get('SERVICE_NAME_API_KEY', '')
-
-if not API_KEY:
- return {"error": "API key not configured"}
+def analyze_stock(ticker):
+ """Analyze a stock and return signal"""
+ return "bullish"
```
-### 3. Timeout Settings
-
-Always set timeouts for network requests:
-
+### Lists and Dictionaries (Collections)
```python
-response = requests.get(url, timeout=10) # 10 second timeout
+tickers = ["AAPL", "GOOGL", "MSFT"]
+result = {"signal": "buy", "confidence": 90}
```
-### 4. Data Validation
+---
-Validate data before returning:
+## How to Test
+### Simple Test:
```python
-def get_quote(symbol):
- # Validate input
- if not symbol or not symbol.isalnum():
- return {"error": "Invalid symbol format"}
-
- # Fetch data
- data = fetch_from_api(symbol)
-
- # Validate output
- if 'price' not in data:
- return {"error": "Invalid data received from API"}
-
- return data
+# Test your function
+result = analyze_stock("AAPL")
+print(result) # Should print "bullish"
```
-### 5. Type Hints
-
-Use type hints for better code clarity:
-
-```python
-from typing import Optional, Dict, Any, List
+### How to Run:
+- **VS Code**: Press F5
+- **Command Line**: `python your_file.py`
+- **PyCharm**: Right-click → Run
-def get_historical(
- symbol: str,
- start_date: Optional[str] = None
-) -> Dict[str, Any]:
- pass
-```
+### Test Checklist:
+✅ Code runs without errors
+✅ Output looks correct
+✅ Comments explain what code does
-### 6. Documentation
+---
-Document every function:
+## Common Tasks
+### 1. Add Comments
```python
-def get_quote(symbol: str) -> Dict[str, Any]:
- """
- Fetch real-time quote for a stock symbol.
-
- Args:
- symbol: Stock ticker symbol (e.g., 'AAPL', 'MSFT')
-
- Returns:
- Dictionary containing:
- - symbol: The ticker symbol
- - price: Current price
- - change: Price change
- - change_percent: Percent change
- - volume: Trading volume
-
- Example:
- >>> get_quote('AAPL')
- {'symbol': 'AAPL', 'price': 175.43, ...}
- """
- pass
+# ===== DATA SOURCES REQUIRED =====
+# INPUT: ticker symbols, end_date, API_KEY
+# OUTPUT: financial metrics, analysis results
+# PARAMETERS: period, limit
```
-### 7. Rate Limiting
-
-Respect API rate limits:
+### 2. Fix Typos
+- Read through code
+- Fix spelling errors in comments
+- Correct variable names
+### 3. Add Simple Functions
```python
-import time
-
-def fetch_batch(symbols, rate_limit_delay=1.0):
- """Fetch multiple symbols with rate limiting"""
- results = []
- for symbol in symbols:
- result = get_quote(symbol)
- results.append(result)
- time.sleep(rate_limit_delay) # Respect rate limits
- return results
-```
-
----
-
-## 🧪 Testing Your Code
-
-### Manual Testing Checklist
-
-Test your wrapper with:
-
-1. **Valid input**
-```bash
-python your_wrapper.py quote AAPL
-```
-
-2. **Invalid symbol**
-```bash
-python your_wrapper.py quote INVALIDXYZ
+def calculate_simple_moving_average(prices, period=20):
+ """Calculate moving average"""
+ if len(prices) < period:
+ return None
+ return sum(prices[-period:]) / period
```
-3. **Missing API key**
-```bash
-unset API_KEY_NAME
-python your_wrapper.py quote AAPL
-```
-
-4. **Network timeout** (disconnect internet temporarily)
-
-5. **Multiple symbols** (if batch command exists)
-```bash
-python your_wrapper.py batch AAPL MSFT GOOGL
-```
-
-### Writing Test Cases
-
-Create a test file `test_your_wrapper.py`:
-
+### 4. Improve Error Messages
```python
-import json
-from your_wrapper import get_quote
-
-def test_valid_symbol():
- result = get_quote('AAPL')
- assert 'error' not in result
- assert 'price' in result
- assert result['symbol'] == 'AAPL'
- print("✓ Valid symbol test passed")
-
-def test_invalid_symbol():
- result = get_quote('INVALIDXYZ')
- assert 'error' in result
- print("✓ Invalid symbol test passed")
-
-if __name__ == "__main__":
- test_valid_symbol()
- test_invalid_symbol()
- print("\n✅ All tests passed!")
+# Before: return "Error"
+# After: return "Invalid ticker symbol format"
```
---
-## 🚀 Submitting Your Work
+## Get Help
-### Before Submitting
+### Where to Ask:
+- **GitHub Issues**: For bugs/questions
+- **Discord/Slack**: Community chat (if available)
+- **Stack Overflow**: General Python questions
-1. **Test thoroughly**
- - Test with real API keys
- - Test error cases
- - Test on both Windows and Mac/Linux (if possible)
+### What to Include:
+1. What you're trying to do
+2. Code you've written
+3. Error messages (copy full text)
+4. What you've tried already
-2. **Document your work**
- - Add comments explaining complex logic
- - Create usage examples
- - Update any relevant README files
+### Best Practices:
+✅ Start with small changes
+✅ Ask questions if stuck
+✅ Celebrate small wins
+✅ Learn from existing code
-3. **Check code quality**
- - Remove debug print statements
- - Fix any linting errors
- - Follow the style of existing scripts
-
-### Creating a Pull Request
-
-1. **Create a new branch**
-```bash
-git checkout -b add-alphavantage-wrapper
-```
-
-2. **Commit your changes**
-```bash
-git add alphavantage_data.py
-git commit -m "Add Alpha Vantage API wrapper
-
-- Implements quote endpoint
-- Supports real-time stock data
-- Includes error handling and rate limiting
-- Tested with multiple symbols"
-```
-
-3. **Push to your fork**
-```bash
-git push origin add-alphavantage-wrapper
-```
-
-4. **Create Pull Request on GitHub**
- - Go to https://github.com/Fincept-Corporation/FinceptTerminal
- - Click "New Pull Request"
- - Select your branch
- - Fill in the template:
-
-```markdown
-## Description
-Add Alpha Vantage API wrapper for real-time stock quotes
-
-## Type of Change
-- [ ] Bug fix
-- [x] New feature
-- [ ] Breaking change
-
-## Testing
-- [x] Tested with valid symbols (AAPL, MSFT, GOOGL)
-- [x] Tested with invalid symbols
-- [x] Tested error handling
-- [x] Tested rate limiting
-
-## API Information
-- API Provider: Alpha Vantage
-- Free Tier: Yes (5 calls/minute, 500/day)
-- API Key Required: Yes
-- Documentation: https://www.alphavantage.co/documentation/
-
-## Screenshots (if applicable)
-[Paste terminal output showing successful data fetch]
-```
-
-### Review Process
-
-1. Maintainers will review your code
-2. They may request changes or improvements
-3. Make requested changes and push updates
-4. Once approved, your code will be merged!
+❌ Don't delete existing code
+❌ Don't commit broken code
+❌ Don't worry about mistakes!
---
-## 📖 Resources & Learning
-
-### Python Learning Resources
-
-**Basics:**
-- Python.org Tutorial: https://docs.python.org/3/tutorial/
-- Real Python: https://realpython.com/
-- Automate the Boring Stuff: https://automatetheboringstuff.com/
-
-**HTTP Requests:**
-- Requests Library: https://requests.readthedocs.io/
-- Working with APIs: https://realpython.com/api-integration-in-python/
-
-**JSON Handling:**
-- JSON in Python: https://realpython.com/python-json/
-
-**Error Handling:**
-- Exception Handling: https://realpython.com/python-exceptions/
-
-### Financial Data Knowledge
-
-**Learn about:**
-- Stock market basics
-- Cryptocurrency fundamentals
-- Economic indicators (GDP, CPI, unemployment)
-- Options and derivatives
-- Financial statements
+## Quick Reference
-**Resources:**
-- Investopedia: https://www.investopedia.com/
-- Khan Academy Finance: https://www.khanacademy.org/economics-finance-domain
+### File Locations:
+- **Agents**: `Agents/Trader_Investors_agent/`
+- **Analytics**: `Analytics/economics/`
+- **Tools**: `Agents/src/tools/`
-### API Development
+### Common Commands:
+- Run code: `python filename.py`
+- Install packages: `pip install package_name`
+- Check Python version: `python --version`
-**RESTful APIs:**
-- REST API Tutorial: https://restfulapi.net/
-- HTTP Status Codes: https://httpstatuses.com/
-
-**API Authentication:**
-- API Keys, OAuth, JWT basics
-
-### Project-Specific
-
-**Existing Wrappers to Study:**
-- `yfinance_data.py` - Simple, well-structured example
-- `fred_data.py` - Environment variables, multiple commands
-- `econdb_data.py` - Async operations, complex data
-- `polygon_data.py` - Class-based wrapper, comprehensive
-
-### Getting Help
-
-**When stuck:**
-1. Check existing wrapper code for examples
-2. Read the API documentation thoroughly
-3. Search GitHub issues for similar problems
-4. Ask in GitHub Discussions
-5. Reach out on community channels
-
-**Where to Ask:**
-- GitHub Issues: For bugs or questions
-- GitHub Discussions: For general help
-- Project Discord/Slack (if available)
+### Remember:
+Every contribution helps! Even fixing a typo makes the project better. Welcome aboard! 🎉
---
-## 🎯 Your Growth Path
-
-### Beginner Tasks (Week 1-2)
-- Study existing wrappers
-- Test all current scripts
-- Build your first simple wrapper (stock quotes)
-- Submit your first PR
-
-### Intermediate Tasks (Week 3-6)
-- Build multi-command wrappers
-- Implement caching mechanisms
-- Add batch operations
-- Create async wrappers (for faster fetching)
-
-### Advanced Tasks (Week 7+)
-- Build complex data processing pipelines
-- Create analysis models/indicators
-- Optimize performance (caching, async)
-- Help review other interns' code
-
-### Impact Metrics
-
-Track your contributions:
-- Number of API wrappers created
-- Data sources added to terminal
-- Pull requests merged
-- Code reviews participated in
-- Issues resolved
-
----
-
-## 💡 Project Ideas & Inspiration
-
-### High-Impact Wrappers to Build
-
-1. **News & Sentiment**
- - NewsAPI wrapper for financial news
- - Reddit API for r/wallstreetbets sentiment
- - Twitter API for trader sentiment
-
-2. **Fundamental Data**
- - SEC EDGAR filings parser
- - Company financials from SimFin
- - Insider trading data
-
-3. **Alternative Data**
- - Satellite imagery analysis APIs
- - Weather data for commodity trading
- - Social media activity metrics
-
-4. **International Markets**
- - NSE India (National Stock Exchange)
- - Tokyo Stock Exchange data
- - LSE (London Stock Exchange)
-
-5. **Specialized Data**
- - Carbon credit prices
- - Real estate market data
- - Supply chain indicators
-
-### Analysis Models
-
-Beyond wrappers, you can create:
-- Technical indicators (custom RSI, MACD)
-- Statistical models
-- Risk analysis tools
-- Portfolio optimization algorithms
-
----
-
-## 🤝 Community & Collaboration
-
-### Connecting with Others
-
-- **Financial Professionals**: Ask them what data they need
-- **Other Interns**: Collaborate on complex projects
-- **Open Source Community**: Participate in discussions
-
-### Building Your Portfolio
-
-This experience gives you:
-- Real-world Python development experience
-- API integration skills
-- Financial domain knowledge
-- Open source contributions (great for resume!)
-- GitHub profile building
-
----
-
-## ⚡ Quick Reference
-
-### Template Checklist
-
-When creating a new wrapper:
-- [ ] Create `api_name_data.py` file
-- [ ] Add docstring at the top
-- [ ] Import required libraries
-- [ ] Define configuration (API keys, base URL)
-- [ ] Implement core functions with error handling
-- [ ] Add type hints
-- [ ] Create CLI interface in `main()`
-- [ ] Test with valid and invalid inputs
-- [ ] Document usage
-- [ ] Create pull request
-
-### Common Issues & Solutions
-
-**Issue**: "ModuleNotFoundError: No module named 'requests'"
-**Solution**: `pip install requests`
-
-**Issue**: "API key not working"
-**Solution**: Check environment variable spelling, restart terminal
-
-**Issue**: "Rate limit exceeded"
-**Solution**: Add delays between requests, implement caching
-
-**Issue**: "Timeout errors"
-**Solution**: Increase timeout value, check internet connection
-
----
-
-## 🎉 Final Words
-
-You're now equipped to contribute meaningful work to Fincept Terminal! Every API wrapper you build makes the platform more powerful and helps financial professionals worldwide.
-
-**Remember:**
-- Start small, learn as you go
-- Don't hesitate to ask questions
-- Study existing code
-- Test thoroughly
-- Document well
-- Have fun building!
-
-**Your work matters.** Financial professionals will use the data sources you integrate to make informed decisions, conduct research, and analyze markets. You're building infrastructure for the future of open-source financial analysis.
-
-Welcome aboard! 🚀
-
----
-
-**Questions?** Open an issue or reach out in GitHub Discussions!
-
-**Repository**: https://github.com/Fincept-Corporation/FinceptTerminal/
-**Contact**: [email protected]
+**Happy coding! 🚀**
diff --git a/fincept-terminal-desktop/.gitignore b/fincept-terminal-desktop/.gitignore
index 2fd601f84..367d7613b 100644
--- a/fincept-terminal-desktop/.gitignore
+++ b/fincept-terminal-desktop/.gitignore
@@ -29,3 +29,4 @@ src-tauri/target
# Python embeddable package (download separately)
src-tauri/resources/python/
!src-tauri/resources/scripts/
+fincept-terminal-desktop/nul
diff --git a/fincept-terminal-desktop/src-tauri/cargo_errors.txt b/fincept-terminal-desktop/src-tauri/cargo_errors.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/adb.rs b/fincept-terminal-desktop/src-tauri/src/commands/adb.rs
new file mode 100644
index 000000000..ee0ad4111
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/adb.rs
@@ -0,0 +1,64 @@
+// Asian Development Bank data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute ADB Python script command
+#[tauri::command]
+pub async fn execute_adb_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "adb_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "ADB script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute ADB command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("ADB command failed: {}", stderr))
+ }
+}
+
+/// Get economic indicators for Asian countries
+#[tauri::command]
+pub async fn get_adb_indicators(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_adb_command(app, "indicators".to_string(), vec![country]).await
+}
+
+/// Search ADB datasets
+#[tauri::command]
+pub async fn search_adb_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_adb_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get development data
+#[tauri::command]
+pub async fn get_adb_development_data(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_adb_command(app, "development".to_string(), vec![country]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/alphavantage.rs b/fincept-terminal-desktop/src-tauri/src/commands/alphavantage.rs
index a38e1873d..509959223 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/alphavantage.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/alphavantage.rs
@@ -1,33 +1,23 @@
// Alpha Vantage data commands
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute Alpha Vantage Python script command
#[tauri::command]
pub async fn execute_alphavantage_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
- // Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("alphavantage_data.py");
-
- // Verify script exists
- if !script_path.exists() {
- return Err(format!(
- "Alpha Vantage script not found at: {}",
- script_path.display()
- ));
- }
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "alphavantage_data.py")?;
// Build command arguments
let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute Alpha Vantage command: {}", e))?;
@@ -43,13 +33,14 @@ pub async fn execute_alphavantage_command(
/// Get quote for a single symbol
#[tauri::command]
-pub async fn get_alphavantage_quote(symbol: String) -> Result<String, String> {
- execute_alphavantage_command("quote".to_string(), vec![symbol]).await
+pub async fn get_alphavantage_quote(app: tauri::AppHandle, symbol: String) -> Result<String, String> {
+ execute_alphavantage_command(app, "quote".to_string(), vec![symbol]).await
}
/// Get daily historical data
#[tauri::command]
pub async fn get_alphavantage_daily(
+ app: tauri::AppHandle,
symbol: String,
outputsize: Option<String>,
) -> Result<String, String> {
@@ -57,12 +48,13 @@ pub async fn get_alphavantage_daily(
if let Some(size) = outputsize {
args.push(size);
}
- execute_alphavantage_command("daily".to_string(), args).await
+ execute_alphavantage_command(app, "daily".to_string(), args).await
}
/// Get intraday data
#[tauri::command]
pub async fn get_alphavantage_intraday(
+ app: tauri::AppHandle,
symbol: String,
interval: Option<String>,
) -> Result<String, String> {
@@ -70,29 +62,29 @@ pub async fn get_alphavantage_intraday(
if let Some(interval) = interval {
args.push(interval);
}
- execute_alphavantage_command("intraday".to_string(), args).await
+ execute_alphavantage_command(app, "intraday".to_string(), args).await
}
/// Get company overview
#[tauri::command]
-pub async fn get_alphavantage_overview(symbol: String) -> Result<String, String> {
- execute_alphavantage_command("overview".to_string(), vec![symbol]).await
+pub async fn get_alphavantage_overview(app: tauri::AppHandle, symbol: String) -> Result<String, String> {
+ execute_alphavantage_command(app, "overview".to_string(), vec![symbol]).await
}
/// Search for symbols/companies
#[tauri::command]
-pub async fn search_alphavantage_symbols(keywords: String) -> Result<String, String> {
- execute_alphavantage_command("search".to_string(), vec![keywords]).await
+pub async fn search_alphavantage_symbols(app: tauri::AppHandle, keywords: String) -> Result<String, String> {
+ execute_alphavantage_command(app, "search".to_string(), vec![keywords]).await
}
/// Get comprehensive data from multiple endpoints
#[tauri::command]
-pub async fn get_alphavantage_comprehensive(symbol: String) -> Result<String, String> {
- execute_alphavantage_command("comprehensive".to_string(), vec![symbol]).await
+pub async fn get_alphavantage_comprehensive(app: tauri::AppHandle, symbol: String) -> Result<String, String> {
+ execute_alphavantage_command(app, "comprehensive".to_string(), vec![symbol]).await
}
/// Get market movers
#[tauri::command]
-pub async fn get_alphavantage_market_movers() -> Result<String, String> {
- execute_alphavantage_command("market_movers".to_string(), vec![]).await
+pub async fn get_alphavantage_market_movers(app: tauri::AppHandle) -> Result<String, String> {
+ execute_alphavantage_command(app, "market_movers".to_string(), vec![]).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/bis.rs b/fincept-terminal-desktop/src-tauri/src/commands/bis.rs
index 5df6e4c7d..58dde3ff8 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/bis.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/bis.rs
@@ -1,33 +1,23 @@
// BIS (Bank for International Settlements) data commands based on SDMX API
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute BIS Python script command
#[tauri::command]
pub async fn execute_bis_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
- // Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("bis_data.py");
-
- // Verify script exists
- if !script_path.exists() {
- return Err(format!(
- "BIS script not found at: {}",
- script_path.display()
- ));
- }
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "bis_data.py")?;
// Build command arguments
let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute BIS command: {}", e))?;
@@ -45,7 +35,7 @@ pub async fn execute_bis_command(
/// Get statistical data for specific flow and key
#[tauri::command]
-pub async fn get_bis_data(
+pub async fn get_bis_data(app: tauri::AppHandle,
flow: String,
key: Option<String>,
start_period: Option<String>,
@@ -75,12 +65,12 @@ pub async fn get_bis_data(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_data".to_string(), args).await
+ execute_bis_command(app, "get_data".to_string(), args).await
}
/// Get information about data availability
#[tauri::command]
-pub async fn get_bis_available_constraints(
+pub async fn get_bis_available_constraints(app: tauri::AppHandle,
flow: String,
key: String,
component_id: String,
@@ -106,14 +96,14 @@ pub async fn get_bis_available_constraints(
if let Some(end) = end_period {
args.push(end);
}
- execute_bis_command("get_available_constraints".to_string(), args).await
+ execute_bis_command(app, "get_available_constraints".to_string(), args).await
}
// STRUCTURE QUERY COMMANDS
/// Get data structure definitions
#[tauri::command]
-pub async fn get_bis_data_structures(
+pub async fn get_bis_data_structures(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -146,12 +136,12 @@ pub async fn get_bis_data_structures(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_data_structures".to_string(), args).await
+ execute_bis_command(app, "get_data_structures".to_string(), args).await
}
/// Get dataflow definitions (available datasets)
#[tauri::command]
-pub async fn get_bis_dataflows(
+pub async fn get_bis_dataflows(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -184,12 +174,12 @@ pub async fn get_bis_dataflows(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_dataflows".to_string(), args).await
+ execute_bis_command(app, "get_dataflows".to_string(), args).await
}
/// Get categorisation definitions
#[tauri::command]
-pub async fn get_bis_categorisations(
+pub async fn get_bis_categorisations(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -222,12 +212,12 @@ pub async fn get_bis_categorisations(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_categorisations".to_string(), args).await
+ execute_bis_command(app, "get_categorisations".to_string(), args).await
}
/// Get content constraint definitions
#[tauri::command]
-pub async fn get_bis_content_constraints(
+pub async fn get_bis_content_constraints(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -260,12 +250,12 @@ pub async fn get_bis_content_constraints(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_content_constraints".to_string(), args).await
+ execute_bis_command(app, "get_content_constraints".to_string(), args).await
}
/// Get actual constraint definitions
#[tauri::command]
-pub async fn get_bis_actual_constraints(
+pub async fn get_bis_actual_constraints(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -298,12 +288,12 @@ pub async fn get_bis_actual_constraints(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_actual_constraints".to_string(), args).await
+ execute_bis_command(app, "get_actual_constraints".to_string(), args).await
}
/// Get allowed constraint definitions
#[tauri::command]
-pub async fn get_bis_allowed_constraints(
+pub async fn get_bis_allowed_constraints(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -336,12 +326,12 @@ pub async fn get_bis_allowed_constraints(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_allowed_constraints".to_string(), args).await
+ execute_bis_command(app, "get_allowed_constraints".to_string(), args).await
}
/// Get general structure definitions
#[tauri::command]
-pub async fn get_bis_structures(
+pub async fn get_bis_structures(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -374,12 +364,12 @@ pub async fn get_bis_structures(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_structures".to_string(), args).await
+ execute_bis_command(app, "get_structures".to_string(), args).await
}
/// Get concept scheme definitions
#[tauri::command]
-pub async fn get_bis_concept_schemes(
+pub async fn get_bis_concept_schemes(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -412,12 +402,12 @@ pub async fn get_bis_concept_schemes(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_concept_schemes".to_string(), args).await
+ execute_bis_command(app, "get_concept_schemes".to_string(), args).await
}
/// Get codelist definitions
#[tauri::command]
-pub async fn get_bis_codelists(
+pub async fn get_bis_codelists(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -450,12 +440,12 @@ pub async fn get_bis_codelists(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_codelists".to_string(), args).await
+ execute_bis_command(app, "get_codelists".to_string(), args).await
}
/// Get category scheme definitions
#[tauri::command]
-pub async fn get_bis_category_schemes(
+pub async fn get_bis_category_schemes(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -488,12 +478,12 @@ pub async fn get_bis_category_schemes(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_category_schemes".to_string(), args).await
+ execute_bis_command(app, "get_category_schemes".to_string(), args).await
}
/// Get hierarchical codelist definitions
#[tauri::command]
-pub async fn get_bis_hierarchical_codelists(
+pub async fn get_bis_hierarchical_codelists(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -526,12 +516,12 @@ pub async fn get_bis_hierarchical_codelists(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_hierarchical_codelists".to_string(), args).await
+ execute_bis_command(app, "get_hierarchical_codelists".to_string(), args).await
}
/// Get agency scheme definitions
#[tauri::command]
-pub async fn get_bis_agency_schemes(
+pub async fn get_bis_agency_schemes(app: tauri::AppHandle,
agency_id: Option<String>,
resource_id: Option<String>,
version: Option<String>,
@@ -564,14 +554,14 @@ pub async fn get_bis_agency_schemes(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_agency_schemes".to_string(), args).await
+ execute_bis_command(app, "get_agency_schemes".to_string(), args).await
}
// ITEM QUERY COMMANDS
/// Get specific concepts from concept schemes
#[tauri::command]
-pub async fn get_bis_concepts(
+pub async fn get_bis_concepts(app: tauri::AppHandle,
agency_id: String,
resource_id: String,
version: String,
@@ -595,12 +585,12 @@ pub async fn get_bis_concepts(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_concepts".to_string(), args).await
+ execute_bis_command(app, "get_concepts".to_string(), args).await
}
/// Get specific codes from codelists
#[tauri::command]
-pub async fn get_bis_codes(
+pub async fn get_bis_codes(app: tauri::AppHandle,
agency_id: String,
resource_id: String,
version: String,
@@ -624,12 +614,12 @@ pub async fn get_bis_codes(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_codes".to_string(), args).await
+ execute_bis_command(app, "get_codes".to_string(), args).await
}
/// Get specific categories from category schemes
#[tauri::command]
-pub async fn get_bis_categories(
+pub async fn get_bis_categories(app: tauri::AppHandle,
agency_id: String,
resource_id: String,
version: String,
@@ -653,12 +643,12 @@ pub async fn get_bis_categories(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_categories".to_string(), args).await
+ execute_bis_command(app, "get_categories".to_string(), args).await
}
/// Get specific hierarchies from hierarchical codelists
#[tauri::command]
-pub async fn get_bis_hierarchies(
+pub async fn get_bis_hierarchies(app: tauri::AppHandle,
agency_id: String,
resource_id: String,
version: String,
@@ -682,14 +672,14 @@ pub async fn get_bis_hierarchies(
} else {
args.push("full".to_string());
}
- execute_bis_command("get_hierarchies".to_string(), args).await
+ execute_bis_command(app, "get_hierarchies".to_string(), args).await
}
// CONVENIENCE METHODS FOR COMMON DATA TYPES
/// Get effective exchange rates data (WS_EER)
#[tauri::command]
-pub async fn get_bis_effective_exchange_rates(
+pub async fn get_bis_effective_exchange_rates(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -708,12 +698,12 @@ pub async fn get_bis_effective_exchange_rates(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_effective_exchange_rates".to_string(), args).await
+ execute_bis_command(app, "get_effective_exchange_rates".to_string(), args).await
}
/// Get central bank policy rates (WS_CBPOL)
#[tauri::command]
-pub async fn get_bis_central_bank_policy_rates(
+pub async fn get_bis_central_bank_policy_rates(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -732,12 +722,12 @@ pub async fn get_bis_central_bank_policy_rates(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_central_bank_policy_rates".to_string(), args).await
+ execute_bis_command(app, "get_central_bank_policy_rates".to_string(), args).await
}
/// Get long-term interest rates (WS_LTINT)
#[tauri::command]
-pub async fn get_bis_long_term_interest_rates(
+pub async fn get_bis_long_term_interest_rates(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -756,12 +746,12 @@ pub async fn get_bis_long_term_interest_rates(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_long_term_interest_rates".to_string(), args).await
+ execute_bis_command(app, "get_long_term_interest_rates".to_string(), args).await
}
/// Get short-term interest rates (WS_STINT)
#[tauri::command]
-pub async fn get_bis_short_term_interest_rates(
+pub async fn get_bis_short_term_interest_rates(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -780,12 +770,12 @@ pub async fn get_bis_short_term_interest_rates(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_short_term_interest_rates".to_string(), args).await
+ execute_bis_command(app, "get_short_term_interest_rates".to_string(), args).await
}
/// Get exchange rates (WS_XRU)
#[tauri::command]
-pub async fn get_bis_exchange_rates(
+pub async fn get_bis_exchange_rates(app: tauri::AppHandle,
currency_pairs: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -804,12 +794,12 @@ pub async fn get_bis_exchange_rates(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_exchange_rates".to_string(), args).await
+ execute_bis_command(app, "get_exchange_rates".to_string(), args).await
}
/// Get credit to non-financial sector (WS_CRD)
#[tauri::command]
-pub async fn get_bis_credit_to_non_financial_sector(
+pub async fn get_bis_credit_to_non_financial_sector(app: tauri::AppHandle,
countries: Option<Vec<String>>,
sectors: Option<Vec<String>>,
start_period: Option<String>,
@@ -832,12 +822,12 @@ pub async fn get_bis_credit_to_non_financial_sector(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_credit_to_non_financial_sector".to_string(), args).await
+ execute_bis_command(app, "get_credit_to_non_financial_sector".to_string(), args).await
}
/// Get house price indices (WS_HP)
#[tauri::command]
-pub async fn get_bis_house_prices(
+pub async fn get_bis_house_prices(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -856,20 +846,20 @@ pub async fn get_bis_house_prices(
if let Some(d) = detail {
args.push(d);
}
- execute_bis_command("get_house_prices".to_string(), args).await
+ execute_bis_command(app, "get_house_prices".to_string(), args).await
}
// OVERVIEW AND SEARCH COMMANDS
/// Get overview of all available datasets
#[tauri::command]
-pub async fn get_bis_available_datasets() -> Result<String, String> {
- execute_bis_command("get_available_datasets".to_string(), vec![]).await
+pub async fn get_bis_available_datasets(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bis_command(app, "get_available_datasets".to_string(), vec![]).await
}
/// Search for datasets matching a query
#[tauri::command]
-pub async fn search_bis_datasets(
+pub async fn search_bis_datasets(app: tauri::AppHandle,
query: String,
agency_id: Option<String>,
) -> Result<String, String> {
@@ -877,12 +867,12 @@ pub async fn search_bis_datasets(
if let Some(agency) = agency_id {
args.push(agency);
}
- execute_bis_command("search_datasets".to_string(), args).await
+ execute_bis_command(app, "search_datasets".to_string(), args).await
}
/// Get comprehensive economic overview for countries
#[tauri::command]
-pub async fn get_bis_economic_overview(
+pub async fn get_bis_economic_overview(app: tauri::AppHandle,
countries: Option<Vec<String>>,
start_period: Option<String>,
end_period: Option<String>,
@@ -897,26 +887,27 @@ pub async fn get_bis_economic_overview(
if let Some(end) = end_period {
args.push(end);
}
- execute_bis_command("get_economic_overview".to_string(), args).await
+ execute_bis_command(app, "get_economic_overview".to_string(), args).await
}
/// Get comprehensive metadata for a specific dataset
#[tauri::command]
-pub async fn get_bis_dataset_metadata(
+pub async fn get_bis_dataset_metadata(app: tauri::AppHandle,
flow: String,
) -> Result<String, String> {
- execute_bis_command("get_dataset_metadata".to_string(), vec![flow]).await
+ execute_bis_command(app, "get_dataset_metadata".to_string(), vec![flow]).await
}
// SPECIALIZED ANALYSIS COMMANDS
/// Get global monetary policy overview
#[tauri::command]
-pub async fn get_bis_monetary_policy_overview() -> Result<String, String> {
+pub async fn get_bis_monetary_policy_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get central bank policy rates for major economies
match get_bis_central_bank_policy_rates(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "EA".to_string()]),
None,
None,
@@ -928,6 +919,7 @@ pub async fn get_bis_monetary_policy_overview() -> Result<String, String> {
// Get short-term interest rates
match get_bis_short_term_interest_rates(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "EA".to_string()]),
None,
None,
@@ -939,6 +931,7 @@ pub async fn get_bis_monetary_policy_overview() -> Result<String, String> {
// Get long-term interest rates
match get_bis_long_term_interest_rates(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "EA".to_string()]),
None,
None,
@@ -957,11 +950,12 @@ pub async fn get_bis_monetary_policy_overview() -> Result<String, String> {
/// Get global exchange rate analysis
#[tauri::command]
-pub async fn get_bis_exchange_rate_analysis() -> Result<String, String> {
+pub async fn get_bis_exchange_rate_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get effective exchange rates
match get_bis_effective_exchange_rates(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "EA".to_string()]),
None,
None,
@@ -973,6 +967,7 @@ pub async fn get_bis_exchange_rate_analysis() -> Result<String, String> {
// Get major currency exchange rates
match get_bis_exchange_rates(
+ app.clone(),
Some(vec!["USD".to_string(), "EUR".to_string(), "GBP".to_string(), "JPY".to_string()]),
None,
None,
@@ -991,11 +986,12 @@ pub async fn get_bis_exchange_rate_analysis() -> Result<String, String> {
/// Get global credit conditions overview
#[tauri::command]
-pub async fn get_bis_credit_conditions_overview() -> Result<String, String> {
+pub async fn get_bis_credit_conditions_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get credit to non-financial sector for major economies
match get_bis_credit_to_non_financial_sector(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "EA".to_string()]),
None,
None,
@@ -1015,11 +1011,12 @@ pub async fn get_bis_credit_conditions_overview() -> Result<String, String> {
/// Get global housing market overview
#[tauri::command]
-pub async fn get_bis_housing_market_overview() -> Result<String, String> {
+pub async fn get_bis_housing_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get house price indices for major economies
match get_bis_house_prices(
+ app.clone(),
Some(vec!["US".to_string(), "GB".to_string(), "JP".to_string(), "CA".to_string()]),
None,
None,
@@ -1038,17 +1035,18 @@ pub async fn get_bis_housing_market_overview() -> Result<String, String> {
/// Get BIS data directory and available resources
#[tauri::command]
-pub async fn get_bis_data_directory() -> Result<String, String> {
+pub async fn get_bis_data_directory(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get available datasets
- match get_bis_available_datasets().await {
+ match get_bis_available_datasets(app.clone()).await {
Ok(data) => results.push(("available_datasets".to_string(), data)),
Err(e) => results.push(("available_datasets".to_string(), format!("Error: {}", e))),
}
// Get data structures for BIS
match get_bis_data_structures(
+ app.clone(),
Some("BIS".to_string()),
None,
None,
@@ -1061,6 +1059,7 @@ pub async fn get_bis_data_directory() -> Result<String, String> {
// Get concept schemes
match get_bis_concept_schemes(
+ app.clone(),
Some("BIS".to_string()),
None,
None,
@@ -1073,6 +1072,7 @@ pub async fn get_bis_data_directory() -> Result<String, String> {
// Get codelists
match get_bis_codelists(
+ app.clone(),
Some("BIS".to_string()),
None,
None,
@@ -1091,35 +1091,35 @@ pub async fn get_bis_data_directory() -> Result<String, String> {
/// Get comprehensive BIS statistics summary
#[tauri::command]
-pub async fn get_bis_comprehensive_summary() -> Result<String, String> {
+pub async fn get_bis_comprehensive_summary(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get monetary policy overview
- match get_bis_monetary_policy_overview().await {
+ match get_bis_monetary_policy_overview(app.clone()).await {
Ok(data) => results.push(("monetary_policy".to_string(), data)),
Err(e) => results.push(("monetary_policy".to_string(), format!("Error: {}", e))),
}
// Get exchange rate analysis
- match get_bis_exchange_rate_analysis().await {
+ match get_bis_exchange_rate_analysis(app.clone()).await {
Ok(data) => results.push(("exchange_rates".to_string(), data)),
Err(e) => results.push(("exchange_rates".to_string(), format!("Error: {}", e))),
}
// Get credit conditions
- match get_bis_credit_conditions_overview().await {
+ match get_bis_credit_conditions_overview(app.clone()).await {
Ok(data) => results.push(("credit_conditions".to_string(), data)),
Err(e) => results.push(("credit_conditions".to_string(), format!("Error: {}", e))),
}
// Get housing market overview
- match get_bis_housing_market_overview().await {
+ match get_bis_housing_market_overview(app.clone()).await {
Ok(data) => results.push(("housing_markets".to_string(), data)),
Err(e) => results.push(("housing_markets".to_string(), format!("Error: {}", e))),
}
// Get data directory
- match get_bis_data_directory().await {
+ match get_bis_data_directory(app.clone()).await {
Ok(data) => results.push(("data_directory".to_string(), data)),
Err(e) => results.push(("data_directory".to_string(), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/bls.rs b/fincept-terminal-desktop/src-tauri/src/commands/bls.rs
index f35b10da6..b80e7550d 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/bls.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/bls.rs
@@ -1,18 +1,17 @@
// BLS (Bureau of Labor Statistics) data commands based on OpenBB bls provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute BLS Python script command
#[tauri::command]
pub async fn execute_bls_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("bls_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "bls_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_bls_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute BLS command: {}", e))?;
@@ -45,7 +44,7 @@ pub async fn execute_bls_command(
/// Search for BLS series by category and query
#[tauri::command]
-pub async fn search_bls_series(
+pub async fn search_bls_series(app: tauri::AppHandle,
query: String,
category: Option<String>,
include_extras: Option<bool>,
@@ -63,12 +62,12 @@ pub async fn search_bls_series(
if let Some(include_code_map) = include_code_map {
args.push(include_code_map.to_string());
}
- execute_bls_command("search_series".to_string(), args).await
+ execute_bls_command(app, "search_series".to_string(), args).await
}
/// Get time series data for specific series IDs
#[tauri::command]
-pub async fn get_bls_series_data(
+pub async fn get_bls_series_data(app: tauri::AppHandle,
series_ids: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -92,148 +91,148 @@ pub async fn get_bls_series_data(
if let Some(aspects) = aspects {
args.push(aspects.to_string());
}
- execute_bls_command("get_series".to_string(), args).await
+ execute_bls_command(app, "get_series".to_string(), args).await
}
/// Get data for popular economic series
#[tauri::command]
-pub async fn get_bls_popular_series() -> Result<String, String> {
- execute_bls_command("get_popular".to_string(), vec![]).await
+pub async fn get_bls_popular_series(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_popular".to_string(), vec![]).await
}
// ECONOMIC OVERVIEW COMMANDS
/// Get comprehensive labor market overview
#[tauri::command]
-pub async fn get_bls_labor_market_overview() -> Result<String, String> {
- execute_bls_command("get_labor_overview".to_string(), vec![]).await
+pub async fn get_bls_labor_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_labor_overview".to_string(), vec![]).await
}
/// Get comprehensive inflation overview
#[tauri::command]
-pub async fn get_bls_inflation_overview() -> Result<String, String> {
- execute_bls_command("get_inflation_overview".to_string(), vec![]).await
+pub async fn get_bls_inflation_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_inflation_overview".to_string(), vec![]).await
}
/// Get Employment Cost Index data
#[tauri::command]
-pub async fn get_bls_employment_cost_index() -> Result<String, String> {
- execute_bls_command("get_employment_cost_index".to_string(), vec![]).await
+pub async fn get_bls_employment_cost_index(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_employment_cost_index".to_string(), vec![]).await
}
/// Get Productivity and Costs data
#[tauri::command]
-pub async fn get_bls_productivity_costs() -> Result<String, String> {
- execute_bls_command("get_productivity_costs".to_string(), vec![]).await
+pub async fn get_bls_productivity_costs(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_productivity_costs".to_string(), vec![]).await
}
/// Get available survey categories
#[tauri::command]
-pub async fn get_bls_survey_categories() -> Result<String, String> {
- execute_bls_command("get_categories".to_string(), vec![]).await
+pub async fn get_bls_survey_categories(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_bls_command(app, "get_categories".to_string(), vec![]).await
}
// SPECIALIZED DATA COMMANDS
/// Get Consumer Price Index data
#[tauri::command]
-pub async fn get_bls_cpi_data(
+pub async fn get_bls_cpi_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular CPI series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let cpi_series = series_ids.unwrap_or_else(|| "CPIAUCSL,CPIAUCNS,CUSR0000SA0".to_string());
- get_bls_series_data(cpi_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, cpi_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
/// Get unemployment rate data
#[tauri::command]
-pub async fn get_bls_unemployment_data(
+pub async fn get_bls_unemployment_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular unemployment series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let unemployment_series = series_ids.unwrap_or_else(|| "UNRATE,LNS14000000".to_string());
- get_bls_series_data(unemployment_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, unemployment_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
/// Get nonfarm payrolls data
#[tauri::command]
-pub async fn get_bls_payrolls_data(
+pub async fn get_bls_payrolls_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular payrolls series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let payrolls_series = series_ids.unwrap_or_else(|| "PAYEMS,CES0000000001".to_string());
- get_bls_series_data(payrolls_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, payrolls_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
/// Get labor force participation rate data
#[tauri::command]
-pub async fn get_bls_participation_data(
+pub async fn get_bls_participation_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular participation series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let participation_series = series_ids.unwrap_or_else(|| "CIVPART,LNS13000000".to_string());
- get_bls_series_data(participation_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, participation_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
/// Get Producer Price Index data
#[tauri::command]
-pub async fn get_bls_ppi_data(
+pub async fn get_bls_ppi_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular PPI series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let ppi_series = series_ids.unwrap_or_else(|| "WPSFD4,PPIACO".to_string());
- get_bls_series_data(ppi_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, ppi_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
/// Get JOLTS (Job Openings and Labor Turnover Survey) data
#[tauri::command]
-pub async fn get_bls_jolts_data(
+pub async fn get_bls_jolts_data(app: tauri::AppHandle,
series_ids: Option<String>, // If None, use popular JOLTS series
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
let jolts_series = series_ids.unwrap_or_else(|| "JTSJOL,JTSQUR,JTSHIL,JTSJOR".to_string());
- get_bls_series_data(jolts_series, start_date, end_date, Some(true), Some(false), Some(false)).await
+ get_bls_series_data(app, jolts_series, start_date, end_date, Some(true), Some(false), Some(false)).await
}
// COMPREHENSIVE ANALYSIS COMMANDS
/// Get comprehensive economic dashboard with key indicators
#[tauri::command]
-pub async fn get_bls_economic_dashboard() -> Result<String, String> {
+pub async fn get_bls_economic_dashboard(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get popular series data
- match get_bls_popular_series().await {
+ match get_bls_popular_series(app.clone()).await {
Ok(data) => results.push(("popular_series".to_string(), data)),
Err(e) => results.push(("popular_series".to_string(), format!("Error: {}", e))),
}
// Get labor market overview
- match get_bls_labor_market_overview().await {
+ match get_bls_labor_market_overview(app.clone()).await {
Ok(data) => results.push(("labor_market".to_string(), data)),
Err(e) => results.push(("labor_market".to_string(), format!("Error: {}", e))),
}
// Get inflation overview
- match get_bls_inflation_overview().await {
+ match get_bls_inflation_overview(app.clone()).await {
Ok(data) => results.push(("inflation".to_string(), data)),
Err(e) => results.push(("inflation".to_string(), format!("Error: {}", e))),
}
// Get employment cost index
- match get_bls_employment_cost_index().await {
+ match get_bls_employment_cost_index(app.clone()).await {
Ok(data) => results.push(("employment_costs".to_string(), data)),
Err(e) => results.push(("employment_costs".to_string(), format!("Error: {}", e))),
}
// Get productivity and costs
- match get_bls_productivity_costs().await {
+ match get_bls_productivity_costs(app).await {
Ok(data) => results.push(("productivity_costs".to_string(), data)),
Err(e) => results.push(("productivity_costs".to_string(), format!("Error: {}", e))),
}
@@ -245,35 +244,35 @@ pub async fn get_bls_economic_dashboard() -> Result<String, String> {
/// Get inflation analysis with CPI breakdown
#[tauri::command]
-pub async fn get_bls_inflation_analysis() -> Result<String, String> {
+pub async fn get_bls_inflation_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get CPI all items
- match get_bls_cpi_data(Some("CPIAUCSL".to_string()), None, None).await {
+ match get_bls_cpi_data(app.clone(), Some("CPIAUCSL".to_string()), None, None).await {
Ok(data) => results.push(("cpi_all_items".to_string(), data)),
Err(e) => results.push(("cpi_all_items".to_string(), format!("Error: {}", e))),
}
// Get core CPI (excluding food and energy)
- match get_bls_cpi_data(Some("CUSR0000SA0L1E".to_string()), None, None).await {
+ match get_bls_cpi_data(app.clone(), Some("CUSR0000SA0L1E".to_string()), None, None).await {
Ok(data) => results.push(("core_cpi".to_string(), data)),
Err(e) => results.push(("core_cpi".to_string(), format!("Error: {}", e))),
}
// Get energy inflation
- match get_bls_cpi_data(Some("CUSR0000SA0E".to_string()), None, None).await {
+ match get_bls_cpi_data(app.clone(), Some("CUSR0000SA0E".to_string()), None, None).await {
Ok(data) => results.push(("energy_inflation".to_string(), data)),
Err(e) => results.push(("energy_inflation".to_string(), format!("Error: {}", e))),
}
// Get food inflation
- match get_bls_cpi_data(Some("CUSR0000SA0F".to_string()), None, None).await {
+ match get_bls_cpi_data(app.clone(), Some("CUSR0000SA0F".to_string()), None, None).await {
Ok(data) => results.push(("food_inflation".to_string(), data)),
Err(e) => results.push(("food_inflation".to_string(), format!("Error: {}", e))),
}
// Get PPI data
- match get_bls_ppi_data(None, None, None).await {
+ match get_bls_ppi_data(app, None, None, None).await {
Ok(data) => results.push(("producer_price_index".to_string(), data)),
Err(e) => results.push(("producer_price_index".to_string(), format!("Error: {}", e))),
}
@@ -285,35 +284,35 @@ pub async fn get_bls_inflation_analysis() -> Result<String, String> {
/// Get labor market analysis with employment metrics
#[tauri::command]
-pub async fn get_bls_labor_analysis() -> Result<String, String> {
+pub async fn get_bls_labor_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get unemployment data
- match get_bls_unemployment_data(None, None, None).await {
+ match get_bls_unemployment_data(app.clone(), None, None, None).await {
Ok(data) => results.push(("unemployment_rate".to_string(), data)),
Err(e) => results.push(("unemployment_rate".to_string(), format!("Error: {}", e))),
}
// Get payrolls data
- match get_bls_payrolls_data(None, None, None).await {
+ match get_bls_payrolls_data(app.clone(), None, None, None).await {
Ok(data) => results.push(("nonfarm_payrolls".to_string(), data)),
Err(e) => results.push(("nonfarm_payrolls".to_string(), format!("Error: {}", e))),
}
// Get labor force participation
- match get_bls_participation_data(None, None, None).await {
+ match get_bls_participation_data(app.clone(), None, None, None).await {
Ok(data) => results.push(("labor_force_participation".to_string(), data)),
Err(e) => results.push(("labor_force_participation".to_string(), format!("Error: {}", e))),
}
// Get JOLTS data
- match get_bls_jolts_data(None, None, None).await {
+ match get_bls_jolts_data(app.clone(), None, None, None).await {
Ok(data) => results.push(("jolts_data".to_string(), data)),
Err(e) => results.push(("jolts_data".to_string(), format!("Error: {}", e))),
}
// Get employment cost index
- match get_bls_employment_cost_index().await {
+ match get_bls_employment_cost_index(app).await {
Ok(data) => results.push(("employment_cost_index".to_string(), data)),
Err(e) => results.push(("employment_cost_index".to_string(), format!("Error: {}", e))),
}
@@ -325,7 +324,7 @@ pub async fn get_bls_labor_analysis() -> Result<String, String> {
/// Get custom series comparison
#[tauri::command]
-pub async fn get_bls_series_comparison(
+pub async fn get_bls_series_comparison(app: tauri::AppHandle,
series_ids: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -334,7 +333,7 @@ pub async fn get_bls_series_comparison(
let mut results = Vec::new();
// Get raw series data
- match get_bls_series_data(series_ids.clone(), start_date.clone(), end_date.clone(), Some(true), Some(false), Some(false)).await {
+ match get_bls_series_data(app.clone(), series_ids.clone(), start_date.clone(), end_date.clone(), Some(true), Some(false), Some(false)).await {
Ok(data) => results.push(("raw_data".to_string(), data)),
Err(e) => results.push(("raw_data".to_string(), format!("Error: {}", e))),
}
@@ -348,7 +347,7 @@ pub async fn get_bls_series_comparison(
let series_list: Vec<&str> = series_ids.split(',').collect();
for series_id in series_list.iter().take(3) { // Limit to first 3 for performance
let trimmed_id = series_id.trim();
- match search_bls_series(trimmed_id.to_string(), Some("cpi".to_string()), Some(true), Some(false)).await {
+ match search_bls_series(app.clone(), trimmed_id.to_string(), Some("cpi".to_string()), Some(true), Some(false)).await {
Ok(search_data) => results.push((format!("search_{}", trimmed_id), search_data)),
Err(_) => {} // Skip search errors
}
@@ -363,11 +362,11 @@ pub async fn get_bls_series_comparison(
/// Get BLS data directory and available series information
#[tauri::command]
-pub async fn get_bls_data_directory() -> Result<String, String> {
+pub async fn get_bls_data_directory(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get survey categories
- match get_bls_survey_categories().await {
+ match get_bls_survey_categories(app.clone()).await {
Ok(data) => results.push(("survey_categories".to_string(), data)),
Err(e) => results.push(("survey_categories".to_string(), format!("Error: {}", e))),
}
@@ -381,7 +380,7 @@ pub async fn get_bls_data_directory() -> Result<String, String> {
];
for (search_term, category) in popular_searches {
- match search_bls_series(search_term.to_string(), Some(category.to_string()), Some(false), Some(false)).await {
+ match search_bls_series(app.clone(), search_term.to_string(), Some(category.to_string()), Some(false), Some(false)).await {
Ok(data) => results.push((format!("sample_{}", category), data)),
Err(e) => results.push((format!("sample_{}", category), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/canada_gov.rs b/fincept-terminal-desktop/src-tauri/src/commands/canada_gov.rs
new file mode 100644
index 000000000..2e83e950c
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/canada_gov.rs
@@ -0,0 +1,63 @@
+// Canadian Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Canada Government Python script command
+#[tauri::command]
+pub async fn execute_canada_gov_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "canada_gov_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Canada Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Canada Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Canada Government command failed: {}", stderr))
+ }
+}
+
+/// Search Canadian government datasets
+#[tauri::command]
+pub async fn search_canada_gov_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_canada_gov_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_canada_gov_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_canada_gov_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
+
+/// Get economic indicators
+#[tauri::command]
+pub async fn get_canada_gov_economic_data(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_canada_gov_command(app, "economic".to_string(), vec![]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/cboe.rs b/fincept-terminal-desktop/src-tauri/src/commands/cboe.rs
index 570140cde..e85691f80 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/cboe.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/cboe.rs
@@ -1,18 +1,17 @@
// CBOE (Chicago Board Options Exchange) data commands based on OpenBB cboe provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute CBOE Python script command
#[tauri::command]
pub async fn execute_cboe_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("cboe_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "cboe_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_cboe_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute CBOE command: {}", e))?;
@@ -45,16 +44,16 @@ pub async fn execute_cboe_command(
/// Get real-time equity quote with implied volatility data
#[tauri::command]
-pub async fn get_cboe_equity_quote(
+pub async fn get_cboe_equity_quote(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_cboe_command("equity_quote".to_string(), args).await
+ execute_cboe_command(app, "equity_quote".to_string(), args).await
}
/// Get historical equity price data
#[tauri::command]
-pub async fn get_cboe_equity_historical(
+pub async fn get_cboe_equity_historical(app: tauri::AppHandle,
symbol: String,
interval: Option<String>,
start_date: Option<String>,
@@ -72,12 +71,12 @@ pub async fn get_cboe_equity_historical(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_cboe_command("equity_historical".to_string(), args).await
+ execute_cboe_command(app, "equity_historical".to_string(), args).await
}
/// Search for equities in CBOE directory
#[tauri::command]
-pub async fn search_cboe_equities(
+pub async fn search_cboe_equities(app: tauri::AppHandle,
query: String,
is_symbol: Option<bool>,
) -> Result<String, String> {
@@ -85,23 +84,23 @@ pub async fn search_cboe_equities(
if let Some(is_symbol) = is_symbol {
args.push(is_symbol.to_string());
}
- execute_cboe_command("equity_search".to_string(), args).await
+ execute_cboe_command(app, "equity_search".to_string(), args).await
}
// INDEX DATA COMMANDS
/// Get constituents for European indices
#[tauri::command]
-pub async fn get_cboe_index_constituents(
+pub async fn get_cboe_index_constituents(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_cboe_command("index_constituents".to_string(), args).await
+ execute_cboe_command(app, "index_constituents".to_string(), args).await
}
/// Get historical index data
#[tauri::command]
-pub async fn get_cboe_index_historical(
+pub async fn get_cboe_index_historical(app: tauri::AppHandle,
symbol: String,
interval: Option<String>,
start_date: Option<String>,
@@ -119,12 +118,12 @@ pub async fn get_cboe_index_historical(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_cboe_command("index_historical".to_string(), args).await
+ execute_cboe_command(app, "index_historical".to_string(), args).await
}
/// Search for indices in CBOE directory
#[tauri::command]
-pub async fn search_cboe_indices(
+pub async fn search_cboe_indices(app: tauri::AppHandle,
query: String,
is_symbol: Option<bool>,
) -> Result<String, String> {
@@ -132,12 +131,12 @@ pub async fn search_cboe_indices(
if let Some(is_symbol) = is_symbol {
args.push(is_symbol.to_string());
}
- execute_cboe_command("index_search".to_string(), args).await
+ execute_cboe_command(app, "index_search".to_string(), args).await
}
/// Get snapshots for all indices in a region
#[tauri::command]
-pub async fn get_cboe_index_snapshots(
+pub async fn get_cboe_index_snapshots(app: tauri::AppHandle,
region: Option<String>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -146,20 +145,20 @@ pub async fn get_cboe_index_snapshots(
} else {
args.push("us".to_string());
}
- execute_cboe_command("index_snapshots".to_string(), args).await
+ execute_cboe_command(app, "index_snapshots".to_string(), args).await
}
/// Get list of all available indices
#[tauri::command]
-pub async fn get_cboe_available_indices() -> Result<String, String> {
- execute_cboe_command("available_indices".to_string(), vec![]).await
+pub async fn get_cboe_available_indices(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_cboe_command(app, "available_indices".to_string(), vec![]).await
}
// FUTURES DATA COMMANDS
/// Get VIX futures curve data
#[tauri::command]
-pub async fn get_cboe_futures_curve(
+pub async fn get_cboe_futures_curve(app: tauri::AppHandle,
symbol: Option<String>,
date: Option<String>,
) -> Result<String, String> {
@@ -172,47 +171,47 @@ pub async fn get_cboe_futures_curve(
if let Some(date) = date {
args.push(date);
}
- execute_cboe_command("futures_curve".to_string(), args).await
+ execute_cboe_command(app, "futures_curve".to_string(), args).await
}
// OPTIONS DATA COMMANDS
/// Get options chains data for a symbol
#[tauri::command]
-pub async fn get_cboe_options_chains(
+pub async fn get_cboe_options_chains(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_cboe_command("options_chains".to_string(), args).await
+ execute_cboe_command(app, "options_chains".to_string(), args).await
}
// COMPREHENSIVE DATA COMMANDS
/// Get comprehensive market overview for US indices
#[tauri::command]
-pub async fn get_cboe_us_market_overview() -> Result<String, String> {
- get_cboe_index_snapshots(Some("us".to_string())).await
+pub async fn get_cboe_us_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ get_cboe_index_snapshots(app, Some("us".to_string())).await
}
/// Get comprehensive market overview for European indices
#[tauri::command]
-pub async fn get_cboe_european_market_overview() -> Result<String, String> {
- get_cboe_index_snapshots(Some("eu".to_string())).await
+pub async fn get_cboe_european_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ get_cboe_index_snapshots(app, Some("eu".to_string())).await
}
/// Get VIX analysis including current levels and futures curve
#[tauri::command]
-pub async fn get_cboe_vix_analysis() -> Result<String, String> {
+pub async fn get_cboe_vix_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get VIX quote
- match get_cboe_equity_quote("VIX".to_string()).await {
+ match get_cboe_equity_quote(app.clone(), "VIX".to_string()).await {
Ok(quote_data) => results.push(("quote".to_string(), quote_data)),
Err(e) => results.push(("quote".to_string(), format!("Error: {}", e))),
}
// Get VIX futures curve
- match get_cboe_futures_curve(Some("VX_EOD".to_string()), None).await {
+ match get_cboe_futures_curve(app.clone(), Some("VX_EOD".to_string()), None).await {
Ok(futures_data) => results.push(("futures".to_string(), futures_data)),
Err(e) => results.push(("futures".to_string(), format!("Error: {}", e))),
}
@@ -224,14 +223,14 @@ pub async fn get_cboe_vix_analysis() -> Result<String, String> {
/// Get comprehensive equity analysis with quote and historical data
#[tauri::command]
-pub async fn get_cboe_equity_analysis(
+pub async fn get_cboe_equity_analysis(app: tauri::AppHandle,
symbol: String,
days_back: Option<i32>,
) -> Result<String, String> {
let mut results = Vec::new();
// Get equity quote
- match get_cboe_equity_quote(symbol.clone()).await {
+ match get_cboe_equity_quote(app.clone(), symbol.clone()).await {
Ok(quote_data) => results.push(("quote".to_string(), quote_data)),
Err(e) => results.push(("quote".to_string(), format!("Error: {}", e))),
}
@@ -242,13 +241,13 @@ pub async fn get_cboe_equity_analysis(
.format("%Y-%m-%d")
.to_string();
- match get_cboe_equity_historical(symbol.clone(), Some("1d".to_string()), Some(start_date), None).await {
+ match get_cboe_equity_historical(app.clone(), symbol.clone(), Some("1d".to_string()), Some(start_date), None).await {
Ok(historical_data) => results.push(("historical".to_string(), historical_data)),
Err(e) => results.push(("historical".to_string(), format!("Error: {}", e))),
}
// Try to get options chains if available
- match get_cboe_options_chains(symbol.clone()).await {
+ match get_cboe_options_chains(app.clone(), symbol.clone()).await {
Ok(options_data) => results.push(("options".to_string(), options_data)),
Err(_) => results.push(("options".to_string(), "Options data not available".to_string())),
}
@@ -261,7 +260,7 @@ pub async fn get_cboe_equity_analysis(
/// Get comprehensive index analysis with historical data and constituents
#[tauri::command]
-pub async fn get_cboe_index_analysis(
+pub async fn get_cboe_index_analysis(app: tauri::AppHandle,
symbol: String,
days_back: Option<i32>,
) -> Result<String, String> {
@@ -273,7 +272,7 @@ pub async fn get_cboe_index_analysis(
.format("%Y-%m-%d")
.to_string();
- match get_cboe_index_historical(symbol.clone(), Some("1d".to_string()), Some(start_date), None).await {
+ match get_cboe_index_historical(app.clone(), symbol.clone(), Some("1d".to_string()), Some(start_date), None).await {
Ok(historical_data) => results.push(("historical".to_string(), historical_data)),
Err(e) => results.push(("historical".to_string(), format!("Error: {}", e))),
}
@@ -281,7 +280,7 @@ pub async fn get_cboe_index_analysis(
// Try to get constituents if it's a European index
let eu_indices = ["BUK100P", "BEP50P", "BDE40P", "BFR40P", "BIT40P"];
if eu_indices.contains(&symbol.as_str()) {
- match get_cboe_index_constituents(symbol.clone()).await {
+ match get_cboe_index_constituents(app.clone(), symbol.clone()).await {
Ok(constituents_data) => results.push(("constituents".to_string(), constituents_data)),
Err(e) => results.push(("constituents".to_string(), format!("Error: {}", e))),
}
@@ -295,11 +294,11 @@ pub async fn get_cboe_index_analysis(
/// Get CBOE market sentiment analysis using VIX and index data
#[tauri::command]
-pub async fn get_cboe_market_sentiment() -> Result<String, String> {
+pub async fn get_cboe_market_sentiment(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get VIX data for fear index
- match get_cboe_equity_quote("VIX".to_string()).await {
+ match get_cboe_equity_quote(app.clone(), "VIX".to_string()).await {
Ok(vix_data) => results.push(("vix".to_string(), vix_data)),
Err(e) => results.push(("vix".to_string(), format!("Error: {}", e))),
}
@@ -307,14 +306,14 @@ pub async fn get_cboe_market_sentiment() -> Result<String, String> {
// Get major US indices
let indices = ["SPX", "NDX", "RUT"];
for index in &indices {
- match get_cboe_equity_quote(index.to_string()).await {
+ match get_cboe_equity_quote(app.clone(), index.to_string()).await {
Ok(index_data) => results.push((index.to_string(), index_data)),
Err(e) => results.push((index.to_string(), format!("Error: {}", e))),
}
}
// Get US market snapshots
- match get_cboe_index_snapshots(Some("us".to_string())).await {
+ match get_cboe_index_snapshots(app.clone(), Some("us".to_string())).await {
Ok(snapshots_data) => results.push(("market_snapshots".to_string(), snapshots_data)),
Err(e) => results.push(("market_snapshots".to_string(), format!("Error: {}", e))),
}
@@ -326,7 +325,7 @@ pub async fn get_cboe_market_sentiment() -> Result<String, String> {
/// Search for symbols across both equities and indices
#[tauri::command]
-pub async fn search_cboe_symbols(
+pub async fn search_cboe_symbols(app: tauri::AppHandle,
query: String,
search_type: Option<String>, // "equities", "indices", or "all"
) -> Result<String, String> {
@@ -334,14 +333,14 @@ pub async fn search_cboe_symbols(
let mut results = Vec::new();
if search_mode == "equities" || search_mode == "all" {
- match search_cboe_equities(query.clone(), Some(false)).await {
+ match search_cboe_equities(app.clone(), query.clone(), Some(false)).await {
Ok(equity_results) => results.push(("equities".to_string(), equity_results)),
Err(e) => results.push(("equities".to_string(), format!("Error: {}", e))),
}
}
if search_mode == "indices" || search_mode == "all" {
- match search_cboe_indices(query.clone(), Some(false)).await {
+ match search_cboe_indices(app.clone(), query.clone(), Some(false)).await {
Ok(index_results) => results.push(("indices".to_string(), index_results)),
Err(e) => results.push(("indices".to_string(), format!("Error: {}", e))),
}
@@ -356,23 +355,23 @@ pub async fn search_cboe_symbols(
/// Get CBOE directory information (companies and indices available)
#[tauri::command]
-pub async fn get_cboe_directory_info() -> Result<String, String> {
+pub async fn get_cboe_directory_info(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get available indices
- match get_cboe_available_indices().await {
+ match get_cboe_available_indices(app.clone()).await {
Ok(indices_data) => results.push(("available_indices".to_string(), indices_data)),
Err(e) => results.push(("available_indices".to_string(), format!("Error: {}", e))),
}
// Get US market snapshots for overview
- match get_cboe_index_snapshots(Some("us".to_string())).await {
+ match get_cboe_index_snapshots(app.clone(), Some("us".to_string())).await {
Ok(us_snapshots) => results.push(("us_market_overview".to_string(), us_snapshots)),
Err(e) => results.push(("us_market_overview".to_string(), format!("Error: {}", e))),
}
// Get European market snapshots for overview
- match get_cboe_index_snapshots(Some("eu".to_string())).await {
+ match get_cboe_index_snapshots(app.clone(), Some("eu".to_string())).await {
Ok(eu_snapshots) => results.push(("european_market_overview".to_string(), eu_snapshots)),
Err(e) => results.push(("european_market_overview".to_string(), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/cftc.rs b/fincept-terminal-desktop/src-tauri/src/commands/cftc.rs
index d33595c69..83e4fbfdb 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/cftc.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/cftc.rs
@@ -1,18 +1,17 @@
// CFTC (Commodity Futures Trading Commission) data commands based on OpenBB cftc provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute CFTC Python script command
#[tauri::command]
pub async fn execute_cftc_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("cftc_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "cftc_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_cftc_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute CFTC command: {}", e))?;
@@ -45,7 +44,7 @@ pub async fn execute_cftc_command(
/// Get Commitment of Traders (COT) data
#[tauri::command]
-pub async fn get_cftc_cot_data(
+pub async fn get_cftc_cot_data(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
futures_only: Option<bool>,
@@ -75,29 +74,29 @@ pub async fn get_cftc_cot_data(
} else {
args.push("1000".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
/// Search for available COT markets
#[tauri::command]
-pub async fn search_cftc_cot_markets(
+pub async fn search_cftc_cot_markets(app: tauri::AppHandle,
query: String,
) -> Result<String, String> {
let args = vec![query];
- execute_cftc_command("search_cot_markets".to_string(), args).await
+ execute_cftc_command(app, "search_cot_markets".to_string(), args).await
}
/// Get information about available COT report types
#[tauri::command]
-pub async fn get_cftc_available_report_types() -> Result<String, String> {
- execute_cftc_command("available_report_types".to_string(), vec![]).await
+pub async fn get_cftc_available_report_types(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_cftc_command(app, "available_report_types".to_string(), vec![]).await
}
// MARKET SENTIMENT ANALYSIS COMMANDS
/// Analyze market sentiment from COT data
#[tauri::command]
-pub async fn analyze_cftc_market_sentiment(
+pub async fn analyze_cftc_market_sentiment(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
) -> Result<String, String> {
@@ -107,12 +106,12 @@ pub async fn analyze_cftc_market_sentiment(
} else {
args.push("disaggregated".to_string());
}
- execute_cftc_command("market_sentiment".to_string(), args).await
+ execute_cftc_command(app, "market_sentiment".to_string(), args).await
}
/// Get summary of current positions for a market
#[tauri::command]
-pub async fn get_cftc_position_summary(
+pub async fn get_cftc_position_summary(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
) -> Result<String, String> {
@@ -122,14 +121,14 @@ pub async fn get_cftc_position_summary(
} else {
args.push("disaggregated".to_string());
}
- execute_cftc_command("position_summary".to_string(), args).await
+ execute_cftc_command(app, "position_summary".to_string(), args).await
}
// COMPREHENSIVE DATA COMMANDS
/// Get comprehensive COT overview for multiple markets
#[tauri::command]
-pub async fn get_cftc_comprehensive_cot_overview(
+pub async fn get_cftc_comprehensive_cot_overview(app: tauri::AppHandle,
identifiers: Option<String>,
report_type: Option<String>,
) -> Result<String, String> {
@@ -142,12 +141,12 @@ pub async fn get_cftc_comprehensive_cot_overview(
} else {
args.push("disaggregated".to_string());
}
- execute_cftc_command("comprehensive_cot_overview".to_string(), args).await
+ execute_cftc_command(app, "comprehensive_cot_overview".to_string(), args).await
}
/// Get historical COT trend data for analysis
#[tauri::command]
-pub async fn get_cftc_cot_historical_trend(
+pub async fn get_cftc_cot_historical_trend(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
period: Option<i32>,
@@ -163,14 +162,14 @@ pub async fn get_cftc_cot_historical_trend(
} else {
args.push("52".to_string());
}
- execute_cftc_command("cot_historical_trend".to_string(), args).await
+ execute_cftc_command(app, "cot_historical_trend".to_string(), args).await
}
// LEGACY COT REPORTS COMMANDS
/// Get legacy COT reports (traditional commercial/non-commercial classification)
#[tauri::command]
-pub async fn get_cftc_legacy_cot(
+pub async fn get_cftc_legacy_cot(app: tauri::AppHandle,
identifier: String,
futures_only: Option<bool>,
start_date: Option<String>,
@@ -195,14 +194,14 @@ pub async fn get_cftc_legacy_cot(
} else {
args.push("500".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
// DISAGGREGATED COT REPORTS COMMANDS
/// Get disaggregated COT reports (detailed trader classifications)
#[tauri::command]
-pub async fn get_cftc_disaggregated_cot(
+pub async fn get_cftc_disaggregated_cot(app: tauri::AppHandle,
identifier: String,
futures_only: Option<bool>,
start_date: Option<String>,
@@ -227,14 +226,14 @@ pub async fn get_cftc_disaggregated_cot(
} else {
args.push("500".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
// TRADERS IN FINANCIAL FUTURES (TFF) COMMANDS
/// Get TFF reports for financial futures
#[tauri::command]
-pub async fn get_cftc_tff_reports(
+pub async fn get_cftc_tff_reports(app: tauri::AppHandle,
identifier: String,
futures_only: Option<bool>,
start_date: Option<String>,
@@ -259,14 +258,14 @@ pub async fn get_cftc_tff_reports(
} else {
args.push("200".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
// SUPPLEMENTAL COT REPORTS COMMANDS
/// Get supplemental COT reports
#[tauri::command]
-pub async fn get_cftc_supplemental_cot(
+pub async fn get_cftc_supplemental_cot(app: tauri::AppHandle,
identifier: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -285,14 +284,14 @@ pub async fn get_cftc_supplemental_cot(
} else {
args.push("100".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
// MARKET SPECIFIC COMMANDS
/// Get COT data for precious metals (gold, silver, platinum, palladium)
#[tauri::command]
-pub async fn get_cftc_precious_metals_cot(
+pub async fn get_cftc_precious_metals_cot(app: tauri::AppHandle,
report_type: Option<String>,
futures_only: Option<bool>,
limit: Option<i32>,
@@ -313,12 +312,12 @@ pub async fn get_cftc_precious_metals_cot(
} else {
args.push("200".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
/// Get COT data for energy markets (crude oil, natural gas, gasoline, heating oil)
#[tauri::command]
-pub async fn get_cftc_energy_cot(
+pub async fn get_cftc_energy_cot(app: tauri::AppHandle,
report_type: Option<String>,
futures_only: Option<bool>,
limit: Option<i32>,
@@ -339,12 +338,12 @@ pub async fn get_cftc_energy_cot(
} else {
args.push("200".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
/// Get COT data for agricultural commodities (corn, wheat, soybeans, cotton, etc.)
#[tauri::command]
-pub async fn get_cftc_agricultural_cot(
+pub async fn get_cftc_agricultural_cot(app: tauri::AppHandle,
report_type: Option<String>,
futures_only: Option<bool>,
limit: Option<i32>,
@@ -365,12 +364,12 @@ pub async fn get_cftc_agricultural_cot(
} else {
args.push("300".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
/// Get COT data for financial futures (currencies, stock indices, interest rates)
#[tauri::command]
-pub async fn get_cftc_financial_cot(
+pub async fn get_cftc_financial_cot(app: tauri::AppHandle,
futures_only: Option<bool>,
limit: Option<i32>,
) -> Result<String, String> {
@@ -386,12 +385,12 @@ pub async fn get_cftc_financial_cot(
} else {
args.push("300".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
/// Get COT data for cryptocurrency futures (bitcoin, ether)
#[tauri::command]
-pub async fn get_cftc_crypto_cot(
+pub async fn get_cftc_crypto_cot(app: tauri::AppHandle,
report_type: Option<String>,
futures_only: Option<bool>,
limit: Option<i32>,
@@ -412,14 +411,14 @@ pub async fn get_cftc_crypto_cot(
} else {
args.push("100".to_string());
}
- execute_cftc_command("cot_data".to_string(), args).await
+ execute_cftc_command(app, "cot_data".to_string(), args).await
}
// ADVANCED ANALYSIS COMMANDS
/// Get COT position changes and momentum analysis
#[tauri::command]
-pub async fn get_cftc_position_changes(
+pub async fn get_cftc_position_changes(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
period: Option<i32>,
@@ -435,12 +434,12 @@ pub async fn get_cftc_position_changes(
} else {
args.push("12".to_string());
}
- execute_cftc_command("cot_historical_trend".to_string(), args).await
+ execute_cftc_command(app, "cot_historical_trend".to_string(), args).await
}
/// Get COT extreme positions analysis (historical extremes)
#[tauri::command]
-pub async fn get_cftc_extreme_positions(
+pub async fn get_cftc_extreme_positions(app: tauri::AppHandle,
identifier: String,
report_type: Option<String>,
) -> Result<String, String> {
@@ -452,5 +451,5 @@ pub async fn get_cftc_extreme_positions(
}
// Use historical trend for extremes analysis
args.push("104".to_string()); // 2 years of data
- execute_cftc_command("cot_historical_trend".to_string(), args).await
+ execute_cftc_command(app, "cot_historical_trend".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/coingecko.rs b/fincept-terminal-desktop/src-tauri/src/commands/coingecko.rs
new file mode 100644
index 000000000..ef3726811
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/coingecko.rs
@@ -0,0 +1,117 @@
+// CoinGecko cryptocurrency data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute CoinGecko Python script command
+#[tauri::command]
+pub async fn execute_coingecko_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "coingecko.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "CoinGecko script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute CoinGecko command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("CoinGecko command failed: {}", stderr))
+ }
+}
+
+/// Get cryptocurrency price
+#[tauri::command]
+pub async fn get_coingecko_price(
+ app: tauri::AppHandle,
+ coin_id: String,
+ vs_currency: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![coin_id];
+ if let Some(currency) = vs_currency {
+ args.push(currency);
+ }
+ execute_coingecko_command(app, "price".to_string(), args).await
+}
+
+/// Get cryptocurrency market data
+#[tauri::command]
+pub async fn get_coingecko_market_data(
+ app: tauri::AppHandle,
+ coin_id: String,
+) -> Result<String, String> {
+ execute_coingecko_command(app, "market_data".to_string(), vec![coin_id]).await
+}
+
+/// Get cryptocurrency historical data
+#[tauri::command]
+pub async fn get_coingecko_historical(
+ app: tauri::AppHandle,
+ coin_id: String,
+ vs_currency: String,
+ days: Option<i32>,
+) -> Result<String, String> {
+ let mut args = vec![coin_id, vs_currency];
+ if let Some(d) = days {
+ args.push(d.to_string());
+ }
+ execute_coingecko_command(app, "historical".to_string(), args).await
+}
+
+/// Search cryptocurrencies
+#[tauri::command]
+pub async fn search_coingecko_coins(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_coingecko_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get trending cryptocurrencies
+#[tauri::command]
+pub async fn get_coingecko_trending(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_coingecko_command(app, "trending".to_string(), vec![]).await
+}
+
+/// Get global cryptocurrency market data
+#[tauri::command]
+pub async fn get_coingecko_global_data(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_coingecko_command(app, "global".to_string(), vec![]).await
+}
+
+/// Get top cryptocurrencies by market cap
+#[tauri::command]
+pub async fn get_coingecko_top_coins(
+ app: tauri::AppHandle,
+ vs_currency: Option<String>,
+ limit: Option<i32>,
+) -> Result<String, String> {
+ let mut args = vec![];
+ if let Some(currency) = vs_currency {
+ args.push(currency);
+ }
+ if let Some(lim) = limit {
+ args.push(lim.to_string());
+ }
+ execute_coingecko_command(app, "top_coins".to_string(), args).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/congress_gov.rs b/fincept-terminal-desktop/src-tauri/src/commands/congress_gov.rs
index b71f7c551..acb1a154c 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/congress_gov.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/congress_gov.rs
@@ -1,18 +1,17 @@
// Congress.gov data commands based on OpenBB congress_gov provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute Congress.gov Python script command
#[tauri::command]
pub async fn execute_congress_gov_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("congress_gov_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "congress_gov_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_congress_gov_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute Congress.gov command: {}", e))?;
@@ -43,7 +42,7 @@ pub async fn execute_congress_gov_command(
/// Get Congressional bills with various filters
#[tauri::command]
-pub async fn get_congress_bills(
+pub async fn get_congress_bills(app: tauri::AppHandle,
congress: Option<i32>,
bill_type: Option<String>,
start_date: Option<String>,
@@ -78,36 +77,36 @@ pub async fn get_congress_bills(
if let Some(get_all) = get_all {
args.push(get_all.to_string());
}
- execute_congress_gov_command("congress_bills".to_string(), args).await
+ execute_congress_gov_command(app, "congress_bills".to_string(), args).await
}
/// Get detailed information about a specific bill
#[tauri::command]
-pub async fn get_bill_info(bill_url: String) -> Result<String, String> {
- execute_congress_gov_command("bill_info".to_string(), vec![bill_url]).await
+pub async fn get_bill_info(app: tauri::AppHandle, bill_url: String) -> Result<String, String> {
+ execute_congress_gov_command(app, "bill_info".to_string(), vec![bill_url]).await
}
/// Get available text versions for a bill
#[tauri::command]
-pub async fn get_bill_text(bill_url: String) -> Result<String, String> {
- execute_congress_gov_command("bill_text".to_string(), vec![bill_url]).await
+pub async fn get_bill_text(app: tauri::AppHandle, bill_url: String) -> Result<String, String> {
+ execute_congress_gov_command(app, "bill_text".to_string(), vec![bill_url]).await
}
/// Download bill text document
#[tauri::command]
-pub async fn download_bill_text(text_url: String) -> Result<String, String> {
- execute_congress_gov_command("download_text".to_string(), vec![text_url]).await
+pub async fn download_bill_text(app: tauri::AppHandle, text_url: String) -> Result<String, String> {
+ execute_congress_gov_command(app, "download_text".to_string(), vec![text_url]).await
}
/// Get comprehensive data for a bill from multiple endpoints
#[tauri::command]
-pub async fn get_comprehensive_bill_data(bill_url: String) -> Result<String, String> {
- execute_congress_gov_command("comprehensive".to_string(), vec![bill_url]).await
+pub async fn get_comprehensive_bill_data(app: tauri::AppHandle, bill_url: String) -> Result<String, String> {
+ execute_congress_gov_command(app, "comprehensive".to_string(), vec![bill_url]).await
}
/// Get a summary of bills by type for a given congress
#[tauri::command]
-pub async fn get_bill_summary_by_congress(
+pub async fn get_bill_summary_by_congress(app: tauri::AppHandle,
congress: Option<i32>,
limit: Option<i32>,
) -> Result<String, String> {
@@ -118,5 +117,5 @@ pub async fn get_bill_summary_by_congress(
if let Some(limit) = limit {
args.push(limit.to_string());
}
- execute_congress_gov_command("summary".to_string(), args).await
+ execute_congress_gov_command(app, "summary".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/data_gov_hk.rs b/fincept-terminal-desktop/src-tauri/src/commands/data_gov_hk.rs
new file mode 100644
index 000000000..8d6cca740
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/data_gov_hk.rs
@@ -0,0 +1,55 @@
+// Hong Kong Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Hong Kong Government Python script command
+#[tauri::command]
+pub async fn execute_data_gov_hk_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "data_gov_hk_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Hong Kong Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Hong Kong Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Hong Kong Government command failed: {}", stderr))
+ }
+}
+
+/// Search Hong Kong government datasets
+#[tauri::command]
+pub async fn search_data_gov_hk_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_data_gov_hk_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_data_gov_hk_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_data_gov_hk_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/databento.rs b/fincept-terminal-desktop/src-tauri/src/commands/databento.rs
new file mode 100644
index 000000000..60c669432
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/databento.rs
@@ -0,0 +1,74 @@
+// Databento market data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Databento Python script command
+#[tauri::command]
+pub async fn execute_databento_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "explore_databento_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Databento script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Databento command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Databento command failed: {}", stderr))
+ }
+}
+
+/// Get market data
+#[tauri::command]
+pub async fn get_databento_market_data(
+ app: tauri::AppHandle,
+ symbol: String,
+ dataset: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![symbol];
+ if let Some(ds) = dataset {
+ args.push(ds);
+ }
+ execute_databento_command(app, "market_data".to_string(), args).await
+}
+
+/// Get available datasets
+#[tauri::command]
+pub async fn get_databento_datasets(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_databento_command(app, "datasets".to_string(), vec![]).await
+}
+
+/// Get historical data
+#[tauri::command]
+pub async fn get_databento_historical(
+ app: tauri::AppHandle,
+ symbol: String,
+ start_date: String,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![symbol, start_date];
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_databento_command(app, "historical".to_string(), args).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/datagov_au.rs b/fincept-terminal-desktop/src-tauri/src/commands/datagov_au.rs
new file mode 100644
index 000000000..927b23fbc
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/datagov_au.rs
@@ -0,0 +1,55 @@
+// Australian Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Australian Government Python script command
+#[tauri::command]
+pub async fn execute_datagov_au_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "datagov_au_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Australian Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Australian Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Australian Government command failed: {}", stderr))
+ }
+}
+
+/// Search Australian government datasets
+#[tauri::command]
+pub async fn search_datagov_au_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_datagov_au_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_datagov_au_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_datagov_au_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/datagovsg.rs b/fincept-terminal-desktop/src-tauri/src/commands/datagovsg.rs
new file mode 100644
index 000000000..9627293e0
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/datagovsg.rs
@@ -0,0 +1,55 @@
+// Singapore Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Singapore Government Python script command
+#[tauri::command]
+pub async fn execute_datagovsg_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "datagovsg_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Singapore Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Singapore Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Singapore Government command failed: {}", stderr))
+ }
+}
+
+/// Search Singapore government datasets
+#[tauri::command]
+pub async fn search_datagovsg_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_datagovsg_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_datagovsg_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_datagovsg_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/datagovuk.rs b/fincept-terminal-desktop/src-tauri/src/commands/datagovuk.rs
new file mode 100644
index 000000000..9a8e2dff7
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/datagovuk.rs
@@ -0,0 +1,55 @@
+// UK Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute UK Government Python script command
+#[tauri::command]
+pub async fn execute_datagovuk_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "datagovuk_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "UK Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute UK Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("UK Government command failed: {}", stderr))
+ }
+}
+
+/// Search UK government datasets
+#[tauri::command]
+pub async fn search_datagovuk_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_datagovuk_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_datagovuk_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_datagovuk_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/ecb.rs b/fincept-terminal-desktop/src-tauri/src/commands/ecb.rs
index 309074838..4748fe912 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/ecb.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/ecb.rs
@@ -1,18 +1,17 @@
// ECB (European Central Bank) data commands based on OpenBB ECB provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute ECB Python script command
#[tauri::command]
pub async fn execute_ecb_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("ecb_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "ecb_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_ecb_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute ECB command: {}", e))?;
@@ -45,27 +44,27 @@ pub async fn execute_ecb_command(
/// Get available ECB data categories and options
#[tauri::command]
-pub async fn get_ecb_available_categories() -> Result<String, String> {
- execute_ecb_command("available_categories".to_string(), vec![]).await
+pub async fn get_ecb_available_categories(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_ecb_command(app, "available_categories".to_string(), vec![]).await
}
/// Get currency reference rates (daily FX rates)
#[tauri::command]
-pub async fn get_ecb_currency_reference_rates() -> Result<String, String> {
- execute_ecb_command("currency_rates".to_string(), vec![]).await
+pub async fn get_ecb_currency_reference_rates(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_ecb_command(app, "currency_rates".to_string(), vec![]).await
}
/// Get ECB overview with multiple data sources
#[tauri::command]
-pub async fn get_ecb_overview() -> Result<String, String> {
- execute_ecb_command("overview".to_string(), vec![]).await
+pub async fn get_ecb_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_ecb_command(app, "overview".to_string(), vec![]).await
}
// YIELD CURVE COMMANDS
/// Get yield curve data with specified parameters
#[tauri::command]
-pub async fn get_ecb_yield_curve(
+pub async fn get_ecb_yield_curve(app: tauri::AppHandle,
rating: Option<String>,
curve_type: Option<String>,
date: Option<String>,
@@ -87,12 +86,12 @@ pub async fn get_ecb_yield_curve(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get AAA-rated spot rate yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_aaa_spot(
+pub async fn get_ecb_yield_curve_aaa_spot(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "aaa".to_string(), "--type".to_string(), "spot_rate".to_string()];
@@ -102,12 +101,12 @@ pub async fn get_ecb_yield_curve_aaa_spot(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get AAA-rated instantaneous forward yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_aaa_forward(
+pub async fn get_ecb_yield_curve_aaa_forward(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "aaa".to_string(), "--type".to_string(), "instantaneous_forward".to_string()];
@@ -117,12 +116,12 @@ pub async fn get_ecb_yield_curve_aaa_forward(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get AAA-rated par yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_aaa_par_yield(
+pub async fn get_ecb_yield_curve_aaa_par_yield(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "aaa".to_string(), "--type".to_string(), "par_yield".to_string()];
@@ -132,12 +131,12 @@ pub async fn get_ecb_yield_curve_aaa_par_yield(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get all ratings spot rate yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_all_spot(
+pub async fn get_ecb_yield_curve_all_spot(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "all_ratings".to_string(), "--type".to_string(), "spot_rate".to_string()];
@@ -147,12 +146,12 @@ pub async fn get_ecb_yield_curve_all_spot(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get all ratings instantaneous forward yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_all_forward(
+pub async fn get_ecb_yield_curve_all_forward(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "all_ratings".to_string(), "--type".to_string(), "instantaneous_forward".to_string()];
@@ -162,12 +161,12 @@ pub async fn get_ecb_yield_curve_all_forward(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
/// Get all ratings par yield curve
#[tauri::command]
-pub async fn get_ecb_yield_curve_all_par_yield(
+pub async fn get_ecb_yield_curve_all_par_yield(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut args = vec!["--rating".to_string(), "all_ratings".to_string(), "--type".to_string(), "par_yield".to_string()];
@@ -177,14 +176,14 @@ pub async fn get_ecb_yield_curve_all_par_yield(
args.push(d);
}
- execute_ecb_command("yield_curve".to_string(), args).await
+ execute_ecb_command(app, "yield_curve".to_string(), args).await
}
// BALANCE OF PAYMENTS COMMANDS
/// Get balance of payments data with specified parameters
#[tauri::command]
-pub async fn get_ecb_balance_of_payments(
+pub async fn get_ecb_balance_of_payments(app: tauri::AppHandle,
country: Option<String>,
frequency: Option<String>,
report_type: Option<String>,
@@ -206,12 +205,12 @@ pub async fn get_ecb_balance_of_payments(
args.push(rt);
}
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get main balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_main(
+pub async fn get_ecb_bop_main(app: tauri::AppHandle,
country: String,
frequency: Option<String>,
) -> Result<String, String> {
@@ -222,12 +221,12 @@ pub async fn get_ecb_bop_main(
args.push(f);
}
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get summary balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_summary(
+pub async fn get_ecb_bop_summary(app: tauri::AppHandle,
country: String,
frequency: Option<String>,
) -> Result<String, String> {
@@ -238,12 +237,12 @@ pub async fn get_ecb_bop_summary(
args.push(f);
}
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get services balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_services(
+pub async fn get_ecb_bop_services(app: tauri::AppHandle,
country: String,
) -> Result<String, String> {
let args = vec![
@@ -255,12 +254,12 @@ pub async fn get_ecb_bop_services(
"quarterly".to_string()
];
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get investment income balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_investment_income(
+pub async fn get_ecb_bop_investment_income(app: tauri::AppHandle,
country: String,
) -> Result<String, String> {
let args = vec![
@@ -272,12 +271,12 @@ pub async fn get_ecb_bop_investment_income(
"quarterly".to_string()
];
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get direct investment balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_direct_investment(
+pub async fn get_ecb_bop_direct_investment(app: tauri::AppHandle,
country: String,
) -> Result<String, String> {
let args = vec![
@@ -289,12 +288,12 @@ pub async fn get_ecb_bop_direct_investment(
"quarterly".to_string()
];
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get portfolio investment balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_portfolio_investment(
+pub async fn get_ecb_bop_portfolio_investment(app: tauri::AppHandle,
country: String,
) -> Result<String, String> {
let args = vec![
@@ -306,12 +305,12 @@ pub async fn get_ecb_bop_portfolio_investment(
"quarterly".to_string()
];
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
/// Get other investment balance of payments data for a country
#[tauri::command]
-pub async fn get_ecb_bop_other_investment(
+pub async fn get_ecb_bop_other_investment(app: tauri::AppHandle,
country: String,
) -> Result<String, String> {
let args = vec![
@@ -323,80 +322,80 @@ pub async fn get_ecb_bop_other_investment(
"quarterly".to_string()
];
- execute_ecb_command("balance_of_payments".to_string(), args).await
+ execute_ecb_command(app, "balance_of_payments".to_string(), args).await
}
// CONVENIENCE COMMANDS FOR MAJOR ECONOMIES
/// Get US balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_united_states(
+pub async fn get_ecb_bop_united_states(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("US".to_string(), frequency).await
+ get_ecb_bop_main(app, "US".to_string(), frequency).await
}
/// Get Japan balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_japan(
+pub async fn get_ecb_bop_japan(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("JP".to_string(), frequency).await
+ get_ecb_bop_main(app, "JP".to_string(), frequency).await
}
/// Get United Kingdom balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_united_kingdom(
+pub async fn get_ecb_bop_united_kingdom(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("GB".to_string(), frequency).await
+ get_ecb_bop_main(app, "GB".to_string(), frequency).await
}
/// Get Switzerland balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_switzerland(
+pub async fn get_ecb_bop_switzerland(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("CH".to_string(), frequency).await
+ get_ecb_bop_main(app, "CH".to_string(), frequency).await
}
/// Get Canada balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_canada(
+pub async fn get_ecb_bop_canada(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("CA".to_string(), frequency).await
+ get_ecb_bop_main(app, "CA".to_string(), frequency).await
}
/// Get Australia balance of payments data
#[tauri::command]
-pub async fn get_ecb_bop_australia(
+pub async fn get_ecb_bop_australia(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
- get_ecb_bop_main("AU".to_string(), frequency).await
+ get_ecb_bop_main(app, "AU".to_string(), frequency).await
}
// ANALYSIS COMMANDS
/// Get comprehensive ECB financial markets analysis
#[tauri::command]
-pub async fn get_ecb_financial_markets_analysis() -> Result<String, String> {
+pub async fn get_ecb_financial_markets_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get currency rates
- match get_ecb_currency_reference_rates().await {
+ match get_ecb_currency_reference_rates(app.clone()).await {
Ok(data) => results.push(("currency_rates".to_string(), data)),
Err(e) => results.push(("currency_rates".to_string(), format!("Error: {}", e))),
}
// Get AAA yield curve
- match get_ecb_yield_curve_aaa_spot(None).await {
+ match get_ecb_yield_curve_aaa_spot(app.clone(), None).await {
Ok(data) => results.push(("yield_curve_aaa_spot".to_string(), data)),
Err(e) => results.push(("yield_curve_aaa_spot".to_string(), format!("Error: {}", e))),
}
// Get all ratings yield curve
- match get_ecb_yield_curve_all_spot(None).await {
+ match get_ecb_yield_curve_all_spot(app.clone(), None).await {
Ok(data) => results.push(("yield_curve_all_spot".to_string(), data)),
Err(e) => results.push(("yield_curve_all_spot".to_string(), format!("Error: {}", e))),
}
@@ -410,7 +409,7 @@ pub async fn get_ecb_financial_markets_analysis() -> Result<String, String> {
/// Get ECB yield curve analysis comparing different ratings and types
#[tauri::command]
-pub async fn get_ecb_yield_curve_analysis(
+pub async fn get_ecb_yield_curve_analysis(app: tauri::AppHandle,
date: Option<String>,
) -> Result<String, String> {
let mut results = Vec::new();
@@ -426,7 +425,7 @@ pub async fn get_ecb_yield_curve_analysis(
];
for (name, rating, curve_type) in curve_types {
- match get_ecb_yield_curve(
+ match get_ecb_yield_curve(app.clone(),
Some(rating.to_string()),
Some(curve_type.to_string()),
date.clone()
@@ -446,7 +445,7 @@ pub async fn get_ecb_yield_curve_analysis(
/// Get ECB major economies balance of payments analysis
#[tauri::command]
-pub async fn get_ecb_major_economies_bop_analysis(
+pub async fn get_ecb_major_economies_bop_analysis(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
let mut results = Vec::new();
@@ -464,7 +463,7 @@ pub async fn get_ecb_major_economies_bop_analysis(
];
for (code, _name) in countries {
- match get_ecb_bop_main(code.to_string(), frequency.clone()).await {
+ match get_ecb_bop_main(app.clone(), code.to_string(), frequency.clone()).await {
Ok(data) => results.push((format!("bop_{}", code.to_lowercase()), data)),
Err(e) => results.push((format!("bop_{}", code.to_lowercase()), format!("Error: {}", e))),
}
@@ -480,7 +479,7 @@ pub async fn get_ecb_major_economies_bop_analysis(
/// Get custom ECB analysis for specific countries and parameters
#[tauri::command]
-pub async fn get_ecb_custom_analysis(
+pub async fn get_ecb_custom_analysis(app: tauri::AppHandle,
countries: String, // Comma-separated country codes
include_yield_curve: Option<bool>,
include_currency_rates: Option<bool>,
@@ -489,7 +488,7 @@ pub async fn get_ecb_custom_analysis(
// Get currency rates if requested
if include_yield_curve.unwrap_or(true) {
- match get_ecb_currency_reference_rates().await {
+ match get_ecb_currency_reference_rates(app.clone()).await {
Ok(data) => results.push(("currency_rates".to_string(), data)),
Err(e) => results.push(("currency_rates".to_string(), format!("Error: {}", e))),
}
@@ -497,7 +496,7 @@ pub async fn get_ecb_custom_analysis(
// Get yield curve if requested
if include_yield_curve.unwrap_or(true) {
- match get_ecb_yield_curve_aaa_spot(None).await {
+ match get_ecb_yield_curve_aaa_spot(app.clone(), None).await {
Ok(data) => results.push(("yield_curve".to_string(), data)),
Err(e) => results.push(("yield_curve".to_string(), format!("Error: {}", e))),
}
@@ -507,7 +506,7 @@ pub async fn get_ecb_custom_analysis(
let country_list: Vec<&str> = countries.split(',').collect();
for country_code in country_list {
let trimmed_code = country_code.trim();
- match get_ecb_bop_main(trimmed_code.to_string(), None).await {
+ match get_ecb_bop_main(app.clone(), trimmed_code.to_string(), None).await {
Ok(data) => results.push((format!("bop_{}", trimmed_code.to_lowercase()), data)),
Err(e) => results.push((format!("bop_{}", trimmed_code.to_lowercase()), format!("Error: {}", e))),
}
@@ -528,17 +527,17 @@ pub async fn get_ecb_custom_analysis(
/// Get current ECB market snapshot
#[tauri::command]
-pub async fn get_ecb_current_market_snapshot() -> Result<String, String> {
+pub async fn get_ecb_current_market_snapshot(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get current currency rates
- match get_ecb_currency_reference_rates().await {
+ match get_ecb_currency_reference_rates(app.clone()).await {
Ok(data) => results.push(("currency_rates".to_string(), data)),
Err(e) => results.push(("currency_rates".to_string(), format!("Error: {}", e))),
}
// Get current yield curve
- match get_ecb_yield_curve_aaa_spot(None).await {
+ match get_ecb_yield_curve_aaa_spot(app.clone(), None).await {
Ok(data) => results.push(("yield_curve_current".to_string(), data)),
Err(e) => results.push(("yield_curve_current".to_string(), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/econdb.rs b/fincept-terminal-desktop/src-tauri/src/commands/econdb.rs
new file mode 100644
index 000000000..228c803d4
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/econdb.rs
@@ -0,0 +1,99 @@
+// EconDB economic database commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute EconDB Python script command
+#[tauri::command]
+pub async fn execute_econdb_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "econdb_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "EconDB script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute EconDB command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("EconDB command failed: {}", stderr))
+ }
+}
+
+/// Get economic series data
+#[tauri::command]
+pub async fn get_econdb_series(
+ app: tauri::AppHandle,
+ ticker: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![ticker];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_econdb_command(app, "series".to_string(), args).await
+}
+
+/// Search economic indicators
+#[tauri::command]
+pub async fn search_econdb_indicators(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_econdb_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get available datasets
+#[tauri::command]
+pub async fn get_econdb_datasets(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_econdb_command(app, "datasets".to_string(), vec![]).await
+}
+
+/// Get country-specific economic data
+#[tauri::command]
+pub async fn get_econdb_country_data(
+ app: tauri::AppHandle,
+ country_code: String,
+) -> Result<String, String> {
+ execute_econdb_command(app, "country".to_string(), vec![country_code]).await
+}
+
+/// Get multiple series
+#[tauri::command]
+pub async fn get_econdb_multiple_series(
+ app: tauri::AppHandle,
+ tickers: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![tickers];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_econdb_command(app, "multiple_series".to_string(), args).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/economic_calendar.rs b/fincept-terminal-desktop/src-tauri/src/commands/economic_calendar.rs
new file mode 100644
index 000000000..ddea5bc37
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/economic_calendar.rs
@@ -0,0 +1,85 @@
+// Economic calendar events commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Economic Calendar Python script command
+#[tauri::command]
+pub async fn execute_economic_calendar_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "economic_calendar.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Economic Calendar script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Economic Calendar command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Economic Calendar command failed: {}", stderr))
+ }
+}
+
+/// Get today's economic events
+#[tauri::command]
+pub async fn get_economic_calendar_today(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_economic_calendar_command(app, "today".to_string(), vec![]).await
+}
+
+/// Get upcoming economic events
+#[tauri::command]
+pub async fn get_economic_calendar_upcoming(
+ app: tauri::AppHandle,
+ days: Option<i32>,
+) -> Result<String, String> {
+ let args = if let Some(d) = days {
+ vec![d.to_string()]
+ } else {
+ vec![]
+ };
+ execute_economic_calendar_command(app, "upcoming".to_string(), args).await
+}
+
+/// Get events by country
+#[tauri::command]
+pub async fn get_economic_calendar_by_country(
+ app: tauri::AppHandle,
+ country: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![country];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_economic_calendar_command(app, "country".to_string(), args).await
+}
+
+/// Get high impact events
+#[tauri::command]
+pub async fn get_economic_calendar_high_impact(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_economic_calendar_command(app, "high_impact".to_string(), vec![]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/eia.rs b/fincept-terminal-desktop/src-tauri/src/commands/eia.rs
index 715f40590..cab4525cc 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/eia.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/eia.rs
@@ -1,18 +1,17 @@
// EIA (U.S. Energy Information Administration) data commands based on OpenBB eia provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute EIA Python script command
#[tauri::command]
pub async fn execute_eia_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("eia_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "eia_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_eia_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute EIA command: {}", e))?;
@@ -45,7 +44,7 @@ pub async fn execute_eia_command(
/// Get petroleum status report data
#[tauri::command]
-pub async fn get_eia_petroleum_status_report(
+pub async fn get_eia_petroleum_status_report(app: tauri::AppHandle,
category: String,
tables: Option<String>,
start_date: Option<String>,
@@ -61,18 +60,18 @@ pub async fn get_eia_petroleum_status_report(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get available petroleum categories
#[tauri::command]
-pub async fn get_eia_petroleum_categories() -> Result<String, String> {
- execute_eia_command("available_categories".to_string(), vec![]).await
+pub async fn get_eia_petroleum_categories(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_eia_command(app, "available_categories".to_string(), vec![]).await
}
/// Get crude oil stocks
#[tauri::command]
-pub async fn get_eia_crude_stocks(
+pub async fn get_eia_crude_stocks(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -83,12 +82,12 @@ pub async fn get_eia_crude_stocks(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_crude_stocks".to_string(), args).await
+ execute_eia_command(app, "get_crude_stocks".to_string(), args).await
}
/// Get gasoline stocks
#[tauri::command]
-pub async fn get_eia_gasoline_stocks(
+pub async fn get_eia_gasoline_stocks(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -99,12 +98,12 @@ pub async fn get_eia_gasoline_stocks(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_gasoline_stocks".to_string(), args).await
+ execute_eia_command(app, "get_gasoline_stocks".to_string(), args).await
}
/// Get petroleum imports
#[tauri::command]
-pub async fn get_eia_petroleum_imports(
+pub async fn get_eia_petroleum_imports(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -115,20 +114,20 @@ pub async fn get_eia_petroleum_imports(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum_imports".to_string(), args).await
+ execute_eia_command(app, "get_petroleum_imports".to_string(), args).await
}
/// Get spot prices
#[tauri::command]
-pub async fn get_eia_spot_prices() -> Result<String, String> {
- execute_eia_command("get_spot_prices".to_string(), vec![]).await
+pub async fn get_eia_spot_prices(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_eia_command(app, "get_spot_prices".to_string(), vec![]).await
}
// SHORT TERM ENERGY OUTLOOK (STEO) COMMANDS
/// Get short term energy outlook data
#[tauri::command]
-pub async fn get_eia_short_term_energy_outlook(
+pub async fn get_eia_short_term_energy_outlook(app: tauri::AppHandle,
table: String,
symbols: Option<String>,
frequency: Option<String>,
@@ -148,18 +147,18 @@ pub async fn get_eia_short_term_energy_outlook(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_steo".to_string(), args).await
+ execute_eia_command(app, "get_steo".to_string(), args).await
}
/// Get available STEO tables
#[tauri::command]
-pub async fn get_eia_steo_tables() -> Result<String, String> {
- execute_eia_command("available_steo_tables".to_string(), vec![]).await
+pub async fn get_eia_steo_tables(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_eia_command(app, "available_steo_tables".to_string(), vec![]).await
}
/// Get energy markets summary
#[tauri::command]
-pub async fn get_eia_energy_markets_summary(
+pub async fn get_eia_energy_markets_summary(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -170,12 +169,12 @@ pub async fn get_eia_energy_markets_summary(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_energy_markets_summary".to_string(), args).await
+ execute_eia_command(app, "get_energy_markets_summary".to_string(), args).await
}
/// Get natural gas summary
#[tauri::command]
-pub async fn get_eia_natural_gas_summary(
+pub async fn get_eia_natural_gas_summary(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -186,14 +185,14 @@ pub async fn get_eia_natural_gas_summary(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_natural_gas_summary".to_string(), args).await
+ execute_eia_command(app, "get_natural_gas_summary".to_string(), args).await
}
// SPECIFIC PETROLEUM DATA COMMANDS
/// Get balance sheet data
#[tauri::command]
-pub async fn get_eia_balance_sheet(
+pub async fn get_eia_balance_sheet(app: tauri::AppHandle,
tables: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -208,12 +207,12 @@ pub async fn get_eia_balance_sheet(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get inputs and production data
#[tauri::command]
-pub async fn get_eia_inputs_production(
+pub async fn get_eia_inputs_production(app: tauri::AppHandle,
tables: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -228,12 +227,12 @@ pub async fn get_eia_inputs_production(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get refiner blender net production
#[tauri::command]
-pub async fn get_eia_refiner_production(
+pub async fn get_eia_refiner_production(app: tauri::AppHandle,
tables: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -248,12 +247,12 @@ pub async fn get_eia_refiner_production(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get distillate fuel oil stocks
#[tauri::command]
-pub async fn get_eia_distillate_stocks(
+pub async fn get_eia_distillate_stocks(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -264,12 +263,12 @@ pub async fn get_eia_distillate_stocks(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get imports by country
#[tauri::command]
-pub async fn get_eia_imports_by_country(
+pub async fn get_eia_imports_by_country(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -280,12 +279,12 @@ pub async fn get_eia_imports_by_country(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get weekly estimates
#[tauri::command]
-pub async fn get_eia_weekly_estimates(
+pub async fn get_eia_weekly_estimates(app: tauri::AppHandle,
tables: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -300,12 +299,12 @@ pub async fn get_eia_weekly_estimates(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
/// Get retail prices
#[tauri::command]
-pub async fn get_eia_retail_prices(
+pub async fn get_eia_retail_prices(app: tauri::AppHandle,
tables: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -320,14 +319,14 @@ pub async fn get_eia_retail_prices(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_petroleum".to_string(), args).await
+ execute_eia_command(app, "get_petroleum".to_string(), args).await
}
// SPECIFIC STEO DATA COMMANDS
/// Get nominal energy prices
#[tauri::command]
-pub async fn get_eia_nominal_prices(
+pub async fn get_eia_nominal_prices(app: tauri::AppHandle,
symbols: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -346,12 +345,12 @@ pub async fn get_eia_nominal_prices(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_steo".to_string(), args).await
+ execute_eia_command(app, "get_steo".to_string(), args).await
}
/// Get US petroleum supply data
#[tauri::command]
-pub async fn get_eia_petroleum_supply(
+pub async fn get_eia_petroleum_supply(app: tauri::AppHandle,
symbols: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -370,12 +369,12 @@ pub async fn get_eia_petroleum_supply(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_steo".to_string(), args).await
+ execute_eia_command(app, "get_steo".to_string(), args).await
}
/// Get electricity industry overview
#[tauri::command]
-pub async fn get_eia_electricity_overview(
+pub async fn get_eia_electricity_overview(app: tauri::AppHandle,
symbols: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -394,12 +393,12 @@ pub async fn get_eia_electricity_overview(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_steo".to_string(), args).await
+ execute_eia_command(app, "get_steo".to_string(), args).await
}
/// Get macroeconomic indicators
#[tauri::command]
-pub async fn get_eia_macroeconomic_indicators(
+pub async fn get_eia_macroeconomic_indicators(app: tauri::AppHandle,
symbols: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -418,26 +417,26 @@ pub async fn get_eia_macroeconomic_indicators(
if let Some(end) = end_date {
args.push(end);
}
- execute_eia_command("get_steo".to_string(), args).await
+ execute_eia_command(app, "get_steo".to_string(), args).await
}
// OVERVIEW AND ANALYSIS COMMANDS
/// Get comprehensive energy overview
#[tauri::command]
-pub async fn get_eia_energy_overview(
+pub async fn get_eia_energy_overview(app: tauri::AppHandle,
limit: Option<i32>,
) -> Result<String, String> {
let mut args = Vec::new();
if let Some(lim) = limit {
args.push(lim.to_string());
}
- execute_eia_command("energy_overview".to_string(), args).await
+ execute_eia_command(app, "energy_overview".to_string(), args).await
}
/// Get petroleum markets overview
#[tauri::command]
-pub async fn get_eia_petroleum_markets_overview() -> Result<String, String> {
+pub async fn get_eia_petroleum_markets_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get key petroleum data
@@ -452,7 +451,7 @@ pub async fn get_eia_petroleum_markets_overview() -> Result<String, String> {
let categories_len = categories.len();
for (category, tables) in categories {
- match get_eia_petroleum_status_report(
+ match get_eia_petroleum_status_report(app.clone(),
category.to_string(),
Some(tables.to_string()),
None,
@@ -471,7 +470,7 @@ pub async fn get_eia_petroleum_markets_overview() -> Result<String, String> {
/// Get natural gas markets overview
#[tauri::command]
-pub async fn get_eia_natural_gas_markets_overview() -> Result<String, String> {
+pub async fn get_eia_natural_gas_markets_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get natural gas data from STEO
@@ -481,7 +480,7 @@ pub async fn get_eia_natural_gas_markets_overview() -> Result<String, String> {
];
for (table, _description) in gas_tables {
- match get_eia_short_term_energy_outlook(
+ match get_eia_short_term_energy_outlook(app.clone(),
table.to_string(),
None,
Some("month".to_string()),
@@ -501,7 +500,7 @@ pub async fn get_eia_natural_gas_markets_overview() -> Result<String, String> {
/// Get energy price trends
#[tauri::command]
-pub async fn get_eia_energy_price_trends(
+pub async fn get_eia_energy_price_trends(app: tauri::AppHandle,
frequency: Option<String>,
) -> Result<String, String> {
let freq = frequency.unwrap_or_else(|| "month".to_string());
@@ -513,7 +512,7 @@ pub async fn get_eia_energy_price_trends(
];
for (table, symbols) in price_tables {
- match get_eia_short_term_energy_outlook(
+ match get_eia_short_term_energy_outlook(app.clone(),
table.to_string(),
Some(symbols.to_string()),
Some(freq.clone()),
@@ -534,7 +533,7 @@ pub async fn get_eia_energy_price_trends(
/// Get energy supply analysis
#[tauri::command]
-pub async fn get_eia_energy_supply_analysis() -> Result<String, String> {
+pub async fn get_eia_energy_supply_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get supply data from petroleum status report
@@ -545,7 +544,7 @@ pub async fn get_eia_energy_supply_analysis() -> Result<String, String> {
];
for (category, tables) in supply_categories {
- match get_eia_petroleum_status_report(
+ match get_eia_petroleum_status_report(app.clone(),
category.to_string(),
Some(tables.to_string()),
None,
@@ -557,7 +556,7 @@ pub async fn get_eia_energy_supply_analysis() -> Result<String, String> {
}
// Get supply data from STEO
- match get_eia_short_term_energy_outlook(
+ match get_eia_short_term_energy_outlook(app.clone(),
"04a".to_string(),
None,
Some("month".to_string()),
@@ -576,7 +575,7 @@ pub async fn get_eia_energy_supply_analysis() -> Result<String, String> {
/// Get energy consumption analysis
#[tauri::command]
-pub async fn get_eia_energy_consumption_analysis() -> Result<String, String> {
+pub async fn get_eia_energy_consumption_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get consumption data from STEO
@@ -587,7 +586,7 @@ pub async fn get_eia_energy_consumption_analysis() -> Result<String, String> {
];
for (table, symbols) in consumption_tables {
- match get_eia_short_term_energy_outlook(
+ match get_eia_short_term_energy_outlook(app.clone(),
table.to_string(),
Some(symbols.to_string()),
Some("month".to_string()),
@@ -607,7 +606,7 @@ pub async fn get_eia_energy_consumption_analysis() -> Result<String, String> {
/// Get custom energy data analysis
#[tauri::command]
-pub async fn get_eia_custom_analysis(
+pub async fn get_eia_custom_analysis(app: tauri::AppHandle,
data_sources: String, // comma-separated list of data sources
start_date: Option<String>,
end_date: Option<String>,
@@ -627,7 +626,7 @@ pub async fn get_eia_custom_analysis(
let category = format!("{}_{}", parts[1], parts[2]);
let tables = if parts.len() > 3 { parts[3] } else { "all" };
- match get_eia_petroleum_status_report(
+ match get_eia_petroleum_status_report(app.clone(),
category,
Some(tables.to_string()),
start_date.clone(),
@@ -641,7 +640,7 @@ pub async fn get_eia_custom_analysis(
// Handle STEO requests
let table = source.strip_prefix("steo_").unwrap_or("01");
- match get_eia_short_term_energy_outlook(
+ match get_eia_short_term_energy_outlook(app.clone(),
table.to_string(),
None,
Some("month".to_string()),
@@ -666,23 +665,23 @@ pub async fn get_eia_custom_analysis(
/// Get current energy market snapshot
#[tauri::command]
-pub async fn get_eia_current_market_snapshot() -> Result<String, String> {
+pub async fn get_eia_current_market_snapshot(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get most recent petroleum data
- match get_eia_petroleum_status_report("balance_sheet".to_string(), Some("stocks,supply".to_string()), None, None).await {
+ match get_eia_petroleum_status_report(app.clone(), "balance_sheet".to_string(), Some("stocks,supply".to_string()), None, None).await {
Ok(data) => results.push(("petroleum_balance".to_string(), data)),
Err(e) => results.push(("petroleum_balance".to_string(), format!("Error: {}", e))),
}
// Get most recent spot prices
- match get_eia_spot_prices().await {
+ match get_eia_spot_prices(app.clone()).await {
Ok(data) => results.push(("spot_prices".to_string(), data)),
Err(e) => results.push(("spot_prices".to_string(), format!("Error: {}", e))),
}
// Get recent STEO data (if available)
- match get_eia_energy_markets_summary(None, None).await {
+ match get_eia_energy_markets_summary(app, None, None).await {
Ok(data) => results.push(("energy_markets".to_string(), data)),
Err(e) => results.push(("energy_markets".to_string(), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/estat_japan.rs b/fincept-terminal-desktop/src-tauri/src/commands/estat_japan.rs
new file mode 100644
index 000000000..0970a9f6e
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/estat_japan.rs
@@ -0,0 +1,55 @@
+// Japan Statistics Bureau data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Japan Statistics Python script command
+#[tauri::command]
+pub async fn execute_estat_japan_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "estat_japan_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Japan Statistics script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Japan Statistics command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Japan Statistics command failed: {}", stderr))
+ }
+}
+
+/// Get statistical data
+#[tauri::command]
+pub async fn get_estat_japan_data(
+ app: tauri::AppHandle,
+ stats_code: String,
+) -> Result<String, String> {
+ execute_estat_japan_command(app, "data".to_string(), vec![stats_code]).await
+}
+
+/// Search statistics
+#[tauri::command]
+pub async fn search_estat_japan_stats(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_estat_japan_command(app, "search".to_string(), vec![query]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/federal_reserve.rs b/fincept-terminal-desktop/src-tauri/src/commands/federal_reserve.rs
index 1aaa3249f..d8823381e 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/federal_reserve.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/federal_reserve.rs
@@ -1,18 +1,17 @@
// Federal Reserve data commands
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute Federal Reserve Python script command
#[tauri::command]
pub async fn execute_federal_reserve_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("federal_reserve_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "federal_reserve_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_federal_reserve_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute Federal Reserve command: {}", e))?;
@@ -43,7 +42,7 @@ pub async fn execute_federal_reserve_command(
/// Get Federal Funds Rate data
#[tauri::command]
-pub async fn get_federal_funds_rate(
+pub async fn get_federal_funds_rate(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -54,12 +53,12 @@ pub async fn get_federal_funds_rate(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_federal_reserve_command("federal_funds_rate".to_string(), args).await
+ execute_federal_reserve_command(app, "federal_funds_rate".to_string(), args).await
}
/// Get SOFR Rate data
#[tauri::command]
-pub async fn get_sofr_rate(
+pub async fn get_sofr_rate(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -70,12 +69,12 @@ pub async fn get_sofr_rate(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_federal_reserve_command("sofr_rate".to_string(), args).await
+ execute_federal_reserve_command(app, "sofr_rate".to_string(), args).await
}
/// Get Treasury Rates data
#[tauri::command]
-pub async fn get_treasury_rates(
+pub async fn get_treasury_rates(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -86,22 +85,22 @@ pub async fn get_treasury_rates(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_federal_reserve_command("treasury_rates".to_string(), args).await
+ execute_federal_reserve_command(app, "treasury_rates".to_string(), args).await
}
/// Get Yield Curve data
#[tauri::command]
-pub async fn get_yield_curve(date: Option<String>) -> Result<String, String> {
+pub async fn get_yield_curve(app: tauri::AppHandle, date: Option<String>) -> Result<String, String> {
let mut args = Vec::new();
if let Some(date) = date {
args.push(date);
}
- execute_federal_reserve_command("yield_curve".to_string(), args).await
+ execute_federal_reserve_command(app, "yield_curve".to_string(), args).await
}
/// Get Money Measures data
#[tauri::command]
-pub async fn get_money_measures(
+pub async fn get_money_measures(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
adjusted: Option<bool>,
@@ -116,12 +115,12 @@ pub async fn get_money_measures(
if let Some(adjusted) = adjusted {
args.push(adjusted.to_string());
}
- execute_federal_reserve_command("money_measures".to_string(), args).await
+ execute_federal_reserve_command(app, "money_measures".to_string(), args).await
}
/// Get Central Bank Holdings data
#[tauri::command]
-pub async fn get_central_bank_holdings(
+pub async fn get_central_bank_holdings(app: tauri::AppHandle,
holding_type: Option<String>,
summary: Option<bool>,
date: Option<String>,
@@ -138,12 +137,12 @@ pub async fn get_central_bank_holdings(
if let Some(date) = date {
args.push(date);
}
- execute_federal_reserve_command("central_bank_holdings".to_string(), args).await
+ execute_federal_reserve_command(app, "central_bank_holdings".to_string(), args).await
}
/// Get Overnight Bank Funding Rate data
#[tauri::command]
-pub async fn get_overnight_bank_funding_rate(
+pub async fn get_overnight_bank_funding_rate(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -154,12 +153,12 @@ pub async fn get_overnight_bank_funding_rate(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_federal_reserve_command("overnight_bank_funding_rate".to_string(), args).await
+ execute_federal_reserve_command(app, "overnight_bank_funding_rate".to_string(), args).await
}
/// Get comprehensive monetary data
#[tauri::command]
-pub async fn get_comprehensive_monetary_data(
+pub async fn get_comprehensive_monetary_data(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -170,11 +169,11 @@ pub async fn get_comprehensive_monetary_data(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_federal_reserve_command("comprehensive_monetary_data".to_string(), args).await
+ execute_federal_reserve_command(app, "comprehensive_monetary_data".to_string(), args).await
}
/// Get market overview
#[tauri::command]
-pub async fn get_fed_market_overview() -> Result<String, String> {
- execute_federal_reserve_command("market_overview".to_string(), vec![]).await
+pub async fn get_fed_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_federal_reserve_command(app, "market_overview".to_string(), vec![]).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/fmp.rs b/fincept-terminal-desktop/src-tauri/src/commands/fmp.rs
index b84018862..605e12a7c 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/fmp.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/fmp.rs
@@ -1,18 +1,17 @@
// FMP (Financial Modeling Prep) data commands based on OpenBB fmp provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute FMP Python script command
#[tauri::command]
pub async fn execute_fmp_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("fmp_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "fmp_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_fmp_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute FMP command: {}", e))?;
@@ -45,25 +44,25 @@ pub async fn execute_fmp_command(
/// Get real-time stock quotes for multiple symbols
#[tauri::command]
-pub async fn get_fmp_equity_quote(
+pub async fn get_fmp_equity_quote(app: tauri::AppHandle,
symbols: String,
) -> Result<String, String> {
let args = vec![symbols];
- execute_fmp_command("equity_quote".to_string(), args).await
+ execute_fmp_command(app, "equity_quote".to_string(), args).await
}
/// Get company profile and basic information
#[tauri::command]
-pub async fn get_fmp_company_profile(
+pub async fn get_fmp_company_profile(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_fmp_command("company_profile".to_string(), args).await
+ execute_fmp_command(app, "company_profile".to_string(), args).await
}
/// Get historical price data for a symbol
#[tauri::command]
-pub async fn get_fmp_historical_prices(
+pub async fn get_fmp_historical_prices(app: tauri::AppHandle,
symbol: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -81,14 +80,14 @@ pub async fn get_fmp_historical_prices(
} else {
args.push("1d".to_string());
}
- execute_fmp_command("historical_prices".to_string(), args).await
+ execute_fmp_command(app, "historical_prices".to_string(), args).await
}
// FINANCIAL STATEMENTS COMMANDS
/// Get income statement data
#[tauri::command]
-pub async fn get_fmp_income_statement(
+pub async fn get_fmp_income_statement(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -104,12 +103,12 @@ pub async fn get_fmp_income_statement(
} else {
args.push("10".to_string());
}
- execute_fmp_command("income_statement".to_string(), args).await
+ execute_fmp_command(app, "income_statement".to_string(), args).await
}
/// Get balance sheet data
#[tauri::command]
-pub async fn get_fmp_balance_sheet(
+pub async fn get_fmp_balance_sheet(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -125,12 +124,12 @@ pub async fn get_fmp_balance_sheet(
} else {
args.push("10".to_string());
}
- execute_fmp_command("balance_sheet".to_string(), args).await
+ execute_fmp_command(app, "balance_sheet".to_string(), args).await
}
/// Get cash flow statement data
#[tauri::command]
-pub async fn get_fmp_cash_flow_statement(
+pub async fn get_fmp_cash_flow_statement(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -146,12 +145,12 @@ pub async fn get_fmp_cash_flow_statement(
} else {
args.push("10".to_string());
}
- execute_fmp_command("cash_flow_statement".to_string(), args).await
+ execute_fmp_command(app, "cash_flow_statement".to_string(), args).await
}
/// Get financial ratios data
#[tauri::command]
-pub async fn get_fmp_financial_ratios(
+pub async fn get_fmp_financial_ratios(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -167,12 +166,12 @@ pub async fn get_fmp_financial_ratios(
} else {
args.push("10".to_string());
}
- execute_fmp_command("financial_ratios".to_string(), args).await
+ execute_fmp_command(app, "financial_ratios".to_string(), args).await
}
/// Get key metrics data
#[tauri::command]
-pub async fn get_fmp_key_metrics(
+pub async fn get_fmp_key_metrics(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -188,54 +187,54 @@ pub async fn get_fmp_key_metrics(
} else {
args.push("10".to_string());
}
- execute_fmp_command("key_metrics".to_string(), args).await
+ execute_fmp_command(app, "key_metrics".to_string(), args).await
}
// MARKET DATA COMMANDS
/// Get market snapshots and indices
#[tauri::command]
-pub async fn get_fmp_market_snapshots() -> Result<String, String> {
- execute_fmp_command("market_snapshots".to_string(), vec![]).await
+pub async fn get_fmp_market_snapshots(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_fmp_command(app, "market_snapshots".to_string(), vec![]).await
}
/// Get current treasury rates
#[tauri::command]
-pub async fn get_fmp_treasury_rates() -> Result<String, String> {
- execute_fmp_command("treasury_rates".to_string(), vec![]).await
+pub async fn get_fmp_treasury_rates(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_fmp_command(app, "treasury_rates".to_string(), vec![]).await
}
// ETF DATA COMMANDS
/// Get ETF information
#[tauri::command]
-pub async fn get_fmp_etf_info(
+pub async fn get_fmp_etf_info(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_fmp_command("etf_info".to_string(), args).await
+ execute_fmp_command(app, "etf_info".to_string(), args).await
}
/// Get ETF holdings data
#[tauri::command]
-pub async fn get_fmp_etf_holdings(
+pub async fn get_fmp_etf_holdings(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_fmp_command("etf_holdings".to_string(), args).await
+ execute_fmp_command(app, "etf_holdings".to_string(), args).await
}
// CRYPTO DATA COMMANDS
/// Get list of available cryptocurrencies
#[tauri::command]
-pub async fn get_fmp_crypto_list() -> Result<String, String> {
- execute_fmp_command("crypto_list".to_string(), vec![]).await
+pub async fn get_fmp_crypto_list(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_fmp_command(app, "crypto_list".to_string(), vec![]).await
}
/// Get historical cryptocurrency prices
#[tauri::command]
-pub async fn get_fmp_crypto_historical(
+pub async fn get_fmp_crypto_historical(app: tauri::AppHandle,
symbol: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -247,14 +246,14 @@ pub async fn get_fmp_crypto_historical(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_fmp_command("crypto_historical".to_string(), args).await
+ execute_fmp_command(app, "crypto_historical".to_string(), args).await
}
// NEWS DATA COMMANDS
/// Get news for a specific company
#[tauri::command]
-pub async fn get_fmp_company_news(
+pub async fn get_fmp_company_news(app: tauri::AppHandle,
symbol: String,
limit: Option<i32>,
) -> Result<String, String> {
@@ -264,28 +263,28 @@ pub async fn get_fmp_company_news(
} else {
args.push("50".to_string());
}
- execute_fmp_command("company_news".to_string(), args).await
+ execute_fmp_command(app, "company_news".to_string(), args).await
}
/// Get general financial news
#[tauri::command]
-pub async fn get_fmp_general_news() -> Result<String, String> {
- execute_fmp_command("general_news".to_string(), vec![]).await
+pub async fn get_fmp_general_news(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_fmp_command(app, "general_news".to_string(), vec![]).await
}
// ECONOMIC DATA COMMANDS
/// Get economic calendar data
#[tauri::command]
-pub async fn get_fmp_economic_calendar() -> Result<String, String> {
- execute_fmp_command("economic_calendar".to_string(), vec![]).await
+pub async fn get_fmp_economic_calendar(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_fmp_command(app, "economic_calendar".to_string(), vec![]).await
}
// INSIDER TRADING COMMANDS
/// Get insider trading data for a symbol
#[tauri::command]
-pub async fn get_fmp_insider_trading(
+pub async fn get_fmp_insider_trading(app: tauri::AppHandle,
symbol: String,
limit: Option<i32>,
) -> Result<String, String> {
@@ -295,14 +294,14 @@ pub async fn get_fmp_insider_trading(
} else {
args.push("100".to_string());
}
- execute_fmp_command("insider_trading".to_string(), args).await
+ execute_fmp_command(app, "insider_trading".to_string(), args).await
}
// INSTITUTIONAL OWNERSHIP COMMANDS
/// Get institutional ownership data
#[tauri::command]
-pub async fn get_fmp_institutional_ownership(
+pub async fn get_fmp_institutional_ownership(app: tauri::AppHandle,
symbol: String,
limit: Option<i32>,
) -> Result<String, String> {
@@ -312,23 +311,23 @@ pub async fn get_fmp_institutional_ownership(
} else {
args.push("100".to_string());
}
- execute_fmp_command("institutional_ownership".to_string(), args).await
+ execute_fmp_command(app, "institutional_ownership".to_string(), args).await
}
// COMPREHENSIVE DATA COMMANDS
/// Get comprehensive company overview including profile, quotes, and key metrics
#[tauri::command]
-pub async fn get_fmp_company_overview(
+pub async fn get_fmp_company_overview(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_fmp_command("company_overview".to_string(), args).await
+ execute_fmp_command(app, "company_overview".to_string(), args).await
}
/// Get all financial statements for a company
#[tauri::command]
-pub async fn get_fmp_financial_statements(
+pub async fn get_fmp_financial_statements(app: tauri::AppHandle,
symbol: String,
period: Option<String>,
limit: Option<i32>,
@@ -344,21 +343,21 @@ pub async fn get_fmp_financial_statements(
} else {
args.push("5".to_string());
}
- execute_fmp_command("financial_statements".to_string(), args).await
+ execute_fmp_command(app, "financial_statements".to_string(), args).await
}
/// Get multiple stock quotes efficiently
#[tauri::command]
-pub async fn get_fmp_market_quotes(
+pub async fn get_fmp_market_quotes(app: tauri::AppHandle,
symbols: String,
) -> Result<String, String> {
let args = vec![symbols];
- execute_fmp_command("equity_quote".to_string(), args).await
+ execute_fmp_command(app, "equity_quote".to_string(), args).await
}
/// Get stock price performance data
#[tauri::command]
-pub async fn get_fmp_price_performance(
+pub async fn get_fmp_price_performance(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
// This would use the price_performance endpoint
@@ -369,12 +368,12 @@ pub async fn get_fmp_price_performance(
chrono::Utc::now().format("%Y-%m-%d").to_string(),
"1d".to_string(),
];
- execute_fmp_command("historical_prices".to_string(), args).await
+ execute_fmp_command(app, "historical_prices".to_string(), args).await
}
/// Get stock screener data
#[tauri::command]
-pub async fn get_fmp_stock_screener(
+pub async fn get_fmp_stock_screener(app: tauri::AppHandle,
market_cap_more_than: Option<f64>,
market_cap_lower_than: Option<f64>,
price_more_than: Option<f64>,
@@ -448,14 +447,14 @@ pub async fn get_fmp_stock_screener(
}
let query_string = args.join("&");
- execute_fmp_command("stock_screener".to_string(), vec![query_string]).await
+ execute_fmp_command(app, "stock_screener".to_string(), vec![query_string]).await
}
/// Get stock price targets and analyst data
#[tauri::command]
-pub async fn get_fmp_price_targets(
+pub async fn get_fmp_price_targets(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_fmp_command("price_targets".to_string(), args).await
+ execute_fmp_command(app, "price_targets".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/fred.rs b/fincept-terminal-desktop/src-tauri/src/commands/fred.rs
new file mode 100644
index 000000000..51433fa88
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/fred.rs
@@ -0,0 +1,110 @@
+// FRED (Federal Reserve Economic Data) commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute FRED Python script command
+#[tauri::command]
+pub async fn execute_fred_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "fred_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "FRED script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute FRED command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("FRED command failed: {}", stderr))
+ }
+}
+
+/// Get FRED series data
+#[tauri::command]
+pub async fn get_fred_series(
+ app: tauri::AppHandle,
+ series_id: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![series_id];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_fred_command(app, "series".to_string(), args).await
+}
+
+/// Search FRED data series
+#[tauri::command]
+pub async fn search_fred_series(
+ app: tauri::AppHandle,
+ search_text: String,
+ limit: Option<i32>,
+) -> Result<String, String> {
+ let mut args = vec![search_text];
+ if let Some(lim) = limit {
+ args.push(lim.to_string());
+ }
+ execute_fred_command(app, "search".to_string(), args).await
+}
+
+/// Get FRED series information
+#[tauri::command]
+pub async fn get_fred_series_info(
+ app: tauri::AppHandle,
+ series_id: String,
+) -> Result<String, String> {
+ execute_fred_command(app, "info".to_string(), vec![series_id]).await
+}
+
+/// Get FRED category data
+#[tauri::command]
+pub async fn get_fred_category(
+ app: tauri::AppHandle,
+ category_id: Option<i32>,
+) -> Result<String, String> {
+ let args = if let Some(cat_id) = category_id {
+ vec![cat_id.to_string()]
+ } else {
+ vec![]
+ };
+ execute_fred_command(app, "category".to_string(), args).await
+}
+
+/// Get multiple FRED series
+#[tauri::command]
+pub async fn get_fred_multiple_series(
+ app: tauri::AppHandle,
+ series_ids: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![series_ids];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_fred_command(app, "multiple_series".to_string(), args).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/french_gov.rs b/fincept-terminal-desktop/src-tauri/src/commands/french_gov.rs
new file mode 100644
index 000000000..b642e3e07
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/french_gov.rs
@@ -0,0 +1,55 @@
+// French Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute French Government Python script command
+#[tauri::command]
+pub async fn execute_french_gov_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "french_gov_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "French Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute French Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("French Government command failed: {}", stderr))
+ }
+}
+
+/// Search French government datasets
+#[tauri::command]
+pub async fn search_french_gov_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_french_gov_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_french_gov_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_french_gov_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/govdata_de.rs b/fincept-terminal-desktop/src-tauri/src/commands/govdata_de.rs
new file mode 100644
index 000000000..af8b6b4c6
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/govdata_de.rs
@@ -0,0 +1,55 @@
+// German Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute German Government Python script command
+#[tauri::command]
+pub async fn execute_govdata_de_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "govdata_de_api_complete.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "German Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute German Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("German Government command failed: {}", stderr))
+ }
+}
+
+/// Search German government datasets
+#[tauri::command]
+pub async fn search_govdata_de_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_govdata_de_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_govdata_de_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_govdata_de_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/government_us.rs b/fincept-terminal-desktop/src-tauri/src/commands/government_us.rs
index 25e9975fe..0e31a0295 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/government_us.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/government_us.rs
@@ -1,18 +1,17 @@
// US Government data commands based on OpenBB government_us provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute US Government Python script command
#[tauri::command]
pub async fn execute_government_us_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("government_us_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "government_us_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_government_us_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute US Government command: {}", e))?;
@@ -43,7 +42,7 @@ pub async fn execute_government_us_command(
/// Get US Treasury prices for a specific date
#[tauri::command]
-pub async fn get_treasury_prices(
+pub async fn get_treasury_prices(app: tauri::AppHandle,
target_date: Option<String>,
cusip: Option<String>,
security_type: Option<String>,
@@ -58,12 +57,12 @@ pub async fn get_treasury_prices(
if let Some(sec_type) = security_type {
args.push(sec_type);
}
- execute_government_us_command("treasury_prices".to_string(), args).await
+ execute_government_us_command(app, "treasury_prices".to_string(), args).await
}
/// Get US Treasury auction data
#[tauri::command]
-pub async fn get_treasury_auctions(
+pub async fn get_treasury_auctions(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
security_type: Option<String>,
@@ -86,12 +85,12 @@ pub async fn get_treasury_auctions(
if let Some(page_num) = page_num {
args.push(page_num.to_string());
}
- execute_government_us_command("treasury_auctions".to_string(), args).await
+ execute_government_us_command(app, "treasury_auctions".to_string(), args).await
}
/// Get comprehensive US Treasury data from multiple endpoints
#[tauri::command]
-pub async fn get_comprehensive_treasury_data(
+pub async fn get_comprehensive_treasury_data(app: tauri::AppHandle,
target_date: Option<String>,
security_type: Option<String>,
) -> Result<String, String> {
@@ -102,17 +101,17 @@ pub async fn get_comprehensive_treasury_data(
if let Some(sec_type) = security_type {
args.push(sec_type);
}
- execute_government_us_command("comprehensive".to_string(), args).await
+ execute_government_us_command(app, "comprehensive".to_string(), args).await
}
/// Get US Treasury data summary with key metrics
#[tauri::command]
-pub async fn get_treasury_summary(
+pub async fn get_treasury_summary(app: tauri::AppHandle,
target_date: Option<String>,
) -> Result<String, String> {
let mut args = Vec::new();
if let Some(date) = target_date {
args.push(date);
}
- execute_government_us_command("summary".to_string(), args).await
+ execute_government_us_command(app, "summary".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/imf.rs b/fincept-terminal-desktop/src-tauri/src/commands/imf.rs
index 066893627..206ae6585 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/imf.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/imf.rs
@@ -1,18 +1,17 @@
// IMF (International Monetary Fund) data commands based on OpenBB imf provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute IMF Python script command
#[tauri::command]
pub async fn execute_imf_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("imf_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "imf_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_imf_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute IMF command: {}", e))?;
@@ -43,7 +42,7 @@ pub async fn execute_imf_command(
/// Get economic indicators data (IRFCL and FSI)
#[tauri::command]
-pub async fn get_imf_economic_indicators(
+pub async fn get_imf_economic_indicators(app: tauri::AppHandle,
countries: Option<String>,
symbols: Option<String>,
frequency: Option<String>,
@@ -70,12 +69,12 @@ pub async fn get_imf_economic_indicators(
if let Some(sector) = sector {
args.push(sector);
}
- execute_imf_command("economic_indicators".to_string(), args).await
+ execute_imf_command(app, "economic_indicators".to_string(), args).await
}
/// Get direction of trade data (exports, imports, balance)
#[tauri::command]
-pub async fn get_imf_direction_of_trade(
+pub async fn get_imf_direction_of_trade(app: tauri::AppHandle,
countries: Option<String>,
counterparts: Option<String>,
direction: Option<String>,
@@ -102,24 +101,24 @@ pub async fn get_imf_direction_of_trade(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_imf_command("direction_of_trade".to_string(), args).await
+ execute_imf_command(app, "direction_of_trade".to_string(), args).await
}
/// Get list of available IMF indicators
#[tauri::command]
-pub async fn get_imf_available_indicators(
+pub async fn get_imf_available_indicators(app: tauri::AppHandle,
query: Option<String>,
) -> Result<String, String> {
let mut args = Vec::new();
if let Some(query) = query {
args.push(query);
}
- execute_imf_command("available_indicators".to_string(), args).await
+ execute_imf_command(app, "available_indicators".to_string(), args).await
}
/// Get comprehensive economic data for a country
#[tauri::command]
-pub async fn get_imf_comprehensive_economic_data(
+pub async fn get_imf_comprehensive_economic_data(app: tauri::AppHandle,
country: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -132,12 +131,12 @@ pub async fn get_imf_comprehensive_economic_data(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_imf_command("comprehensive_economic_data".to_string(), args).await
+ execute_imf_command(app, "comprehensive_economic_data".to_string(), args).await
}
/// Get IMF reserves data (top line indicators)
#[tauri::command]
-pub async fn get_imf_reserves_data(
+pub async fn get_imf_reserves_data(app: tauri::AppHandle,
countries: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -161,12 +160,12 @@ pub async fn get_imf_reserves_data(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_imf_command("economic_indicators".to_string(), args).await
+ execute_imf_command(app, "economic_indicators".to_string(), args).await
}
/// Get IMF trade data (exports, imports, balance)
#[tauri::command]
-pub async fn get_imf_trade_summary(
+pub async fn get_imf_trade_summary(app: tauri::AppHandle,
country: String,
counterpart: Option<String>,
frequency: Option<String>,
@@ -192,5 +191,5 @@ pub async fn get_imf_trade_summary(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_imf_command("direction_of_trade".to_string(), args).await
+ execute_imf_command(app, "direction_of_trade".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/market_data.rs b/fincept-terminal-desktop/src-tauri/src/commands/market_data.rs
index c44ce431e..87cab1710 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/market_data.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/market_data.rs
@@ -35,9 +35,9 @@ pub struct PeriodReturnsResponse {
/// Fetch a single quote
#[tauri::command]
-pub async fn get_market_quote(symbol: String) -> Result<QuoteResponse, String> {
+pub async fn get_market_quote(app: tauri::AppHandle, symbol: String) -> Result<QuoteResponse, String> {
- let provider = YFinanceProvider::new();
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
match provider.get_quote(&symbol).await {
Some(quote) => Ok(QuoteResponse {
@@ -55,9 +55,9 @@ pub async fn get_market_quote(symbol: String) -> Result<QuoteResponse, String> {
/// Fetch multiple quotes (batch)
#[tauri::command]
-pub async fn get_market_quotes(symbols: Vec<String>) -> Result<QuotesResponse, String> {
+pub async fn get_market_quotes(app: tauri::AppHandle, symbols: Vec<String>) -> Result<QuotesResponse, String> {
- let provider = YFinanceProvider::new();
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
let quotes = provider.get_quotes(symbols).await;
Ok(QuotesResponse {
@@ -69,9 +69,9 @@ pub async fn get_market_quotes(symbols: Vec<String>) -> Result<QuotesResponse, S
/// Fetch period returns (7D, 30D)
#[tauri::command]
-pub async fn get_period_returns(symbol: String) -> Result<PeriodReturnsResponse, String> {
+pub async fn get_period_returns(app: tauri::AppHandle, symbol: String) -> Result<PeriodReturnsResponse, String> {
- let provider = YFinanceProvider::new();
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
match provider.get_period_returns(&symbol).await {
Some((seven_day, thirty_day)) => Ok(PeriodReturnsResponse {
@@ -93,8 +93,8 @@ pub async fn get_period_returns(symbol: String) -> Result<PeriodReturnsResponse,
/// Health check for market data provider
#[tauri::command]
-pub async fn check_market_data_health() -> Result<bool, String> {
- let provider = YFinanceProvider::new();
+pub async fn check_market_data_health(app: tauri::AppHandle) -> Result<bool, String> {
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
Ok(provider.health_check().await)
}
@@ -108,11 +108,12 @@ pub struct HistoricalResponse {
/// Fetch historical data for a symbol
#[tauri::command]
pub async fn get_historical_data(
+ app: tauri::AppHandle,
symbol: String,
start_date: String,
end_date: String,
) -> Result<HistoricalResponse, String> {
- let provider = YFinanceProvider::new();
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
match provider.get_historical(&symbol, &start_date, &end_date).await {
Some(data) => Ok(HistoricalResponse {
@@ -137,8 +138,8 @@ pub struct StockInfoResponse {
/// Fetch stock info (company data, metrics, etc.)
#[tauri::command]
-pub async fn get_stock_info(symbol: String) -> Result<StockInfoResponse, String> {
- let provider = YFinanceProvider::new();
+pub async fn get_stock_info(app: tauri::AppHandle, symbol: String) -> Result<StockInfoResponse, String> {
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
match provider.get_info(&symbol).await {
Some(info) => Ok(StockInfoResponse {
@@ -163,8 +164,8 @@ pub struct FinancialsResponse {
/// Fetch financial statements (income, balance sheet, cash flow)
#[tauri::command]
-pub async fn get_financials(symbol: String) -> Result<FinancialsResponse, String> {
- let provider = YFinanceProvider::new();
+pub async fn get_financials(app: tauri::AppHandle, symbol: String) -> Result<FinancialsResponse, String> {
+ let provider = YFinanceProvider::new(&app).map_err(|e| e.to_string())?;
match provider.get_financials(&symbol).await {
Some(financials) => Ok(FinancialsResponse {
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/mod.rs b/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
index 236a0db17..3104c2453 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/mod.rs
@@ -22,3 +22,31 @@ pub mod ecb;
pub mod wto;
pub mod unesco;
pub mod oscar;
+
+// Financial data sources
+pub mod fred;
+pub mod coingecko;
+pub mod worldbank;
+pub mod trading_economics;
+pub mod econdb;
+
+// Government data sources
+pub mod canada_gov;
+pub mod datagovuk;
+pub mod datagov_au;
+pub mod estat_japan;
+pub mod govdata_de;
+
+// Regional data sources
+pub mod datagovsg;
+pub mod data_gov_hk;
+pub mod french_gov;
+pub mod swiss_gov;
+pub mod spain_data;
+pub mod adb;
+
+// Specialized data sources
+pub mod openafrica;
+pub mod economic_calendar;
+pub mod databento;
+pub mod sentinelhub;
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/multpl.rs b/fincept-terminal-desktop/src-tauri/src/commands/multpl.rs
index 0bf554e04..7fd80bc10 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/multpl.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/multpl.rs
@@ -1,18 +1,17 @@
// MULTPL (S&P 500 Multiples) data commands based on OpenBB multpl provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute MULTPL Python script command
#[tauri::command]
pub async fn execute_multpl_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("multpl_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "multpl_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_multpl_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute MULTPL command: {}", e))?;
@@ -45,7 +44,7 @@ pub async fn execute_multpl_command(
/// Get data for a specific series
#[tauri::command]
-pub async fn get_multpl_series(
+pub async fn get_multpl_series(app: tauri::AppHandle,
series_name: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -57,12 +56,12 @@ pub async fn get_multpl_series(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_series".to_string(), args).await
+ execute_multpl_command(app, "get_series".to_string(), args).await
}
/// Get data for multiple series
#[tauri::command]
-pub async fn get_multpl_multiple_series(
+pub async fn get_multpl_multiple_series(app: tauri::AppHandle,
series_names: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -74,20 +73,20 @@ pub async fn get_multpl_multiple_series(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_multiple".to_string(), args).await
+ execute_multpl_command(app, "get_multiple".to_string(), args).await
}
/// Get list of available series
#[tauri::command]
-pub async fn get_multpl_available_series() -> Result<String, String> {
- execute_multpl_command("available_series".to_string(), vec![]).await
+pub async fn get_multpl_available_series(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_multpl_command(app, "available_series".to_string(), vec![]).await
}
// CONVENIENCE METHODS FOR POPULAR SERIES
/// Get Shiller P/E ratio data
#[tauri::command]
-pub async fn get_multpl_shiller_pe(
+pub async fn get_multpl_shiller_pe(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -98,12 +97,12 @@ pub async fn get_multpl_shiller_pe(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_shiller_pe".to_string(), args).await
+ execute_multpl_command(app, "get_shiller_pe".to_string(), args).await
}
/// Get P/E ratio data
#[tauri::command]
-pub async fn get_multpl_pe_ratio(
+pub async fn get_multpl_pe_ratio(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -114,12 +113,12 @@ pub async fn get_multpl_pe_ratio(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_pe_ratio".to_string(), args).await
+ execute_multpl_command(app, "get_pe_ratio".to_string(), args).await
}
/// Get dividend yield data
#[tauri::command]
-pub async fn get_multpl_dividend_yield(
+pub async fn get_multpl_dividend_yield(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -130,12 +129,12 @@ pub async fn get_multpl_dividend_yield(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_dividend_yield".to_string(), args).await
+ execute_multpl_command(app, "get_dividend_yield".to_string(), args).await
}
/// Get earnings yield data
#[tauri::command]
-pub async fn get_multpl_earnings_yield(
+pub async fn get_multpl_earnings_yield(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -146,12 +145,12 @@ pub async fn get_multpl_earnings_yield(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_earnings_yield".to_string(), args).await
+ execute_multpl_command(app, "get_earnings_yield".to_string(), args).await
}
/// Get price-to-sales ratio data
#[tauri::command]
-pub async fn get_multpl_price_to_sales(
+pub async fn get_multpl_price_to_sales(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -162,213 +161,213 @@ pub async fn get_multpl_price_to_sales(
if let Some(end) = end_date {
args.push(end);
}
- execute_multpl_command("get_price_to_sales".to_string(), args).await
+ execute_multpl_command(app, "get_price_to_sales".to_string(), args).await
}
// SPECIFIC SERIES CATEGORY COMMANDS
/// Get Shiller P/E data by month
#[tauri::command]
-pub async fn get_multpl_shiller_pe_monthly(
+pub async fn get_multpl_shiller_pe_monthly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("shiller_pe_month".to_string(), start_date, end_date).await
+ get_multpl_series(app, "shiller_pe_month".to_string(), start_date, end_date).await
}
/// Get Shiller P/E data by year
#[tauri::command]
-pub async fn get_multpl_shiller_pe_yearly(
+pub async fn get_multpl_shiller_pe_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("shiller_pe_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "shiller_pe_year".to_string(), start_date, end_date).await
}
/// Get P/E ratio data by year
#[tauri::command]
-pub async fn get_multpl_pe_yearly(
+pub async fn get_multpl_pe_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("pe_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "pe_year".to_string(), start_date, end_date).await
}
/// Get dividend data by year
#[tauri::command]
-pub async fn get_multpl_dividend_yearly(
+pub async fn get_multpl_dividend_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("dividend_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "dividend_year".to_string(), start_date, end_date).await
}
/// Get dividend data by month
#[tauri::command]
-pub async fn get_multpl_dividend_monthly(
+pub async fn get_multpl_dividend_monthly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("dividend_month".to_string(), start_date, end_date).await
+ get_multpl_series(app, "dividend_month".to_string(), start_date, end_date).await
}
/// Get dividend growth data by year
#[tauri::command]
-pub async fn get_multpl_dividend_growth_yearly(
+pub async fn get_multpl_dividend_growth_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("dividend_growth_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "dividend_growth_year".to_string(), start_date, end_date).await
}
/// Get dividend yield data by year
#[tauri::command]
-pub async fn get_multpl_dividend_yield_yearly(
+pub async fn get_multpl_dividend_yield_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("dividend_yield_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "dividend_yield_year".to_string(), start_date, end_date).await
}
/// Get earnings data by year
#[tauri::command]
-pub async fn get_multpl_earnings_yearly(
+pub async fn get_multpl_earnings_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("earnings_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "earnings_year".to_string(), start_date, end_date).await
}
/// Get earnings data by month
#[tauri::command]
-pub async fn get_multpl_earnings_monthly(
+pub async fn get_multpl_earnings_monthly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("earnings_month".to_string(), start_date, end_date).await
+ get_multpl_series(app, "earnings_month".to_string(), start_date, end_date).await
}
/// Get earnings growth data by year
#[tauri::command]
-pub async fn get_multpl_earnings_growth_yearly(
+pub async fn get_multpl_earnings_growth_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("earnings_growth_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "earnings_growth_year".to_string(), start_date, end_date).await
}
/// Get earnings yield data by year
#[tauri::command]
-pub async fn get_multpl_earnings_yield_yearly(
+pub async fn get_multpl_earnings_yield_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("earnings_yield_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "earnings_yield_year".to_string(), start_date, end_date).await
}
/// Get real price data by year
#[tauri::command]
-pub async fn get_multpl_real_price_yearly(
+pub async fn get_multpl_real_price_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("real_price_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "real_price_year".to_string(), start_date, end_date).await
}
/// Get inflation-adjusted price data by year
#[tauri::command]
-pub async fn get_multpl_inflation_adjusted_price_yearly(
+pub async fn get_multpl_inflation_adjusted_price_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("inflation_adjusted_price_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "inflation_adjusted_price_year".to_string(), start_date, end_date).await
}
/// Get sales data by year
#[tauri::command]
-pub async fn get_multpl_sales_yearly(
+pub async fn get_multpl_sales_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("sales_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "sales_year".to_string(), start_date, end_date).await
}
/// Get sales growth data by year
#[tauri::command]
-pub async fn get_multpl_sales_growth_yearly(
+pub async fn get_multpl_sales_growth_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("sales_growth_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "sales_growth_year".to_string(), start_date, end_date).await
}
/// Get real sales data by year
#[tauri::command]
-pub async fn get_multpl_real_sales_yearly(
+pub async fn get_multpl_real_sales_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("real_sales_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "real_sales_year".to_string(), start_date, end_date).await
}
/// Get price-to-sales data by year
#[tauri::command]
-pub async fn get_multpl_price_to_sales_yearly(
+pub async fn get_multpl_price_to_sales_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("price_to_sales_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "price_to_sales_year".to_string(), start_date, end_date).await
}
/// Get price-to-book value data by year
#[tauri::command]
-pub async fn get_multpl_price_to_book_yearly(
+pub async fn get_multpl_price_to_book_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("price_to_book_value_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "price_to_book_value_year".to_string(), start_date, end_date).await
}
/// Get book value data by year
#[tauri::command]
-pub async fn get_multpl_book_value_yearly(
+pub async fn get_multpl_book_value_yearly(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
- get_multpl_series("book_value_year".to_string(), start_date, end_date).await
+ get_multpl_series(app, "book_value_year".to_string(), start_date, end_date).await
}
// OVERVIEW AND ANALYSIS COMMANDS
/// Get valuation overview with key metrics
#[tauri::command]
-pub async fn get_multpl_valuation_overview() -> Result<String, String> {
- execute_multpl_command("get_valuation_overview".to_string(), vec![]).await
+pub async fn get_multpl_valuation_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_multpl_command(app, "get_valuation_overview".to_string(), vec![]).await
}
/// Get dividend overview
#[tauri::command]
-pub async fn get_multpl_dividend_overview() -> Result<String, String> {
- execute_multpl_command("get_dividend_overview".to_string(), vec![]).await
+pub async fn get_multpl_dividend_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_multpl_command(app, "get_dividend_overview".to_string(), vec![]).await
}
/// Get earnings overview
#[tauri::command]
-pub async fn get_multpl_earnings_overview() -> Result<String, String> {
- execute_multpl_command("get_earnings_overview".to_string(), vec![]).await
+pub async fn get_multpl_earnings_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_multpl_command(app, "get_earnings_overview".to_string(), vec![]).await
}
/// Get comprehensive overview across all categories
#[tauri::command]
-pub async fn get_multpl_comprehensive_overview() -> Result<String, String> {
- execute_multpl_command("get_comprehensive_overview".to_string(), vec![]).await
+pub async fn get_multpl_comprehensive_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_multpl_command(app, "get_comprehensive_overview".to_string(), vec![]).await
}
// CUSTOM ANALYSIS COMMANDS
/// Get complete valuation analysis
#[tauri::command]
-pub async fn get_multpl_valuation_analysis() -> Result<String, String> {
+pub async fn get_multpl_valuation_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get all valuation metrics
@@ -379,7 +378,7 @@ pub async fn get_multpl_valuation_analysis() -> Result<String, String> {
];
for series in valuation_series {
- match get_multpl_series(series.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), series.to_string(), None, None).await {
Ok(data) => results.push((series.to_string(), data)),
Err(e) => results.push((series.to_string(), format!("Error: {}", e))),
}
@@ -393,7 +392,7 @@ pub async fn get_multpl_valuation_analysis() -> Result<String, String> {
/// Get complete dividend analysis
#[tauri::command]
-pub async fn get_multpl_dividend_analysis() -> Result<String, String> {
+pub async fn get_multpl_dividend_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get all dividend metrics
@@ -403,7 +402,7 @@ pub async fn get_multpl_dividend_analysis() -> Result<String, String> {
];
for series in dividend_series {
- match get_multpl_series(series.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), series.to_string(), None, None).await {
Ok(data) => results.push((series.to_string(), data)),
Err(e) => results.push((series.to_string(), format!("Error: {}", e))),
}
@@ -417,7 +416,7 @@ pub async fn get_multpl_dividend_analysis() -> Result<String, String> {
/// Get complete earnings analysis
#[tauri::command]
-pub async fn get_multpl_earnings_analysis() -> Result<String, String> {
+pub async fn get_multpl_earnings_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get all earnings metrics
@@ -428,7 +427,7 @@ pub async fn get_multpl_earnings_analysis() -> Result<String, String> {
];
for series in earnings_series {
- match get_multpl_series(series.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), series.to_string(), None, None).await {
Ok(data) => results.push((series.to_string(), data)),
Err(e) => results.push((series.to_string(), format!("Error: {}", e))),
}
@@ -442,7 +441,7 @@ pub async fn get_multpl_earnings_analysis() -> Result<String, String> {
/// Get complete sales analysis
#[tauri::command]
-pub async fn get_multpl_sales_analysis() -> Result<String, String> {
+pub async fn get_multpl_sales_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get all sales metrics
@@ -453,7 +452,7 @@ pub async fn get_multpl_sales_analysis() -> Result<String, String> {
];
for series in sales_series {
- match get_multpl_series(series.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), series.to_string(), None, None).await {
Ok(data) => results.push((series.to_string(), data)),
Err(e) => results.push((series.to_string(), format!("Error: {}", e))),
}
@@ -467,7 +466,7 @@ pub async fn get_multpl_sales_analysis() -> Result<String, String> {
/// Get historical price analysis
#[tauri::command]
-pub async fn get_multpl_price_analysis() -> Result<String, String> {
+pub async fn get_multpl_price_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get all price metrics
@@ -477,7 +476,7 @@ pub async fn get_multpl_price_analysis() -> Result<String, String> {
];
for series in price_series {
- match get_multpl_series(series.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), series.to_string(), None, None).await {
Ok(data) => results.push((series.to_string(), data)),
Err(e) => results.push((series.to_string(), format!("Error: {}", e))),
}
@@ -491,7 +490,7 @@ pub async fn get_multpl_price_analysis() -> Result<String, String> {
/// Get custom date range analysis for multiple series
#[tauri::command]
-pub async fn get_multpl_custom_analysis(
+pub async fn get_multpl_custom_analysis(app: tauri::AppHandle,
series_names: String,
start_date: String,
end_date: String,
@@ -503,7 +502,7 @@ pub async fn get_multpl_custom_analysis(
for series in series_list {
let trimmed_series = series.trim();
- match get_multpl_series(trimmed_series.to_string(), Some(start_date.clone()), Some(end_date.clone())).await {
+ match get_multpl_series(app.clone(), trimmed_series.to_string(), Some(start_date.clone()), Some(end_date.clone())).await {
Ok(data) => results.push((trimmed_series.to_string(), data)),
Err(e) => results.push((trimmed_series.to_string(), format!("Error: {}", e))),
}
@@ -521,7 +520,7 @@ pub async fn get_multpl_custom_analysis(
/// Get year-over-year comparison for a specific series
#[tauri::command]
-pub async fn get_multpl_year_over_year_comparison(
+pub async fn get_multpl_year_over_year_comparison(app: tauri::AppHandle,
series_name: String,
years: Option<i32>, // Number of years to compare, default 10
) -> Result<String, String> {
@@ -531,7 +530,7 @@ pub async fn get_multpl_year_over_year_comparison(
.format("%Y-%m-%d")
.to_string();
- match get_multpl_series(series_name.clone(), Some(start_date), Some(end_date)).await {
+ match get_multpl_series(app, series_name.clone(), Some(start_date), Some(end_date)).await {
Ok(data) => {
Ok(serde_json::json!({
"year_over_year_comparison": data,
@@ -545,14 +544,14 @@ pub async fn get_multpl_year_over_year_comparison(
/// Get current market valuation summary
#[tauri::command]
-pub async fn get_multpl_current_valuation() -> Result<String, String> {
+pub async fn get_multpl_current_valuation(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get current key valuation metrics
let key_metrics = vec!["shiller_pe_month", "pe_month", "dividend_yield_month", "earnings_yield_month"];
for metric in key_metrics {
- match get_multpl_series(metric.to_string(), None, None).await {
+ match get_multpl_series(app.clone(), metric.to_string(), None, None).await {
Ok(data) => results.push((metric.to_string(), data)),
Err(e) => results.push((metric.to_string(), format!("Error: {}", e))),
}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/nasdaq.rs b/fincept-terminal-desktop/src-tauri/src/commands/nasdaq.rs
index efbc912ff..9b9afed07 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/nasdaq.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/nasdaq.rs
@@ -1,19 +1,18 @@
// NASDAQ data commands based on OpenBB nasdaq provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
use chrono::Datelike;
/// Execute NASDAQ Python script command
#[tauri::command]
pub async fn execute_nasdaq_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("nasdaq_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "nasdaq_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -28,7 +27,7 @@ pub async fn execute_nasdaq_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute NASDAQ command: {}", e))?;
@@ -46,7 +45,7 @@ pub async fn execute_nasdaq_command(
/// Search for equities in NASDAQ directory
#[tauri::command]
-pub async fn search_nasdaq_equities(
+pub async fn search_nasdaq_equities(app: tauri::AppHandle,
query: Option<String>,
is_etf: Option<bool>,
) -> Result<String, String> {
@@ -57,12 +56,12 @@ pub async fn search_nasdaq_equities(
if let Some(etf) = is_etf {
args.push(etf.to_string());
}
- execute_nasdaq_command("search_equities".to_string(), args).await
+ execute_nasdaq_command(app, "search_equities".to_string(), args).await
}
/// Get equity screener results with filters
#[tauri::command]
-pub async fn get_nasdaq_equity_screener(
+pub async fn get_nasdaq_equity_screener(app: tauri::AppHandle,
exchange: Option<String>,
market_cap: Option<String>,
sector: Option<String>,
@@ -93,15 +92,16 @@ pub async fn get_nasdaq_equity_screener(
if let Some(lim) = limit {
args.push(lim.to_string());
}
- execute_nasdaq_command("equity_screener".to_string(), args).await
+ execute_nasdaq_command(app, "equity_screener".to_string(), args).await
}
/// Get top performing stocks
#[tauri::command]
-pub async fn get_nasdaq_top_performers(
+pub async fn get_nasdaq_top_performers(app: tauri::AppHandle,
limit: Option<i32>,
) -> Result<String, String> {
get_nasdaq_equity_screener(
+ app,
Some("all".to_string()),
Some("all".to_string()),
Some("all".to_string()),
@@ -112,11 +112,12 @@ pub async fn get_nasdaq_top_performers(
/// Get stocks by market cap category
#[tauri::command]
-pub async fn get_nasdaq_stocks_by_market_cap(
+pub async fn get_nasdaq_stocks_by_market_cap(app: tauri::AppHandle,
market_cap: String,
limit: Option<i32>,
) -> Result<String, String> {
get_nasdaq_equity_screener(
+ app,
Some("all".to_string()),
Some(market_cap),
Some("all".to_string()),
@@ -127,11 +128,12 @@ pub async fn get_nasdaq_stocks_by_market_cap(
/// Get stocks by sector
#[tauri::command]
-pub async fn get_nasdaq_stocks_by_sector(
+pub async fn get_nasdaq_stocks_by_sector(app: tauri::AppHandle,
sector: String,
limit: Option<i32>,
) -> Result<String, String> {
get_nasdaq_equity_screener(
+ app,
Some("all".to_string()),
Some("all".to_string()),
Some(sector),
@@ -142,11 +144,12 @@ pub async fn get_nasdaq_stocks_by_sector(
/// Get stocks by exchange
#[tauri::command]
-pub async fn get_nasdaq_stocks_by_exchange(
+pub async fn get_nasdaq_stocks_by_exchange(app: tauri::AppHandle,
exchange: String,
limit: Option<i32>,
) -> Result<String, String> {
get_nasdaq_equity_screener(
+ app,
Some(exchange),
Some("all".to_string()),
Some("all".to_string()),
@@ -157,17 +160,17 @@ pub async fn get_nasdaq_stocks_by_exchange(
/// Search for ETFs
#[tauri::command]
-pub async fn search_nasdaq_etfs(
+pub async fn search_nasdaq_etfs(app: tauri::AppHandle,
query: Option<String>,
) -> Result<String, String> {
- search_nasdaq_equities(query, Some(true)).await
+ search_nasdaq_equities(app, query, Some(true)).await
}
// CALENDAR COMMANDS
/// Get dividend calendar
#[tauri::command]
-pub async fn get_nasdaq_dividend_calendar(
+pub async fn get_nasdaq_dividend_calendar(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -178,17 +181,18 @@ pub async fn get_nasdaq_dividend_calendar(
if let Some(end) = end_date {
args.push(end);
}
- execute_nasdaq_command("dividend_calendar".to_string(), args).await
+ execute_nasdaq_command(app, "dividend_calendar".to_string(), args).await
}
/// Get upcoming dividends
#[tauri::command]
-pub async fn get_nasdaq_upcoming_dividends(
+pub async fn get_nasdaq_upcoming_dividends(app: tauri::AppHandle,
days: Option<i32>,
) -> Result<String, String> {
let days_ahead = days.unwrap_or(7);
let end_date = chrono::Utc::now() + chrono::Duration::days(days_ahead as i64);
get_nasdaq_dividend_calendar(
+ app,
Some(chrono::Utc::now().format("%Y-%m-%d").to_string()),
Some(end_date.format("%Y-%m-%d").to_string())
).await
@@ -196,7 +200,7 @@ pub async fn get_nasdaq_upcoming_dividends(
/// Get earnings calendar
#[tauri::command]
-pub async fn get_nasdaq_earnings_calendar(
+pub async fn get_nasdaq_earnings_calendar(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
) -> Result<String, String> {
@@ -207,17 +211,18 @@ pub async fn get_nasdaq_earnings_calendar(
if let Some(end) = end_date {
args.push(end);
}
- execute_nasdaq_command("earnings_calendar".to_string(), args).await
+ execute_nasdaq_command(app, "earnings_calendar".to_string(), args).await
}
/// Get upcoming earnings
#[tauri::command]
-pub async fn get_nasdaq_upcoming_earnings(
+pub async fn get_nasdaq_upcoming_earnings(app: tauri::AppHandle,
days: Option<i32>,
) -> Result<String, String> {
let days_ahead = days.unwrap_or(7);
let end_date = chrono::Utc::now() + chrono::Duration::days(days_ahead as i64);
get_nasdaq_earnings_calendar(
+ app,
Some(chrono::Utc::now().format("%Y-%m-%d").to_string()),
Some(end_date.format("%Y-%m-%d").to_string())
).await
@@ -225,7 +230,7 @@ pub async fn get_nasdaq_upcoming_earnings(
/// Get IPO calendar
#[tauri::command]
-pub async fn get_nasdaq_ipo_calendar(
+pub async fn get_nasdaq_ipo_calendar(app: tauri::AppHandle,
status: Option<String>,
is_spo: Option<bool>,
start_date: Option<String>,
@@ -248,23 +253,24 @@ pub async fn get_nasdaq_ipo_calendar(
if let Some(end) = end_date {
args.push(end);
}
- execute_nasdaq_command("ipo_calendar".to_string(), args).await
+ execute_nasdaq_command(app, "ipo_calendar".to_string(), args).await
}
/// Get upcoming IPOs
#[tauri::command]
-pub async fn get_nasdaq_upcoming_ipos() -> Result<String, String> {
- get_nasdaq_ipo_calendar(Some("upcoming".to_string()), Some(false), None, None).await
+pub async fn get_nasdaq_upcoming_ipos(app: tauri::AppHandle, ) -> Result<String, String> {
+ get_nasdaq_ipo_calendar(app, Some("upcoming".to_string()), Some(false), None, None).await
}
/// Get recent IPOs
#[tauri::command]
-pub async fn get_nasdaq_recent_ipos(
+pub async fn get_nasdaq_recent_ipos(app: tauri::AppHandle,
days: Option<i32>,
) -> Result<String, String> {
let days_back = days.unwrap_or(30);
let start_date = chrono::Utc::now() - chrono::Duration::days(days_back as i64);
get_nasdaq_ipo_calendar(
+ app,
Some("priced".to_string()),
Some(false),
Some(start_date.format("%Y-%m-%d").to_string()),
@@ -274,29 +280,29 @@ pub async fn get_nasdaq_recent_ipos(
/// Get filed IPOs
#[tauri::command]
-pub async fn get_nasdaq_filed_ipos() -> Result<String, String> {
- get_nasdaq_ipo_calendar(Some("filed".to_string()), Some(false), None, None).await
+pub async fn get_nasdaq_filed_ipos(app: tauri::AppHandle, ) -> Result<String, String> {
+ get_nasdaq_ipo_calendar(app, Some("filed".to_string()), Some(false), None, None).await
}
/// Get withdrawn IPOs
#[tauri::command]
-pub async fn get_nasdaq_withdrawn_ipos() -> Result<String, String> {
- get_nasdaq_ipo_calendar(Some("withdrawn".to_string()), Some(false), None, None).await
+pub async fn get_nasdaq_withdrawn_ipos(app: tauri::AppHandle, ) -> Result<String, String> {
+ get_nasdaq_ipo_calendar(app, Some("withdrawn".to_string()), Some(false), None, None).await
}
/// Get secondary public offerings (SPOs)
#[tauri::command]
-pub async fn get_nasdaq_spo_calendar(
+pub async fn get_nasdaq_spo_calendar(app: tauri::AppHandle,
status: Option<String>,
) -> Result<String, String> {
- get_nasdaq_ipo_calendar(status.or_else(|| Some("priced".to_string())), Some(true), None, None).await
+ get_nasdaq_ipo_calendar(app, status.or_else(|| Some("priced".to_string())), Some(true), None, None).await
}
// ECONOMIC CALENDAR COMMANDS
/// Get economic calendar
#[tauri::command]
-pub async fn get_nasdaq_economic_calendar(
+pub async fn get_nasdaq_economic_calendar(app: tauri::AppHandle,
start_date: Option<String>,
end_date: Option<String>,
country: Option<String>,
@@ -311,15 +317,16 @@ pub async fn get_nasdaq_economic_calendar(
if let Some(c) = country {
args.push(c);
}
- execute_nasdaq_command("economic_calendar".to_string(), args).await
+ execute_nasdaq_command(app, "economic_calendar".to_string(), args).await
}
/// Get today's economic events
#[tauri::command]
-pub async fn get_nasdaq_today_economic_events(
+pub async fn get_nasdaq_today_economic_events(app: tauri::AppHandle,
country: Option<String>,
) -> Result<String, String> {
get_nasdaq_economic_calendar(
+ app,
Some(chrono::Utc::now().format("%Y-%m-%d").to_string()),
Some(chrono::Utc::now().format("%Y-%m-%d").to_string()),
country
@@ -328,12 +335,13 @@ pub async fn get_nasdaq_today_economic_events(
/// Get this week's economic events
#[tauri::command]
-pub async fn get_nasdaq_week_economic_events(
+pub async fn get_nasdaq_week_economic_events(app: tauri::AppHandle,
country: Option<String>,
) -> Result<String, String> {
let start_date = chrono::Utc::now() - chrono::Duration::days(chrono::Utc::now().weekday().num_days_from_monday() as i64);
let end_date = start_date + chrono::Duration::days(4);
get_nasdaq_economic_calendar(
+ app,
Some(start_date.format("%Y-%m-%d").to_string()),
Some(end_date.format("%Y-%m-%d").to_string()),
country
@@ -344,7 +352,7 @@ pub async fn get_nasdaq_week_economic_events(
/// Get top retail activity
#[tauri::command]
-pub async fn get_nasdaq_top_retail_activity(
+pub async fn get_nasdaq_top_retail_activity(app: tauri::AppHandle,
limit: Option<i32>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -353,40 +361,41 @@ pub async fn get_nasdaq_top_retail_activity(
} else {
args.push("10".to_string());
}
- execute_nasdaq_command("top_retail".to_string(), args).await
+ execute_nasdaq_command(app, "top_retail".to_string(), args).await
}
/// Get retail sentiment leaders
#[tauri::command]
-pub async fn get_nasdaq_retail_sentiment(
+pub async fn get_nasdaq_retail_sentiment(app: tauri::AppHandle,
limit: Option<i32>,
) -> Result<String, String> {
// This would use top retail activity data and filter by sentiment
// For now, return the top retail activity
- get_nasdaq_top_retail_activity(limit).await
+ get_nasdaq_top_retail_activity(app, limit).await
}
// COMPREHENSIVE OVERVIEW COMMANDS
/// Get comprehensive market overview
#[tauri::command]
-pub async fn get_nasdaq_market_overview() -> Result<String, String> {
- execute_nasdaq_command("market_overview".to_string(), vec![]).await
+pub async fn get_nasdaq_market_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_nasdaq_command(app, "market_overview".to_string(), vec![]).await
}
/// Get dividend-focused overview
#[tauri::command]
-pub async fn get_nasdaq_dividend_overview() -> Result<String, String> {
+pub async fn get_nasdaq_dividend_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get upcoming dividends
- match get_nasdaq_upcoming_dividends(Some(14)).await {
+ match get_nasdaq_upcoming_dividends(app.clone(), Some(14)).await {
Ok(data) => results.push(("upcoming_dividends".to_string(), data)),
Err(e) => results.push(("upcoming_dividends".to_string(), format!("Error: {}", e))),
}
// Get top dividend stocks
match get_nasdaq_equity_screener(
+ app,
Some("all".to_string()),
Some("all".to_string()),
Some("all".to_string()),
@@ -404,23 +413,23 @@ pub async fn get_nasdaq_dividend_overview() -> Result<String, String> {
/// Get IPO-focused overview
#[tauri::command]
-pub async fn get_nasdaq_ipo_overview() -> Result<String, String> {
+pub async fn get_nasdaq_ipo_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get upcoming IPOs
- match get_nasdaq_upcoming_ipos().await {
+ match get_nasdaq_upcoming_ipos(app.clone()).await {
Ok(data) => results.push(("upcoming_ipos".to_string(), data)),
Err(e) => results.push(("upcoming_ipos".to_string(), format!("Error: {}", e))),
}
// Get recent IPOs
- match get_nasdaq_recent_ipos(Some(30)).await {
+ match get_nasdaq_recent_ipos(app.clone(), Some(30)).await {
Ok(data) => results.push(("recent_ipos".to_string(), data)),
Err(e) => results.push(("recent_ipos".to_string(), format!("Error: {}", e))),
}
// Get filed IPOs
- match get_nasdaq_filed_ipos().await {
+ match get_nasdaq_filed_ipos(app).await {
Ok(data) => results.push(("filed_ipos".to_string(), data)),
Err(e) => results.push(("filed_ipos".to_string(), format!("Error: {}", e))),
}
@@ -432,17 +441,18 @@ pub async fn get_nasdaq_ipo_overview() -> Result<String, String> {
/// Get earnings-focused overview
#[tauri::command]
-pub async fn get_nasdaq_earnings_overview() -> Result<String, String> {
+pub async fn get_nasdaq_earnings_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get upcoming earnings
- match get_nasdaq_upcoming_earnings(Some(7)).await {
+ match get_nasdaq_upcoming_earnings(app.clone(), Some(7)).await {
Ok(data) => results.push(("upcoming_earnings".to_string(), data)),
Err(e) => results.push(("upcoming_earnings".to_string(), format!("Error: {}", e))),
}
// Get today's earnings
match get_nasdaq_earnings_calendar(
+ app,
Some(chrono::Utc::now().format("%Y-%m-%d").to_string()),
Some(chrono::Utc::now().format("%Y-%m-%d").to_string())
).await {
@@ -457,7 +467,7 @@ pub async fn get_nasdaq_earnings_overview() -> Result<String, String> {
/// Get sector analysis overview
#[tauri::command]
-pub async fn get_nasdaq_sector_analysis() -> Result<String, String> {
+pub async fn get_nasdaq_sector_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get data for major sectors
@@ -469,7 +479,7 @@ pub async fn get_nasdaq_sector_analysis() -> Result<String, String> {
let sectors_clone = sectors.clone();
for sector in sectors {
- match get_nasdaq_stocks_by_sector(sector.to_string(), Some(20)).await {
+ match get_nasdaq_stocks_by_sector(app.clone(), sector.to_string(), Some(20)).await {
Ok(data) => results.push((format!("sector_{}", sector), data)),
Err(e) => results.push((format!("sector_{}", sector), format!("Error: {}", e))),
}
@@ -483,7 +493,7 @@ pub async fn get_nasdaq_sector_analysis() -> Result<String, String> {
/// Get market cap analysis overview
#[tauri::command]
-pub async fn get_nasdaq_market_cap_analysis() -> Result<String, String> {
+pub async fn get_nasdaq_market_cap_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get data for each market cap category
@@ -491,7 +501,7 @@ pub async fn get_nasdaq_market_cap_analysis() -> Result<String, String> {
let market_caps_clone = market_caps.clone();
for market_cap in market_caps {
- match get_nasdaq_stocks_by_market_cap(market_cap.to_string(), Some(20)).await {
+ match get_nasdaq_stocks_by_market_cap(app.clone(), market_cap.to_string(), Some(20)).await {
Ok(data) => results.push((format!("market_cap_{}", market_cap), data)),
Err(e) => results.push((format!("market_cap_{}", market_cap), format!("Error: {}", e))),
}
@@ -505,7 +515,7 @@ pub async fn get_nasdaq_market_cap_analysis() -> Result<String, String> {
/// Get exchange comparison overview
#[tauri::command]
-pub async fn get_nasdaq_exchange_comparison() -> Result<String, String> {
+pub async fn get_nasdaq_exchange_comparison(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get data for each exchange
@@ -513,7 +523,7 @@ pub async fn get_nasdaq_exchange_comparison() -> Result<String, String> {
let exchanges_clone = exchanges.clone();
for exchange in exchanges {
- match get_nasdaq_stocks_by_exchange(exchange.to_string(), Some(25)).await {
+ match get_nasdaq_stocks_by_exchange(app.clone(), exchange.to_string(), Some(25)).await {
Ok(data) => results.push((format!("exchange_{}", exchange), data)),
Err(e) => results.push((format!("exchange_{}", exchange), format!("Error: {}", e))),
}
@@ -527,7 +537,7 @@ pub async fn get_nasdaq_exchange_comparison() -> Result<String, String> {
/// Get custom date range analysis
#[tauri::command]
-pub async fn get_nasdaq_date_range_analysis(
+pub async fn get_nasdaq_date_range_analysis(app: tauri::AppHandle,
start_date: String,
end_date: String,
) -> Result<String, String> {
@@ -535,6 +545,7 @@ pub async fn get_nasdaq_date_range_analysis(
// Get dividends for date range
match get_nasdaq_dividend_calendar(
+ app.clone(),
Some(start_date.clone()),
Some(end_date.clone())
).await {
@@ -544,6 +555,7 @@ pub async fn get_nasdaq_date_range_analysis(
// Get earnings for date range
match get_nasdaq_earnings_calendar(
+ app.clone(),
Some(start_date.clone()),
Some(end_date.clone())
).await {
@@ -553,6 +565,7 @@ pub async fn get_nasdaq_date_range_analysis(
// Get economic events for date range
match get_nasdaq_economic_calendar(
+ app,
Some(start_date.clone()),
Some(end_date.clone()),
None
@@ -572,7 +585,7 @@ pub async fn get_nasdaq_date_range_analysis(
/// Get NASDAQ directory information
#[tauri::command]
-pub async fn get_nasdaq_directory_info() -> Result<String, String> {
+pub async fn get_nasdaq_directory_info(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Search for popular stocks
@@ -580,7 +593,7 @@ pub async fn get_nasdaq_directory_info() -> Result<String, String> {
let popular_searches_clone = popular_searches.clone();
for search_term in popular_searches {
- match search_nasdaq_equities(Some(search_term.to_string()), None).await {
+ match search_nasdaq_equities(app.clone(), Some(search_term.to_string()), None).await {
Ok(data) => results.push((format!("search_{}", search_term), data)),
Err(e) => results.push((format!("search_{}", search_term), format!("Error: {}", e))),
}
@@ -588,6 +601,7 @@ pub async fn get_nasdaq_directory_info() -> Result<String, String> {
// Get general screener data
match get_nasdaq_equity_screener(
+ app,
Some("all".to_string()),
Some("all".to_string()),
Some("all".to_string()),
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/oecd.rs b/fincept-terminal-desktop/src-tauri/src/commands/oecd.rs
index f9d79424b..fc42a8645 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/oecd.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/oecd.rs
@@ -1,18 +1,17 @@
// OECD data commands based on OpenBB oecd provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute OECD Python script command
#[tauri::command]
pub async fn execute_oecd_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("oecd_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "oecd_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_oecd_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute OECD command: {}", e))?;
@@ -43,7 +42,7 @@ pub async fn execute_oecd_command(
/// Get real GDP data for specified countries
#[tauri::command]
-pub async fn get_oecd_gdp_real(
+pub async fn get_oecd_gdp_real(app: tauri::AppHandle,
countries: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -62,12 +61,12 @@ pub async fn get_oecd_gdp_real(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_oecd_command("gdp_real".to_string(), args).await
+ execute_oecd_command(app, "gdp_real".to_string(), args).await
}
/// Get Consumer Price Index data
#[tauri::command]
-pub async fn get_oecd_consumer_price_index(
+pub async fn get_oecd_consumer_price_index(app: tauri::AppHandle,
countries: Option<String>,
expenditure: Option<String>,
frequency: Option<String>,
@@ -98,12 +97,12 @@ pub async fn get_oecd_consumer_price_index(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_oecd_command("cpi".to_string(), args).await
+ execute_oecd_command(app, "cpi".to_string(), args).await
}
/// Get GDP forecast data
#[tauri::command]
-pub async fn get_oecd_gdp_forecast(
+pub async fn get_oecd_gdp_forecast(app: tauri::AppHandle,
countries: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -118,12 +117,12 @@ pub async fn get_oecd_gdp_forecast(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_oecd_command("gdp_forecast".to_string(), args).await
+ execute_oecd_command(app, "gdp_forecast".to_string(), args).await
}
/// Get unemployment rate data
#[tauri::command]
-pub async fn get_oecd_unemployment(
+pub async fn get_oecd_unemployment(app: tauri::AppHandle,
countries: Option<String>,
frequency: Option<String>,
start_date: Option<String>,
@@ -142,12 +141,12 @@ pub async fn get_oecd_unemployment(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_oecd_command("unemployment".to_string(), args).await
+ execute_oecd_command(app, "unemployment".to_string(), args).await
}
/// Get comprehensive economic summary for a country
#[tauri::command]
-pub async fn get_oecd_economic_summary(
+pub async fn get_oecd_economic_summary(app: tauri::AppHandle,
country: Option<String>,
start_date: Option<String>,
end_date: Option<String>,
@@ -162,11 +161,11 @@ pub async fn get_oecd_economic_summary(
if let Some(end_date) = end_date {
args.push(end_date);
}
- execute_oecd_command("economic_summary".to_string(), args).await
+ execute_oecd_command(app, "economic_summary".to_string(), args).await
}
/// Get list of available countries and data categories
#[tauri::command]
-pub async fn get_oecd_country_list() -> Result<String, String> {
- execute_oecd_command("country_list".to_string(), vec![]).await
+pub async fn get_oecd_country_list(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_oecd_command(app, "country_list".to_string(), vec![]).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/openafrica.rs b/fincept-terminal-desktop/src-tauri/src/commands/openafrica.rs
new file mode 100644
index 000000000..cc6c4dada
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/openafrica.rs
@@ -0,0 +1,64 @@
+// OpenAFRICA data portal commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute OpenAFRICA Python script command
+#[tauri::command]
+pub async fn execute_openafrica_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "openafrica_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "OpenAFRICA script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute OpenAFRICA command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("OpenAFRICA command failed: {}", stderr))
+ }
+}
+
+/// Search African datasets
+#[tauri::command]
+pub async fn search_openafrica_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_openafrica_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_openafrica_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_openafrica_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
+
+/// Get datasets by country
+#[tauri::command]
+pub async fn get_openafrica_country_datasets(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_openafrica_command(app, "country".to_string(), vec![country]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/polygon.rs b/fincept-terminal-desktop/src-tauri/src/commands/polygon.rs
index 2eec03e24..05e5b6fc5 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/polygon.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/polygon.rs
@@ -1,5 +1,6 @@
// Polygon.io data commands
use serde::{Deserialize, Serialize};
+use crate::utils::python::{get_python_path, get_script_path};
use std::process::Command;
#[derive(Debug, Serialize, Deserialize)]
@@ -12,15 +13,13 @@ pub struct PolygonResponse {
/// Execute Polygon.io Python script command
#[tauri::command]
pub async fn execute_polygon_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path - use CARGO_MANIFEST_DIR for correct path resolution
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("polygon_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "polygon_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -35,7 +34,7 @@ pub async fn execute_polygon_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute command: {}", e))?;
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/sec.rs b/fincept-terminal-desktop/src-tauri/src/commands/sec.rs
index c4960486b..13fbc94e1 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/sec.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/sec.rs
@@ -1,18 +1,17 @@
// SEC (Securities and Exchange Commission) data commands based on OpenBB sec provider
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute SEC Python script command
#[tauri::command]
pub async fn execute_sec_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("sec_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "sec_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_sec_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute SEC command: {}", e))?;
@@ -45,7 +44,7 @@ pub async fn execute_sec_command(
/// Get company filings from SEC database
#[tauri::command]
-pub async fn get_sec_company_filings(
+pub async fn get_sec_company_filings(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
form_type: Option<String>,
@@ -74,52 +73,52 @@ pub async fn get_sec_company_filings(
} else {
args.push("100".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
/// Get CIK (Central Index Key) for a company symbol
#[tauri::command]
-pub async fn get_sec_cik_map(
+pub async fn get_sec_cik_map(app: tauri::AppHandle,
symbol: String,
) -> Result<String, String> {
let args = vec![symbol];
- execute_sec_command("cik_map".to_string(), args).await
+ execute_sec_command(app, "cik_map".to_string(), args).await
}
/// Get symbol mapping for a CIK
#[tauri::command]
-pub async fn get_sec_symbol_map(
+pub async fn get_sec_symbol_map(app: tauri::AppHandle,
cik: String,
) -> Result<String, String> {
let args = vec![cik];
- execute_sec_command("symbol_map".to_string(), args).await
+ execute_sec_command(app, "symbol_map".to_string(), args).await
}
// FILING CONTENT COMMANDS
/// Get content of a specific SEC filing
#[tauri::command]
-pub async fn get_sec_filing_content(
+pub async fn get_sec_filing_content(app: tauri::AppHandle,
filing_url: String,
) -> Result<String, String> {
let args = vec![filing_url];
- execute_sec_command("filing_content".to_string(), args).await
+ execute_sec_command(app, "filing_content".to_string(), args).await
}
/// Parse HTML content from SEC filing
#[tauri::command]
-pub async fn parse_sec_filing_html(
+pub async fn parse_sec_filing_html(app: tauri::AppHandle,
html_content: String,
) -> Result<String, String> {
let args = vec![html_content];
- execute_sec_command("parse_filing_html".to_string(), args).await
+ execute_sec_command(app, "parse_filing_html".to_string(), args).await
}
// INSIDER TRADING COMMANDS
/// Get insider trading data (Form 4 filings)
#[tauri::command]
-pub async fn get_sec_insider_trading(
+pub async fn get_sec_insider_trading(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
start_date: Option<String>,
@@ -144,14 +143,14 @@ pub async fn get_sec_insider_trading(
} else {
args.push("100".to_string());
}
- execute_sec_command("insider_trading".to_string(), args).await
+ execute_sec_command(app, "insider_trading".to_string(), args).await
}
// INSTITUTIONAL OWNERSHIP COMMANDS
/// Get institutional ownership data (Form 13F filings)
#[tauri::command]
-pub async fn get_sec_institutional_ownership(
+pub async fn get_sec_institutional_ownership(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
start_date: Option<String>,
@@ -176,14 +175,14 @@ pub async fn get_sec_institutional_ownership(
} else {
args.push("50".to_string());
}
- execute_sec_command("institutional_ownership".to_string(), args).await
+ execute_sec_command(app, "institutional_ownership".to_string(), args).await
}
// COMPANY SEARCH COMMANDS
/// Search for companies in SEC database
#[tauri::command]
-pub async fn search_sec_companies(
+pub async fn search_sec_companies(app: tauri::AppHandle,
query: String,
is_fund: Option<bool>,
) -> Result<String, String> {
@@ -191,40 +190,40 @@ pub async fn search_sec_companies(
if let Some(is_fund) = is_fund {
args.push(is_fund.to_string());
}
- execute_sec_command("search_companies".to_string(), args).await
+ execute_sec_command(app, "search_companies".to_string(), args).await
}
/// Search for ETFs and mutual funds
#[tauri::command]
-pub async fn search_sec_etfs_mutual_funds(
+pub async fn search_sec_etfs_mutual_funds(app: tauri::AppHandle,
query: String,
) -> Result<String, String> {
let args = vec![query];
- execute_sec_command("search_etfs_mutual_funds".to_string(), args).await
+ execute_sec_command(app, "search_etfs_mutual_funds".to_string(), args).await
}
// FORM TYPE HELPERS
/// Get list of available SEC form types
#[tauri::command]
-pub async fn get_sec_available_form_types() -> Result<String, String> {
- execute_sec_command("available_form_types".to_string(), vec![]).await
+pub async fn get_sec_available_form_types(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_sec_command(app, "available_form_types".to_string(), vec![]).await
}
// COMPANY FACTS COMMANDS
/// Get company facts data from SEC API
#[tauri::command]
-pub async fn get_sec_company_facts(
+pub async fn get_sec_company_facts(app: tauri::AppHandle,
cik: String,
) -> Result<String, String> {
let args = vec![cik];
- execute_sec_command("company_facts".to_string(), args).await
+ execute_sec_command(app, "company_facts".to_string(), args).await
}
/// Get financial statements data using company facts
#[tauri::command]
-pub async fn get_sec_financial_statements(
+pub async fn get_sec_financial_statements(app: tauri::AppHandle,
cik: String,
taxonomy: Option<String>,
fact_list: Option<String>,
@@ -238,14 +237,14 @@ pub async fn get_sec_financial_statements(
if let Some(fact_list) = fact_list {
args.push(fact_list);
}
- execute_sec_command("financial_statements".to_string(), args).await
+ execute_sec_command(app, "financial_statements".to_string(), args).await
}
// COMPREHENSIVE DATA COMMANDS
/// Get comprehensive company overview including filings, facts, and insider data
#[tauri::command]
-pub async fn get_sec_company_overview(
+pub async fn get_sec_company_overview(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
) -> Result<String, String> {
@@ -256,12 +255,12 @@ pub async fn get_sec_company_overview(
if let Some(cik) = cik {
args.push(cik);
}
- execute_sec_command("company_overview".to_string(), args).await
+ execute_sec_command(app, "company_overview".to_string(), args).await
}
/// Get all filings of a specific form type within date range
#[tauri::command]
-pub async fn get_sec_filings_by_form_type(
+pub async fn get_sec_filings_by_form_type(app: tauri::AppHandle,
form_type: String,
start_date: Option<String>,
end_date: Option<String>,
@@ -279,14 +278,14 @@ pub async fn get_sec_filings_by_form_type(
} else {
args.push("100".to_string());
}
- execute_sec_command("filings_by_form_type".to_string(), args).await
+ execute_sec_command(app, "filings_by_form_type".to_string(), args).await
}
// SECURITIES SEARCH COMMANDS
/// Search for equity securities
#[tauri::command]
-pub async fn search_sec_equities(
+pub async fn search_sec_equities(app: tauri::AppHandle,
query: String,
is_fund: Option<bool>,
use_cache: Option<bool>,
@@ -298,12 +297,12 @@ pub async fn search_sec_equities(
if let Some(use_cache) = use_cache {
args.push(use_cache.to_string());
}
- execute_sec_command("search_companies".to_string(), args).await
+ execute_sec_command(app, "search_companies".to_string(), args).await
}
/// Search for mutual funds and ETFs
#[tauri::command]
-pub async fn search_sec_mutual_funds_etfs(
+pub async fn search_sec_mutual_funds_etfs(app: tauri::AppHandle,
query: String,
use_cache: Option<bool>,
) -> Result<String, String> {
@@ -311,14 +310,14 @@ pub async fn search_sec_mutual_funds_etfs(
if let Some(use_cache) = use_cache {
args.push(use_cache.to_string());
}
- execute_sec_command("search_etfs_mutual_funds".to_string(), args).await
+ execute_sec_command(app, "search_etfs_mutual_funds".to_string(), args).await
}
// ADVANCED SEC DATA COMMANDS
/// Get SEC filing metadata and document URLs
#[tauri::command]
-pub async fn get_sec_filing_metadata(
+pub async fn get_sec_filing_metadata(app: tauri::AppHandle,
filing_url: String,
use_cache: Option<bool>,
) -> Result<String, String> {
@@ -326,12 +325,12 @@ pub async fn get_sec_filing_metadata(
if let Some(use_cache) = use_cache {
args.push(use_cache.to_string());
}
- execute_sec_command("filing_content".to_string(), args).await
+ execute_sec_command(app, "filing_content".to_string(), args).await
}
/// Get recent 8-K filings (current reports)
#[tauri::command]
-pub async fn get_sec_recent_current_reports(
+pub async fn get_sec_recent_current_reports(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
limit: Option<i32>,
@@ -348,12 +347,12 @@ pub async fn get_sec_recent_current_reports(
} else {
args.push("20".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
/// Get annual reports (10-K filings)
#[tauri::command]
-pub async fn get_sec_annual_reports(
+pub async fn get_sec_annual_reports(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
limit: Option<i32>,
@@ -370,12 +369,12 @@ pub async fn get_sec_annual_reports(
} else {
args.push("5".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
/// Get quarterly reports (10-Q filings)
#[tauri::command]
-pub async fn get_sec_quarterly_reports(
+pub async fn get_sec_quarterly_reports(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
limit: Option<i32>,
@@ -392,12 +391,12 @@ pub async fn get_sec_quarterly_reports(
} else {
args.push("8".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
/// Get registration statements (S-1, S-3 filings)
#[tauri::command]
-pub async fn get_sec_registration_statements(
+pub async fn get_sec_registration_statements(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
form_types: Option<String>,
@@ -420,12 +419,12 @@ pub async fn get_sec_registration_statements(
} else {
args.push("10".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
/// Get beneficial ownership reports (Form 3, 4, 5)
#[tauri::command]
-pub async fn get_sec_beneficial_ownership(
+pub async fn get_sec_beneficial_ownership(app: tauri::AppHandle,
symbol: Option<String>,
cik: Option<String>,
form_types: Option<String>,
@@ -448,5 +447,5 @@ pub async fn get_sec_beneficial_ownership(
} else {
args.push("20".to_string());
}
- execute_sec_command("company_filings".to_string(), args).await
+ execute_sec_command(app, "company_filings".to_string(), args).await
}
\ No newline at end of file
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/sentinelhub.rs b/fincept-terminal-desktop/src-tauri/src/commands/sentinelhub.rs
new file mode 100644
index 000000000..e2d5ddf2f
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/sentinelhub.rs
@@ -0,0 +1,70 @@
+// Sentinel Hub satellite data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Sentinel Hub Python script command
+#[tauri::command]
+pub async fn execute_sentinelhub_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "sentinelhub_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Sentinel Hub script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Sentinel Hub command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Sentinel Hub command failed: {}", stderr))
+ }
+}
+
+/// Get satellite imagery
+#[tauri::command]
+pub async fn get_sentinelhub_imagery(
+ app: tauri::AppHandle,
+ location: String,
+ date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![location];
+ if let Some(d) = date {
+ args.push(d);
+ }
+ execute_sentinelhub_command(app, "imagery".to_string(), args).await
+}
+
+/// Get available collections
+#[tauri::command]
+pub async fn get_sentinelhub_collections(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_sentinelhub_command(app, "collections".to_string(), vec![]).await
+}
+
+/// Search satellite data
+#[tauri::command]
+pub async fn search_sentinelhub_data(
+ app: tauri::AppHandle,
+ bbox: String,
+ start_date: String,
+ end_date: String,
+) -> Result<String, String> {
+ execute_sentinelhub_command(app, "search".to_string(), vec![bbox, start_date, end_date]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/spain_data.rs b/fincept-terminal-desktop/src-tauri/src/commands/spain_data.rs
new file mode 100644
index 000000000..4e48fd4f7
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/spain_data.rs
@@ -0,0 +1,54 @@
+// Spanish economic data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Spain data Python script command
+#[tauri::command]
+pub async fn execute_spain_data_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "spain_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Spain data script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Spain data command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Spain data command failed: {}", stderr))
+ }
+}
+
+/// Get Spanish economic indicators
+#[tauri::command]
+pub async fn get_spain_economic_data(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_spain_data_command(app, "economic".to_string(), vec![]).await
+}
+
+/// Search Spanish datasets
+#[tauri::command]
+pub async fn search_spain_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_spain_data_command(app, "search".to_string(), vec![query]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/swiss_gov.rs b/fincept-terminal-desktop/src-tauri/src/commands/swiss_gov.rs
new file mode 100644
index 000000000..9eb8e8ed9
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/swiss_gov.rs
@@ -0,0 +1,55 @@
+// Swiss Government data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Swiss Government Python script command
+#[tauri::command]
+pub async fn execute_swiss_gov_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "swiss_gov_api.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Swiss Government script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Swiss Government command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Swiss Government command failed: {}", stderr))
+ }
+}
+
+/// Search Swiss government datasets
+#[tauri::command]
+pub async fn search_swiss_gov_datasets(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_swiss_gov_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get dataset by ID
+#[tauri::command]
+pub async fn get_swiss_gov_dataset(
+ app: tauri::AppHandle,
+ dataset_id: String,
+) -> Result<String, String> {
+ execute_swiss_gov_command(app, "dataset".to_string(), vec![dataset_id]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/trading_economics.rs b/fincept-terminal-desktop/src-tauri/src/commands/trading_economics.rs
new file mode 100644
index 000000000..48d9a9b7a
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/trading_economics.rs
@@ -0,0 +1,117 @@
+// Trading Economics data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute Trading Economics Python script command
+#[tauri::command]
+pub async fn execute_trading_economics_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "trading_economics_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "Trading Economics script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute Trading Economics command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("Trading Economics command failed: {}", stderr))
+ }
+}
+
+/// Get economic indicators for a country
+#[tauri::command]
+pub async fn get_trading_economics_indicators(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_trading_economics_command(app, "indicators".to_string(), vec![country]).await
+}
+
+/// Get historical data for an indicator
+#[tauri::command]
+pub async fn get_trading_economics_historical(
+ app: tauri::AppHandle,
+ country: String,
+ indicator: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![country, indicator];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_trading_economics_command(app, "historical".to_string(), args).await
+}
+
+/// Get economic calendar events
+#[tauri::command]
+pub async fn get_trading_economics_calendar(
+ app: tauri::AppHandle,
+ country: Option<String>,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![];
+ if let Some(c) = country {
+ args.push(c);
+ }
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_trading_economics_command(app, "calendar".to_string(), args).await
+}
+
+/// Get market snapshots
+#[tauri::command]
+pub async fn get_trading_economics_markets(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_trading_economics_command(app, "markets".to_string(), vec![]).await
+}
+
+/// Get country credit ratings
+#[tauri::command]
+pub async fn get_trading_economics_ratings(
+ app: tauri::AppHandle,
+ country: Option<String>,
+) -> Result<String, String> {
+ let args = if let Some(c) = country {
+ vec![c]
+ } else {
+ vec![]
+ };
+ execute_trading_economics_command(app, "ratings".to_string(), args).await
+}
+
+/// Get forecasts for indicators
+#[tauri::command]
+pub async fn get_trading_economics_forecasts(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_trading_economics_command(app, "forecasts".to_string(), vec![country]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/worldbank.rs b/fincept-terminal-desktop/src-tauri/src/commands/worldbank.rs
new file mode 100644
index 000000000..53ef69007
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/commands/worldbank.rs
@@ -0,0 +1,118 @@
+// World Bank data commands
+use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
+
+/// Execute World Bank Python script command
+#[tauri::command]
+pub async fn execute_worldbank_command(
+ app: tauri::AppHandle,
+ command: String,
+ args: Vec<String>,
+) -> Result<String, String> {
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "worldbank_data.py")?;
+
+ if !script_path.exists() {
+ return Err(format!(
+ "World Bank script not found at: {}",
+ script_path.display()
+ ));
+ }
+
+ let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
+ cmd_args.extend(args);
+
+ let output = Command::new(&python_path)
+ .args(&cmd_args)
+ .output()
+ .map_err(|e| format!("Failed to execute World Bank command: {}", e))?;
+
+ if output.status.success() {
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ Ok(stdout.to_string())
+ } else {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ Err(format!("World Bank command failed: {}", stderr))
+ }
+}
+
+/// Get World Bank indicator data
+#[tauri::command]
+pub async fn get_worldbank_indicator(
+ app: tauri::AppHandle,
+ indicator: String,
+ country: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![indicator, country];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_worldbank_command(app, "indicator".to_string(), args).await
+}
+
+/// Search World Bank indicators
+#[tauri::command]
+pub async fn search_worldbank_indicators(
+ app: tauri::AppHandle,
+ query: String,
+) -> Result<String, String> {
+ execute_worldbank_command(app, "search".to_string(), vec![query]).await
+}
+
+/// Get country information
+#[tauri::command]
+pub async fn get_worldbank_country_info(
+ app: tauri::AppHandle,
+ country_code: String,
+) -> Result<String, String> {
+ execute_worldbank_command(app, "country_info".to_string(), vec![country_code]).await
+}
+
+/// Get list of countries
+#[tauri::command]
+pub async fn get_worldbank_countries(
+ app: tauri::AppHandle,
+) -> Result<String, String> {
+ execute_worldbank_command(app, "countries".to_string(), vec![]).await
+}
+
+/// Get GDP data for countries
+#[tauri::command]
+pub async fn get_worldbank_gdp(
+ app: tauri::AppHandle,
+ country: String,
+ start_date: Option<String>,
+ end_date: Option<String>,
+) -> Result<String, String> {
+ let mut args = vec![country];
+ if let Some(start) = start_date {
+ args.push(start);
+ }
+ if let Some(end) = end_date {
+ args.push(end);
+ }
+ execute_worldbank_command(app, "gdp".to_string(), args).await
+}
+
+/// Get economic overview for a country
+#[tauri::command]
+pub async fn get_worldbank_economic_overview(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_worldbank_command(app, "economic_overview".to_string(), vec![country]).await
+}
+
+/// Get development indicators
+#[tauri::command]
+pub async fn get_worldbank_development_indicators(
+ app: tauri::AppHandle,
+ country: String,
+) -> Result<String, String> {
+ execute_worldbank_command(app, "development_indicators".to_string(), vec![country]).await
+}
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/wto.rs b/fincept-terminal-desktop/src-tauri/src/commands/wto.rs
index e62d68b27..19311a14c 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/wto.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/wto.rs
@@ -1,18 +1,17 @@
// WTO (World Trade Organization) data commands based on WTO APIs
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute WTO Python script command
#[tauri::command]
pub async fn execute_wto_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
// Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("wto_data.py");
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "wto_data.py")?;
// Verify script exists
if !script_path.exists() {
@@ -27,7 +26,7 @@ pub async fn execute_wto_command(
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute WTO command: {}", e))?;
@@ -45,21 +44,21 @@ pub async fn execute_wto_command(
/// Get available WTO APIs and endpoints
#[tauri::command]
-pub async fn get_wto_available_apis() -> Result<String, String> {
- execute_wto_command("available_apis".to_string(), vec![]).await
+pub async fn get_wto_available_apis(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_wto_command(app, "available_apis".to_string(), vec![]).await
}
/// Get comprehensive WTO overview across all APIs
#[tauri::command]
-pub async fn get_wto_overview() -> Result<String, String> {
- execute_wto_command("overview".to_string(), vec![]).await
+pub async fn get_wto_overview(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_wto_command(app, "overview".to_string(), vec![]).await
}
// QUANTITATIVE RESTRICTIONS (QR) COMMANDS
/// Get QR members list
#[tauri::command]
-pub async fn get_wto_qr_members(
+pub async fn get_wto_qr_members(app: tauri::AppHandle,
member_code: Option<String>,
name: Option<String>,
page: Option<i32>,
@@ -81,12 +80,12 @@ pub async fn get_wto_qr_members(
args.push(p.to_string());
}
- execute_wto_command("qr_members".to_string(), args).await
+ execute_wto_command(app, "qr_members".to_string(), args).await
}
/// Get QR products list
#[tauri::command]
-pub async fn get_wto_qr_products(
+pub async fn get_wto_qr_products(app: tauri::AppHandle,
hs_version: String,
code: Option<String>,
description: Option<String>,
@@ -109,12 +108,12 @@ pub async fn get_wto_qr_products(
args.push(p.to_string());
}
- execute_wto_command("qr_products".to_string(), args).await
+ execute_wto_command(app, "qr_products".to_string(), args).await
}
/// Get QR notifications list
#[tauri::command]
-pub async fn get_wto_qr_notifications(
+pub async fn get_wto_qr_notifications(app: tauri::AppHandle,
reporter_member_code: Option<String>,
notification_year: Option<i32>,
page: Option<i32>,
@@ -136,21 +135,21 @@ pub async fn get_wto_qr_notifications(
args.push(p.to_string());
}
- execute_wto_command("qr_notifications".to_string(), args).await
+ execute_wto_command(app, "qr_notifications".to_string(), args).await
}
/// Get QR details by ID
#[tauri::command]
-pub async fn get_wto_qr_details(
+pub async fn get_wto_qr_details(app: tauri::AppHandle,
qr_id: i32,
) -> Result<String, String> {
let args = vec!["--qr_id".to_string(), qr_id.to_string()];
- execute_wto_command("qr_details".to_string(), args).await
+ execute_wto_command(app, "qr_details".to_string(), args).await
}
/// Get QR list with filters
#[tauri::command]
-pub async fn get_wto_qr_list(
+pub async fn get_wto_qr_list(app: tauri::AppHandle,
reporter_member_code: Option<String>,
in_force_only: Option<bool>,
year_of_entry_into_force: Option<i32>,
@@ -190,20 +189,20 @@ pub async fn get_wto_qr_list(
args.push(p.to_string());
}
- execute_wto_command("qr_list".to_string(), args).await
+ execute_wto_command(app, "qr_list".to_string(), args).await
}
/// Get QR HS versions
#[tauri::command]
-pub async fn get_wto_qr_hs_versions() -> Result<String, String> {
- execute_wto_command("qr_hs_versions".to_string(), vec![]).await
+pub async fn get_wto_qr_hs_versions(app: tauri::AppHandle, ) -> Result<String, String> {
+ execute_wto_command(app, "qr_hs_versions".to_string(), vec![]).await
}
// EPING (SPS/TBT NOTIFICATIONS) COMMANDS
/// Get ePing members list
#[tauri::command]
-pub async fn get_wto_eping_members(
+pub async fn get_wto_eping_members(app: tauri::AppHandle,
language: Option<i32>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -213,12 +212,12 @@ pub async fn get_wto_eping_members(
args.push(l.to_string());
}
- execute_wto_command("eping_members".to_string(), args).await
+ execute_wto_command(app, "eping_members".to_string(), args).await
}
/// Search ePing notifications
#[tauri::command]
-pub async fn search_wto_eping_notifications(
+pub async fn search_wto_eping_notifications(app: tauri::AppHandle,
language: Option<i32>,
domain_ids: Option<i32>,
document_symbol: Option<String>,
@@ -288,14 +287,14 @@ pub async fn search_wto_eping_notifications(
args.push(ps.to_string());
}
- execute_wto_command("eping_search".to_string(), args).await
+ execute_wto_command(app, "eping_search".to_string(), args).await
}
// TIMESERIES API COMMANDS
/// Get timeseries topics
#[tauri::command]
-pub async fn get_wto_timeseries_topics(
+pub async fn get_wto_timeseries_topics(app: tauri::AppHandle,
language: Option<i32>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -305,12 +304,12 @@ pub async fn get_wto_timeseries_topics(
args.push(l.to_string());
}
- execute_wto_command("timeseries_topics".to_string(), args).await
+ execute_wto_command(app, "timeseries_topics".to_string(), args).await
}
/// Get timeseries indicators
#[tauri::command]
-pub async fn get_wto_timeseries_indicators(
+pub async fn get_wto_timeseries_indicators(app: tauri::AppHandle,
indicator: Option<String>,
name: Option<String>,
topics: Option<String>,
@@ -356,12 +355,12 @@ pub async fn get_wto_timeseries_indicators(
args.push(l.to_string());
}
- execute_wto_command("timeseries_indicators".to_string(), args).await
+ execute_wto_command(app, "timeseries_indicators".to_string(), args).await
}
/// Get timeseries data
#[tauri::command]
-pub async fn get_wto_timeseries_data(
+pub async fn get_wto_timeseries_data(app: tauri::AppHandle,
indicator: String,
reporters: Option<String>,
partners: Option<String>,
@@ -444,12 +443,12 @@ pub async fn get_wto_timeseries_data(
args.push(im.to_string());
}
- execute_wto_command("timeseries_data".to_string(), args).await
+ execute_wto_command(app, "timeseries_data".to_string(), args).await
}
/// Get timeseries reporting economies
#[tauri::command]
-pub async fn get_wto_timeseries_reporters(
+pub async fn get_wto_timeseries_reporters(app: tauri::AppHandle,
name: Option<String>,
individual_group: Option<String>,
regions: Option<String>,
@@ -483,14 +482,14 @@ pub async fn get_wto_timeseries_reporters(
args.push(l.to_string());
}
- execute_wto_command("timeseries_reporters".to_string(), args).await
+ execute_wto_command(app, "timeseries_reporters".to_string(), args).await
}
// TFAD (TRADE FACILITATION AGREEMENT DATABASE) COMMANDS
/// Get TFAD data
#[tauri::command]
-pub async fn get_wto_tfad_data(
+pub async fn get_wto_tfad_data(app: tauri::AppHandle,
countries: Option<String>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -500,14 +499,14 @@ pub async fn get_wto_tfad_data(
args.push(c);
}
- execute_wto_command("tfad_data".to_string(), args).await
+ execute_wto_command(app, "tfad_data".to_string(), args).await
}
// ANALYSIS COMMANDS
/// Get trade restrictions analysis
#[tauri::command]
-pub async fn get_wto_trade_restrictions_analysis(
+pub async fn get_wto_trade_restrictions_analysis(app: tauri::AppHandle,
member_code: Option<String>,
) -> Result<String, String> {
let mut args = Vec::new();
@@ -517,12 +516,12 @@ pub async fn get_wto_trade_restrictions_analysis(
args.push(mc);
}
- execute_wto_command("trade_restrictions_analysis".to_string(), args).await
+ execute_wto_command(app, "trade_restrictions_analysis".to_string(), args).await
}
/// Get notifications analysis
#[tauri::command]
-pub async fn get_wto_notifications_analysis(
+pub async fn get_wto_notifications_analysis(app: tauri::AppHandle,
language: Option<i32>,
domain_ids: Option<i32>,
date_from: Option<String>,
@@ -550,12 +549,12 @@ pub async fn get_wto_notifications_analysis(
args.push(dt);
}
- execute_wto_command("notifications_analysis".to_string(), args).await
+ execute_wto_command(app, "notifications_analysis".to_string(), args).await
}
/// Get trade statistics analysis
#[tauri::command]
-pub async fn get_wto_trade_statistics_analysis(
+pub async fn get_wto_trade_statistics_analysis(app: tauri::AppHandle,
indicator: Option<String>,
reporter: Option<String>,
years: Option<String>,
@@ -577,12 +576,12 @@ pub async fn get_wto_trade_statistics_analysis(
args.push(y);
}
- execute_wto_command("trade_statistics_analysis".to_string(), args).await
+ execute_wto_command(app, "trade_statistics_analysis".to_string(), args).await
}
/// Get comprehensive WTO analysis
#[tauri::command]
-pub async fn get_wto_comprehensive_analysis(
+pub async fn get_wto_comprehensive_analysis(app: tauri::AppHandle,
member_code: Option<String>,
indicator: Option<String>,
) -> Result<String, String> {
@@ -598,15 +597,16 @@ pub async fn get_wto_comprehensive_analysis(
args.push(i);
}
- execute_wto_command("comprehensive_analysis".to_string(), args).await
+ execute_wto_command(app, "comprehensive_analysis".to_string(), args).await
}
// CONVENIENCE COMMANDS FOR MAJOR ECONOMIES
/// Get US trade data analysis
#[tauri::command]
-pub async fn get_wto_us_trade_analysis() -> Result<String, String> {
+pub async fn get_wto_us_trade_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
get_wto_trade_statistics_analysis(
+ app,
Some("TP_A_0010".to_string()),
Some("US".to_string()),
Some("2020-2023".to_string())
@@ -615,8 +615,9 @@ pub async fn get_wto_us_trade_analysis() -> Result<String, String> {
/// Get China trade data analysis
#[tauri::command]
-pub async fn get_wto_china_trade_analysis() -> Result<String, String> {
+pub async fn get_wto_china_trade_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
get_wto_trade_statistics_analysis(
+ app,
Some("TP_A_0010".to_string()),
Some("CN".to_string()),
Some("2020-2023".to_string())
@@ -625,8 +626,9 @@ pub async fn get_wto_china_trade_analysis() -> Result<String, String> {
/// Get Germany trade data analysis
#[tauri::command]
-pub async fn get_wto_germany_trade_analysis() -> Result<String, String> {
+pub async fn get_wto_germany_trade_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
get_wto_trade_statistics_analysis(
+ app,
Some("TP_A_0010".to_string()),
Some("DE".to_string()),
Some("2020-2023".to_string())
@@ -635,8 +637,9 @@ pub async fn get_wto_germany_trade_analysis() -> Result<String, String> {
/// Get Japan trade data analysis
#[tauri::command]
-pub async fn get_wto_japan_trade_analysis() -> Result<String, String> {
+pub async fn get_wto_japan_trade_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
get_wto_trade_statistics_analysis(
+ app,
Some("TP_A_0010".to_string()),
Some("JP".to_string()),
Some("2020-2023".to_string())
@@ -645,8 +648,9 @@ pub async fn get_wto_japan_trade_analysis() -> Result<String, String> {
/// Get UK trade data analysis
#[tauri::command]
-pub async fn get_wto_uk_trade_analysis() -> Result<String, String> {
+pub async fn get_wto_uk_trade_analysis(app: tauri::AppHandle, ) -> Result<String, String> {
get_wto_trade_statistics_analysis(
+ app,
Some("TP_A_0010".to_string()),
Some("GB".to_string()),
Some("2020-2023".to_string())
@@ -657,7 +661,7 @@ pub async fn get_wto_uk_trade_analysis() -> Result<String, String> {
/// Get recent TBT notifications
#[tauri::command]
-pub async fn get_wto_recent_tbt_notifications(
+pub async fn get_wto_recent_tbt_notifications(app: tauri::AppHandle,
days_back: Option<i32>,
) -> Result<String, String> {
let days = days_back.unwrap_or(30);
@@ -665,6 +669,7 @@ pub async fn get_wto_recent_tbt_notifications(
let date_from = (chrono::Utc::now() - chrono::Duration::days(days as i64)).format("%Y-%m-%d").to_string();
search_wto_eping_notifications(
+ app,
Some(1), // English
Some(1), // TBT domain
None,
@@ -681,7 +686,7 @@ pub async fn get_wto_recent_tbt_notifications(
/// Get recent SPS notifications
#[tauri::command]
-pub async fn get_wto_recent_sps_notifications(
+pub async fn get_wto_recent_sps_notifications(app: tauri::AppHandle,
days_back: Option<i32>,
) -> Result<String, String> {
let days = days_back.unwrap_or(30);
@@ -689,6 +694,7 @@ pub async fn get_wto_recent_sps_notifications(
let date_from = (chrono::Utc::now() - chrono::Duration::days(days as i64)).format("%Y-%m-%d").to_string();
search_wto_eping_notifications(
+ app,
Some(1), // English
Some(2), // SPS domain
None,
@@ -705,10 +711,11 @@ pub async fn get_wto_recent_sps_notifications(
/// Get member specific comprehensive analysis
#[tauri::command]
-pub async fn get_wto_member_analysis(
+pub async fn get_wto_member_analysis(app: tauri::AppHandle,
member_code: String,
) -> Result<String, String> {
get_wto_comprehensive_analysis(
+ app,
Some(member_code),
Some("TP_A_0010".to_string())
).await
@@ -716,11 +723,12 @@ pub async fn get_wto_member_analysis(
/// Get global trade overview
#[tauri::command]
-pub async fn get_wto_global_trade_overview() -> Result<String, String> {
+pub async fn get_wto_global_trade_overview(app: tauri::AppHandle, ) -> Result<String, String> {
let mut results = Vec::new();
// Get timeseries data for global trade
match get_wto_timeseries_data(
+ app.clone(),
"TP_A_0010".to_string(), // Merchandise trade value
Some("all".to_string()),
Some("all".to_string()),
@@ -741,12 +749,12 @@ pub async fn get_wto_global_trade_overview() -> Result<String, String> {
}
// Get recent notifications
- match get_wto_recent_tbt_notifications(Some(7)).await {
+ match get_wto_recent_tbt_notifications(app.clone(), Some(7)).await {
Ok(data) => results.push(("recent_tbt_notifications".to_string(), data)),
Err(e) => results.push(("recent_tbt_notifications".to_string(), format!("Error: {}", e))),
}
- match get_wto_recent_sps_notifications(Some(7)).await {
+ match get_wto_recent_sps_notifications(app.clone(), Some(7)).await {
Ok(data) => results.push(("recent_sps_notifications".to_string(), data)),
Err(e) => results.push(("recent_sps_notifications".to_string(), format!("Error: {}", e))),
}
@@ -760,7 +768,7 @@ pub async fn get_wto_global_trade_overview() -> Result<String, String> {
/// Get sector-specific trade analysis
#[tauri::command]
-pub async fn get_wto_sector_trade_analysis(
+pub async fn get_wto_sector_trade_analysis(app: tauri::AppHandle,
sector_codes: String,
reporter: Option<String>,
years: Option<String>,
@@ -773,6 +781,7 @@ pub async fn get_wto_sector_trade_analysis(
for sector in sectors {
let trimmed_sector = sector.trim();
match get_wto_timeseries_data(
+ app.clone(),
format!("TP_S_{}", trimmed_sector),
reporter.clone(),
Some("default".to_string()),
@@ -805,7 +814,7 @@ pub async fn get_wto_sector_trade_analysis(
/// Get comparative trade analysis between economies
#[tauri::command]
-pub async fn get_wto_comparative_trade_analysis(
+pub async fn get_wto_comparative_trade_analysis(app: tauri::AppHandle,
economies: String,
indicator: Option<String>,
years: Option<String>,
@@ -821,6 +830,7 @@ pub async fn get_wto_comparative_trade_analysis(
for economy in economy_list {
let trimmed_economy = economy.trim();
match get_wto_timeseries_data(
+ app.clone(),
indicator_code.clone(),
Some(trimmed_economy.to_string()),
Some("all".to_string()),
diff --git a/fincept-terminal-desktop/src-tauri/src/commands/yfinance.rs b/fincept-terminal-desktop/src-tauri/src/commands/yfinance.rs
index 9313e1df9..c0a9147a7 100644
--- a/fincept-terminal-desktop/src-tauri/src/commands/yfinance.rs
+++ b/fincept-terminal-desktop/src-tauri/src/commands/yfinance.rs
@@ -1,33 +1,23 @@
// Yahoo Finance data commands
use std::process::Command;
+use crate::utils::python::{get_python_path, get_script_path};
/// Execute Yahoo Finance Python script command
#[tauri::command]
pub async fn execute_yfinance_command(
+ app: tauri::AppHandle,
command: String,
args: Vec<String>,
) -> Result<String, String> {
- // Get the Python script path
- let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
- let script_path = manifest_dir
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- // Verify script exists
- if !script_path.exists() {
- return Err(format!(
- "YFinance script not found at: {}",
- script_path.display()
- ));
- }
+ let python_path = get_python_path(&app)?;
+ let script_path = get_script_path(&app, "yfinance_data.py")?;
// Build command arguments
let mut cmd_args = vec![script_path.to_string_lossy().to_string(), command];
cmd_args.extend(args);
// Execute Python script
- let output = Command::new("python")
+ let output = Command::new(&python_path)
.args(&cmd_args)
.output()
.map_err(|e| format!("Failed to execute command: {}", e))?;
diff --git a/fincept-terminal-desktop/src-tauri/src/data_sources/yfinance.rs b/fincept-terminal-desktop/src-tauri/src/data_sources/yfinance.rs
index 1b55b973d..9cdb15ed1 100644
--- a/fincept-terminal-desktop/src-tauri/src/data_sources/yfinance.rs
+++ b/fincept-terminal-desktop/src-tauri/src/data_sources/yfinance.rs
@@ -4,6 +4,7 @@
use serde::{Deserialize, Serialize};
use anyhow::{Result, Context};
use std::process::Command;
+use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuoteData {
@@ -31,12 +32,23 @@ pub struct HistoricalData {
pub adj_close: f64,
}
-pub struct YFinanceProvider {}
+pub struct YFinanceProvider {
+ python_path: PathBuf,
+ script_path: PathBuf,
+}
impl YFinanceProvider {
- /// Create a new YFinance provider instance
- pub fn new() -> Self {
- Self {}
+ /// Create a new YFinance provider instance with runtime paths
+ pub fn new(app: &tauri::AppHandle) -> Result<Self> {
+ let python_path = crate::utils::python::get_python_path(app)
+ .map_err(|e| anyhow::anyhow!(e))?;
+ let script_path = crate::utils::python::get_script_path(app, "yfinance_data.py")
+ .map_err(|e| anyhow::anyhow!(e))?;
+
+ Ok(Self {
+ python_path,
+ script_path,
+ })
}
/// Fetch real-time quote for a single symbol
@@ -62,18 +74,8 @@ impl YFinanceProvider {
/// Internal batch fetch method - calls Python yfinance script with multiple symbols
async fn fetch_batch_quotes(&self, symbols: Vec<String>) -> Result<Vec<QuoteData>> {
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
-
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- let mut cmd = Command::new(&python_path);
- cmd.arg(&script_path).arg("batch_quotes");
+ let mut cmd = Command::new(&self.python_path);
+ cmd.arg(&self.script_path).arg("batch_quotes");
for symbol in symbols {
cmd.arg(symbol);
@@ -97,19 +99,8 @@ impl YFinanceProvider {
/// Internal fetch method - calls Python yfinance script
async fn fetch_quote(&self, symbol: &str) -> Result<QuoteData> {
- // Use absolute path from project root
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
-
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- let output = Command::new(&python_path)
- .arg(&script_path)
+ let output = Command::new(&self.python_path)
+ .arg(&self.script_path)
.arg("quote")
.arg(symbol)
.output()
@@ -151,18 +142,8 @@ impl YFinanceProvider {
start_date: &str,
end_date: &str,
) -> Result<Vec<HistoricalData>> {
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
-
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- let output = Command::new(&python_path)
- .arg(&script_path)
+ let output = Command::new(&self.python_path)
+ .arg(&self.script_path)
.arg("historical")
.arg(symbol)
.arg(start_date)
@@ -234,18 +215,8 @@ impl YFinanceProvider {
/// Internal info fetch method - calls Python yfinance script
async fn fetch_info(&self, symbol: &str) -> Result<serde_json::Value> {
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
-
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- let output = Command::new(&python_path)
- .arg(&script_path)
+ let output = Command::new(&self.python_path)
+ .arg(&self.script_path)
.arg("info")
.arg(symbol)
.output()
@@ -273,18 +244,8 @@ impl YFinanceProvider {
/// Internal financials fetch method - calls Python yfinance script
async fn fetch_financials(&self, symbol: &str) -> Result<serde_json::Value> {
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
-
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join("yfinance_data.py");
-
- let output = Command::new(&python_path)
- .arg(&script_path)
+ let output = Command::new(&self.python_path)
+ .arg(&self.script_path)
.arg("financials")
.arg(symbol)
.output()
@@ -303,11 +264,7 @@ impl YFinanceProvider {
}
}
-impl Default for YFinanceProvider {
- fn default() -> Self {
- Self::new()
- }
-}
+// Removed Default implementation - requires AppHandle
#[cfg(test)]
mod tests {
diff --git a/fincept-terminal-desktop/src-tauri/src/lib.rs b/fincept-terminal-desktop/src-tauri/src/lib.rs
index 5631793ed..5b22a19a0 100644
--- a/fincept-terminal-desktop/src-tauri/src/lib.rs
+++ b/fincept-terminal-desktop/src-tauri/src/lib.rs
@@ -10,6 +10,7 @@ use sha2::{Sha256, Digest};
// Data sources and commands modules
mod data_sources;
mod commands;
+mod utils;
// Global state to manage MCP server processes
struct MCPState {
@@ -202,21 +203,26 @@ fn sha256_hash(input: String) -> String {
// Execute Python script with arguments and environment variables
#[tauri::command]
fn execute_python_script(
+ app: tauri::AppHandle,
script_name: String,
args: Vec<String>,
env: Option<HashMap<String, String>>,
) -> Result<String, String> {
println!("[Tauri] Executing Python script: {} with args: {:?}", script_name, args);
- let python_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("python")
- .join("python.exe");
+ let python_path = utils::python::get_python_path(&app)?;
+ let script_path = utils::python::get_script_path(&app, &script_name)?;
- let script_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
- .join("resources")
- .join("scripts")
- .join(&script_name);
+ println!("[Tauri] Python path: {:?}", python_path);
+ println!("[Tauri] Script path: {:?}", script_path);
+
+ // Verify paths exist
+ if !python_path.exists() {
+ return Err(format!("Python executable not found at: {:?}", python_path));
+ }
+ if !script_path.exists() {
+ return Err(format!("Script not found at: {:?}", script_path));
+ }
let mut cmd = Command::new(&python_path);
cmd.arg(&script_path).args(&args);
@@ -675,7 +681,114 @@ pub fn run() {
commands::oscar::oscar_get_instrument_types,
commands::oscar::oscar_search_weather_instruments,
commands::oscar::oscar_get_climate_monitoring_instruments,
- commands::oscar::oscar_get_overview_statistics
+ commands::oscar::oscar_get_overview_statistics,
+ // FRED (Federal Reserve Economic Data) Commands
+ commands::fred::execute_fred_command,
+ commands::fred::get_fred_series,
+ commands::fred::search_fred_series,
+ commands::fred::get_fred_series_info,
+ commands::fred::get_fred_category,
+ commands::fred::get_fred_multiple_series,
+ // CoinGecko Commands
+ commands::coingecko::execute_coingecko_command,
+ commands::coingecko::get_coingecko_price,
+ commands::coingecko::get_coingecko_market_data,
+ commands::coingecko::get_coingecko_historical,
+ commands::coingecko::search_coingecko_coins,
+ commands::coingecko::get_coingecko_trending,
+ commands::coingecko::get_coingecko_global_data,
+ commands::coingecko::get_coingecko_top_coins,
+ // World Bank Commands
+ commands::worldbank::execute_worldbank_command,
+ commands::worldbank::get_worldbank_indicator,
+ commands::worldbank::search_worldbank_indicators,
+ commands::worldbank::get_worldbank_country_info,
+ commands::worldbank::get_worldbank_countries,
+ commands::worldbank::get_worldbank_gdp,
+ commands::worldbank::get_worldbank_economic_overview,
+ commands::worldbank::get_worldbank_development_indicators,
+ // Trading Economics Commands
+ commands::trading_economics::execute_trading_economics_command,
+ commands::trading_economics::get_trading_economics_indicators,
+ commands::trading_economics::get_trading_economics_historical,
+ commands::trading_economics::get_trading_economics_calendar,
+ commands::trading_economics::get_trading_economics_markets,
+ commands::trading_economics::get_trading_economics_ratings,
+ commands::trading_economics::get_trading_economics_forecasts,
+ // EconDB Commands
+ commands::econdb::execute_econdb_command,
+ commands::econdb::get_econdb_series,
+ commands::econdb::search_econdb_indicators,
+ commands::econdb::get_econdb_datasets,
+ commands::econdb::get_econdb_country_data,
+ commands::econdb::get_econdb_multiple_series,
+ // Canada Government Commands
+ commands::canada_gov::execute_canada_gov_command,
+ commands::canada_gov::search_canada_gov_datasets,
+ commands::canada_gov::get_canada_gov_dataset,
+ commands::canada_gov::get_canada_gov_economic_data,
+ // UK Government Commands
+ commands::datagovuk::execute_datagovuk_command,
+ commands::datagovuk::search_datagovuk_datasets,
+ commands::datagovuk::get_datagovuk_dataset,
+ // Australian Government Commands
+ commands::datagov_au::execute_datagov_au_command,
+ commands::datagov_au::search_datagov_au_datasets,
+ commands::datagov_au::get_datagov_au_dataset,
+ // Japan Statistics Commands
+ commands::estat_japan::execute_estat_japan_command,
+ commands::estat_japan::get_estat_japan_data,
+ commands::estat_japan::search_estat_japan_stats,
+ // German Government Commands
+ commands::govdata_de::execute_govdata_de_command,
+ commands::govdata_de::search_govdata_de_datasets,
+ commands::govdata_de::get_govdata_de_dataset,
+ // Singapore Government Commands
+ commands::datagovsg::execute_datagovsg_command,
+ commands::datagovsg::search_datagovsg_datasets,
+ commands::datagovsg::get_datagovsg_dataset,
+ // Hong Kong Government Commands
+ commands::data_gov_hk::execute_data_gov_hk_command,
+ commands::data_gov_hk::search_data_gov_hk_datasets,
+ commands::data_gov_hk::get_data_gov_hk_dataset,
+ // French Government Commands
+ commands::french_gov::execute_french_gov_command,
+ commands::french_gov::search_french_gov_datasets,
+ commands::french_gov::get_french_gov_dataset,
+ // Swiss Government Commands
+ commands::swiss_gov::execute_swiss_gov_command,
+ commands::swiss_gov::search_swiss_gov_datasets,
+ commands::swiss_gov::get_swiss_gov_dataset,
+ // Spain Data Commands
+ commands::spain_data::execute_spain_data_command,
+ commands::spain_data::get_spain_economic_data,
+ commands::spain_data::search_spain_datasets,
+ // Asian Development Bank Commands
+ commands::adb::execute_adb_command,
+ commands::adb::get_adb_indicators,
+ commands::adb::search_adb_datasets,
+ commands::adb::get_adb_development_data,
+ // OpenAFRICA Commands
+ commands::openafrica::execute_openafrica_command,
+ commands::openafrica::search_openafrica_datasets,
+ commands::openafrica::get_openafrica_dataset,
+ commands::openafrica::get_openafrica_country_datasets,
+ // Economic Calendar Commands
+ commands::economic_calendar::execute_economic_calendar_command,
+ commands::economic_calendar::get_economic_calendar_today,
+ commands::economic_calendar::get_economic_calendar_upcoming,
+ commands::economic_calendar::get_economic_calendar_by_country,
+ commands::economic_calendar::get_economic_calendar_high_impact,
+ // Databento Commands
+ commands::databento::execute_databento_command,
+ commands::databento::get_databento_market_data,
+ commands::databento::get_databento_datasets,
+ commands::databento::get_databento_historical,
+ // Sentinel Hub Commands
+ commands::sentinelhub::execute_sentinelhub_command,
+ commands::sentinelhub::get_sentinelhub_imagery,
+ commands::sentinelhub::get_sentinelhub_collections,
+ commands::sentinelhub::search_sentinelhub_data
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
diff --git a/fincept-terminal-desktop/src-tauri/src/utils/mod.rs b/fincept-terminal-desktop/src-tauri/src/utils/mod.rs
new file mode 100644
index 000000000..c0a088c75
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/utils/mod.rs
@@ -0,0 +1 @@
+pub mod python;
diff --git a/fincept-terminal-desktop/src-tauri/src/utils/python.rs b/fincept-terminal-desktop/src-tauri/src/utils/python.rs
new file mode 100644
index 000000000..966a21f6d
--- /dev/null
+++ b/fincept-terminal-desktop/src-tauri/src/utils/python.rs
@@ -0,0 +1,35 @@
+// Utility module for Python execution path resolution
+use std::path::PathBuf;
+use tauri::Manager;
+
+/// Get the Python executable path at runtime
+pub fn get_python_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
+ let resource_dir = app
+ .path()
+ .resource_dir()
+ .map_err(|e| format!("Failed to get resource directory: {}", e))?;
+
+ let python_exe = if cfg!(target_os = "windows") {
+ "python.exe"
+ } else {
+ "python"
+ };
+
+ Ok(resource_dir
+ .join("resources")
+ .join("python")
+ .join(python_exe))
+}
+
+/// Get a Python script path at runtime
+pub fn get_script_path(app: &tauri::AppHandle, script_name: &str) -> Result<PathBuf, String> {
+ let resource_dir = app
+ .path()
+ .resource_dir()
+ .map_err(|e| format!("Failed to get resource directory: {}", e))?;
+
+ Ok(resource_dir
+ .join("resources")
+ .join("scripts")
+ .join(script_name))
+}