Catalog npm
Back to packageRELEASE DETAILS

0.0.11

npm

5paisajs

Javascript client for 5paisa APIs natively written in .NET

5paisa-trading-apisalgonodejstradingtrading-api
Published18 Jun 2021
Direct dependencies15
Transitive dependenciesNot calculated

README

Current package documentation

5paisajs

Official Javascript client for 5paisa APIs natively written in .NET

Installation

npm install 5paisajs --save

Documentation

Docs are hosted at https://5paisa.github.io/5paisa-js/

Usage

Authentication

Authenticating with TOTP

Get your API keys from (https://tradestation.5paisa.com/apidoc)

// Configuration for your app
const conf = {
  appSource: "",
  appName: "",
  userId: "",
  password: "",
  userKey: "",
  encryptionKey: "",
  clientCode: "",
};

const { FivePaisaClient } = require("5paisajs");

var client = new FivePaisaClient(conf);

// This client object can be used to login multiple users.
client
  .get_TOTP_Session("Client code", "TOTP", "PIN")
  .then((response) => {
    // Fetch holdings, positions or place orders here.
    // Some things to try out are given below.
  })
  .catch((err) => {
    // Oh no :/
    console.log(err);
  });

Authenticating with Access Token

Get your API keys from (https://tradestation.5paisa.com/apidoc)

// Configuration for your app
const conf = {
  appSource: "",
  appName: "",
  userId: "",
  password: "",
  userKey: "",
  encryptionKey: "",
  clientCode: "",
};

const { FivePaisaClient } = require("5paisajs");

var client = new FivePaisaClient(conf);

// This client object can be used to login multiple users.
const access_token = "";

client
  .set_access_token(access_token)
  .then((res) => {
    // Fetch holdings, positions or place orders here.
    // Some things to try out are given below.
  })
  .catch((err) => {
    // Oh no :/
    console.log(err);
  });

Authenticating with Request Token

Get your API keys from (https://tradestation.5paisa.com/apidoc)

OAUTH Approach

First get a token by logging in to -> https://dev-openapi.5paisa.com/WebVendorLogin/VLogin/Index?VendorKey=&ResponseURL=

VendorKey is UesrKey for individuals user

for e.g. you can use ResponseURL as https://www.5paisa.com/technology/developer-apis Pass the token received in the response url after successful login to get an access token (this also sets the token for all the APIs you use)- Please note that you need to copy the request token from URL and paste in this code and start the code within 30s.

client.get_oauth_session('Your Request Token')

After successful authentication, you should get a Logged in!! message in console

// Configuration for your app
const conf = {
  appSource: "",
  appName: "",
  userId: "",
  password: "",
  userKey: "",
  encryptionKey: "",
  clientCode: "",
};

const { FivePaisaClient } = require("5paisajs");

var client = new FivePaisaClient(conf);

// This client object can be used to login multiple users.
const request_token = "";

client
  .get_oauth_session(request_token)
  .then((res) => {
    // Fetch holdings, positions or place orders here.
    // Some things to try out are given below.
  })
  .catch((err) => {
    // Oh no :/
    console.log(err);
  });

Fetch Holdings

client
  .getHoldings()
  .then((holdings) => {
    console.log(holdings);
  })
  .catch((err) => {
    console.log(err);
  });

/*
[
  {
    BseCode: 535755,
    CurrentPrice: 140,
    DPQty: 0,
    Exch: '\x00',
    ExchType: 'C',
    FullName: 'XYZ ABC',
    NseCode: 30108,
    POASigned: 'N',
    PoolQty: 1,
    Quantity: 1,
    ScripMultiplier: 1,
    Symbol: 'XYZ'
  }
]
*/

Fetch Positions

client
  .getPositions()
  .then((positions) => {
    console.log(positions);
  })
  .catch((err) => {
    console.log(err);
  });

Place order

var options = {
  exchangeSegment: "C",
  atMarket: false,
  stopLossPrice: 0,
  isVTD: false,
  isIOCOrder: false,
  isIntraday: false,
  ahPlaced: "N",
  IOCOrder: false,
  price: 208,
};
try {
  client.placeOrder("BUY", "1660", "1", "N", options).then((response) => {
    console.log(response);
  });
} catch (err) {
  console.log(err);
}

Modify order

    client.modifyOrder("1100000007628729", "1", "210", "1660", false, "N", "C", true).then((response) => {
            console.log(response)
        })
    } ).catch((err) => {
        console.log(err)
    });

Cancel Order

 client.cancelOrder("1100000007973827", "1", "205", "1660", false, "N", "C", false).then((response) => {
            console.log(response)
        })
    } ).catch((err) => {
        console.log(err)
    });

