Inspiration

The world of finance and investing can often feel complex and overwhelming, especially for those without a background in the field. We've identified three roadblocks that hinder the investment journey for everyone:

  1. Navigating the Stock Market: The complexity and time-consuming nature of stock market navigation often deters potential investors. We aimed to simplify and personalize this experience.
  2. Market Misinformation: The prevalence of inaccurate and obsolete data often leads investors to make uninformed decisions.
  3. Cost, Hallucination Problems in Existing AI Agents: AI agents currently depend heavily on internet scraping, a method that's not only expensive and time-consuming but also lacks in accuracy and timeliness and prone to AI hallucinations.

What Our App Does

"StockSage AI," our smart chatbot, simplifies financial market navigation by providing personalized, real-time advice and data visualizations. Leveraging Google Vertex AI and MongoDB, StockSage offers a cost-effective, accurate alternative to traditional AI tools.

  1. Chat Interface: Users can ask personalized queries
  2. Data Visualizations: Displays market trends and prices with colorful and intuitive graphics
  3. Real-time Analysis: Bot evaluates reliable news data, updated multiple times daily
  4. Efficient AI Search: Leverages databases over web scraping for acquiring information, optimizing cost and accuracy

Please see the image gallery below for a preview of the features!

How We Built It

Building StockSage AI involved a three-step process:

Step 1: Data Collection & Analysis:

The first step was to collect and analyze data from reliable financial sources. We used Google Cloud's Pub/Sub and Dataflow services to create a real-time data pipeline. This pipeline streamed financial news and price data into Google's Vertex AI for embedding.

# Code from our getnewsprices.py file
from getnews import get_news
from getprices import get_prices

news_data = get_news()
price_data = get_prices()

embedded_data = vertex_ai.embed_data(news_data, price_data)

The embedded data was then analyzed using Google Vertex AI. This allowed us to derive insights from our collected data and use these insights to inform the responses provided by our chatbot.

# Code from our embeddingcollecti.py file
from vertex_ai import analyze_data

insights = analyze_data(embedded_data)

Step 2: MongoDB Database:

Once our data had been collected and analyzed, it was stored in MongoDB Atlas, MongoDB's fully-managed cloud database. This not only provided a scalable and performant method of storing information, but also helped to ensure the accuracy of our data and prevent AI hallucinations.

// Code from our chatvertex.py file
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb+srv://<username>:<password>@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  dbo.collection("financial_data").insertOne(embedded_data, function(err, res) {
    if (err) throw err;
    console.log("Data inserted");
    db.close();
  });
});

We took advantage of MongoDB's Atlas Search, which provides a more efficient and effective means of retrieving information for our AI agents. We used Atlas Search's vector search feature to perform semantic search on our embedded data.

// Code from our chatvertex.py file
var searchQuery = { "$search": { "vector": { "values": insights } } }
dbo.collection("financial_data").find(searchQuery).toArray(function(err, result) {
  if (err) throw err;
  console.log(result);
  db.close();
});

Step 3: Client Request Processing:

The final step in building our application was implementing the process for handling client requests. When a client makes a request, the request is processed by Google Vertex AI's Natural Language Processing (NLP) capabilities.

# Code from our streamlitmain.py file
client_request = get_client_request()
processed_request = vertex_ai.process_request(client_request)

This processing allows us to determine the most appropriate response based on the insights derived from our data analysis. In this way, we can provide users with reliable, real-time financial advice.

# Code from our streamlitmain.py file
response = generate_response(processed_request, insights)
send_response(response)

By leveraging the strengths of the MongoDB Vector Search and Google Vertex AI services, we're able to offer a solution that not only simplifies financial market navigation but also provides accurate, real-time advice and data visualizations. This has the potential to add significant value to both individual investors and financial institutions, as well as to MongoDB and Google Cloud users.

Challenges we ran into

We faced a couple of challenges involving MongoDB's Vector Search in our development process. We also found that Vertex AI was not as adept at integrating with MongoDB as we had hoped, which we addressed by focusing on its core capabilities and limiting its functionality.

Accomplishments that we're proud of

We're extremely proud of the progress we've made with StockSage AI. Here are a few highlights:

  1. Practical AI Agent: We successfully created an AI agent that has real-world applications. StockSage AI simplifies the complex world of finance, making it accessible to everyone, regardless of their financial background.
  2. Innovative Use of MongoDB: We discovered the potential of using MongoDB as an AI Knowledge Database. This not only optimized the performance of our AI agent but also significantly reduced the cost and time associated with data scraping.
  3. First-time Experiences: For the majority of us, this was our first time participating in a hackathon. It was also our first time to make use of MongoDB and Google Vertex AI. The learning curve was steep, but the experience was rewarding. We're proud of how quickly we were able to adapt and leverage these powerful tools.

What We Learned

We learned how to use MongoDB's Vector Search to efficiently retrieve information from our database. This was instrumental to us in improving performance of our AI agent. We also explored the capabilities of Google Vertex AI, learning how to use its various features such as data embedding, analysis, and natural language processing.

What's Next for StockSage AI

We're excited about the future of StockSage AI. Here are a few enhancements we're planning:

  1. Tailored Chat Services: We plan to offer different chat services tailored to users with different financial backgrounds. This will make our tool even more personalized and user-friendly.
  2. Expanded Visualizations: We plan to offer a greater variety of data visualizations to make financial data more understandable and engaging. We're also looking into expanding our services to include crypto currency data.

Closing Thoughts

We really enjoyed building this application! We learned a lot about MongoDB, and Google Vertex AI. We were particularly fascinated about the potential of MongoDB Vector Search to serve as a AI Knowledge database, and we will look for ways use these services for our personal projects in the future.

Built With

Share this project:

Updates