All Projects → albertosantini → Node Finance

albertosantini / Node Finance

Licence: mit
Module for portfolio optimization, prices and options

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Finance

okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Stars: ✭ 87 (-13.86%)
Mutual labels:  portfolio, finance, optimization
Python Trading Robot
A trading robot, that can submit basic orders in an automated fashion using the TD API.
Stars: ✭ 235 (+132.67%)
Mutual labels:  portfolio, finance
Alpha Mind
quantitative security portfolio analysis. The analysis pipeline including data storage abstraction, alpha calculation, ML based alpha combining and portfolio calculation.
Stars: ✭ 171 (+69.31%)
Mutual labels:  portfolio, finance
SBTi-finance-tool
This toolkit helps companies and financial institutions to assess the temperature alignment of current targets, commitments, and investment and lending portfolios, and to use this information to develop targets for official validation by the SBTi. See the wiki for a change log.
Stars: ✭ 39 (-61.39%)
Mutual labels:  portfolio, finance
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (+4.95%)
Mutual labels:  finance, optimization
Quant Notes
Quantitative Interview Preparation Guide, updated version here ==>
Stars: ✭ 180 (+78.22%)
Mutual labels:  finance, optimization
lakshmi
Investing library and command-line interface inspired by the Bogleheads philosophy
Stars: ✭ 107 (+5.94%)
Mutual labels:  portfolio, finance
Riskparity.py
Fast and scalable design of risk parity portfolios
Stars: ✭ 122 (+20.79%)
Mutual labels:  finance, optimization
crypto-portfolio
A CLI Cyrptocurrency Portfolio Tracker
Stars: ✭ 12 (-88.12%)
Mutual labels:  portfolio, finance
pytr
Use TradeRepublic in terminal and mass download all documents
Stars: ✭ 141 (+39.6%)
Mutual labels:  portfolio, finance
wallstreet
Stock Quotes and Charts for the Terminal
Stars: ✭ 75 (-25.74%)
Mutual labels:  quotes, finance
AIPortfolio
Use AI to generate a optimized stock portfolio
Stars: ✭ 28 (-72.28%)
Mutual labels:  portfolio, finance
simple portfolio
Export trades from Robinhood and run basic reporting on portfolio performance
Stars: ✭ 17 (-83.17%)
Mutual labels:  portfolio, finance
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-85.15%)
Mutual labels:  portfolio, finance
Algotrader
Simple algorithmic stock and option trading for Node.js.
Stars: ✭ 468 (+363.37%)
Mutual labels:  quotes, portfolio
Portfolio
A simple tool to calculate the overall performance of an investment portfolio.
Stars: ✭ 1,326 (+1212.87%)
Mutual labels:  portfolio
Advisor
Open-source implementation of Google Vizier for hyper parameters tuning
Stars: ✭ 1,359 (+1245.54%)
Mutual labels:  optimization
Limes
Link Discovery Framework for Metric Spaces.
Stars: ✭ 94 (-6.93%)
Mutual labels:  optimization
Coinwink
Crypto Alerts, Watchlist and Portfolio Tracking App
Stars: ✭ 95 (-5.94%)
Mutual labels:  portfolio
Leerob.io
✨ My portfolio built with Next.js, MDX, Tailwind CSS, and Vercel.
Stars: ✭ 1,369 (+1255.45%)
Mutual labels:  portfolio

FINANCE

NPM version

This module contains an implementation of Markowitz algorithm for the portfolio optimization, a routine for retrieving historical prices from Yahoo, statistical information for stocks and a routine for calculating implied volatility using Black and Scholes formula.

Example

See examples directory.

For a frontend, see node-conpa.

Installation

To install with npm:

npm install finance

Tested with Node.js 10.x, R 3.4.3 and Rserve 1.7.3.

Notes

Before using crm methods, you need to configure the details of the persistence system. The portfolios are saved on a CouchDB instance. The configuration allows a live and testing environment.

