Skip to main content

No project description provided

Project description

The Firstock Connect API Python client - v3

To communicate with the Firstock Connect API using Python, you can use the official Python client library provided by Firstock.
Licensed under the MIT License.

Documentation

  • python client documentation

v3 - Changes

  • Error code response structured has been changed
  • Renamed

Installing the client

You can install the pre release via pip pip install --upgrade thefirstock

Its recommended to update setuptools to latest if you are facing any issue while installing

pip install -U pip setuptools

Since some of the dependencies uses C extensions it has to compiled before installing the package.

API usage

from thefirstock import thefirstock

login = thefirstock.firstock_login(userId='', password='', TOTP='', vendorCode='', apiKey='')

"""Place an order"""
placeOrder = thefirstock.firstock_placeOrder(
    exchange="",
    tradingSymbol="",
    quantity="",
    price="",
    product="",
    transactionType="",
    priceType="",
    retention="",
    triggerPrice="",
    remarks=""
)

"Fetch single order deatils"
SOH = thefirstock.firstock_SingleOrderHistory(
    orderNumber=placeOrder["data"]["orderNumber"],
)

"""Order book"""
orderBook = thefirstock.firstock_orderBook()

"""Cancel order"""
cancelOrder = thefirstock.firstock_cancelOrder(orderNumber=placeOrder["data"]["orderNumber"])


"""Historical data"""
timePriceSeries = thefirstock.firstock_TimePriceSeries(
    exchange="NSE",
    token="22",
    startTime="16/08/2022 09:45:32",
    endTime="15/02/2023 13:45:32",
    interval="5"
)

Refer to the Firstock Connect Documentation for the complete list of supported methods.

WebSocket usage

from typing import Any
from thefirstock.firstockModules import firstockWebSockets
from thefirstock.pyClient.websocket import WsClient
from thefirstock.pyClient.websocket.enums import MessageTopic

"""Initilizer"""
client = firstockWebSockets.webSocketLogin()
ws = client.ws


@ws.on_connect
def connected(client, message):
    """Establishment of connection for required symbol"""
    if message.get('s') == 'OK':
        client.subscribe_feed('NSE', '26000') # Subscribe to NIFTY
        client.subscribe_feed('NSE', '26009') # Subscribe to BANKNIFTY


@ws.on_message(MessageTopic.SUBSCRIBE_FEED)
def msg_handler(client: WsClient, message: Any):
    """Prints the message successfully"""
    print(message)


ws.connect(uid='userId', actid='userId')
ws.run_forever()

Run unit tests

python setup.py test

Changelog

Check release notes.

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

test_firstock-0.0.3.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

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

test_firstock-0.0.3-py3-none-any.whl (90.4 kB view details)

Uploaded Python 3

File details

Details for the file test_firstock-0.0.3.tar.gz.

File metadata

  • Download URL: test_firstock-0.0.3.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for test_firstock-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d823950685a0668495d188f9be2c1eb226107c96f2be7d2e6a7649ed032b3206
MD5 a064190e26d89d69273046214eeba522
BLAKE2b-256 204a6048c16a32fae1747ce8c26bc8cc32eea26c700f2aa4d4af5b5aa4dbd2f2

See more details on using hashes here.

File details

Details for the file test_firstock-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: test_firstock-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 90.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for test_firstock-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9fb1e207257246f29ebb933437ff5d8020cb8334f03c5944cea2835dffc2e423
MD5 31749083ec469f48de2bbe5223c1e45c
BLAKE2b-256 d3cb62f68f02b40fa403dd7bab6dfcb62075fb3d2188661ffecf43ea77015d0f

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