Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 2.65 KB

README.md

File metadata and controls

76 lines (60 loc) · 2.65 KB

stocksim

Changelog Tests License

Simulate stock price over a future period

Installation

Install this tool using pip:

pip install stocksim

You can also run stocksim with uvx without installing it like so:

uvx --from git+https://github.com/lvg77/stocksim stocksim --ticker AAPL --traget-price 250

This command will run the tool in temporary venv which will be then discarded

Usage

The stocksim tool provides a command-line interface to run Monte Carlo simulations for stock price prediction. To use the tool, you can run the following command:

stocksim [OPTIONS]

The available options are:

  • --ticker TEXT: Stock ticker symbol.
  • --target-price FLOAT: Target price for probability calculation.
  • --days INTEGER: Number of days for simulation.
  • --runs INTEGER: Number of Monte Carlo simulation runs.
  • --returns-dist [bootstrap|normal]: Method for generating returns.
  • --ever-above FLOAT: Target price to calculate probability of ever reaching above (defaults to --target-price if not specified).
  • --ever-below FLOAT: Target price to calculate probability of ever dipping below.
  • --history: Number of years of historical data to use. For half year use 0.5.

Here's an example usage:

stocksim --ticker AAPL --target-price 150 --days 30 --runs 1000 --returns-dist bootstrap --ever-above 160

This will run a Monte Carlo simulation for the Apple (AAPL) stock with the following parameters:

  • Target price: $150
  • Number of days: 30
  • Number of simulations: 1000
  • Returns distribution method: Bootstrap
  • Probability of ever reaching above $160

The tool will output the simulation results, including the probability of the stock price exceeding the target price, the probability of the stock price ever reaching above the specified price, and the simulated price range.

For help, run:

stocksim --help

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd stocksim
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

python -m pytest