Predict the price of a stock using the power of machine learning!
- Installation (Server Side)
- Environment Variables (Server Side)
- Usage (Client Side)
- Example Request
- Example Response
- Compiling
- Clone the repository.
git clone https://github.com/BastianAsmussen/StockPredictor.git
- Create a
.env
file.$ touch .env # Add the following to the .env file. # WORKERS=4 # IP="127.0.0.1" # PORT=8080
- Compile the project.
cargo build --release
- Getting logger information. (Optional)
source RUST_LOG=stock_predictor # Set the environment variable.
set RUST_LOG=stock_predictor # Set the environment variable.
```
6. Run the project.
### Linux
```sh
./target/release/stock_predictor
.\target\release\stock_predictor.exe
Variable | Description |
---|---|
WORKERS | The number of workers (threads) to use for the HTTP server. |
IP | The IP address to use for the HTTP server. |
PORT | The port to use for the HTTP server. |
- Send a
GET
request to the server.curl -X GET "http://127.0.0.1:8080/predict" -H "Content-Type: application/json" -d '{ "symbol": "AAPL", "days": 7 }'
{
"symbol": "AAPL",
"days": 7
}
Field | Type | Description |
---|---|---|
symbol | string | The stock symbol. |
days | int | The number of days to predict into the future. |
{
"request": {
"symbol": "AAPL",
"days": 7
},
"error": null,
"predictions": [
191.48390197753906,
192.28878784179688,
192.40756225585938,
192.34530639648438,
192.67547607421875,
193.71231079101562,
193.5487518310547
],
"modelRmse": 0.00010840992763405666
}
Field | Type | Description |
---|---|---|
request | object | The request that was sent to the server. |
error | string | The error message if an error occurred. |
predictions | array | The predicted prices. |
modelRmse | float64 | The root mean squared error of the model. |
- Clone the repository.
git clone https://github.com/BastianAsmussen/Stock-Predictor.git as stock_predictor
- Change directory to the project folder.
cd stock_predictor
- Compile the project.
cargo build --release
- Getting logger information. (Optional)
source RUST_LOG=stock_predictor # Set the environment variable.
set RUST_LOG=stock_predictor # Set the environment variable.
- Run the project.
./target/release/stock_predictor
.\target\release\stock_predictor.exe