cryptoagent


Namecryptoagent JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/The-Swarm-Corporation/CryptoAgent
Summarycryptoagent - Swarms
upload_time2024-09-27 03:02:37
maintainerNone
docs_urlNone
authorKye Gomez
requires_python<4.0,>=3.10
licenseMIT
keywords artificial intelligence deep learning optimizers prompt engineering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Multi-Modality](agorabanner.png)](https://discord.com/servers/agora-999382051935506503)

# CryptoAgent: Real-Time Cryptocurrency Data Analysis Agent

[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)


CryptoAgent is a professional, enterprise-grade solution designed to fetch, analyze, and summarize real-time cryptocurrency data. It integrates with CoinGecko's API to retrieve the latest crypto metrics and leverages OpenAI's advanced language model to generate insightful, concise reports tailored for crypto investors and financial analysts.

## Key Features

- **Real-Time Data Fetching**: Retrieves live cryptocurrency data, including current price, market capitalization, trading volume, supply details, and recent price changes.
- **Advanced Analysis**: Summarizes complex crypto data into clear, actionable insights, allowing users to stay informed on key market trends.
- **Enterprise-Grade Reliability**: Built with robust error handling, retries, and logging to ensure uninterrupted data retrieval and analysis.
- **Customizable Reports**: Designed to provide tailored insights based on user requirements, making it suitable for investors, traders, and analysts.

## Use Cases

- **Market Monitoring**: Track real-time prices and key metrics for any cryptocurrency.
- **Investment Research**: Generate comprehensive reports on specific coins, including trends, market sentiment, and price changes.
- **Financial Analysis**: Use CryptoAgent to analyze large volumes of crypto data, summarize trends, and provide strategic insights.

## Installation


## Usage

```python
import os
from cryptoagent.main import OpenAIChat
from swarms import Agent
from cryptoagent.main import CryptoAnalysis

# Create an instance of the OpenAIChat class for LLM integration
api_key = os.getenv("OPENAI_API_KEY")
model = OpenAIChat(
    openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1
)

# Create the input agent
input_agent = Agent(
    agent_name="Crypto-Analysis-Agent",
    system_prompt="You are a financial analysis agent that provides crypto analysis with live data.",
    llm=model,
    max_loops=1,
    autosave=True,
    dashboard=False,
    verbose=True,
    dynamic_temperature_enabled=True,
    saved_state_path="crypto_agent.json",
    user_name="swarms_corp",
    retry_attempts=2,
    context_length=10000,
)

# Create CryptoAnalysis instance and pass the input agent
crypto_analyzer = CryptoAnalysis(agent=input_agent)

# Example coin IDs to summarize multiple coins
coin_ids = ["bitcoin", "ethereum", "dogecoin", "xrp"]

# Fetch and summarize crypto data for multiple coins in parallel
summaries = crypto_analyzer.run(coin_ids)

# Print the summaries
for summary in summaries:
    print(summary)
```

## Components Overview

### 1. **CryptoTool**
`CryptoTool` integrates with CoinGecko's API to fetch real-time cryptocurrency data. It provides detailed information such as:

- Current price
- Market capitalization
- 24-hour trading volume
- Circulating and total supply
- Price changes over 24 hours

Example of fetching data for a cryptocurrency:

```python
crypto_tool = CryptoTool()
crypto_data = crypto_tool.get_crypto_data("bitcoin")
```

### 2. **CryptoAnalysisAgent**
`CryptoAnalysisAgent` is the core component that combines data fetching with advanced analysis. It generates custom prompts for OpenAI's GPT-4 model, enabling deeper insights into the fetched data.

Example of running the agent:

```python
agent = CryptoAnalysisAgent(
    agent_name="Crypto-Analysis-Agent",
    system_prompt=CRYPTO_AGENT_SYS_PROMPT,
    llm=model
)

# Fetch and analyze Bitcoin data
response = agent.run("Analyze the recent price changes and trends of Bitcoin.", "bitcoin")
print(response)
```

### 3. **Loguru for Logging**
The `loguru` library is integrated for real-time logging, making it easy to trace operations, handle errors, and ensure transparency in the data pipeline.

Example of error handling:

```python
try:
    response = requests.get(self.api_url, params=params)
    response.raise_for_status()
except requests.RequestException as e:
    logger.error(f"Error fetching crypto data: {e}")
```

## System Architecture

CryptoAgent follows a modular architecture:

- **CryptoTool** handles all interactions with the CoinGecko API.
- **CryptoAnalysisAgent** performs the crypto analysis by combining data fetched from the API with OpenAI's powerful language models.
- **Agent Framework**: The agent architecture, powered by `swarms`, ensures flexibility, scalability, and reliability for enterprise deployments.

## Enterprise-Grade Features

- **Scalability**: Easily integrates into larger infrastructures for monitoring hundreds of cryptocurrencies simultaneously.
- **Error Handling and Retries**: Built-in mechanisms for handling API failures and retrying failed requests ensure uninterrupted service.
- **Customization**: Modify the system prompt to tailor the analysis to specific use cases, whether it’s for a hedge fund, a financial institution, or individual investors.
- **Security**: Sensitive API keys and environment variables are securely managed via `.env` and best practices for API management.

## Getting Started

1. **Prerequisites**: Ensure you have Python 3.8+ installed.
2. **API Access**: You’ll need an OpenAI API key to interact with the model.
3. **Run the Agent**: Follow the instructions in the [Installation](#installation) section to set up and run CryptoAgent.

## Sample Output

```text
Coin: Bitcoin (BTC)
Current Price: $45,320.12
Market Cap: $853,000,000,000
24h Trading Volume: $32,000,000,000
Circulating Supply: 18,700,000 BTC
Total Supply: N/A
Price Change (24h): +4.2%

Analysis: Bitcoin has seen a significant price increase of 4.2% over the past 24 hours, driven by increased trading volume. The market cap remains strong, reflecting continued investor confidence.
```

## Future Enhancements

- **Multi-Coin Analysis**: Enable simultaneous analysis of multiple cryptocurrencies for portfolio managers.
- **Sentiment Analysis**: Incorporate social media and news sentiment analysis into the crypto reports.
- **Predictive Analytics**: Add a layer of predictive insights using historical data to forecast market trends.
  
## Contributing

We welcome contributions from the community! Please follow our [contribution guidelines](CONTRIBUTING.md) and submit pull requests.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contact

For enterprise inquiries, custom deployments, or support, please contact [support@cryptoagent.io](mailto:support@cryptoagent.io).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/The-Swarm-Corporation/CryptoAgent",
    "name": "cryptoagent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, optimizers, Prompt Engineering",
    "author": "Kye Gomez",
    "author_email": "kye@apac.ai",
    "download_url": "https://files.pythonhosted.org/packages/96/a2/2130c25f206aecfa3eb3bcd596452e24c4e21531bc67592b90405ea53e11/cryptoagent-0.0.1.tar.gz",
    "platform": null,
    "description": "[![Multi-Modality](agorabanner.png)](https://discord.com/servers/agora-999382051935506503)\n\n# CryptoAgent: Real-Time Cryptocurrency Data Analysis Agent\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge&logo=x&logoColor=white)](https://x.com/kyegomezb)\n\n\nCryptoAgent is a professional, enterprise-grade solution designed to fetch, analyze, and summarize real-time cryptocurrency data. It integrates with CoinGecko's API to retrieve the latest crypto metrics and leverages OpenAI's advanced language model to generate insightful, concise reports tailored for crypto investors and financial analysts.\n\n## Key Features\n\n- **Real-Time Data Fetching**: Retrieves live cryptocurrency data, including current price, market capitalization, trading volume, supply details, and recent price changes.\n- **Advanced Analysis**: Summarizes complex crypto data into clear, actionable insights, allowing users to stay informed on key market trends.\n- **Enterprise-Grade Reliability**: Built with robust error handling, retries, and logging to ensure uninterrupted data retrieval and analysis.\n- **Customizable Reports**: Designed to provide tailored insights based on user requirements, making it suitable for investors, traders, and analysts.\n\n## Use Cases\n\n- **Market Monitoring**: Track real-time prices and key metrics for any cryptocurrency.\n- **Investment Research**: Generate comprehensive reports on specific coins, including trends, market sentiment, and price changes.\n- **Financial Analysis**: Use CryptoAgent to analyze large volumes of crypto data, summarize trends, and provide strategic insights.\n\n## Installation\n\n\n## Usage\n\n```python\nimport os\nfrom cryptoagent.main import OpenAIChat\nfrom swarms import Agent\nfrom cryptoagent.main import CryptoAnalysis\n\n# Create an instance of the OpenAIChat class for LLM integration\napi_key = os.getenv(\"OPENAI_API_KEY\")\nmodel = OpenAIChat(\n    openai_api_key=api_key, model_name=\"gpt-4o-mini\", temperature=0.1\n)\n\n# Create the input agent\ninput_agent = Agent(\n    agent_name=\"Crypto-Analysis-Agent\",\n    system_prompt=\"You are a financial analysis agent that provides crypto analysis with live data.\",\n    llm=model,\n    max_loops=1,\n    autosave=True,\n    dashboard=False,\n    verbose=True,\n    dynamic_temperature_enabled=True,\n    saved_state_path=\"crypto_agent.json\",\n    user_name=\"swarms_corp\",\n    retry_attempts=2,\n    context_length=10000,\n)\n\n# Create CryptoAnalysis instance and pass the input agent\ncrypto_analyzer = CryptoAnalysis(agent=input_agent)\n\n# Example coin IDs to summarize multiple coins\ncoin_ids = [\"bitcoin\", \"ethereum\", \"dogecoin\", \"xrp\"]\n\n# Fetch and summarize crypto data for multiple coins in parallel\nsummaries = crypto_analyzer.run(coin_ids)\n\n# Print the summaries\nfor summary in summaries:\n    print(summary)\n```\n\n## Components Overview\n\n### 1. **CryptoTool**\n`CryptoTool` integrates with CoinGecko's API to fetch real-time cryptocurrency data. It provides detailed information such as:\n\n- Current price\n- Market capitalization\n- 24-hour trading volume\n- Circulating and total supply\n- Price changes over 24 hours\n\nExample of fetching data for a cryptocurrency:\n\n```python\ncrypto_tool = CryptoTool()\ncrypto_data = crypto_tool.get_crypto_data(\"bitcoin\")\n```\n\n### 2. **CryptoAnalysisAgent**\n`CryptoAnalysisAgent` is the core component that combines data fetching with advanced analysis. It generates custom prompts for OpenAI's GPT-4 model, enabling deeper insights into the fetched data.\n\nExample of running the agent:\n\n```python\nagent = CryptoAnalysisAgent(\n    agent_name=\"Crypto-Analysis-Agent\",\n    system_prompt=CRYPTO_AGENT_SYS_PROMPT,\n    llm=model\n)\n\n# Fetch and analyze Bitcoin data\nresponse = agent.run(\"Analyze the recent price changes and trends of Bitcoin.\", \"bitcoin\")\nprint(response)\n```\n\n### 3. **Loguru for Logging**\nThe `loguru` library is integrated for real-time logging, making it easy to trace operations, handle errors, and ensure transparency in the data pipeline.\n\nExample of error handling:\n\n```python\ntry:\n    response = requests.get(self.api_url, params=params)\n    response.raise_for_status()\nexcept requests.RequestException as e:\n    logger.error(f\"Error fetching crypto data: {e}\")\n```\n\n## System Architecture\n\nCryptoAgent follows a modular architecture:\n\n- **CryptoTool** handles all interactions with the CoinGecko API.\n- **CryptoAnalysisAgent** performs the crypto analysis by combining data fetched from the API with OpenAI's powerful language models.\n- **Agent Framework**: The agent architecture, powered by `swarms`, ensures flexibility, scalability, and reliability for enterprise deployments.\n\n## Enterprise-Grade Features\n\n- **Scalability**: Easily integrates into larger infrastructures for monitoring hundreds of cryptocurrencies simultaneously.\n- **Error Handling and Retries**: Built-in mechanisms for handling API failures and retrying failed requests ensure uninterrupted service.\n- **Customization**: Modify the system prompt to tailor the analysis to specific use cases, whether it\u2019s for a hedge fund, a financial institution, or individual investors.\n- **Security**: Sensitive API keys and environment variables are securely managed via `.env` and best practices for API management.\n\n## Getting Started\n\n1. **Prerequisites**: Ensure you have Python 3.8+ installed.\n2. **API Access**: You\u2019ll need an OpenAI API key to interact with the model.\n3. **Run the Agent**: Follow the instructions in the [Installation](#installation) section to set up and run CryptoAgent.\n\n## Sample Output\n\n```text\nCoin: Bitcoin (BTC)\nCurrent Price: $45,320.12\nMarket Cap: $853,000,000,000\n24h Trading Volume: $32,000,000,000\nCirculating Supply: 18,700,000 BTC\nTotal Supply: N/A\nPrice Change (24h): +4.2%\n\nAnalysis: Bitcoin has seen a significant price increase of 4.2% over the past 24 hours, driven by increased trading volume. The market cap remains strong, reflecting continued investor confidence.\n```\n\n## Future Enhancements\n\n- **Multi-Coin Analysis**: Enable simultaneous analysis of multiple cryptocurrencies for portfolio managers.\n- **Sentiment Analysis**: Incorporate social media and news sentiment analysis into the crypto reports.\n- **Predictive Analytics**: Add a layer of predictive insights using historical data to forecast market trends.\n  \n## Contributing\n\nWe welcome contributions from the community! Please follow our [contribution guidelines](CONTRIBUTING.md) and submit pull requests.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nFor enterprise inquiries, custom deployments, or support, please contact [support@cryptoagent.io](mailto:support@cryptoagent.io).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "cryptoagent - Swarms",
    "version": "0.0.1",
    "project_urls": {
        "Documentation": "https://github.com/The-Swarm-Corporation/CryptoAgent",
        "Homepage": "https://github.com/The-Swarm-Corporation/CryptoAgent",
        "Repository": "https://github.com/The-Swarm-Corporation/CryptoAgent"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " optimizers",
        " prompt engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e42c467fd22c7a3d2e8fe73933ad3e17ffaf514f39209613777452517c9056c0",
                "md5": "d018a4f28512234200be64e4f8e8250f",
                "sha256": "71044fb6bfa624fae047b33f33474593865e1783158c2ef3288bad1a19156cf0"
            },
            "downloads": -1,
            "filename": "cryptoagent-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d018a4f28512234200be64e4f8e8250f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6907,
            "upload_time": "2024-09-27T03:02:36",
            "upload_time_iso_8601": "2024-09-27T03:02:36.045184Z",
            "url": "https://files.pythonhosted.org/packages/e4/2c/467fd22c7a3d2e8fe73933ad3e17ffaf514f39209613777452517c9056c0/cryptoagent-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "96a22130c25f206aecfa3eb3bcd596452e24c4e21531bc67592b90405ea53e11",
                "md5": "a76dd38a390a389b1db9bfb35d572be9",
                "sha256": "112c9dba2baa456b40ed886c9d6c1e9c6d08922506b09e0435f69bd8e6962c3a"
            },
            "downloads": -1,
            "filename": "cryptoagent-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a76dd38a390a389b1db9bfb35d572be9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 6559,
            "upload_time": "2024-09-27T03:02:37",
            "upload_time_iso_8601": "2024-09-27T03:02:37.563971Z",
            "url": "https://files.pythonhosted.org/packages/96/a2/2130c25f206aecfa3eb3bcd596452e24c4e21531bc67592b90405ea53e11/cryptoagent-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 03:02:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "The-Swarm-Corporation",
    "github_project": "CryptoAgent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "cryptoagent"
}
        
Elapsed time: 1.21055s