Project Overview
`Go Stock Tracker` is a Go-based application designed to track and display stock market data in real-time. Utilizing the Gin web framework for routing and WebSocket for real-time communication, this application fetches stock data from an external API and presents updated information at regular intervals.
- Real-time stock data tracking through WebSocket.
- Efficient web routing using Gin framework.
- Periodic updates of stock data at configurable intervals.
- Fetches data from external stock market APIs.
- Scalable architecture suitable for expanding to multiple stock symbols.
- Go (1.x or later)
- External API key for stock data (e.g., Alpha Vantage)
- Git
- Clone the Repository
API_KEY=<Your_Alpha_Vantage_API_Key>
git clone https://github.com/your-username/go-stock-tracker.git
go run app.go
Postman allows you to test WebSocket connections and send messages. Here's how you can test the /ws
WebSocket endpoint:
-
Open Postman
-
Create a New WebSocket Request
- Click on the
New
button. - Select
WebSocket Request
.
- Click on the
-
Configure the WebSocket URL
- Enter the WebSocket URL in the format:
ws://localhost:8080/ws
(adjust the domain and port as per your server configuration).
- Enter the WebSocket URL in the format:
-
Connect to the WebSocket
- Click
Connect
to establish a WebSocket connection.
- Click
-
Send a Message
- To request stock data, send a JSON message in the following format:
{ "action": "getStock", "ticker": "YOUR_STOCK_TICKER" }
- Replace
YOUR_STOCK_TICKER
with the desired stock symbol (e.g.,IBM
orAAPL
).
- To request stock data, send a JSON message in the following format:
-
Receive Updates
- After sending the message, you should receive periodic updates with the latest stock data.
- The updates will appear in the
Messages
section of Postman.
-
Close the Connection
- Once done, you can close the WebSocket connection by clicking the
Disconnect
button.
- Once done, you can close the WebSocket connection by clicking the
Note: Ensure your Go Stock Tracker application is running before testing with Postman.
Note:
- I have removed the sections commented out with
<!-- -->
as they might be related to features not currently implemented. - The WebSocket section is now more focused on the real-time aspect of your application.
- Remember to replace
https://github.com/your-username/go-stock-tracker.git
with your actual repository URL. - Ensure that the
.env
file and your API key are appropriately configured as per your project setup.