npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

inves-broker

v0.6.4

Published

Interact with multiple broker APIs in the Indian stock market.

Downloads

463

Readme

inves-broker

inves-broker provides a unified interface for dealing with multiple broker APIs in the Indian stock market.

Currently supported brokers

  1. Kite by Zerodha
  2. Paytm Money

Quick Start

npm install inves-broker
import { IConnect, BrokerName } from 'inves-broker';

const kite = IConnect(BrokerName.KITE, {
                kiteAPIKey: process.env.KITE_API_KEY,
                kiteAPISecret: process.env.KITE_API_SECRET
            });
const kiteUrl = await kite.getLoginURL({});


const paytm = IConnect(BrokerName.PAYTM_MONEY, {
                paytmMoneyAPIKey: process.env.PAYTM_API_KEY,
                paytmMoneyAPISecret: process.env.PAYTM_API_SECRET
            });
const paytmUrl = await paytm.getLoginURL({});

Why

Building a platform to support order placement and retrieval via multiple brokers is an exhaustive task. To achieve the same end goal, each broker has a slightly different way of doing things. Integrating each broker would require extensive reading of all the documentation followed by a tedious implementation.

How do we solve for multiple brokers under a common interface?

We enforce a standard of how you should place an order, get order information, etc. This standard closely conforms to Zerodha's way of doing things. If you are familiar with using the Kite API, you will find inves-broker's interface to be similar. For exceptional cases where a broker cannot fit within a standard, we provide an extended support for that. Hence, all brokers under inves-broker follow the Open-closed principle.

Usage

Each broker class will provide the methods listed here. In some cases, it will be necessary to deviate from the standard. This is described below.

Paytm Money and Dhan

Paytm Money and Dhan identify an instrument via its list of security ids. This list needs to be downloaded once a day. By default, when you place an order, this list is downloaded and stored in memory for the next 24 hours. Hence, the first call to place an order would be slow. Subsequent calls would just hit the cache. However, if you wish to pre-fetch this list, even before you invoke the placeOrder method, you can do this via following:

import { IConnect, BrokerName, PaytmMoneyBroker } from 'inves-broker';

const broker = IConnect(BrokerName.PAYTM_MONEY, config);
if (broker instanceof PaytmMoneyBroker) {
     await broker.triggerMemoizationOfSecurityList();
}

Contributing

  • We follow the conventional commit message spec. It's recommended that you read more about on conventionalcommits.org.
  • Each accepted pull request will be squashed and merged.