Skip to main content

Python SDK for 5paisa APIs natively written in VB.NET

Project description

5paisa Python SDK

Python SDK for 5paisa APIs natively written in VB .NET

5paisa logo

Features

  • Order placement, modification and cancellation
  • Fetching user info including holdings, positions, margin and order book.
  • Fetching order status and trade information.

Usage

Configuring API keys

Get your API keys from https://www.5paisa.com/developerapi/apikeys

Configure these keys in a file named keys.conf in the same directory as your python script exists

A sample keys.conf is given below:

[KEYS]
APP_NAME=YOUR_APP_NAME_HERE
APP_SOURCE=YOUR_APP_SOURCE_HERE
USER_ID=YOUR_USER_ID_HERE
PASSWORD=YOUR_PASSWORD_HERE
USER_KEY=YOUR_USER_KEY_HERE
ENCRYPTION_KEY=YOUR_ENCRYPTION_KEY_HERE

Authentication

from py5paisa import FivePaisaClient

client = FivePaisaClient(email="random_email@xyz.com", passwd="password", dob="YYYYMMDD")
client.login()

After successful authentication, the cookie is persisted for subsequent requests.

Fetching user info

# Fetches holdings
client.holdings()

# Fetches margin
client.margin()

# Fetches positions
client.positions()

# Fetches the order book of the client
client.order_book()

Placing an order

# This is an indicative order.

from py5paisa.order import Order, OrderType, Exchange, ExchangeType

test_order = Order(order_for=OrderType.PLACE, exchange=Exchange.BSE, exchange_type=ExchangeType.CASH, price=0,
            order_id=0, order_type="BUY", quantity=10, scrip_code=500875, atmarket=True, remote_order_id="23324", exch_order_id="0", disqty=10, stoploss_price=0, is_stoploss_order=False, ioc_order=False, is_intraday=False, is_vtd=False, vtd="", ahplaced="Y", public_ip="45.112.149.104", order_validity=0, traded_qty=0)

print(client.place_order(test_order))

Fetching Order Status and Trade Information

from py5paisa.order import OrderForStatus, Exchange, ExchangeType, RequestList

test_order_status = OrderForStatus(exchange=Exchange.BSE, exchange_type=ExchangeType.CASH, scrip_code=500875, order_id=0)

req_list = RequestList()
# Add multiple orders to the RequestList to know status of multiple orders at once.
req_list.add_order(test_order_status)

# Fetches the trade details
print(client.fetch_trade_info(req_list))

# Fetches the order status
print(client.fetch_order_status(req_list))

TODO

  • Handle responses more gracefully.
  • Write tests.
  • Add logging

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py5paisa-0.1.2.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py5paisa-0.1.2-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file py5paisa-0.1.2.tar.gz.

File metadata

  • Download URL: py5paisa-0.1.2.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.11

File hashes

Hashes for py5paisa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 41dc2d36aaf9f78015ee647fccc61afb575a6ff8c8c01a257e5d0238a43876a8
MD5 0dea5d1511682d527e8842feb98b3126
BLAKE2b-256 7c3a0447819a09a3ae148185fcadf8c1479271603e11937f08f64ba9ba073c91

See more details on using hashes here.

File details

Details for the file py5paisa-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: py5paisa-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.11

File hashes

Hashes for py5paisa-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 43f85928441984450cf37a24475a4592b2bef5fb3c8fb541723d4c074765f6e7
MD5 9eedcbddc99516baedbcacb5aebe7ed3
BLAKE2b-256 45492f920a5140cfe65ec7eb2dfad2011ff23e926144dabf7418ea62665be4fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page