Package: optitrader
OptitraderOptitrader is an open-source Python package designed for portfolio optimization, quantitative finance, and algorithmic trading. It empowers users with a wide array of tools to effortlessly construct personalized portfolios, thoroughly analyze optimization outcomes, and seamlessly execute trades usingAlpaca's Trading API.Accessible through an intuitive web-basedStreamlitdashboard hosted athttps://optitrader.streamlit.app, Optitrader enables users to interact with its rich features and harness the potential of portfolio optimization and algorithmic trade execution.UsingPython package: to add and install this package as a dependency of your project, runpoetry add optitrader.Python CLI: to view this app's CLI commands once it's installed, runoptitrader --help.Rest API: to serve this application as a REST API, rundocker compose up appand openlocalhost:8080in your browser to see the documentation. Within the Dev Container, this is equivalent to runningpoe api.Streamlit Dashboard: to use this application from a Streamlit dashboard, runoptitrader dashboard. This is equivalent to runningpoe appand openlocalhost:8000in your browser.ExampleOnce the package has been installed you can use it as follows:fromoptitraderimportOptitraderfromoptitrader.optimization.objectivesimportCVaRObjectiveFunctionfromoptitrader.enumsimportUniverseNameoptimal_ptf=Optitrader(objectives=[CVaRObjectiveFunction()],universe_name=UniverseName.POPULAR_STOCKS,).solve()# Optimal Portfolio:Portfolio(weights={'AAPL':0.18168,'BABA':0.00369,'BRK.B':0.15119,'META':0.04067,'MSFT':0.01936,'ORCL':0.16028,'PFE':0.00207,'TSLA':0.01057,'V':0.02516,'WMT':0.40532},objective_values={'Conditional Value at Risk':0.007560866163075728})and you can use the available methods of thePortfolio class, such aspie_plot:optimal_ptf.pie_plot()ContributingThis project has been boostrapped usingthis cookiecutter template.Prerequisites1. Set up Git to use SSHGenerate an SSH keyandadd the SSH key to your GitHub account.Configure SSH to automatically load your SSH keys:cat<< EOF >> ~/.ssh/configHost *AddKeysToAgent yesIgnoreUnknown UseKeychainUseKeychain yesEOF2. Install DockerInstall Docker Desktop.EnableUse Docker Compose V2in Docker Desktop's preferences window.Linux only:Configure Docker to use the BuildKit build system. On macOS and Windows, BuildKit is enabled by default in Docker Desktop.Export your user's user id and group id so thatfiles created in the Dev Container are owned by your user:cat<< EOF >> ~/.bashrcexport UID=$(id --user)export GID=$(id --group)EOF3. Install VS Code or PyCharmInstall VS CodeandVS Code's Dev Containers extension. Alternatively, installPyCharm.Optional:install aNerd Fontsuch asFiraCode Nerd Fontandconfigure VS Codeorconfigure PyCharmto use it.Development environmentsThe following development environments are supported:⭐️GitHub Codespaces: click onCodeand selectCreate codespaceto start a Dev Container withGitHub Codespaces.⭐️Dev Container (with container volume): click onOpen in Dev Containersto clone this repository in a container volume and create a Dev Container with VS Code.Dev Container: clone this repository, open it with VS Code, and runCtrl/⌘+⇧+P→Dev Containers: Reopen in Container.PyCharm: clone this repository, open it with PyCharm, andconfigure Docker Compose as a remote interpreterwith thedevservice.Terminal: clone this repository, open it with your terminal, and rundocker compose up --detach devto start a Dev Container in the background, and then rundocker compose exec dev zshto open a shell prompt in the Dev Container.DevelopingThis project follows theConventional Commitsstandard to automateSemantic VersioningandKeep A ChangelogwithCommitizen.Runpoefrom within the development environment to print a list ofPoe the Poettasks available to run on this project.Runpoetry add {package}from within the development environment to install a run time dependency and add it topyproject.tomlandpoetry.lock. Add--group testor--group devto install a CI or development dependency, respectively.Runpoetry updatefrom within the development environment to upgrade all dependencies to the latest versions allowed bypyproject.toml.Runcz bumpto bump the package's version, update theCHANGELOG.md, and create a git tag.Similar projectsoptitrader is built by keeping in mind the availability of other great open-source repositories, such as:Riskfolio-LibPyPortfolioOpt