Git Product home page Git Product logo

stock-calc's Introduction

Stocks Calculator

This is a small tool to help calculate your stock investments.

Portfolio

The tool allows multiple portfolios to be chosen from. Portfolios are supplied in JSON format. It uses .jsonc extension to allow comments.

To create a new portfolio, create a portfolio file under src/data named _settings.<portfolio_name>.jsonc.

A portfolio object contains:

  • brokerageFeeFlat: A flat amount of money the brokage take on each order. It's added to each order no matter what the value is.
  • tradingFeePercentage: The trading fee is taken as a percentage of the total order value.
  • minimumTradingFeeFlat: The minimum amount of trading fee that is taken.
  • securities: A list of securities in a portfolio.

The securities list consists of security objects, which contains:

  • tick: The tick of the security.
  • exchange: The exchange symbol for the security, used with the tick to determine the correct security.
  • shares: The number of shares the portfolio have of this security.
  • targetPercentage: The percentage this security contributes to in the portfolio. Must be 1 or less.
  • isin: (Optional) An International Securities Identification Number (ISIN) is a 12-digit alphanumeric code that uniquely identifies a specific security. Can be used to find the security.

The price of each security is fetched automatically from public records using either the combination of the tick and exchange, or using the isin if available.

Available operations

The tool can be used by running:

npm run cli -- <command> [options]

This is a list of global options available in all operations

  • -pt, --portfolio <type>: the portfolio to use (default: "EUR")
  • -h, --help: display help for command

Show Portfolio

Show information about the current portfolio.

npm run cli -- show [options]
npm run cli:show -- [options]

Create minimal portfolio

Calculates the minimum number of shares you need to buy to satisfy your portfolio.

npm run cli -- minimal [options]
npm run cli:minimal -- [options]
  • Options:
  • -p, --precision <precision>: how much can your securities percentage deviate from target (default: "0.01")
  • -s, --shares-step <step>: the minimum amount of shares a security is incremented by (default: "1")

Create a portfolio with exact value

Calculates the minimum number of shares you need to buy to satisfy your portfolio.

npm run cli -- target [options] <price>
npm run cli:target -- [options] <price>
  • Arguments:
    • price: target portfolio price

Invest amount in portfolio

Calculates the number of shares you need to buy to satisfy your portfolio if you invest additionally

npm run cli -- invest [options] <investment>
npm run cli:invest -- [options] <investment>
  • Arguments:
    • investment: Additional investment amount

Rebalance portfolio

Rebalance the current portfolio

npm run cli -- rebalance [options]
npm run cli:rebalance -- [options]

stock-calc's People

Contributors

armaaar avatar

Watchers

 avatar

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.