Narcoleptic Pony Machine

    @extra-fyers/websocket.web
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.6 • Public • Published

    A Javascript interface for FYERS API {websocket}.
    📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs.

    The objective of this package is to provide a cleaner interface to FYERS API. This websocket namespace provides the same interface as FYERS WebSocket API, along with parsing of binary market data. This allows you to recieve instant notifications of order update and market data.

    Global functions such as connectOrderUpdate() are stateless and accept Authorization as the first parameter. This authorization can be obtained be performing login with loginStep1() and loginStep2() in the http interface. On the other hand, global functions such as subscribeOrderUpdate() accept Connection as the first parameter, which is returned by the connect functions.

    This package is available in both Node.js and Web formats. The web format is exposed as extra_fyers_websocket standalone variable and can be loaded from jsDelivr CDN.

    This is part of package extra-fyers.
    Stability: Experimental.


    const {http} = require('extra-fyers');
    
    async function main() {
      var app_id       = '****';  // app_id recieved after creating app
      var access_token = '****';  // access_token recieved after login
      var auth = {app_id, access_token};
    
      // List equity and commodity fund limits.
      console.log(await http.getFunds(auth));
    
      // List holdings.
      console.log(await http.getHoldings(auth));
    
      // Place CNC market order for SBIN (equity) on NSE for 5 shares
      var id = await http.placeOrder(auth, {
        symbol: 'NSE:SBIN-EQ',
        productType: "CNC",
        qty: 5,
        side: 1, // BUY
        type: 2, // MARKET
        offlineOrder: "False"
      });
    
      // List postions for today (should list NSE:SBIN-EQ-CNC).
      console.log(await http.getPositions(auth));
    }
    main();


    Index

    Property Description
    MARKET_DATA_URL Root URL for Market data notifications.
    ORDER_UPDATE_URL Root URL for Order update notifications.
    Connection Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
    connectOrderUpdate Connect to Order update URL with WebSocket.
    subscribeOrderUpdate Subscribe to order update.
    unsubscribeOrderUpdate Unsubscribe to order update.
    connectMarketData Connect to Market data URL with WebSocket.
    subscribeMarketQuote Subscribe to market quote.
    subscribeMarketDepth Subscribe to market depth.
    unsubscribeMarketQuote Unsubscribe to market quote.
    unsubscribeMarketDepth Unsubscribe to market depth.


    References



    Install

    npm i @extra-fyers/websocket.web

    DownloadsWeekly Downloads

    11

    Version

    1.3.6

    License

    MIT

    Unpacked Size

    26.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • wolfram77