Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Exchange Sim Prices

A simple stock exchange price simulation service built with Rust that provides real-time stock price feeds via gRPC.

Overview

This project implements a gRPC server that simulates stock price movements for a set of predefined tickers (AAPL, TSLA, GOOG, AMZN, MSFT, NFLX, META, NVDA, JPM, V). The service provides both single price requests and streaming price feeds with realistic price fluctuations based on a drift and volatility model.

Features

  • gRPC API: Provides a Protocol Buffers-based API for price feeds
  • Price Simulation: Realistic price movements with small upward drift and random volatility
  • Streaming Support: Real-time price streaming for continuous updates
  • Multiple Tickers: Supports 10 popular stock tickers with initial base prices
  • Configurable Server: Environment-based configuration for host and port settings

Prerequisites

  • Rust (latest stable version)
  • Protocol Buffers compiler (protoc)

To install protobuf compiler on Ubuntu/Debian:

sudo apt-get install protobuf-compiler

Building and Running

  1. Clone the repository:
git clone https://github.com/loudsheep/stock-exchange-sim-prices.git
cd stock-exchange-sim-prices
  1. Build the project:
cargo build
  1. Run the server:
cargo run

The server will start listening on 127.0.0.1:50051 by default.

Configuration

The server can be configured using environment variables:

  • SERVER_HOST: Server host address (default: 127.0.0.1)
  • SERVER_PORT: Server port number (default: 50051)

You can create a .env file based on .env.example for local development.

API

The service provides two gRPC endpoints:

  • GetPrice(PriceRequest) -> PriceResponse: Get current price for a specific ticker
  • StreamPrices(PriceRequest) -> stream PriceResponse: Stream continuous price updates

Supported Tickers

  • AAPL (Apple Inc.)
  • TSLA (Tesla, Inc.)
  • GOOG (Alphabet Inc.)
  • AMZN (Amazon.com, Inc.)
  • MSFT (Microsoft Corporation)
  • NFLX (Netflix, Inc.)
  • META (Meta Platforms, Inc.)
  • NVDA (NVIDIA Corporation)
  • JPM (JPMorgan Chase & Co.)
  • V (Visa Inc.)

License

This project is available for educational and demonstration purposes.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages