New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mfchart

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

mfchart

Financial Time Series Data Storing on MongoDB Database

latest
Source
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

MongoDB Financial Chart - MFChart

MFChart is a promise based TypeScript library to store financial time series data using MongoDB database. The library is designed for very specific use case, though it can be used as a general for storing time series data. Imagine you have investment portfolios and you would like to have charts (1 day, 1 week, 1 month, 3 months,...) for every single portfolio. MFChart addresses this particular issue by using MongoDB database.

For now, MFChart provides 1 day, 1 week, 1 month, 3 months and 1 year charts with following intervals:

 - 1 day in 5 minutes intervals.
 - 1 week in 30 minutes intervals.
 - 1 month in 2 hours intervals.
 - 3 months in 12 hours intervals.
 - 1 year in 1 day intervals.

How to Install?

Before installing the project make sure you already installed minimum requirements: TypeScript Compiler (tsc) and MongoDB.

npm i mfchart

How to Import and Creat a MFChart Object?

import MFChart from 'mfchart';
const db = // Establish  MongoDB connection here.

// Arguments:
// -db: MongoDB database instance. It is assumed that the user already
//  established MongoDB connection.
// -coll_name: Collection name. Note that it will add _<type>_coll at the end
//  of the provided name. For example, if you provide my_coll it would be
//  my_coll_<type>_coll. By default it is set to 'mfchart'.
const chart = new MFChart(db, 'coll_name');

MFChart Public Methods

// Method updates all type of charts and creates them if they do not exist.
//
// Arguments:
// -id: Valid MongoDB document ID (more precisely BSON object and/or string).
// -value: A value to be stored. Note that timestamp will ge generated.
// -name: Chart name. By default it is set to an empty string.
//
// Returns an array of updated charts' data. [1d, 1w, 1m, 3m, 1y].
async updateAllCharts(id, value, name);
// Method updates given type of chart and creates a new one if it does not
// exist. It is a promise based method and throws an exception if there is
// a database error or chart type is not valid.
//
// Arguments:
// -type: Chart type. It must be '1d', '1w', '1m', '3m' or '1y'.
// -id: Valid MongoDB document ID (more precisely BSON object and/or string).
// -value: A value to be stored. Note that timestamp will be generated.
// -name: Chart name. By default it is set to an empty string.
//
// Returns updated chart data.
async updateChart(type, id, value, name);
// Get chart data based on provided type and ID.
//
// Arguments:
// -type: Chart type. It must be '1d', '1w', '1m', '3m' or '1y'.
// -id: Investment portfolio MongoDB document's ID.
async getChartData(type, id)
// Deletes all the above mentioned charts from the MongoDB database.
//
// Arguments:
// -id: Chart ID.
deleteCharts(id)

Example

Please take a look at the tests.mjs file for a simple example.

Contributions

Contributions are welcome and can be made by submitting GitHub pull requests to this repository. In general, the MFChart source code follows Airbnb JavaScript Style Guide and the rules specified in .eslintrc.json file.

License

This source code is available to everyone under the standard MIT LICENSE.

FAQs

Package last updated on 02 Aug 2020

Did you know?

Socket

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.

Install

Related posts