# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['shoonyapy']

package_data = \
{'': ['*']}

install_requires = \
['getmac>=0.8.2,<0.9.0', 'pandas>=1.3.1,<2.0.0', 'requests>=2.26.0,<3.0.0']

setup_kwargs = {
    'name': 'shoonyapy',
    'version': '0.1.1',
    'description': 'Unofficial Python wrapper for Trading REST APIs for Finvasia Shoonya platform',
    'long_description': '# Shoonya Trading APIs\n\nUnofficial Python Trading APIs for Finvasia Shoonya Platform.\n\nTo support this project consider opening account with [finvasia.com](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=) with [this referral link](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=).\n\n[Finvasia](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=) offers Zero Brokerage trading and is doing good recently with it\'s new Shoonya platform.  \nPlease check [shoonya](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=) web platform.  \nSupport this work by opening account with [Finvasia](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=)\n\n**WORK IS STILL IN PROGRESS**\n\n**USE AT YOUR OWN RISK, DO NOT EXPECT 100% PERFECT DATA**\n\n**USE ONLY DURING LIVE MARKET**\n\n**THIS API DOES NOT WORK ON SATURDAY SUNDAY**\n\n**DataApi MAY WORK ON WEEKENDS WITH FEW EXCEPTIONS**\n\n**Documentation is incomplete expect bugs and send pull requests**\n\n## Installation\n\n- Python version `>3.9` is needed for this module to work\n- Git is required for below command to work\n- `pip install git+https://gitlab.com/algo2t/shoonyapy.git`\n\n## Alternate way to install\n- Python version `>3.9` is needed for this module to work\n- Download the wheel from [releases](https://gitlab.com/algo2t/shoonyapy/-/releases)\n- `python -m pip install shoonyapy-0.1.0-py3-none-any.whl`\n\n\n## How to setup a good environment\n\n- Install latest Python version 3.9.x, download it from [here](https://www.python.org/downloads/)\n- Linux comes with python upgrade it to latest version 3.9.x\n- Use [scoop.sh](https://scoop.sh) for Windows as package manager.\n- Use your favorite editor like [VSCodium](https://vscodium.com/) or [VSCode](https://code.visualstudio.com/) download it from [here](https://code.visualstudio.com/Download)\n- VScode is available for Windows, Linux and Mac\n- Python extension for vscode is [here](https://marketplace.visualstudio.com/items?itemName=ms-python.python)\n- MagicPython is also good extension\n- Wonderful documentation for working with python and vscode is [here](https://code.visualstudio.com/docs/languages/python)\n- Use virtualenv to create a virtual python env so that your system is not affected\n- Steps for virtualenv creation - `python -m pip install virtualenv` and then virtualenv venv\n- Activate the `venv` => `.\\venv\\Scripts\\activate` (this is an example for Windows OS)\n- Install and upgrade modules `(venv) PS D:\\trading\\algo2trade\\shoonya> python -m pip install -U pip wheel setuptools pylint rope autopep8`\n\n## Usage\n\n### Creating a `config.py` example\n\n```python\n\nusername=\'FA12345\'\npassword=\'FinvAsia@P123\'\n# Date of Birth format is dd-MM-yyyy e.g 29-06-1984\npan_or_dob=\'ABCDE1234Z\'\n\n\n```\n\n### Login or Using DataApi and ShoonyaApi\n\n```python\n\nfrom shoonyapy import ShoonyaApi, DataApi\nimport logging\n\nimport config\n\nfrom datetime import datetime as dt\nfrom time import sleep\nimport pandas as pd\n\n\nlogging.basicConfig(level=logging.DEBUG)\n\n\nbegin = dt.now()\nprint(begin)\n\ndata = DataApi()\n\nshoonya = ShoonyaApi(config.username, config.password,\n                     config.pan_or_dob, debug=True)\n\nsbin = data.get_instrument_by_exchange_symbol(\'NSE\', \'SBIN\')\n\norder_no = shoonya.place_order(sbin, 1, order_type=shoonya.ORDER_TYPE_LIMIT, price=472,\n                               product=shoonya.PRODUCT_INTRADAY, txn_type=shoonya.TRANSACTION_TYPE_SELL, is_amo=False)\n\ndf = shoonya.orders()\ndf = df.loc[df[\'status\'].str.contains(\'Pending\'), [\n    \'order_no\', \'status\', \'segment\', \'product\']]\nprint(df)\n\n\nend = dt.now()\n\nduration = end - begin\nprint(end)\nprint(f"milliseconds taken :: {duration.microseconds/1000}")\n\n```\n\n## API Short Documentation\n\n### Modify Orders API is still underdevelopment so do not use it.\n\n#### List Orders or Order Book\n\n`shoonya.orders()`\n\n#### Order History or Order Details\n\n`shoonya.order_history(order_no, segment)`\n\n#### List Trades or Trade Book\n\n`shoonya.trades()`\n\n#### Trade History or Trade Details\n\n`shoonya.trade_history()`\n\n#### Holdings\n\n`shoonya.holdings()`\n\n#### Net Position or Positions\n\n`shoonya.positions()`\n\n#### Fund Limit or Funds - NOT WORKING\n\n`shoonya.funds()`\n\n### Order Management APIs\n\n### Place Bracket Order\n\n```python\n\ninst = data.get_instrument_by_exchange_symbol(\'MCX\', \'GOLDPETAL21AUGFUT\')\nprint(data.ltp(inst).ltp)\n\norder_no = shoonya.place_bracket_order(inst, shoonya.TRANSACTION_TYPE_BUY, \\\n    shoonya.ORDER_TYPE_MARKET, 1, 0, 0, 2, 1)\n\ninst = data.get_instrument_by_exchange_symbol(\'NSE\', \'SBIN\')\norder_no = shoonya.place_bracket_order(inst, shoonya.TRANSACTION_TYPE_BUY, \\\n    shoonya.ORDER_TYPE_LIMIT, quantity=1, price=450, profit=2, stoploss=10)\n\nprint(order_no)\n\n```\n\n### Exit Bracket Order\n\n```python\n\nbo_exit = shoonya.exit_bracket_order(order_no, shoonya.SEGMENT_COMMODITY)\nprint(bo_exit)\n\n```\n\n### Square Off All Positions\n\n`shoonya.square_off_all()`\n\n### Square Off Symbol Positions\n\n```python\ninst = data.get_instrument_by_exchange_symbol(\'NSE\', \'SBIN\')\nshoonya.square_off_symbol(instrument.symbol)\n\n```\n\n### Exit Pending Orders\n\n`shoonya.exit_pending_orders()`\n\n### Place Order\n\n```python\n\ndata = DataApi()\ninst = data.get_instrument_by_exchange_symbol(exchange, symbol)\nprint(inst)\norder_no = shoonya.place_order(inst, quantity, price, is_amo=True)\nprint(order_no)\n```\n\n### Cancel Order\n\n`shoonya.cancel_order(order_no, shoonya.SEGMENT_COMMODITY)`\n\n### Market Status\n\n```python\n\nshoonya = ShoonyaApi(config.username, config.password,\n                     config.pan_or_dob, debug=True)\n\nshoonya.market_status(exchange=\'MCX\')\nshoonya.market_status(mkt_type=shoonya.MARKET_TYPE_OL)\nshoonya.market_status(mkt_type=\'\')\nshoonya.market_status(exchange=shoonya.EXCHANGE_NSE, segment=shoonya.SEGMENT_DERIVATIVE, mkt_type=shoonya.MARKET_TYPE_NL)\n\n```\n\n## DataApi example for Indices Nifty Bank and Nifty 50 no login is required\n\n```python\n\nfrom shoonyapy import DataApi\n\nfrom datetime import datetime as dt\nfrom datetime import timedelta as td\n\nfrom collections import namedtuple\n\ndata = DataApi()\n\n\nInstrument = namedtuple(\'Instrument\', [\'exchange\', \'segment\', \'token\', \'symbol\',\n                                       \'name\', \'expiry\', \'lot_size\'])\n\ninst = Instrument(\'NSE_INDICES\',\'E\',\'26009\',\'Nifty Bank\', \'Nifty Bank\',\'0001-01-01T00:00:00\', 0)\ndf = data.history(inst, start_time=dt.today() - td(days=5))\nprint(df)\ninst = Instrument(\'NSE_INDICES\',\'E\',\'26000\',\'Nifty 50\', \'Nifty Bank\',\'0001-01-01T00:00:00\', 0)\n\n# Default end_time is today\ndf = data.history(inst, start_time=dt.today() - td(days=5))\nprint(df)\n\ndf = data.history(inst, start_time=dt.today() - td(days=5), end_time=dt.today() - td(days=3), interval=15)\nprint(df)\n\n\n```\n\n### Types of Exchanges\n\n```python\n\n\nshoonya.EXCHANGE_NSE\nshoonya.EXCHANGE_BSE\nshoonya.EXCHANGE_MCX\n\n```\n\n### Types of Segments\n\n```python\n\n\nshoonya.SEGMENT_EQUITY\nshoonya.SEGMENT_DERIVATIVE\nshoonya.SEGMENT_CURRENCY\nshoonya.SEGMENT_COMMODITY\n\n```\n\n### Types of Transactions\n\n```python\n\nshoonya.TRANSACTION_TYPE_BUY\nshoonya.TRANSACTION_TYPE_SELL\n\n\n```\n\n### Types of Products\n\n```python\n\n\nshoonya.PRODUCT_NORMAL\nshoonya.PRODUCT_INTRADAY\nshoonya.PRODUCT_MARGIN\nshoonya.PRODUCT_BO\nshoonya.PRODUCT_CO\nshoonya.PRODUCT_CNC\nshoonya.PRODUCT_MTF\n\n\n```\n\n### Types of Markets\n\n```python\n\nshoonya.MARKET_TYPE_NL\nshoonya.MARKET_TYPE_OL\nshoonya.MARKET_TYPE_AU\nshoonya.MARKET_TYPE_SP\nshoonya.MARKET_TYPE_A1\nshoonya.MARKET_TYPE_A2\n\n\n```\n\n## Contributing\n\nYou can contribute to the project by submitting issues, merge requests, etc.\nDocumentation updates or WiKi Updates can be suggested by users.\n\n## Donations\n\nFor any donations, please connect with the author.\n\n## Authors and acknowledgment\n\nThanks to people who motivated to create this project.  \nThanks Finvasia / Shoonya Team for providing API Documentation\n\n### Dependencies\n\n- Python [requests](https://docs.python-requests.org/en/master/)\n- Python [pandas](https://pandas.pydata.org/docs/index.html)\n- Python [getmac](https://getmac.readthedocs.io/en/latest/)\n\n## License\n\nThis project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.\nFree distribution is allowed.\n\n## Project status\n\nThis project is a hobby project and must not be considered as legally bonded with Finvasia.\nIn case, you want to support this project consider opening account with [finvasia.com](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=) with [this referral link](https://prism.finvasia.com/register/?franchiseLead=MzYzMDE=).\n',
    'author': 'Algo 2 Trade',
    'author_email': 'help@algo2.trade',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://gitlab.com/algo2t/shoonyapy',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.9,<4.0',
}


setup(**setup_kwargs)
