Giter VIP home page Giter VIP logo

simple_portfolio's Introduction

simple_metrics for Robinhood

Simple portfolio metrics applied to your Robinhood portfolio.

example 1

from simple_metrics import fetch, export

account = {
        'username': 'my username',
        'password': 'my password'}

#
# export stock trades to -> stock_orders.csv
#
stock_orders = fetch.stock_trades(account, {})
export.stock_orders(stock_orders, {})

#
# export -> option_orders.csv
#
option_orders = fetch.option_orders(account, {})
export.option_orders(option_orders, {})

example 2

Run the calculate_options.py script in the examples folder, it generates total and daily returns, as well as fetching greeks for open option positions.

Options Example

install

pip install simple_metrics

package api

Functionality includes:

  • Fetch Stock order history
  • Fetch Option order history
  • Export Stock order history
  • Export Option order history

local development

Git clone this repo and run,

pip install . --process-dependency-links --editable

Adding --editable allows you to pull in code changes without having to run pip install.

simple_portfolio's People

Contributors

westonplatter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simple_portfolio's Issues

delta calculation issue

I believe there is a problem with the delta calculation for aggregated positions. In particular, if quantity is >1, the delta should be multiplied by the number of contracts.

This diff should take care of it:

diff --git a/simple_portfolio/calculate.py b/simple_portfolio/calculate.py
index 765278b..90efc93 100644
--- a/simple_portfolio/calculate.py
+++ b/simple_portfolio/calculate.py
@@ -55,6 +55,7 @@ def doit():
ops["return_today"] = ops["market_value"] - ops["pv_prev"]
ops["return_total"] = ops["market_value"] - ops["pv_orig"]

+ ops["delta"] = ops["delta"] * abs(ops["quantity"]) * 100

agg_ops = ( ops[["symbol", "market_value", "return_today", "pv_prev",
"return_total", "pv_orig", "delta", "theta"]].

Apparently delta has the right sign already when exported, but quantity is either positive or negative (bought vs. sold), thus the abs().

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.