magiprop-charges
v1.0.4
Published
A comprehensive utility for calculating brokerage, taxes, and other charges for trades executed through Zerodha, including support for equities, F&O, commodities, and currency segments.
Downloads
2
Readme
Charges Calculator
A Node.js package for calculating charges for trades based on asset type, broker, and transaction type. Supports equity, currency, and intraday trades.
Installation
To install the package, use npm:
npm install charges-calculator
Usage After installation, you can require the package and use the getCharges function to calculate various trading charges.
Example
const { getCharges } = require('charges-calculator');
// Example usage for equity trading
const equityCharges = getCharges(
'equity', // assetType
'cash', // type (e.g., 'ce', 'pe', 'fut', 'cash')
'ZERODHA', // broker (e.g., 'ZERODHA', '5PAISA')
'buy', // transactionType (e.g., 'buy', 'sell')
100, // premiumPrice (price per unit)
10, // quantity
'NSE' // stockExchange (e.g., 'NSE', 'BSE')
);
console.log('Equity Charges:', equityCharges);
// Example usage for currency trading
const currencyCharges = getCharges(
'currency', // assetType
'ce', // type (e.g., 'ce', 'pe')
'5PAISA', // broker (e.g., 'ZERODHA', '5PAISA')
'sell', // transactionType (e.g., 'buy', 'sell')
150, // premiumPrice (price per unit)
20, // quantity
'BSE' // stockExchange (e.g., 'NSE', 'BSE')
);
console.log('Currency Charges:', currencyCharges);
API getCharges(assetType, type, broker, transactionType, premiumPrice, quantity, stockExchange) Calculates the charges based on the parameters provided.