Place BO-CO Order

var a = {};
client
  .bocoorder(1660, 1, 205, 0, 217, "B", "N", "C", "P", 200, a)
  .then((Response) => {
    console.log(Response);
  })
  .catch((err) => {
    console.log(err);
  });
// Note : For Cover order par Order_for='c'

Modified Bo-Co Order

var a = {
  ExchOrderId: "1100000008193800",
};
client
  .bocoorder(1660, 1, 205, 0, 217, "B", "N", "C", "M", 200, a)
  .then((Response) => {
    console.log(Response);
  })
  .catch((err) => {
    console.log(err);
  });

// Note : We Can not Modify Target And Stoploss legs

Modify legs of Executed Bo-Co Order

var ab = {
  price: 215,
};

client
  .Mod_bo_order("S", 1660, 1, "N", "1100000008697274", ab)
  .then((Response) => {
    console.log(Response);
  })
  .catch((err) => {
    console.log(err);
  });
// Note : This is for modify profit order.

var ab = {
  isStopLossOrder: true,
  stopLossPrice: 205,
  isIntraday: true,
  atMarket: true,
};

client
  .Mod_bo_order("S", 1660, 1, "N", "1100000008697274", ab)
  .then((Response) => {
    console.log(Response);
  })
  .catch((err) => {
    console.log(err);
  });
// Note : this is for modify stoploss order.

MarketFeed

a = [
  {
    Exch: "N",
    ExchType: "D",
    Symbol: "NIFTY 27 MAY 2021 CE 14500.00",
    Expiry: "20210527",
    StrikePrice: "14500",
    OptionType: "CE",
  },
];

client
  .getMarketFeed(a)
  .then((response) => {
    console.log(response);
  })
  .catch((err) => {
    console.log(err);
  });

Fetch market feed by scrip

a = [
  {
    Exch: "N",
    ExchType: "C",
    ScripCode: "0",
    ScripData: "RELIANCE_EQ",
  },
  {
    Exch: "N",
    ExchType: "D",
    ScripCode: "40354",
    ScripData: "",
  },
];

client
  .fetch_market_feed_by_scrip(a)
  .then((response) => {
    console.log(response);
  })
  .catch((err) => {
    console.log(err);
  });

OrderStatus

orderList = [
  {
    Exch: "N",
    RemoteOrderID: "1000000002817035",
  },
  {
    Exch: "N",
    RemoteOrderID: "23060806720092",
  },
];
client
  .getOrderStatus(orderList)
  .then((response) => {
    console.log(response);
  })
  .catch((err) => {
    console.log(err);
  });

MarketDepth

a = [
  { Exchange: "N", ExchangeType: "D", ScripCode: "51440" },
  { Exchange: "N", ExchangeType: "C", ScripCode: "1660" },
];
client
  .getmarketdepth(a)
  .then((response) => {
    console.log(response);
  })
  .catch((err) => {
    console.log(err);
  });

Historical Data

// historicalData(<Exchange>,<Exchange Type>,<Scrip Code>,<Time Frame>,<From Data>,<To Date>)
a = client.historicalData("n", "c", "1660", "1m", "2021-05-31", "2021-06-01");

//Note: Timeframe should be from this list ['1m','5m','10m','15m','30m','60m','1d']

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 18