finance.crm.configure({
    liveDomain: "x.x.x",
    liveUrl: "http://key1:[email protected]",
    liveDb: "myLiveDBName",
    testingUrl: "http://key2:[email protected]",
    testingDb: "myTestingDBName",
    design: "designName",
});

In the support directory there is a script to install the design document with the views used in the dashboard tab.

Methods

keystatistics.getKeyStatistics(params, callback)

It retrieves the key statistics for the stocks and returns an array of objects to create an uneditable form on front-end side.

Params

  • symbol asset symbol.

Callback response

  • keyStatistics object.

optionchain.getOptionChainFromYahoo(params, callback)

It retrieves the strike values for calls and puts from Yahoo! Finance.

Params

  • symbol asset symbol.
  • expiration expiration month. Has to be in the form: "YYYY-MM-DD", example: "2016-01-03".

Callback response

  • optionChain

    • strike strike value of the asset.
    • expDateStr expire date (string).
    • expDate expire date (Date).
    • now Date.
    • calls vector of call values.
    • puts vector of put values.

parsecsv.parse(arr, options)

Arguments

  • arr is the string containing the comma separated value content.

  • options

    • skipHeader flag to skip the first row (dafault false).
    • delimeter is the delimeter between the fields (default ",").
    • reverse to reverse the rows (default false).
    • column is the column to extract (default 0).
    • replaceZeroes flag to replace zeroes with the previous value (default false).
    • skipNRecords flag to skip records (default 0).

performances.getPerformances(x, weights)

It calculates the weighted performance for a matrix.

Arguments

  • x matrix containing the values (i.e. the asset returns).
  • weights the weights

Returns a vector containing the weighted perfomance of the matrix.

portfolio.getOptimalPortfolio(params, callback, config)

It creates an optimal portfolio. If config is defined, the method call a Rserve instance, otherwise a native implementation is used.

Params

  • prods vector of symbols.
  • referenceDate reference date (String).
  • targetReturn weekly target return, if undefined, the mean of returns.
  • lows vector of constraints.
  • highs vector of constraints.
  • shorts a logical indicating whether shortsales are allowed.

Callback response

  • perf performances vector.

  • message error message, if empty the optimization is fine.

  • optim details of quadprog response.

    • solution vector of weights.
    • value the value of the quadratic function at the solution.
    • unconstrained_solution vector of the unconstrained minimizer.
    • iterations the number of iterations the algorithm needed.
    • iact vector with the indices of the active constraints at the solution.
    • message error message, if empty the optimization is fine.
    • pm portfolio return.
    • ps portfolio risk.

Config

  • host hostname or ip address of R instance.
  • port port of Rserve instance.
  • user username for remote connection of Rserve instance.
  • password password for remote connection of Rserve instance.
  • debug boolean to enable rio logging.

portfolio.getScriptOptimalPortfolio(params, callback)

It retrieves the source code of the R script calculating the optimal portfolio.

Params See portfolio.getOptimalPortfolio.

Callback response

  • source the source code of the script.

quotes.getQuotes(symbol, refDate, callback)

It retrieves the prices from Yahoo! finance.

Arguments

  • symbol asset symbol.
  • refDate reference date (Date).

Callback response

  • error calback error.

  • symbol asset symbol.

  • prices

    • beforeRefDate CSV string of prices before reference date.
    • afterRefDate CSV string of prices after reference date.

returns.getReturns(symbols, refDate, callback)

It retrieves the prices from Yahoo! finance and calculates the log returns of the close prices.

Arguments

  • symbols vector containing the symbols of the assets.
  • refDate reference date (String).

Callback response

  • returns

    • message message error.
    • beforeRefDate vector of log returns of close prices before reference date.
    • afterRefDate vector of log returns of close prices after reference date.

riskfreerate.getRiskFreeRateFromYahoo(callback)

It retrieves the risk free rate from Yahoo! Finance.

