Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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 options smile using Black and Scholes formula.
See examples directory.
To install with npm:
npm install finance
Tested with node 0.4.12 and tested results with R 2.13.1.
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 system.
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",
});
If you use crm module, in lib/couchdb there is the file containing the code for the views to inject to CouchDB instance.
It creates an optimal portfolio.
Params
prods vector of symbols.
referenceDate
targetReturn if undefined, the mean of returns will be the default
lows constraints
highs constraints
Callback response
perf performances vector.
message error message, empty is ok.
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, empty is ok.
pm return
ps risk
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.
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.
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
stats array of statistics objects
type set to 'uneditable'.
inputParams
label the label of the field.
value the value of the field.
It retrieves the strike values for calls and puts from Yahoo! Finance.
Arguments
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.
It retrieves the risk free rate from Yahoo! Finance.
Callback response
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.
It calculates the implied volatility for an option using Black and Scholes formula.
Arguments
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.
It configure CRM database instance (i.e. a CouchDB instance). The user can configure a testing and live instance.
Params
liveDomain url for the live domain.
keylive "user:password" string, credentials for live instance.
dbLive name of live instance.
keyTesting "user:password" string, credentials for testing instance.
dbTesting name of testing instance.
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
It retrieves the number of portfolios saved.
Response callback
rows array of results.
key null.
value the number of portfolios.
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
lowBounds vector containing low constraints.
highBounds vector containing high 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.