GithubHelp home page GithubHelp logo

mann9939 / py5paisa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openapi-5p/py5paisa

0.0 0.0 0.0 122 KB

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

Home Page: https://5paisa.github.io

Makefile 12.19% Python 87.81%

py5paisa's Introduction

5paisa Python SDK

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

5paisa logo

Documentation

Read the docs hosted here

Features

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

Installation

pip install pyp5aisa

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="[email protected]", passwd="password", dob="YYYYMMDD")
client.login()

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

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()

Scrip codes reference:

BSE: https://www.bseindia.com/ NSE: https://nse-scrips.herokuapp.com/

Placing an order

# Note: This is an indicative order.

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

test_order = Order(order_type=OrderType.BUY, scrip_code=11111, quantity=10)

client.place_order(test_order)

Modifying an order

client.modify_order(exch_order_id="12345678", traded_qty=10, scrip_code=11111)

Canceling an order

client.cancel_order(exch_order_id="12345678", traded_qty=10, scrip_code=11111)

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
client.fetch_trade_info(req_list)

# Fetches the order status
client.fetch_order_status(req_list)

TODO

  • Write tests.

Credits

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

py5paisa's People

Contributors

ba11b0y avatar 5paisa avatar mann9939 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.