Callback response

  • riskfree risk free rate.

volatility.getImpliedVolatility(params, callback)

It calculates the implied volatility for an option using Black and Scholes formula.

Arguments

  • symbol asset symbol.

Callback response

  • option

    • strike strike of the asset.
    • riskfree risk free rate.
    • expDate expire date (string).
    • callVolatility implied volatility for the calls.
    • putVolatility implied volatility for the puts.

crm.configure(params)

It configures a CRM database instance (i.e. a CouchDB instance). The user can configure a testing and live instance.

Params

  • liveDomain url for the live domain.
  • liveUrl url for the live instance, eventually with the credentials.
  • liveDb name of live instance.
  • testingUrl url for the testing instance, eventually with the credentials.
  • testingDb name of testing instance.
  • design name of design document.

crm.putPortfolioOnCRM(params, callback)

It saves a portfolio and his stats to CRM database.

Params

  • symbols portfolio assets.
  • weights weights of the portfolio assets.
  • ref reference date (string).
  • ret target return of the portfolio.
  • risk risk of the portofolio.
  • perf performances vector.
  • highs high constraints.
  • lows low constraints.

Response callback

  • id id of the portfolio saved.

crm.getPortfolio(params, callback)

It retrieves a portfolio.

Params

  • id portfolio id.

Response callback

  • assets portfolio assets.

  • constraints portfolio constraints.

    • highs high constraints.
    • lows low constraints.
  • created_at creation date of the portfolio.

  • perf performances vector.

  • ref reference date (string).

  • ret target return of the portfolio.

  • risk risk of the portofolio.

  • weights weights of the portfolio assets.

crm.queryByDate(params, callback)

It retrieves the portfolios by date sorted by a metric.

Params

  • metric "perf", "risk", "ret".
  • beginRefDate start date formatted yyyy/mm/dd.
  • endRefDate end date formatted yyyy/mm/dd.
  • limit maximum number of records.
  • sort "asc, "desc".

Response callback

  • docs array of results.

    • metric kind of metric.
    • ref reference date.
    • assets array of assets.
    • weights array of weights.

crm.getPortfolioCount(callback)

It retrieves the number of portfolios saved.

Response callback

  • rows array of results.

    • key null.
    • value the number of portfolios.

crm.getMostUsedAssets(callback)

Response callback

  • MostUsedAssets

    • key asset symbol.

    • value

      • stock asset frequency.

crm.getLastCreatedPortfolios(limit, callback)

It retrieves the latest portofolios created.

Arguments

  • limit maximum number of records.

Response callback

  • rows array of results.

    • key Date (string).

    • value Portfolio.

      • created_at creation date (string).

      • assets vector containing the assets.

      • weights the weight of the assets.

      • ref reference date.

      • ret target return.

      • risk portfolio risk.

      • perf portfolio performance at reference date.

      • constraints

        • lowBounds vector containing low constraints.
        • highBounds vector containing high constraints.

crm.getHighProfileRiskPortfolios(limit, callback)

It retrieves the portfolios with high profile risk.

For arguments and response callback see getLastCreatedPortofolios method.

crm.getLowProfileRiskPortfolios(limit, callback)

It retrieves the portfolios with low profile risk.

For arguments and response callback see getLastCreatedPortofolios method.

crm.getHighProfileReturnPortfolios(limit, callback)

It retrieves the portfolios with high profile return.

For arguments and response callback see getLastCreatedPortofolios method.

crm.getLowProfileReturnPortfolios(limit, callback)

It retrieves the portfolios with low profile return.

For arguments and response callback see getLastCreatedPortofolios method.

crm.getBestPerformingPortfolios(limit, callback)

It retrieves the portfolios with the best performance.

For arguments and response callback see getLastCreatedPortofolios method.

crm.getWorstPerformingPortfolios(limit, callback)

It retrieves the portfolios with the worst performance.

For arguments and response callback see getLastCreatedPortofolios method.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].