greeksoft 0.1.1
The official Python client for communicating with Greeksoft's CTCL Application API
License: MIT License

# GreekSoft API
Greeksoft API is a Python-based package that allows users to subscribe to the Greek token and retrieve the latest tick by tick data. This project helps in authenticating a user, broadcasting tokens, and placing orders in a seamless manner.

# Features Authentication: 
By passing a username, session password, and user password, the project authenticates the user.
# Token Retrieval: 
Retrieves the latest token broadcast.
# Order Placement: 
Capable of placing orders once authenticated.

# Technologies Used
Python built-in Libs & third party libs (Pandas, numpy,requests,etc.)


# What's New in Version 0.1.1

**New Feature**: Added New Feature to get Contract Data of All NSE,BSE,MCX...etc at one function call as api.get_contract_data().

**New Feature**: Added New Feature to get OHLC data of the passed 'greektoken' of said Date with its interval from minutes to hrs as api.get_ohlc_data(token,date,interval)

**Major Changes**: After Calling Token_broadcast function we just have to use .get() method, below are the instruction given as follows.

```
pip install greeksoft
```

Usage
Once installed, you can use the project by importing the Greek_API from the greek_api_client package. Below is an example of how to use the API:

```
from greeksoft import GreekAPI

username="username" # String Format

session_pwd="session_pwd"  #String Format

user_pwd="user_pwd" #String Format

procli="procli" # for client id procli="2", retail id procli='1'

ac_no='ac_no' # if retail id pass account number in String Format. 

api = Greek_API(username,session_pwd,user_pwd,procli,ac_no,is_secure,is_base_64,rest_ip,rest_port)
      # Authenticates the provided credentials and handles the JSON, secure, and unsecure flags
      # as per the server configuration. The `rest_ip` and `rest_port` are user-defined inputs
      # to enable server communication based on the specific setup required by the organization.

token_no='102000000' # string format

# Authenticate and fetch the latest token

token_b = api.token_broadcast('token_no','asset_type') # token_no in 'String', asset_type='option' or 'future' or 'equity' in string format.

# token=token_b.get('token') <-- get token no

# symbol=token_b.get('symbol') <-- get symbol name of token passed

# time=token_b.get('ltt') <-- provide the time

# strike=token_b.get('strikeprice') <-- get Strike

# option_type=token_b.get('optiontype') <-- get Option type CE or PE

# instrument=token_b.get('instrument') <-- get instrument type FUTSTK,OPTSTK...

# bid_price=token_b.get('bid') <-- get bid price of token passed

# ask_price=token_b.get('ask') <-- get ask price of token passed


# Subscribe with the Greek Token and pass it in list eg:token_list=['','',...] into the declared variable. 

token_list=['102000000','102000000',...] # Only pass Greek Token.

req_data='' For passing empty string we will get only token,symbol,last traded price, last traded time.

req_data='depth' For passing depth as string we will get only token, symbol,depth inplace of last traded price, last traded time.

req_data='ask/bid' For passing ask/bid as string we will get token, symbol,ask price and its bid price, last traded time.req_data

req_data='allresp' For passing allresp as string we will get token.symbol,all data of traded at the respective time and its last traded time.

for data in api.get_apollo_resp(token_list,req_data='allresp' or 'ask/bid' or 'depth' or ''): # To get response of tokens passed of list using loop.
    print(data)

# Place order passing required parameters, # token_no='102000000', symbol="RELIANCE", qty="minimum_lot" for respective token,

# price= value get from bid/ask price from token broadcast against respective token in strictly in string format,

#buysell= if buy then pass 1 and for sell 2 in integer format,

# For Respective symbols in options: lot='1' corresponds to 75 units (qty='75') same as respective symbols quantity
# For equity: lot='1' corresponds to 1 unit (qty='1')
# For futures: lot='1' corresponds to 1 unit (qty='1')

#ordtype=1, trigprice=0,exchange='NSE','BSE'..etc whichever token is based on exchange type,

#strategyname="example" strategy name will be anything as per userinput.

var_response=api.place_order(tokenno,symbol,lot,qty,price,buysell,ordtype,trigprice,exchange,strategyname) # pass the required parameters

print(var_response) # acknowledge the response get from place order function.

**NetPosition as per StrategyWise**

net_position_strategywise=api.Net_Position_Details_strategywise() # to get the net position of Greek ID as per strategy wise
print(net_position)

**NetPosition request**

net_position_request=api.Net_Position_request() # to get the limited data of net position of Greek ID.strategy

**NetPosition Detailed**

net_position_detailed=api.Net_position_Detailed() # to get the detailed data of the net position of Greek ID

**Order Traded Status**

order_traded_status=api.Order_Trade_status('gorderid') # to get the status of booked order status of Greekorder_Id passed as string.

**Pending Order**

pending_order=api.all_pending_order() # by calling this function we will get all pending order status as while using this function no parameters required to be passed.

**Cancel Order**

cancel_order=api.cancel_order(ord_id) # Passing the greek orderid as string and to cancel the pending order.

**Modify Order**

modify_order=api.modify_order(price,lot,qty,ordtype,gorderid) # to modify the pending order by its latest ask/bid price as in string ,in lot will be the value of multiple of minimum_lot in string,its quantity in string, ordtype in interger and mandatory part gorderid as greek order id in string.

**Rejected Order**

rejected_order=api.api.Orderbook_Rejected() # to get list of all rejected order.

**Orderbook All**

orderbook_all=api.Orderbook_All() # to get the list of all placed order,pending_order ,with all strategy wise.

**Orderbook Traded**

orderbook_traded=api.Orderbook_Traded() # to get the list of all placed and confirmed Booked orders data with all strategy wise.

**Unsubscribe Token**
api.unsubscribe_token(token) # Token in string--MANDATORY

**Close connection**
api.close_connection() # to terminate all sessions

**Contract Data**
api.get_contract_data() # to get all get_contract_data data which contains greektoken, exchange token,expiry,etc...

**OHLC Data**
api.get_ohlc_data(token,date,interval) # token='greektoken', date='YYYYMMDD'<--format interval= 1 for 1hr and 0.1 for minutes.


```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.