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

myespresso

v1.0.0

Published

espresso sdk

Downloads

52

Readme

Espresso Javascript Client SDK

myespresso is a NodeJS library that provides a set of tools and functionalities for interacting with the Espresso trading platform.
With myespresso, users can access a variety of trading-related information such as stock prices, market trends, historical data,
stream live market data (WebSockets), and more.It also provides the ability to execute trades and orders in real time.

Installation

Install via npm

npm i myespresso

Getting started with API

let { EspressoApi, WebSocket } = require("myespresso");


let espresso_api = new EspressoApi({
	api_key: 'YOUR_API_KEY',
	state: 'YOUR_STATE',
	customer_id: 'YOUR_CUSTOMER_ID',
	//  OPTIONAL  If user does not have valid access token then use generateSession method
	// access_token:
	// 	'YOUR_ACCESS_TOKEN',
});

// If user does not have valid access token then use generateSession method
espresso_api
	.generateSession(
		'YOUR_REQUEST_TOKEN',
		'YOUR_SECRET_KEY'
	)
	// pass request token in generateSession method as an argument
	.then((data) => {
		console.log('data::::::', data);
    let token ="YOUR_TOKEN"
    SetToken method
    espresso_api.setAccessToken(token);

    // fundDetails method
    let exchange = 'NC';
    return espresso_api.getFundsDetails(exchange)

    //place new order
    return  espresso_api.placeNewOrder({
    "customerId": XXXX,
    "scripCode": 2475,
    "tradingSymbol": "ONGC",
    "exchange": "NC",
    "transactionType": "B",
    "quantity": 1,
    "disclosedQty": 0,
    "price": "92.50",
    "triggerPrice": "0",
    "rmsCode": "ANY",
    "afterHour": "N",
    "orderType": "NORMAL",
    "channelUser": "XXXXX",
    "validity": "GFD",
    "requestType": "NEW",
    "productType": "INVESTMENT"
    })

    // modify order
    return espresso_api.modifyOrder({
    "orderId":"XXXX"
    "customerId": XXXX,
    "scripCode": 2475,
    "tradingSymbol": "ONGC",
    "exchange": "NC",
    "transactionType": "B",
    "quantity": 1,
    "disclosedQty": 0,
    "executedQty":0,
    "price": "95",
    "triggerPrice": "0",
    "rmsCode": "SKSIMNSE1",
    "afterHour": "N",
    "orderType": "NORMAL",
    "channelUser": "XXXXX",
    "validity": "GFD",
    "requestType": "MODIFY",
    "productType": "INVESTMENT"
    })

    // cancel order
    return  espresso_api.cancelOrder({
    "orderId":"XXXX"
    "customerId": XXXX,
    "scripCode": 2475,
    "tradingSymbol": "ONGC",
    "exchange": "NC",
    "transactionType": "B",
    "quantity": 1,
    "disclosedQty": 0,
    "executedQty":0,
    "price": "95",
    "triggerPrice": "0",
    "rmsCode": "SKSIMNSE1",
    "afterHour": "N",
    "orderType": "NORMAL",
    "channelUser": "XXXXX",
    "validity": "GFD",
    "requestType": "CANCEL",
    "productType": "INVESTMENT"
    })

    // cancel order by id
    return espresso_api.cancelOrderById("order_id").

    // one day trade history
    return espresso_api.getAllOrdersHistoryOfDay()

    // Retrieve all trade history
    return  espresso_api.getAllTradesHistory()


    //Retrieve hitory by order id
    return  espresso_api.getHistoryByOrderID(exchange,orderID)


    //Retrieve trade by order id
    return  espresso_api.getTradeGeneratedByOrder(exchange,orderID)

    //Retrieve holding details
    return  espresso_api.getHoldings()

    //Retrieve active script details
    return  espresso_api.getActiveScriptOfDay('NC')

    //Retrieve script details
    return  espresso_api.getScriptMasterCSV('NC')
	})
	.catch((error) => {
		log error
	});


// ########################### Socket Sample Code Starts Here ###########################

let ws = new WebSocket({
	access_token:"YOUR_ACCESS_TOKEN"
	api_key: 'YOUR_API_KEY',
});

//to create connect
ws.connect().then(() => {
	let subscribe = {
		action: 'subscribe',
		key: ['feed'],
		value: [''],
	};
	let feedData = {
		action: 'feed',
		key: ['ltp'],
		value: ['NC22,NF37833,NF37834'],
	};
	let unsubscribe = {
		action: 'subscribe',
		key: ['feed'],
		value: ['NC22,NF37833,NF37834'],
	};

    //to subscribe
	ws.subscribe(subscribe);

    //to fetch data
	ws.fetchData(feedData);

    //to unsubscribe
	ws.unsubscribe(unsubscribe);

	ws.on('tick', receiveTick);

	function receiveTick(data) {
		console.log('receiveTick:::::', data);
	}
});

// ########################### Socket Sample Code Ends Here ###########################