Skip to main content

Unofficial Trading APIs for Finvasia Shoonya Platform, help for algo traders

Project description

shoonya

Unofficial Trading APIs for Finvasia Shoonya Web Platform.

Finvasia offers Zero Brokerage trading and is doing good recently with it's new Shoonya platform.
Please check shoonya web platform.
Open account with Finvasia

WORK IS STILL IN PROGRESS

USE AT YOUR OWN RISK

Installation

  • Python version >3.9 is needed for this module to work
  • Git is required for below command to work
  • pip install git+https://gitlab.com/algo2t/shoonya.git

Alternate way

  • Download the .whl file from releases section
  • Using pip to install => python -m pip install shoonya-0.1.0-py3-none-any.whl

How to setup a good environment

  • Install latest Python version 3.9.x, download it from here
  • Linux comes with python upgrade it to latest version 3.9.x
  • Use scoop for Windows as package manager.
  • Use your favorite editor like VSCodium or VSCode download it from here
  • VScode is available for Windows, Linux and Mac
  • Python extension for vscode is here
  • MagicPython is also good extension
  • Wonderful documentation for working with python and vscode is here
  • Use virtualenv to create a virtual python env so that your system is not affected
  • Steps for virtualenv creation - python -m pip install virtualenv and then virtualenv venv
  • Activate the venv => .\venv\Scripts\activate (this is an example for Windows OS)
  • Install and upgrade modules (venv) PS D:\trading\algo2trade\shoonya> python -m pip install -U pip wheel setuptools pylint rope autopep8

Usage

# Check config.py example FIRST

from config import username, password, panno

from shoonya import Shoonya

access_params = Shoonya.login_and_get_authorizations(username=username, password=password, panno=panno)

print(access_params)
with open('params.json', 'w') as wrl:
    json.dump(access_params, wrl)

config.py example

username='FA12345'
password='FinvAsia@P123'
panno='ABCDE1234Z'

Usage existing params.json

import json
from config import username, password, panno

from shoonya import Shoonya, TransactionType, ProductType, OrderType, InstrumentType


# NOTE: The params.json is created using the above login example

ACCESS_FILE = f'params.json'
with open(ACCESS_FILE, "r") as access:
    credentials = json.load(access)
    access_token = credentials["access_token"]
    key = credentials['key']
    token = credentials["token_id"]
    username = credentials['user_id']
    usercode = credentials["usercode"]
    usertype = credentials["usertype"]
    panno = credentials['panno']

shn = Shoonya(username, access_token, panno, key,
              token, usercode, usertype, master_contracts_to_download=['NSE', 'NFO'])

bal = shn.get_limits()
print(bal)
df = pd.DataFrame(bal, index=None)
df['MTM'] = df['REALISED_PROFITS'] + df['MTM_COMBINED']
print(df[['MTM','REALISED_PROFITS', 'AMOUNT_UTILIZED',
      'CLEAR_BALANCE', 'AVAILABLE_BALANCE', 'MTM_COMBINED']])

scrip = shn.get_instrument_by_symbol('NSE', 'SBIN')
print(scrip)

Check complete example in examples folder

  • Here using_existing_access_tokens.py is present for help

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

shoonya-0.1.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

shoonya-0.1.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file shoonya-0.1.1.tar.gz.

File metadata

  • Download URL: shoonya-0.1.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.8 Windows/10

File hashes

Hashes for shoonya-0.1.1.tar.gz
Algorithm Hash digest
SHA256 538b5ec01f2704665dcd5e72cd69c59bd7b910c13e95795447d1914a51b396e2
MD5 d03131b79c594e08fd931b8992d00a24
BLAKE2b-256 9a3e6886258c5a648522817f5ab39d7994f84661b8459f89d178cc4fa433bdea

See more details on using hashes here.

File details

Details for the file shoonya-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: shoonya-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.8 Windows/10

File hashes

Hashes for shoonya-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 091e2e017c63d16aea8c67d8cdc0e2e2feab2245ccb7b402bf59dae11f146248
MD5 1664cf5a99eb61dea17e07fa21c889cc
BLAKE2b-256 71c70c598aa0a1758e8d151576a0988fc25c107d3798fc02207d25adf06e4db6

See more details on using hashes here.

Supported by

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