-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerized version #152
base: main
Are you sure you want to change the base?
Dockerized version #152
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Use Python 3.10 slim image as base | ||
FROM python:3.10-slim | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
gcc \ | ||
python3-dev \ | ||
curl \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed when you use "pip install poetry" |
||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use "pip install poetry" to get rid of curl |
||
ENV PATH="/root/.local/bin:$PATH" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can combine this with line 30 to remove this docker layer: ENV PYTHONUNBUFFERED=1 |
||
|
||
# Copy requirements first to leverage Docker cache | ||
# Copy source code | ||
COPY src/ src/ | ||
COPY .env . | ||
COPY .gitignore . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
COPY README.md . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
COPY LICENSE . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
COPY pyproject.toml . | ||
|
||
# Install Python dependencies | ||
RUN poetry install | ||
|
||
# Set environment variable for Python to run in unbuffered mode | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Set default command with -u flag for unbuffered output | ||
ENTRYPOINT ["poetry", "run", "python", "-u", "src/main.py"] | ||
CMD ["--ticker", "AAPL,MSFT,NVDA"] # Optional default arguments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a new line at end of file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,18 @@ You can optionally specify the start and end dates to backtest over a specific t | |
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01 | ||
``` | ||
|
||
## Using Docker | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the info to create a .env file first. |
||
To build the docker container: | ||
```bash | ||
docker build . | ||
``` | ||
|
||
To run the docker container: | ||
```bash | ||
docker run -it <container_name> --ticker AAPL,MSFT,NVDA | ||
``` | ||
|
||
## Project Structure | ||
``` | ||
ai-hedge-fund/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May change it to python 3.13. Python 3.10 will be end of life next year.