Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
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.
See examples directory.
For a frontend, see node-conpa.
To install with npm:
npm install finance
Tested with Node.js 7.x, R 3.3.2 and Rserve 1.7.3.
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:pass1@p.c.com",
liveDb: "myLiveDBName",
testingUrl: "http://key2:pass2@p.c.com",
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.
It retrieves the key statistics for the stocks and returns an array of objects to create an uneditable form on front-end side.
Params
Callback response
It retrieves the strike values for calls and puts from Yahoo! Finance.
Params
Callback response
optionChain
Arguments
arr is the string containing the comma separated value content.
options
It calculates the weighted performance for a matrix.
Arguments
Returns a vector containing the weighted perfomance of the matrix.
It creates an optimal portfolio. If config is defined, the method call a Rserve instance, otherwise a native implementation is used.
Params
Callback response
perf performances vector.
message error message, if empty the optimization is fine.
optim details of quadprog response.
Config
It retrieves the source code of the R script calculating the optimal portfolio.
Params See portfolio.getOptimalPortfolio.
Callback response
It retrieves the prices from Yahoo! finance.
Arguments
Callback response
error calback error.
symbol asset symbol.
prices
It retrieves the prices from Yahoo! finance and calculates the log returns of the close prices.
Arguments
Callback response
returns
It retrieves the risk free rate from Yahoo! Finance.
Callback response
It calculates the implied volatility for an option using Black and Scholes formula.
Arguments
Callback response
option
It configures a CRM database instance (i.e. a CouchDB instance). The user can configure a testing and live instance.
Params
It saves a portfolio and his stats to CRM database.
Params
Response callback
It retrieves a portfolio.
Params
Response callback
assets portfolio assets.
constraints portfolio 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.
It retrieves the number of portfolios saved.
Response callback
rows array of results.
Response callback
MostUsedAssets
key asset symbol.
value
It retrieves the latest portofolios created.
Arguments
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
It retrieves the portfolios with high profile risk.
For arguments and response callback see getLastCreatedPortofolios method.
It retrieves the portfolios with low profile risk.
For arguments and response callback see getLastCreatedPortofolios method.
It retrieves the portfolios with high profile return.
For arguments and response callback see getLastCreatedPortofolios method.
It retrieves the portfolios with low profile return.
For arguments and response callback see getLastCreatedPortofolios method.
It retrieves the portfolios with the best performance.
For arguments and response callback see getLastCreatedPortofolios method.
It retrieves the portfolios with the worst performance.
For arguments and response callback see getLastCreatedPortofolios method.
FAQs
Module for portfolio optimization, prices and options
The npm package finance receives a total of 0 weekly downloads. As such, finance popularity was classified as not popular.
We found that finance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.