Code Monkey home page Code Monkey logo

chinchalinchin / scrilla Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 140.8 MB

A python application that wraps around various financial APIs, calculates statistics and optimizes portfolio allocations.

Home Page: https://pypi.org/project/scrilla/

License: GNU General Public License v3.0

Python 99.31% HTML 0.36% Shell 0.27% Dockerfile 0.07%
python finance alphavantage quandl pyqt scipy portfolio-optimization iex statistics quantitative-finance trading government

scrilla's Introduction

scrilla: A Financial Optimization Application

scrilla is an open-source financial analysis application written in Python. It can optimize portfolios, calculate statistics using a variety of methods and algorithms, generate graphical plots and much more. It uses historical data retrieved from various sources, such as the US Treasury RSS Feed, AlphaVantage, IEX and Quandl, to calibrate models.

NOTE: None of the results of scrilla should be interpretted as financial advice. All results assume past trends will continue indefinitely into the future, which is usually never the case in reality.

Documentation

Coverage

Code Analysis

DeepSource
DeepSource

Pipelines

Branch Status
pypi/micro-update CircleCI
pypi/minor-update CircleCI
develop/main CircleCI

Quick Start

Refer to the documentation for more detailed information on installation and usage.

Installation

PyPi Distribution

Install the package with the Python package manager,

pip install scrilla

This will install a command line interface on your path under the name scrilla. Confirm your installation with with the version command,

scrilla version

You may need to add your Python scripts /bin/ to the $PATH if this command is not found.

To keep the installation as minimal as possible, the base package does not include the GUI libraries. You can install the optional GUI dependency (PySide6) with,

pip install scrilla[gui]

Note, the GUI has a different CLI entrypoint, namely,

scrilla-gui

Source

If you are developing, you can build from source. git clone the repository and then from the root directory install the project dependencies and build the library,

pip3 install -r requirements.txt
python3 -m build

cd into the generated /dist/ to manually install the packaged code,

pip install scrilla-<major>.<minor>.<micro>-py3-none-any.whl

Configuration

In order to use this application, you will need to register for API keys with AlphaVantage, IEX and Quandl/Nasdaq. The program will need to be made aware of these keys somehow. The best option is storing these credentials in environment variables. You can add the following lines to your .bashrc profile or corresponding configuration file for whatever shell you are using,

export ALPHA_VANTAGE_KEY=<key goes here>
export QUANDL_KEY=<key goes here>
export IEX_KEY=<key goes here>

You can also invoke the CLI function store to store the credentials in the local installation /data/common/ directory. To do so,

scrilla store -key <key> -value <value>

where <key> is one of the values: ALPHA_VANTAGE_KEY, QUANDL_KEY or IEX_KEY. <value> is the corresponding key itself given to you after registration. Obviously, <value> is case-sensitive

Keep in mind if using this method to store the API keys, the keys will be stored unencrypted in the local installation's /data/common/ directory. The recommended method is storing the credentials in the environment.

If no API keys are found through either of these methods, the application will raise an exception.

NOTE: The Quandl/Nasdaq key is technically no required for the majority of the application to function, as interest rates are now retrieved directly from the US Treasury RSS feed. However, it is still recommended that you register for an API key, as Quandl/Nasdaq is still the only source of economic statistics, like GDP or inflation rates.

Environment File

A sample environment file has been included in /env/.sample.env. To configure the application environment, copy this file into a new environment, adjust the values and load it into your session,

cp ./env/.sample.env ./env/.env
# adjust .env values
source ./env/.env
# the values loaded into your session will now configure scrilla's execution environment
scrilla risk-profile GD LMT 

Usage

Portfolio Optimization

The following command will optimize a portfolio of consisting of ALLY, BX, GLD, BTC and ETH over the specified date range and save the result to a JSON file,

scrilla optimize-portfolio ALLY BX GLD BTC ETH \
    -start <YYYY-MM-DD> \
    -end <YYYY-MM-DD> \
    -save <absolute path to json file> 

Efficient Frontier

The following command will calculaate the efficient frontier for a portfolio consisting of SPY, GLD and USO over the specified date range and save the result to a JSON file,

scrilla efficient-frontier SPY GLD USO \
    --start <YYYY-MM-DD> \
    --end <YYYY-MM-DD> \
    --save <absolute path to json file>

The following command will generate a plot of this frontier in the return-volatility plane,

scrilla plot-ef SPY GLD USO \
    --start <YYYY-MM-DD> \ 
    --end <YYYY-MM-DD> 

scrilla has lots of other functions. See usage for more information.

Cloud

TODO

currently working on a DynamoDB-based cache and Dockerfiles for lambda functions wrapped around scrilla's main features. will update this section once everything is completed.

scrilla's People

Contributors

chinchalinchin avatar deepsource-autofix[bot] avatar deepsourcebot avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

webclinic017

scrilla's Issues

Quandl USTREASURY/YIELD feed no longer exists

Quandl was acquired by Nasdaq and their APIs were incorporated into the existing data.nasdaq APIs. The support for some of the feeds was dropped in the reshuffling. In particular, the free feed for the yield curve (USTREASURY/YIELD) is no longer refreshed daily and, in fact, hasn't been refreshed since February of this year. This was the feed this application used to determine the latest interest rate. As a result, any calculations involving interest rate since approximately 02-01-2022 (which is virtually every calculation in this application...) will fail, since there is no interest rate to retrieve.

Currently working on directly parsing the treasury.gov's XML feed for the yield curve instead of Nasdaq/Quandl's Rest API in feature/treasury-data branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.