Native requirements
15 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^0.19.2runtime
axios-cookiejar-support
Environment
{
  "local_name": "axios-cookiejar-support",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
jsdoc
Environment
{
  "local_name": "jsdoc",
  "alias": false,
  "peer_metadata": null
}
^3.6.5runtime
tough-cookie
Environment
{
  "local_name": "tough-cookie",
  "alias": false,
  "peer_metadata": null
}
^4.0.0runtime
request
Environment
{
  "local_name": "request",
  "alias": false,
  "peer_metadata": null
}
^2.88.2runtime
node-pandas
Environment
{
  "local_name": "node-pandas",
  "alias": false,
  "peer_metadata": null
}
^1.0.5runtime
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^0.19.2development
axios-cookiejar-support
Environment
{
  "local_name": "axios-cookiejar-support",
  "alias": false,
  "peer_metadata": null
}
^1.0.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^4.11.0development
eslint-config-concise
Environment
{
  "local_name": "eslint-config-concise",
  "alias": false,
  "peer_metadata": null
}
^0.15.0development
eslint-config-concise-jest
Environment
{
  "local_name": "eslint-config-concise-jest",
  "alias": false,
  "peer_metadata": null
}
^0.15.0development
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^0.14.3development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^21.2.1development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^5.0.0development
minami
Environment
{
  "local_name": "minami",
  "alias": false,
  "peer_metadata": null
}
^1.2.3development
npm-run-all
Environment
{
  "local_name": "npm-run-all",
  "alias": false,
  "peer_metadata": null
}
^4.1.2development
prettier-eslint-cli
Environment
{
  "local_name": "prettier-eslint-cli",
  "alias": false,
  "peer_metadata": null
}
^4.4.0development
tough-cookie
Environment
{
  "local_name": "tough-cookie",
  "alias": false,
  "peer_metadata": null
}
^4.0.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-psV9o4CX9SSx1d7x8C4uh4FrXpkwsioSDqGpyhX5IoFmsXCzyaCLynNRfnUaHx0mNBfagyzbWp5ZOrfPb4LsIg==",
  "shasum": "4ff3b19502d5f7a704c33861bb14ad918caa5bbb",
  "tarball": "https://registry.npmjs.org/5paisajs/-/5paisajs-0.0.11.tgz",
  "fileCount": 5,
  "unpackedSize": 38165,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzIUzCRA9TVsSAnZWagAAK08P+wcf8ZF1cLRkgd9+NbDh\nRfdW3CP4kEQV+z6VKlHRA2+Lk31mOoGtlCu0sRvPSmEFRCgWyi/m/GaIra/a\nAJDaVlzj0wau2P5r4itozlU1LnOK2iqkLvZ2n3xyInuoXc+TZuUdpIZLZ483\ngw+p1nANv0TwsGgAsBAaZ2Crpr9LQ39dVbQhwucTf+Nx4huuKyow2nUf59lD\nouR+FcCUmH/stHzoIulWtCJk8k5stka8eTEtwZ5j6GF4/FGej8qWI3e7EMOM\nwIpwrXJH2G/Fr3jjZhr1ANNwzzn+8ZcTplawduNYPk1KVtJcIU71paZSNhbQ\nJ+q/r0Z7vuKJQ23hATW5VWVu5iJYbHHA8sujkiipEEs5X7NIcg0ks4OO5Vts\nwLWAhk58e+JHIavnkEq/KgcEitZfW1aWduN3a8c+KbIx1492pjmj9evi7Q4w\naS4W5T7/GZB0QsxLLC1k+HL+WkyoNlJ53EV6dFQ4Uy0OaZ47J4G3t57WZAGt\ncymxocGo2oGWPa/r0uxgmm75XsLkKzs+0EvkoF9etgAImR3T+YNfAnG8XC+P\n8hDBO9jvLTv9b7TbYoWIdhQFsfcRsobB4Fz72uiDL4jh6eLMSSfR5JKwhXDQ\nbIfYGRUU959uFUlMrZjo1/8S7tm0zIf8+zLIhIDYxOdwm2o85VV0ud7L9tEi\nz8Lr\r\n=Amw3\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIA1AagIsNsYoYOC3nEaLWaqz+pl5lDyAIHHxh7yEYycFAiEAne810U67Yi2svnSl+RnQ/v0BDPfUoDo5KBwgzVqluWE="
    }
  ]
}

Repository

PENDING
openapi-5p/5paisajs

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
5paisa/5paisajs

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:38 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:f33f4143abcd8fbdaf48067573aba4eb04ee8c99f427f5c06ff46d8f7daffbd0

Other collected versions

0.0.2520 Nov0.0.2410 Oct0.0.2326 Sept0.0.2227 Jul0.0.2120 Jul0.0.2013 JunView all collected versions →