Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inves-broker

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inves-broker

Interact with multiple broker APIs in the Indian stock market.

  • 0.6.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-7.87%
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 02 Jan 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc