Skip to main content

A Python library for trading in the Indian Finance Sector with support for multiple broker APIs.

Reason this release was yanked:

wrong docs

Project description

Fenix – Indian Broker Trading Library

License

A Python library for trading in the Indian Finance Sector with support for many broker APIs.

Install · Usage · Manual

The Fenix library is used to connect and trade with brokers in the Indian Financial Markets. It provides quick access to market data, order palcemement, etc. for storage, analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering.

It is intended to be used by coders, developers, technically-skilled traders, data-scientists and financial analysts for building trading algorithms.

Current feature list:

  • support for many brokers — more coming soon.
  • optional normalized data for cross-exchange analytics.
  • an out of the box unified API that is extremely easy to integrate.
  • works in Python 3.

Supported Indian Brokers

The fenix library currently supports the following 16 indian brokers and their trading APIs:

Logo Id Name Supported
aliceblue AliceBlue 🟢
angelone AngelOne 🟢
choice Choice 🟢
finvasia Finvasia 🟢
fivepaisa 5paisa 🟢
fyers Fyers 🟢
iifl IIFL 🟢
kotak Kotak 🟢
kotakneo Kotak Neo 🟢
kunjee Kunjee 🟢
mastertrust Master Trust 🟢
motilaloswal Motilal Oswal 🟢
symphony JM Financial 🟢
upstox Upstox 🟢
vpc VPC 🟢
zerodha Zerodha 🟢

Install

fenix in PyPI

pip install fenix
import fenix
print(fenix.brokers)
# print a list of all available exchange classes

Documentation

Read the Manual for more details.

Usage

Intro

The fenix library provides unifed methods for fetching market data, generating access tokens, placing different order types, fetching orderbook & tradebook, fetching order updates, etc.

In order to trade you need to provide your user credentials. It usually means signing up to the broker and creating API keys for your account. Some exchanges require personal info or identification. Sometimes verification may be necessary as well. In this case you will need to register yourself, this library will not create accounts or API keys for you.

Using this library you can perform the following:

  • get instrument tokens for equity, options for both NSE & BSE.
  • trade by making market, limit, stoploss and stoploss-market and bracket orders (if provided by the broker).
  • modify and cancel open orders.
  • query single order updates.
  • query orderbook & tradebook.
  • query positionbook.
  • query holdings.
  • query personal account info.
  • query rms limits.

Examples

# coding=utf-8

from fenix import aliceblue, angelone, zerodha, iifl
from fenix import constants


# Download all the FNO Intrument Tokens, Symbols, Lot Size
nfo_tokens = zerodha.create_fno_tokens()


# Create Headers which contain Access Token used to place orders, fetch orderbook, etc.
params = {
    "user_id": "YOUR_USER_ID",
    "password": 'YOUR_PASSWORD',
    "totpstr": 'YOUR_TOTP_STRING',
    "api_key": 'YOUR_API_KEY',
    "api_secret":'YOUR_API_SECRET'
    }

headers = zerodha.create_headers(params)


# Place a Limit Order in the FNO Segment
limit_order = zerodha.limit_order_fno(
                        price = 13.0,
                        option = "CE",
                        strike_price = 45500,
                        quantity = 15,
                        side = "BUY",
                        unique_id = 'LIMITOrderNFO',
                        headers = headers,
                        )


# Fetch the current detail of a single order
order_detail = zerodha.fetch_order('ORDER_ID', headers)


# Modify an open order
modified_order = zerodha.modify_order(
                            order_id='231217000002374',
                            price=10.0,
                            trigger=9.5,
                            quantity=15,
                            order_type=constants.OrderType.SL,
                            validity=constants.Validity.DAY,
                            headers=headers
                            )

# Cancel an open order
cancelled_order = zerodha.cancel_order(
                            order_id='231217000005603',
                            headers=headers
                            )

# Fetch OrderBook
orderbook = aliceblue.fetch_orders(headers=headers)


print(aliceblue.id, aliceblue.create_fno_tokens())
print(angelone.id, angelone.create_fno_tokens())

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

fenix-2.0.0.tar.gz (242.5 kB view details)

Uploaded Source

Built Distribution

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

fenix-2.0.0-py3-none-any.whl (223.5 kB view details)

Uploaded Python 3

File details

Details for the file fenix-2.0.0.tar.gz.

File metadata

  • Download URL: fenix-2.0.0.tar.gz
  • Upload date:
  • Size: 242.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fenix-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a3ca1d8f039bd03f1ab85689fa0d436bf1df2ec784ddeb9c4fa62b1ec89449ba
MD5 3c6ea6f3fec85d9b65e09f8632ca94e3
BLAKE2b-256 876ad71b8381eebfec845feb4257190040a5ce9ebbd55c331bb3e34637656173

See more details on using hashes here.

File details

Details for the file fenix-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: fenix-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 223.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fenix-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d41d25a4b9d6a8a974aefaddf99f26907537cac851548faa27c27b7cfa47adaa
MD5 c5bbd269f1014cf5ea7d1b4827c7762b
BLAKE2b-256 5ff6f8f4156afbe1df1c47006c946e6c97f2c21a687a67e62ba0e737f28f9307

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