├── .gitignore ├── .idea ├── .gitignore ├── fyers-api-sample-code.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── My API Sample Script(GET STARTED) ├── Sample_Test_trading_Data.py └── websocket sample script │ ├── websocket_background.ipynb │ ├── websocket_background.py │ ├── websocket_foreground.ipynb │ └── websocket_foreground.py ├── python ├── apiCalls.py └── getAccessToken.py └── v3 ├── Postman V3 ├── FYERS API V3.postman_collection.json ├── FYERS API V3.postman_environment.json └── FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv ├── node ├── account_info │ ├── funds.js │ └── getprofile.js ├── broker_info │ └── market_status.js ├── login │ └── get_access_token.js ├── market_data │ ├── depth.js │ ├── history.js │ └── quotes.js ├── package-lock.json ├── package.json ├── transaction │ ├── orders │ │ ├── cancel_multi_order..js │ │ ├── cancel_order.js │ │ ├── modify_order.js │ │ ├── mulit_order.js │ │ ├── multi_modify.js │ │ └── place_order.js │ └── positions │ │ ├── convert_position.js │ │ ├── exit_by_id.js │ │ └── exit_position.js ├── transaction_info │ ├── holdings.js │ ├── orderbook.js │ ├── orderbook_byID.js │ ├── position.js │ └── tradebook.js └── websocket │ ├── data_socket │ ├── data_websocket.js │ ├── depthUpdate.js │ ├── indexUpdate.js │ ├── liteSymbolUpdate.js │ ├── symbolUpdate.js │ └── unsubscribeUpdate.js │ └── order_socket │ ├── onGeneral.js │ ├── onOrders.js │ ├── onPosition.js │ └── ontrade.js └── python ├── account_info ├── funds.py └── getprofile.py ├── broker_info └── market_status.py ├── login └── get_access_token.py ├── market_data ├── depth.py ├── history.py └── quotes.py ├── transaction ├── orders │ ├── cancel_multi_order.py │ ├── cancel_order.py │ ├── modify_order.py │ ├── mulit_order.py │ ├── multi_modify.py │ └── place_order.py └── positions │ ├── convert_position.py │ ├── exit_by_id.py │ └── exit_position.py ├── transaction_info ├── holdings.py ├── orderbook.py ├── orderbook_byID.py ├── position.py └── tradebook.py └── websocket ├── data_socket ├── data_websocket_background.py ├── data_websocket_foreground.py ├── depthUpdate.py ├── indexUpdate.py ├── liteSymbolUpdate.py ├── symbolUpdate.py └── unsubscribeUpdate.py ├── order_socket ├── onGeneral.py ├── onOrders.py ├── onPosition.py ├── ontrade.py ├── order_websocket_background.py └── order_websocket_foreground.py └── tbt_socket ├── ondepth.py ├── order_websocket_background.py └── order_websocket_foreground.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore .pyc files 2 | *.pyc -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/fyers-api-sample-code.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /My API Sample Script(GET STARTED)/Sample_Test_trading_Data.py: -------------------------------------------------------------------------------- 1 | from fyers_api import accessToken 2 | from fyers_api import fyersModel 3 | import webbrowser 4 | 5 | 6 | """ 7 | In order to get started with Fyers API we would like you to do the following things first. 8 | 1. Checkout our API docs : https://myapi.fyers.in/docs/ 9 | 2. Create an APP using our API dashboard : https://myapi.fyers.in/dashboard/ 10 | 11 | Once you have created an APP you can start using the below SDK 12 | """ 13 | 14 | #### Generate an authcode and then make a request to generate an accessToken (Login Flow) 15 | 16 | """ 17 | 1. Input parameters 18 | """ 19 | redirect_uri= "APP REDIRECT URI" ## redircet_uri you entered while creating APP. 20 | client_id = "L9NY****W-100" ## Client_id here refers to APP_ID of the created app 21 | secret_key = "MH*****TJ5" ## app_secret key which you got after creating the app 22 | grant_type = "authorization_code" ## The grant_type always has to be "authorization_code" 23 | response_type = "code" ## The response_type always has to be "code" 24 | state = "sample" ## The state field here acts as a session manager. you will be sent with the state field after successfull generation of auth_code 25 | 26 | 27 | ### Connect to the sessionModel object here with the required input parameters 28 | appSession = accessToken.SessionModel(client_id = client_id, redirect_uri = redirect_uri,response_type=response_type,state=state,secret_key=secret_key,grant_type=grant_type) 29 | 30 | ### Make a request to generate_authcode object this will return a login url which you need to open in your browser from where you can get the generated auth_code 31 | generateTokenUrl = appSession.generate_authcode() 32 | 33 | """There are two method to get the Login url if you are not automating the login flow 34 | 1. Just by printing the variable name 35 | 2. There is a library named as webbrowser which will then open the url for you without the hasel of copy pasting 36 | both the methods are mentioned below""" 37 | print((generateTokenUrl)) 38 | webbrowser.open(generateTokenUrl,new=1) 39 | 40 | """ 41 | run the code firstly upto this after you generate the auth_code comment the above code and start executing the below code """ 42 | ########################################################################################################################## 43 | 44 | ### After succesfull login the user can copy the generated auth_code over here and make the request to generate the accessToken 45 | auth_code = "Paste the auth_code generated from the first request" 46 | appSession.set_token(auth_code) 47 | response = appSession.generate_token() 48 | 49 | ### There can be two cases over here you can successfully get the acccessToken over the request or you might get some error over here. so to avoid that have this in try except block 50 | try: 51 | access_token = response["access_token"] 52 | except Exception as e: 53 | print(e,response) ## This will help you in debugging then and there itself like what was the error and also you would be able to see the value you got in response variable. instead of getting key_error for unsuccessfull response. 54 | 55 | 56 | 57 | 58 | ## Once you have generated accessToken now we can call multiple trading related or data related apis after that in order to do so we need to first initialize the fyerModel object with all the requried params. 59 | """ 60 | fyerModel object takes following values as arguments 61 | 1. accessToken : this is the one which you received from above 62 | 2. client_id : this is basically the app_id for the particular app you logged into 63 | """ 64 | fyers = fyersModel.FyersModel(token=access_token,is_async=False,client_id=client_id,log_path="/home/downloads/") 65 | 66 | 67 | ### After this point you can call the relevant apis and get started with 68 | 69 | #################################################################################################################### 70 | """ 71 | 1. User Apis : This includes (Profile,Funds,Holdings) 72 | """ 73 | 74 | print(fyers.get_profile()) ## This will provide us with the user related data 75 | 76 | print(fyers.funds()) ## This will provide us with the funds the user has 77 | 78 | print(fyers.holdings()) ## This will provide the available holdings the user has 79 | 80 | 81 | ######################################################################################################################## 82 | 83 | """ 84 | 2. Transaction Apis : This includes (Tradebook,Orderbook,Positions) 85 | """ 86 | 87 | print(fyers.tradebook()) ## This will provide all the trade related information 88 | 89 | print(fyers.orderbook()) ## This will provide the user with all the order realted information 90 | 91 | print(fyers.positions()) ## This will provide the user with all the positions the user has on his end 92 | 93 | 94 | ###################################################################################################################### 95 | 96 | """ 97 | 3. Order Placement : This Apis helps to place order. 98 | There are two ways to place order 99 | a. single order : wherein you can fire one order at a time 100 | b. multi order : this is used to place a basket of order but the basket size can max be 10 symbols 101 | """ 102 | 103 | ## SINGLE ORDER 104 | 105 | data = { 106 | "symbol":"NSE:ONGC-EQ", 107 | "qty":1, 108 | "type":1, 109 | "side":1, 110 | "productType":"INTRADAY", 111 | "limitPrice":0, 112 | "stopPrice":0, 113 | "validity":"DAY", 114 | "disclosedQty":0, 115 | "offlineOrder":"False", 116 | "stopLoss":0, 117 | "takeProfit":0 118 | } ## This is a sample example to place a limit order you can make the further changes based on your requriements 119 | 120 | print(fyers.place_order(data)) 121 | 122 | ## MULTI ORDER 123 | 124 | data = [{ "symbol":"NSE:SBIN-EQ", 125 | "qty":1, 126 | "type":1, 127 | "side":1, 128 | "productType":"INTRADAY", 129 | "limitPrice":61050, 130 | "stopPrice":0 , 131 | "disclosedQty":0, 132 | "validity":"DAY", 133 | "offlineOrder":"False", 134 | "stopLoss":0, 135 | "takeProfit":0 136 | }, 137 | { 138 | "symbol":"NSE:HDFC-EQ", 139 | "qty":1, 140 | "type":2, 141 | "side":1, 142 | "productType":"INTRADAY", 143 | "limitPrice":0, 144 | "stopPrice":0 , 145 | "disclosedQty":0, 146 | "validity":"DAY", 147 | "offlineOrder":"False", 148 | "stopLoss":0, 149 | "takeProfit":0 150 | }] ### This takes input as a list containing multiple single order data into it and the execution of the orders goes in the same format as mentioned. 151 | 152 | print(fyers.place_basket_orders(data)) 153 | 154 | 155 | ################################################################################################################### 156 | 157 | """ 158 | 4. Other Transaction : This includes (modify_order,exit_position,cancel_order,convert_positions) 159 | """ 160 | 161 | ## Modify_order request 162 | data = { 163 | "id":7574657627567, 164 | "type":1, 165 | "limitPrice": 61049, 166 | "qty":1 167 | } 168 | 169 | print(fyers.modify_order(data)) 170 | 171 | ## Modify Multi Order 172 | 173 | data = [ 174 | { "id":8102710298291, 175 | "type":1, 176 | "limitPrice": 61049, 177 | "qty":0 178 | }, 179 | { 180 | "id":8102710298292, 181 | "type":1, 182 | "limitPrice": 61049, 183 | "qty":1 184 | }] 185 | 186 | print(fyers.modify_basket_orders(data)) 187 | 188 | 189 | ### Cancel_order 190 | data = {"id":'808058117761'} 191 | print(fyers.cancel_order(data)) 192 | 193 | ### cancel_multi_order 194 | data = [ 195 | { 196 | "id":'808058117761' 197 | }, 198 | { 199 | "id":'808058117762' 200 | }] 201 | 202 | print(fyers.cancel_basket_orders(data)) 203 | 204 | 205 | ### Exit Position 206 | data = { 207 | "id":"NSE:SBIN-EQ-INTRADAY" 208 | } 209 | 210 | print(fyers.exit_positions(data)) 211 | 212 | 213 | ### Convert Position 214 | 215 | data = { 216 | "symbol":"MCX:SILVERMIC20NOVFUT", 217 | "positionSide":1, 218 | "convertQty":1, 219 | "convertFrom":"INTRADAY", 220 | "convertTo":"CNC" 221 | } 222 | 223 | print(fyers.convert_position(data)) 224 | 225 | 226 | ################################################################################################################# 227 | 228 | """ 229 | DATA APIS : This includes following Apis(History,Quotes,MarketDepth) 230 | """ 231 | 232 | ## Historical Data 233 | 234 | data = {"symbol":"NSE:SBIN-EQ","resolution":"D","date_format":"0","range_from":"1622097600","range_to":"1622097685","cont_flag":"1"} 235 | 236 | print(fyers.history(data)) 237 | 238 | ## Quotes 239 | 240 | data = {"symbols":"NSE:SBIN-EQ"} 241 | print(fyers.quotes(data)) 242 | 243 | 244 | ## Market Depth 245 | 246 | data = {"symbol":"NSE:SBIN-EQ","ohlcv_flag":"1"} 247 | print(fyers.depth(data)) 248 | 249 | -------------------------------------------------------------------------------- /My API Sample Script(GET STARTED)/websocket sample script/websocket_background.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "source": [ 7 | "\n", 8 | "from fyers_api.Websocket import ws" 9 | ], 10 | "outputs": [], 11 | "metadata": {} 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "source": [ 16 | "# order update (Background Process)\n", 17 | "\n", 18 | "Main Pointers:\n", 19 | "1. To run the process in background the \"run_background\" flag should be set to True.\n", 20 | "2. you can access the log files by providing the log_path to the FyersSocket Object\n", 21 | "3. fs.keep_running() is necessary in order to get the data from Thread\n", 22 | "4. custom_message() this function can be anything which you want to configure at your end " 23 | ], 24 | "metadata": {} 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "source": [ 30 | "def run_process_background_order_update(access_token):\n", 31 | " data_type = \"orderUpdate\"\n", 32 | " fs = ws.FyersSocket(access_token=access_token,run_background=True,log_path=\"/home/Downloads/\")\n", 33 | " fs.websocket_data = custom_message\n", 34 | " fs.subscribe(data_type=data_type)\n", 35 | " \n", 36 | " fs.keep_running()\n", 37 | "\n", 38 | "\n", 39 | "def custom_message(msg):\n", 40 | " print (f\"Custom:{msg}\") \n", 41 | "\n", 42 | "\n", 43 | "def main():\n", 44 | " access_token= \"L9*****BW-100:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9******************************lcnMuaW4iLCJpYXQiOjE2MzE1ODY2MzUsImV4cCI6MTYzMTY2NTgzNSwibmJmIjoxNjMxNTg2NjM1LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCaFFBbExjOTlIUG85TTF4LWl5bTBZRFRHMHhXSi1HVGRkNU5BWlFET2xXYUpIS2h4S2RjMXVYckthc1R3VGlDQ01sYTBhanp6SmYwSWtHSHVFQjcwTThUcFcxckctQUdOWGZlQWhzZVY0bTVRSm1FRT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.Dacrm4oZU1Vcarr3nW8rKueJpVNBJCNVvdjg0cDMQrQ\"\n", 45 | " run_process_background_order_update(access_token)\n", 46 | "if __name__ == '__main__':\n", 47 | "\tmain()" 48 | ], 49 | "outputs": [], 50 | "metadata": {} 51 | }, 52 | { 53 | "cell_type": "markdown", 54 | "source": [ 55 | "# Symbol Data (Background Process)\n", 56 | "\n", 57 | "Main Pointers:\n", 58 | "1. To run the process in background the \"run_background\" flag should be set to True.\n", 59 | "2. you can access the log files by providing the log_path to the FyersSocket Object\n", 60 | "3. fs.keep_running() is necessary in order to get the data from Thread\n", 61 | "4. custom_message() this function can be anything which you want to configure at your end " 62 | ], 63 | "metadata": {} 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "source": [ 69 | "def run_process_background_symbol_data(access_token):\n", 70 | " data_type = \"symbolData\"\n", 71 | " symbol = [\"NSE:SBIN-EQ\",\"NSE:ONGC-EQ\"] ##NSE,BSE sample symbols\n", 72 | "# symbol =[\"MCX:SILVERMIC21NOVFUT\",\"MCX:GOLDPETAL21SEPFUT\"] ##MCX SYMBOLS \n", 73 | " fs = ws.FyersSocket(access_token=access_token,run_background=True,log_path=\"/home/Downloads/\")\n", 74 | " fs.websocket_data = custom_message\n", 75 | " fs.subscribe(symbol=symbol,data_type=data_type)\n", 76 | " fs.keep_running()\n", 77 | "\n", 78 | "def custom_message(msg):\n", 79 | " print (f\"Custom:{msg}\") \n", 80 | "\n", 81 | "\n", 82 | "def main():\n", 83 | " access_token= \"L9******BW-100:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ****************************nllcnMuaW4iLCJpYXQiOjE2MzE1ODY2MzUsImV4cCI6MTYzMTY2NTgzNSwibmJmIjoxNjMxNTg2NjM1LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCaFFBbExjOTlIUG85TTF4LWl5bTBZRFRHMHhXSi1HVGRkNU5BWlFET2xXYUpIS2h4S2RjMXVYckthc1R3VGlDQ01sYTBhanp6SmYwSWtHSHVFQjcwTThUcFcxckctQUdOWGZlQWhzZVY0bTVRSm1FRT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.Dacrm4oZU1Vcarr3nW8rKueJpVNBJCNVvdjg0cDMQrQ\"\n", 84 | " run_process_background_symbol_data(access_token)\n", 85 | " \n", 86 | "if __name__ == '__main__':\n", 87 | "\tmain()" 88 | ], 89 | "outputs": [], 90 | "metadata": {} 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "source": [], 96 | "outputs": [], 97 | "metadata": {} 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": null, 102 | "source": [], 103 | "outputs": [], 104 | "metadata": {} 105 | } 106 | ], 107 | "metadata": { 108 | "kernelspec": { 109 | "display_name": "Python 3 (ipykernel)", 110 | "language": "python", 111 | "name": "python3" 112 | }, 113 | "language_info": { 114 | "codemirror_mode": { 115 | "name": "ipython", 116 | "version": 3 117 | }, 118 | "file_extension": ".py", 119 | "mimetype": "text/x-python", 120 | "name": "python", 121 | "nbconvert_exporter": "python", 122 | "pygments_lexer": "ipython3", 123 | "version": "3.7.11" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 5 128 | } -------------------------------------------------------------------------------- /My API Sample Script(GET STARTED)/websocket sample script/websocket_background.py: -------------------------------------------------------------------------------- 1 | 2 | from fyers_api.Websocket import ws 3 | from fyers_api import fyersModel 4 | 5 | fyers = fyersModel.FyersModel(token="access_token as defined in main block",is_async=False,client_id="client_id(APP_ID)") ## Create a fyersModel object if in any scenario you want to call the trading and data apis when certain condiiton in websocket data is met so that can be triggered by calling the method/object after subscribing and before the keep_running method as shown in run_process_background_symbol_data 6 | 7 | 8 | def run_process_background_symbol_data(access_token): 9 | '''This function is used for running the symbol_Data in background 10 | 1. log_path here is configurable this specifies where the output will be stored for you if the process is running in background 11 | 2. data_type == SymbolData this specfies while using this function you will be able to connect to symbolwebsocket to get the symbolData 12 | 3. run_background = True specifies that the process will be running in background and the data will be stored in the log file the path to which is specified over the log_path''' 13 | 14 | data_type = "symbolData" 15 | symbol =["NSE:NIFTY50-INDEX","NSE:NIFTYBANK-INDEX","NSE:SBIN-EQ","NSE:HDFC-EQ","NSE:IOC-EQ"] 16 | fs = ws.FyersSocket(access_token=access_token,run_background=True,log_path="/home/Downloads/") 17 | fs.websocket_data = custom_message 18 | fs.subscribe(symbol=symbol,data_type=data_type) 19 | 20 | print(fyers.get_profile()) 21 | print(fyers.orderbook()) 22 | fs.keep_running() 23 | 24 | 25 | def run_process_background_order_update(access_token): 26 | '''This function is used for running the order_update in background 27 | 1. log_path here is configurable this specifies where the output will be stored for you if the process is running in background 28 | 2. data_type == orderUpdate this specfies while using this function you will be able to connect to orderwebsocket to get the orderUpdate 29 | 3. run_background = True specifies that the process will be running in background and the data will be stored in the log file the path to which is specified over the log_path''' 30 | 31 | data_type = "orderUpdate" 32 | fs = ws.FyersSocket(access_token=access_token,run_background=True,log_path="/home/Downloads/") 33 | fs.websocket_data = custom_message 34 | fs.subscribe(data_type=data_type) 35 | fs.keep_running() 36 | 37 | 38 | def custom_message(msg): ### This function can be anything which you want to configure at your end 39 | print (f"Custom:{msg}") 40 | 41 | 42 | def main(): 43 | access_token = "eyJ0eXDRzdW5tQ3FmQWN6bDVESkZsMEJLeEw3N3E5RUttMWRYNzcta05VaXhiNE4xY3ZoVGU0RGx4YUFBTERuekhqeU4xQT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EU**************************kEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.SqubA2d3axSDQW3xah8d_ZI_xFQSkDeSExv4EvotuGs" 44 | ## For regular api calls you the access_token as mentioned above 45 | ### Insert the accessToken and app_id over here in the following format for subscribing the websocket data (APP_ID:access_token) 46 | access_token_websocket= "L9*****6BW-100:eyJ0eXDRzdW5tQ3FmQWN6bDVESkZsMEJLeEw3N3E5RUttMWRYNzcta05VaXhiNE4xY3ZoVGU0RGx4YUFBTERuekhqeU4xQT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.SqubA2d3axSDQW3xah8d_ZI_xFQSkDeSExv4EvotuGs" 47 | 48 | ## run a specific process you need to connect to get the updates on 49 | run_process_background_symbol_data(access_token_websocket) 50 | 51 | run_process_background_order_update(access_token_websocket) 52 | 53 | if __name__ == '__main__': 54 | main() -------------------------------------------------------------------------------- /My API Sample Script(GET STARTED)/websocket sample script/websocket_foreground.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "source": [ 7 | "\n", 8 | "from fyers_api.Websocket import ws\n" 9 | ], 10 | "outputs": [], 11 | "metadata": {} 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "source": [ 16 | "# order Update (Foreground Process)\n", 17 | "\n", 18 | "Main Pointers:\n", 19 | "1. To run the process in background the \"run_background\" flag should be set to False.\n", 20 | "2. you can access the log files by providing the log_path to the FyersSocket Object\n", 21 | "3. fs.keep_running() is necessary in order to get the data from Thread\n", 22 | "4. custom_message() this function can be anything which you want to configure at your end " 23 | ], 24 | "metadata": {} 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "source": [ 30 | "def run_process_foreground_order_update(access_token):\n", 31 | " data_type = \"orderUpdate\"\n", 32 | " fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path=\"\")\n", 33 | " fs.websocket_data = custom_message\n", 34 | " fs.subscribe(data_type=data_type)\n", 35 | " fs.keep_running()\n", 36 | "\n", 37 | "\n", 38 | "def custom_message(msg):\n", 39 | " print (f\"Custom:{msg}\") \n", 40 | "\n", 41 | "\n", 42 | "def main():\n", 43 | " access_token= \"L9*******BW-100:eyJ0eXAiOiJKV1QiLCJhbGci************************kuZnllcnMuaW4iLCJpYXQiOjE2MzI0NzgzNzgsImV4cCI6MTYzMjUyOTg1OCwibmJmIjoxNjMyNDc4Mzc4LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCaFRhU3FPWXdVNE50cE9UQm9tbHl5Y3RTb0o3QlVDUFRwWkNHem85SW5VVFlNRWZrdm5lWHFETTJiTEtub09Nc1h0d2hGQ0J3c2JtRWZlWm1TRWdrZ1NNcUJJektRX2RLOWtLajBnZ1dUNUVIOTF1az0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.qkdO2vC8mic10ETqQloSrQ6-iHKX5eBWlZ3pBfMxAIA\"\n", 44 | " run_process_foreground_order_update(access_token)\n", 45 | "if __name__ == '__main__':\n", 46 | "\tmain()" 47 | ], 48 | "outputs": [], 49 | "metadata": {} 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "source": [ 54 | "# Symbol Data (Foreground Process)\n", 55 | "\n", 56 | "Main Pointers:\n", 57 | "1. To run the process in background the \"run_background\" flag should be set to False.\n", 58 | "2. you can access the log files by providing the log_path to the FyersSocket Object\n", 59 | "3. fs.keep_running() is necessary in order to get the data from Thread\n", 60 | "4. custom_message() this function can be anything which you want to configure at your end " 61 | ], 62 | "metadata": {} 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "source": [ 68 | "def run_process_foreground_symbol_data(access_token):\n", 69 | " data_type = \"symbolData\"\n", 70 | " symbol = [\"NSE:NIFTY50-INDEX\",\"NSE:SBIN-EQ\"] ##NSE,BSE sample symbols\n", 71 | "# symbol =[\"MCX:ALUMINIUM21SEPFUT\",\"MCX:SILVERMIC21NOVFUT\"]\n", 72 | " fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path=\"\")\n", 73 | " fs.websocket_data = custom_message\n", 74 | " fs.subscribe(symbol=symbol,data_type=data_type)\n", 75 | " # symbol = [\"NSE:ONGC-EQ\"]\n", 76 | " # fs.unsubscribe(symbol=symbol)\n", 77 | " fs.keep_running()\n", 78 | "\n", 79 | "def custom_message(msg):\n", 80 | " print (f\"Custom:{msg}\") \n", 81 | "\n", 82 | "\n", 83 | "def main():\n", 84 | " access_token= \"L*********BW-100:eyJ0eXAiOiJKV1QiLCJhbGc***************************cGkuZnllcnMuaW4iLCJpYXQiOjE2MzI4MDYxNjQsImV4cCI6MTYzMjg3NTQwNCwibmJmIjoxNjMyODA2MTY0LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCaFVxVVVoT0VINDUyUGRhRW5pZWNHQS1QaUNhaXFwVVdsYl92ZE9SdmFMOFUwTGt6WVJFLTByLUNHZkEteS1UUmo0UndDYi1CaXItcEtsWGs4SnJNMkNzVU9wdmhEc290TUVfYUdyUU85TjUwaExDWT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.hcxy3cddSU9crbB0qw1kIoYEYbGLh4o2-RmDzK3nYOs\"\n", 85 | " run_process_foreground_symbol_data(access_token)\n", 86 | "\n", 87 | "if __name__ == '__main__':\n", 88 | "\tmain()" 89 | ], 90 | "outputs": [], 91 | "metadata": {} 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "source": [], 97 | "outputs": [], 98 | "metadata": {} 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "source": [], 104 | "outputs": [], 105 | "metadata": {} 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "Python 3 (ipykernel)", 111 | "language": "python", 112 | "name": "python3" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.8.10" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 5 129 | } -------------------------------------------------------------------------------- /My API Sample Script(GET STARTED)/websocket sample script/websocket_foreground.py: -------------------------------------------------------------------------------- 1 | 2 | from fyers_api.Websocket import ws 3 | 4 | 5 | def run_process_foreground_symbol_data(access_token): 6 | '''This function is used for running the symbolData in foreground 7 | 1. log_path here is configurable this specifies where the output will be stored for you 8 | 2. data_type == symbolData this specfies while using this function you will be able to connect to symbolwebsocket to get the symbolData 9 | 3. run_background = False specifies that the process will be running in foreground''' 10 | data_type = "symbolData" 11 | # symbol = ["NSE:SBIN-EQ","NSE:ONGC-EQ"] ##NSE,BSE sample symbols 12 | symbol =["NSE:NIFTY50-INDEX","NSE:NIFTYBANK-INDEX","NSE:SBIN-EQ","NSE:HDFC-EQ","NSE:IOC-EQ"] 13 | # symbol =["MCX:SILVERMIC21NOVFUT","MCX:GOLDPETAL21SEPTFUT"] 14 | fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path="/home/Downloads/") 15 | fs.websocket_data = custom_message 16 | fs.subscribe(symbol=symbol,data_type=data_type) 17 | fs.keep_running() 18 | 19 | 20 | def run_process_foreground_order_update(access_token): 21 | '''This function is used for running the order_update in background 22 | 1. log_path here is configurable this specifies where the output will be stored for you. 23 | 2. data_type == orderUpdate this specfies while using this function you will be able to connect to orderwebsocket to get the orderUpdate 24 | 3. run_background = False specifies that the process will be running in foreground ''' 25 | data_type = "orderUpdate" 26 | fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path="/home/Downloads/") 27 | fs.websocket_data = custom_message 28 | fs.subscribe(data_type=data_type) 29 | fs.keep_running() 30 | 31 | 32 | def custom_message(msg): 33 | print (f"Custom:{msg}") 34 | 35 | 36 | def main(): 37 | ### Insert the accessToken and app_id over here in the following format (APP_ID:access_token) 38 | access_token= "L9****6BW-100:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2MzM2Njc5MjksImV4cCI6MTYzMzczOTQ0OSwibmJmIjoxNjMzNjY3OTI5LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDow**********************************aFg4dFotcFZpOGdvYmMtMlRfNmNmYlowQlVFbVJFel9XSjJCRmJTRURWUm1GbDRzdW5tQ3FmQWN6bDVESkZsMEJLeEw3N3E5RUttMWRYNzcta05VaXhiNE4xY3ZoVGU0RGx4YUFBTERuekhqeU4xQT0iLCJkaXNwbGF5X25hQMDA0MDQiLCJhcHBUeXBlIjoxMDAsInBvYV9mbGFnIjoiTiJ9.SqubA2d3axSDQW3xah8d_ZI_xFQSkDeSExv4EvotuGs" 39 | 40 | ## run a specific process you need to connect to get the updates on 41 | run_process_foreground_symbol_data(access_token) 42 | 43 | # run_process_foreground_order_update(access_token) 44 | 45 | if __name__ == '__main__': 46 | main() -------------------------------------------------------------------------------- /python/apiCalls.py: -------------------------------------------------------------------------------- 1 | moduleName = "apiCalls" 2 | """ 3 | 1.We need to first install fyers-apiv2(can be installed as 'pip install fyers-apiv2) if not installed. 4 | 2.We then need to import fyersModel module from fyers_api directory(as done below). 5 | """ 6 | from fyers_api import fyersModel 7 | 8 | 9 | def api_call(access_token, appId, log_path): 10 | functionName = "api_call" 11 | """ 12 | :param access_token: "https://XXXXXX.com" 13 | :param app_id: "XXXXXXXXXXX" 14 | :param log_path: "home/gfxcgv/vgghvb/xxxx" 15 | """ 16 | 17 | # If you want to make asynchronous API calls then assign the below variable as True and then pass it in the functions, by default its value is False 18 | is_async = False 19 | 20 | # Creating an instance of fyers model in order to call the apis 21 | fyers = fyersModel.FyersModel(token=access_token, is_async=is_async, log_path=log_path, client_id=appId) 22 | 23 | # Setting the AccessToken 24 | fyers.token = access_token 25 | 26 | ## uncomment the any of the following requests to send a particular request and get the required data 27 | 28 | # print(fyers.get_profile()) 29 | # print(fyers.tradebook()) 30 | # print(fyers.positions()) 31 | # print(fyers.holdings()) 32 | # print(fyers.convert_position({"symbol":"MCX:SILVERMIC20AUGFUT","positionSide":"1","convertQty":"1","convertFrom":"MARGIN","convertTo":"INTRADAY"})) 33 | # print(fyers.funds()) 34 | # print(fyers.orderbook()) 35 | # print(fyers.cancel_order({'id':'8080582117761'})) 36 | # print(fyers.place_order({"symbol":"MCX:SILVERMIC20AUGFUT","qty":"1","type":"1","side":"1","productType":"INTRADAY","limitPrice":"76700","stopPrice":"0","disclosedQty":"0","validity":"DAY","offlineOrder":"False","stopLoss":"0","takeProfit":"0"})) 37 | # print(fyers.modify_order({"id":"808058117761", "qty":"0","type":"1","limitPrice":"71100","stopPrice":"0"})) #modify instead of update 38 | # print(fyers.minquantity()) 39 | # print(fyers.get_orders({'id':'808078094451'})) 40 | # print(fyers.market_status()) 41 | # print(fyers.exit_positions({"id":"MCX:SILVERMIC20AUGFUT-MARGIN"})) 42 | # print(fyers.generate_data_token({"vendorApp":"0KMS0EZVXI"})) 43 | # print(fyers.cancel_basket_orders([{"id":"120080780536"},{"id":"120080777069"}])) 44 | # print(fyers.place_basket_orders([{"symbol":"NSE:SBIN-EQ","qty":"1","type":"1","side":"1","productType":"INTRADAY","limitPrice":"191","stopPrice":"0","disclosedQty":"0","validity":"DAY","offlineOrder":"False","stopLoss":"0","takeProfit":"0"},{"symbol":"NSE:SBIN-EQ","qty":"1","type":"1","side":"1","productType":"INTRADAY","limitPrice":"191","stopPrice":"0","disclosedQty":"0","validity":"DAY","offlineOrder":"False","stopLoss":"0","takeProfit":"0"}])) 45 | # print(fyers.modify_basket_orders([{"id":"120080780536", "type":1, "limitPrice": 190, "stopPrice":0},{"id":"120080777069", "type":1, "limitPrice": 190}])) 46 | 47 | if __name__ == '__main__': 48 | # the access token returned fro generate_access_token(x,x,x,x) function from getAccessToken.py module 49 | access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2MTExNTI5MzUsImV4cCI6MTYxMTE4OTA1NSwibmJmIjoxNjExMTUyOTM1LCJhdWQiOlsieDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCZ0NENG51WjBNblNIam1ibHhzZDBZZUd4aW1jR09UTUo3c3R4MVZZTi1WekdkVUdrU1g0U09vWHFqMFBkMW8yZVZTanlHYWhMM21CT3lIb2g3WS1JdTRyX0NlV2NxN2hna1dzQ09iVHROT3A4TmtLST0iLCJkaXNwbGF5X25hbWUiOiJBUktBIE1BTkRXXXXXXXXXXXXXXXXXXXXXXXIsImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJZIn0.51x5O0gpHC7xNpGukWPQZU7wDZY2B_XNxB8Hlulspro" 50 | 51 | # The app id we get after creating the app 52 | appId = "EXXXXXXVWZ" 53 | 54 | # The system path where we want to store the logs e.g-c:\user\vvvv\xxxx\nnnn 55 | log_path = r"/home/fyers/Desktop/fyers-api-py/fyers_api" 56 | 57 | ## uncomment any of the function in the api_call to get the required output 58 | api_call(access_token, appId, log_path) 59 | -------------------------------------------------------------------------------- /python/getAccessToken.py: -------------------------------------------------------------------------------- 1 | moduleName = "getAccessToken" 2 | """ 3 | 1.We need to first install fyers-apiv2(can be installed as 'pip install fyers-apiv2) 4 | 2.We then need to import accesToken module from fyers_api directory(as done below) 5 | 3.We also need to import webbrowser to preform an action while generating authcode 6 | """ 7 | 8 | from fyers_api import accessToken 9 | 10 | import webbrowser 11 | 12 | 13 | def getauthToken(appId, redirect_uri): 14 | functionName = "getauthToken" 15 | """ 16 | :param app_id: "XXXXXXXXXXX" 17 | :param redirect_url: "https://XXXXXX.com" 18 | 1. This function open this url in the browser. 19 | 2. This will ask you to login and will ask you to approve the app if it is not approved already. 20 | 3. Once that is done, it will redirect to a url (added while app creation) with the auth_code. The url will look like 21 | https://www.google.com/?auth_code=eyJ0eXAiOiXXXXXGciOiJIUzI1NiJ9.eyXXXXXXXXXXXXXInN1YiI6ImF1dGhDb2XXXXXXXXXXXXXXXXXX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXVpZCI6ImZhOGNhYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg&user_id=DP00404 22 | 4. You have to take the auth_code from the url and use that token in your generate_access_token function. 23 | """ 24 | response_type="code" 25 | grant_type="authorization_code" 26 | # creating an instance appSession to generate the auth code by passing app id and redirect url as parameter 27 | appSession = accessToken.SessionModel(client_id=appId,redirect_uri=redirect_uri,response_type=response_type, grant_type=grant_type,state="state",scope="",nonce="") 28 | 29 | # The variable `generateTokenUrl` will have a url like https://uat-api.fyers.in/api/dev/generate-authcode?appId=B8PXXXH8T6&redirectUrl=https%3A%2F%2Fgoogle.com 30 | generateTokenUrl = appSession.generate_authcode() 31 | 32 | # This command is used to open the url in default system brower 33 | webbrowser.open(generateTokenUrl, new=1) 34 | 35 | 36 | def generate_access_token(auth_code, appId, secret_key): 37 | functionName = "generate_access_token" 38 | """ 39 | :param auth_code: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTM1ODY2NzEsInN1YiI6ImF1dGhDb2RlIiwiYXBwX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXXXXXXXXXXXYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg" 40 | :param app_id: "B8PXXXXXXX" 41 | :param secret_key: "XXXXXXKGN0" 42 | :param redirect_url: "https://XXXXXX.com" 43 | :return: access_token: "eyJ0eXAiOiJKV1QiLCXXXX1NiJ9.eyJpYXXXXXXXXXXMsIm5iZiI6MTU5MzU4ODM3MywiZXhwIjoxNTkzNjQ5ODEzLCJpc3MiOiJhcGkuZnllcnMuaW4iLCJzdWIiOiJhY2Nlc3MiLCJhdWQiOiJ4OjAseDoxLHg6MiIsImF0X2hhc2giOiJnQUFBQUFCZV9EcVZIZExMMTAzTVpVN1NYSkZfR2p5R3hidzMtTVVhb0VEMGI0QUVvNjFsR24tREY2OFU5cXhuNzd0UXVoOVVJalYtNm9MVXhINVFfWE1WTEJfRXpROGV2clJmUzlNUXB0Y2J5c2ltN1drWllZTT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQifQ.cAfrj2TxAyb8A_9DfiCb1hLIZg_mH-xvP3Ybnj3a4AE" 44 | 45 | 1.this function takes the param and return the access_token 46 | 2.the access_token created will be used further .(in fyersModel)] 47 | 3. one can get the auth_code from the url generated by getauthToken function (from auth_code= ..... &user_Id=xxxxxx before &) 48 | """ 49 | # creating an instance appSession by passing app id,secret key and redirect url as parameter 50 | appSession = accessToken.SessionModel(client_id=appId, secret_key=secret_key,grant_type="authorization_code") 51 | 52 | # we need to pass the auth code in set_token method 53 | appSession.set_token(auth_code) 54 | # generate_token function will return us the access token and we store in variable "access_token" 55 | access_token = appSession.generate_token() 56 | return access_token 57 | 58 | 59 | def main(): 60 | """ 61 | Starting Steps. 62 | 1.We first need to uncomment the function getauthToken(appId, redirect_url). 63 | 2.We need to make sure generate_access_token(auth_code, appId, app_secret, redirect_url) func is commented. 64 | 3.We need to run this module code once passing the parameters to getauthToken(appId, redirect_url) func. 65 | 4.We copy the auth_code provided from our browser and store in the variable in "auth_code". 66 | 5.Next we need to uncomment the function generate_access_token(auth_code, appId, app_secret, redirect_url). 67 | 6.Then we need to make sure getauthToken(appId, redirect_url) func is commented. 68 | 7.We run this module again with appropriate parameters. 69 | """ 70 | # The provided redirct url while creating the app 71 | redirect_url = "https://www.google.com/" 72 | 73 | # The app id we get after creating the app 74 | appId = "OCDXXXXXXJ-100" 75 | 76 | # Function to get the auth code and need to be commented while calling the generate_access_token(x,x,x) func. 77 | # getauthToken(appId, redirect_url) 78 | 79 | 80 | 81 | 82 | # The app secret we got after creating the app. 83 | app_secret = "BXXXXFM90" 84 | 85 | # the genarted auth code we got from browser after running the getauthToken(x,x) func. 86 | auth_code = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2MTExNTI4ODcsImV4cCI6MTYxMTE1MzE4NywibmJmIjoxNjExMTUyODg3LCJhdWQiOiJbXCJ4OjJcIiwgXCJ4OjFcIiwgXCJ4OjBcIl0iLCJzdWIiOiJhdXRoX2NvZGUiLCJkaXNwbGF5X25hbWUiOiJEQTAwNTk2Iiwibm9uY2UiOiIiLCJhcHBfaWQiOiJPQ0RXUzAyNXXXXXXXXXXXXXXXXXXXXXXXXXXXY2NhMzRkYjNiNzI1ZTdmNjQ4NjAyZDk0IiwiaXBBZGRyIjoiMjAyLjE0Mi4xMTkuNDkiLCJzY29wZSI6IiJ9.M1u8yMtoUbfJ9DPQ82-r_Q9qWEAr_s1DM1TQxWIdopY" 87 | 88 | # Function to get the access token and need to be commented while calling the getauthToken(x,x) func. 89 | print(generate_access_token(auth_code, appId, app_secret)) 90 | 91 | 92 | if __name__ == '__main__': 93 | main() 94 | -------------------------------------------------------------------------------- /v3/Postman V3/FYERS API V3.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "5edc3d4e-b012-4b20-9f45-d9931201985b", 4 | "name": "FYERS API V3", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", 6 | "_exporter_id": "24894415" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Authentication", 11 | "item": [ 12 | { 13 | "name": "OIDC - Auth Flow", 14 | "item": [ 15 | { 16 | "name": "generate-authcode", 17 | "request": { 18 | "method": "GET", 19 | "header": [], 20 | "url": { 21 | "raw": "https://api-t1.fyers.in/api/v3/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state&scope=openid&nonce=sample_nonce", 22 | "protocol": "https", 23 | "host": [ 24 | "api-t1", 25 | "fyers", 26 | "in" 27 | ], 28 | "path": [ 29 | "api", 30 | "v3", 31 | "generate-authcode" 32 | ], 33 | "query": [ 34 | { 35 | "key": "client_id", 36 | "value": "sample_client_id", 37 | "description": "This is your application id" 38 | }, 39 | { 40 | "key": "redirect_uri", 41 | "value": "sample_redirect_uri", 42 | "description": "The redirect uri should be the exact same as what was provided at the time of app creation" 43 | }, 44 | { 45 | "key": "response_type", 46 | "value": "code" 47 | }, 48 | { 49 | "key": "state", 50 | "value": "sample_state", 51 | "description": "This will be sent back to you in the redirect URL" 52 | }, 53 | { 54 | "key": "scope", 55 | "value": "openid" 56 | }, 57 | { 58 | "key": "nonce", 59 | "value": "sample_nonce", 60 | "description": "This will be included in the id_token which is received at the end of step 2" 61 | } 62 | ] 63 | }, 64 | "description": "## Step 1\r\n\r\nYou need to redirect the user to the login page with all the necessary query parameters." 65 | }, 66 | "response": [] 67 | }, 68 | { 69 | "name": "validate_auth_code", 70 | "request": { 71 | "method": "POST", 72 | "header": [], 73 | "body": { 74 | "mode": "raw", 75 | "raw": "{\n \"grant_type\":\"authorization_code\", \n \"appIdHash\":\"{{appId_hash}}\",\n \"code\": \"{{auth_code}}\"\n}", 76 | "options": { 77 | "raw": { 78 | "language": "json" 79 | } 80 | } 81 | }, 82 | "url": { 83 | "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", 84 | "protocol": "https", 85 | "host": [ 86 | "api-t1", 87 | "fyers", 88 | "in" 89 | ], 90 | "path": [ 91 | "api", 92 | "v3", 93 | "validate-authcode" 94 | ] 95 | }, 96 | "description": "## Step 2\r\n\r\n- code\r\n - You will be required to take the authentication code received in the first request and send it to the backend server in this request. \r\n\r\n- appIdHash\r\n - This needs to be created at your end with the application id and the secret key\r\n - You will need to send the SHA256 hash of appId:secretKey\r\n - Eg: appId = abcd1234-100 and secretKey = qwerty6789\r\n - Create a string variable abcd1234-100:qwerty6789\r\n - Create a SHA256 hash of the newly created string\r\n - You can use this only tool to create a SHA256 string while testing: https://emn178.github.io/online-tools/sha256.html" 97 | }, 98 | "response": [] 99 | } 100 | ] 101 | }, 102 | { 103 | "name": "OIDC - PKCE Flow", 104 | "item": [ 105 | { 106 | "name": "generate-authcode", 107 | "request": { 108 | "method": "GET", 109 | "header": [], 110 | "url": { 111 | "raw": "https://api-t1.fyers.in/api/v3/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&code_challenge=sample_code_challenge&state=sample_state&scope=openid&nonce=sample_nonce", 112 | "protocol": "https", 113 | "host": [ 114 | "api-t1", 115 | "fyers", 116 | "in" 117 | ], 118 | "path": [ 119 | "api", 120 | "v3", 121 | "generate-authcode" 122 | ], 123 | "query": [ 124 | { 125 | "key": "client_id", 126 | "value": "sample_client_id", 127 | "description": "This is your application id" 128 | }, 129 | { 130 | "key": "redirect_uri", 131 | "value": "sample_redirect_uri", 132 | "description": "The redirect uri should be the exact same as what was provided at the time of app creation" 133 | }, 134 | { 135 | "key": "response_type", 136 | "value": "code" 137 | }, 138 | { 139 | "key": "code_challenge", 140 | "value": "sample_code_challenge", 141 | "description": "This is a SHA256 hash of the code_verifier which you have created at your end" 142 | }, 143 | { 144 | "key": "state", 145 | "value": "sample_state", 146 | "description": "This will be sent back to you in the redirect URL" 147 | }, 148 | { 149 | "key": "scope", 150 | "value": "openid" 151 | }, 152 | { 153 | "key": "nonce", 154 | "value": "sample_nonce", 155 | "description": "This will be included in the id_token which is received at the end of step 2" 156 | } 157 | ] 158 | }, 159 | "description": "# Step 1\r\nThe PKCE flow is used for Single Page Application (SPA) / Mobile Apps wherein storing the secret key is unsafe. For such applications. \r\n\r\n## Parameters\r\n- You will be required to create a random string within your front end application called code_verifier\r\n- The code_challenge is the SHA256 hash of the code_verifier. \r\n - You can use this only tool to create a SHA256 string while testing: https://emn178.github.io/online-tools/sha256.html\r\n- You will also be required to create a unique string within your front end application called nonce. You will receive the nonce in the id_token at the end of step 2" 160 | }, 161 | "response": [] 162 | }, 163 | { 164 | "name": "validate_auth_code", 165 | "request": { 166 | "method": "POST", 167 | "header": [], 168 | "body": { 169 | "mode": "raw", 170 | "raw": "{\n \"grant_type\":\"authorization_code\", \n \"code_verifier\":\"sample_code_challenge\",\n \"code\":\"{{auth_code}}\"\n}", 171 | "options": { 172 | "raw": { 173 | "language": "json" 174 | } 175 | } 176 | }, 177 | "url": { 178 | "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", 179 | "protocol": "https", 180 | "host": [ 181 | "api-t1", 182 | "fyers", 183 | "in" 184 | ], 185 | "path": [ 186 | "api", 187 | "v3", 188 | "validate-authcode" 189 | ] 190 | }, 191 | "description": "## Step 2\r\n- code - This is the Authrorization code which is received in step 1\r\n- code_verifier - This is the random string which was created in step 1" 192 | }, 193 | "response": [] 194 | } 195 | ] 196 | }, 197 | { 198 | "name": "OAuth2 - Auth Flow", 199 | "item": [ 200 | { 201 | "name": "generate-authcode", 202 | "request": { 203 | "method": "GET", 204 | "header": [], 205 | "url": { 206 | "raw": "https://api-t1.fyers.in/api/v3/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state", 207 | "protocol": "https", 208 | "host": [ 209 | "api-t1", 210 | "fyers", 211 | "in" 212 | ], 213 | "path": [ 214 | "api", 215 | "v3", 216 | "generate-authcode" 217 | ], 218 | "query": [ 219 | { 220 | "key": "client_id", 221 | "value": "sample_client_id", 222 | "description": "This is your application id" 223 | }, 224 | { 225 | "key": "redirect_uri", 226 | "value": "sample_redirect_uri", 227 | "description": "The redirect uri should be the exact same as what was provided at the time of app creation" 228 | }, 229 | { 230 | "key": "response_type", 231 | "value": "code" 232 | }, 233 | { 234 | "key": "state", 235 | "value": "sample_state", 236 | "description": "This will be sent back to you in the redirect URL" 237 | } 238 | ] 239 | }, 240 | "description": "## Step 1\r\n\r\nYou need to redirect the user to the login page with all the necessary query parameters." 241 | }, 242 | "response": [] 243 | }, 244 | { 245 | "name": "validate_auth_code", 246 | "request": { 247 | "method": "POST", 248 | "header": [], 249 | "body": { 250 | "mode": "raw", 251 | "raw": "{\n \"grant_type\":\"authorization_code\", \n \"appIdHash\":\"{{appId_hash}}\",\n \"code\":\"{{auth_code}}\"\n}", 252 | "options": { 253 | "raw": { 254 | "language": "json" 255 | } 256 | } 257 | }, 258 | "url": { 259 | "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", 260 | "protocol": "https", 261 | "host": [ 262 | "api-t1", 263 | "fyers", 264 | "in" 265 | ], 266 | "path": [ 267 | "api", 268 | "v3", 269 | "validate-authcode" 270 | ] 271 | }, 272 | "description": "## Step 2\r\n\r\n- code\r\n - You will be required to take the authentication code received in the first request and send it to the backend server in this request.\r\n\r\n- appIdHash\r\n - This needs to be created at your end with the application id and the secret key\r\n - You will need to send the SHA256 hash of appId:secretKey\r\n - Eg: appId = abcd1234-100 and secretKey = qwerty6789\r\n - Create a string variable abcd1234-100:qwerty6789\r\n - Create a SHA256 hash of the newly created string\r\n - You can use this only tool to create a SHA256 string while testing: https://emn178.github.io/online-tools/sha256.html" 273 | }, 274 | "response": [] 275 | } 276 | ] 277 | }, 278 | { 279 | "name": "OAuth2 - PKCE Flow", 280 | "item": [ 281 | { 282 | "name": "generate-authcode", 283 | "request": { 284 | "method": "GET", 285 | "header": [], 286 | "url": { 287 | "raw": "https://api-t1.fyers.in/api/v3/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&code_challenge=sample_code_challenge&state=sample_state&nonce=sample_nonce&scope=openid", 288 | "protocol": "https", 289 | "host": [ 290 | "api-t1", 291 | "fyers", 292 | "in" 293 | ], 294 | "path": [ 295 | "api", 296 | "v3", 297 | "generate-authcode" 298 | ], 299 | "query": [ 300 | { 301 | "key": "client_id", 302 | "value": "sample_client_id", 303 | "description": "This is your application id" 304 | }, 305 | { 306 | "key": "redirect_uri", 307 | "value": "sample_redirect_uri", 308 | "description": "The redirect uri should be the exact same as what was provided at the time of app creation" 309 | }, 310 | { 311 | "key": "response_type", 312 | "value": "code" 313 | }, 314 | { 315 | "key": "code_challenge", 316 | "value": "sample_code_challenge", 317 | "description": "This is a SHA256 hash of the code_verifier which you have created at your end" 318 | }, 319 | { 320 | "key": "state", 321 | "value": "sample_state", 322 | "description": "This will be sent back to you in the redirect URL" 323 | }, 324 | { 325 | "key": "nonce", 326 | "value": "sample_nonce", 327 | "description": "This will be included in the id_token which is received at the end of step 2" 328 | }, 329 | { 330 | "key": "scope", 331 | "value": "openid" 332 | } 333 | ] 334 | }, 335 | "description": "# Step 1\r\nThe PKCE flow is used for Single Page Application (SPA) / Mobile Apps wherein storing the secret key is unsafe. For such applications. \r\n\r\n## Parameters\r\n- You will be required to create a random string within your front end application called code_verifier\r\n- The code_challenge is the SHA256 hash of the code_verifier. \r\n - You can use this only tool to create a SHA256 string while testing: https://emn178.github.io/online-tools/sha256.html\r\n- You will also be required to create a unique string within your front end application called nonce. You will receive the nonce in the id_token at the end of step 2" 336 | }, 337 | "response": [] 338 | }, 339 | { 340 | "name": "validate_auth_code", 341 | "request": { 342 | "method": "POST", 343 | "header": [], 344 | "body": { 345 | "mode": "raw", 346 | "raw": "{\n \"grant_type\":\"authorization_code\", \n \"code_verifier\":\"sample_code_challenge\",\n \"code\":\"{{auth_code}}\"\n}", 347 | "options": { 348 | "raw": { 349 | "language": "json" 350 | } 351 | } 352 | }, 353 | "url": { 354 | "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", 355 | "protocol": "https", 356 | "host": [ 357 | "api-t1", 358 | "fyers", 359 | "in" 360 | ], 361 | "path": [ 362 | "api", 363 | "v3", 364 | "validate-authcode" 365 | ] 366 | }, 367 | "description": "## Step 2\r\n- code - This is the Authrorization code which is received in step 1\r\n- code_verifier - This is the random string which was created in step 1" 368 | }, 369 | "response": [] 370 | } 371 | ] 372 | } 373 | ] 374 | }, 375 | { 376 | "name": "Account Info", 377 | "item": [ 378 | { 379 | "name": "profile", 380 | "request": { 381 | "method": "GET", 382 | "header": [ 383 | { 384 | "key": "Authorization", 385 | "value": "{{appId}}:{{access_token}}", 386 | "type": "text" 387 | } 388 | ], 389 | "url": { 390 | "raw": "https://api-t1.fyers.in/api/v3/profile", 391 | "protocol": "https", 392 | "host": [ 393 | "api-t1", 394 | "fyers", 395 | "in" 396 | ], 397 | "path": [ 398 | "api", 399 | "v3", 400 | "profile" 401 | ] 402 | } 403 | }, 404 | "response": [] 405 | }, 406 | { 407 | "name": "Funds", 408 | "request": { 409 | "method": "GET", 410 | "header": [ 411 | { 412 | "key": "Authorization", 413 | "type": "text", 414 | "value": "{{appId}}:{{access_token}}" 415 | } 416 | ], 417 | "url": { 418 | "raw": "https://api-t1.fyers.in/api/v3/funds", 419 | "protocol": "https", 420 | "host": [ 421 | "api-t1", 422 | "fyers", 423 | "in" 424 | ], 425 | "path": [ 426 | "api", 427 | "v3", 428 | "funds" 429 | ] 430 | } 431 | }, 432 | "response": [] 433 | } 434 | ] 435 | }, 436 | { 437 | "name": "Transactions Info", 438 | "item": [ 439 | { 440 | "name": "Tradebook", 441 | "request": { 442 | "method": "GET", 443 | "header": [ 444 | { 445 | "key": "Authorization", 446 | "type": "text", 447 | "value": "{{appId}}:{{access_token}}" 448 | }, 449 | { 450 | "key": "version", 451 | "value": "3", 452 | "type": "text" 453 | } 454 | ], 455 | "url": { 456 | "raw": "https://api-t1.fyers.in/api/v3/tradebook", 457 | "protocol": "https", 458 | "host": [ 459 | "api-t1", 460 | "fyers", 461 | "in" 462 | ], 463 | "path": [ 464 | "api", 465 | "v3", 466 | "tradebook" 467 | ] 468 | } 469 | }, 470 | "response": [] 471 | }, 472 | { 473 | "name": "Holdings", 474 | "request": { 475 | "method": "GET", 476 | "header": [ 477 | { 478 | "key": "Authorization", 479 | "type": "text", 480 | "value": "{{appId}}:{{access_token}}" 481 | }, 482 | { 483 | "key": "version", 484 | "value": "3", 485 | "type": "text" 486 | } 487 | ], 488 | "url": { 489 | "raw": "https://api-t1.fyers.in/api/v3/holdings", 490 | "protocol": "https", 491 | "host": [ 492 | "api-t1", 493 | "fyers", 494 | "in" 495 | ], 496 | "path": [ 497 | "api", 498 | "v3", 499 | "holdings" 500 | ] 501 | } 502 | }, 503 | "response": [] 504 | }, 505 | { 506 | "name": "Position", 507 | "request": { 508 | "method": "GET", 509 | "header": [ 510 | { 511 | "key": "Authorization", 512 | "type": "text", 513 | "value": "{{appId}}:{{access_token}}" 514 | }, 515 | { 516 | "key": "version", 517 | "value": "3", 518 | "type": "text" 519 | } 520 | ], 521 | "url": { 522 | "raw": "https://api-t1.fyers.in/api/v3/positions", 523 | "protocol": "https", 524 | "host": [ 525 | "api-t1", 526 | "fyers", 527 | "in" 528 | ], 529 | "path": [ 530 | "api", 531 | "v3", 532 | "positions" 533 | ] 534 | } 535 | }, 536 | "response": [] 537 | }, 538 | { 539 | "name": "orders", 540 | "request": { 541 | "method": "GET", 542 | "header": [ 543 | { 544 | "key": "Authorization", 545 | "type": "text", 546 | "value": "{{appId}}:{{access_token}}" 547 | }, 548 | { 549 | "key": "version", 550 | "value": "3", 551 | "type": "text" 552 | } 553 | ], 554 | "url": { 555 | "raw": "https://api-t1.fyers.in/api/v3/orders", 556 | "protocol": "https", 557 | "host": [ 558 | "api-t1", 559 | "fyers", 560 | "in" 561 | ], 562 | "path": [ 563 | "api", 564 | "v3", 565 | "orders" 566 | ] 567 | } 568 | }, 569 | "response": [] 570 | }, 571 | { 572 | "name": "Orders with FIlter", 573 | "request": { 574 | "method": "GET", 575 | "header": [ 576 | { 577 | "key": "Authorization", 578 | "value": "{{appId}}:{{access_token}}", 579 | "type": "text" 580 | }, 581 | { 582 | "key": "version", 583 | "value": "3", 584 | "type": "text" 585 | } 586 | ], 587 | "url": { 588 | "raw": "https://api-t1.fyers.in/api/v3/orders?id=230XXXXXXX4267", 589 | "protocol": "https", 590 | "host": [ 591 | "api-t1", 592 | "fyers", 593 | "in" 594 | ], 595 | "path": [ 596 | "api", 597 | "v3", 598 | "orders" 599 | ], 600 | "query": [ 601 | { 602 | "key": "id", 603 | "value": "230XXXXXXX4267" 604 | } 605 | ] 606 | } 607 | }, 608 | "response": [] 609 | } 610 | ] 611 | }, 612 | { 613 | "name": "Transactions", 614 | "item": [ 615 | { 616 | "name": "Orders", 617 | "item": [ 618 | { 619 | "name": "Intraday/Margin/CNC Orders", 620 | "item": [ 621 | { 622 | "name": "Place Order-Limit", 623 | "request": { 624 | "method": "POST", 625 | "header": [ 626 | { 627 | "key": "Authorization", 628 | "type": "text", 629 | "value": "{{appId}}:{{access_token}}" 630 | }, 631 | { 632 | "key": "Content-Type", 633 | "type": "text", 634 | "value": "application/json" 635 | } 636 | ], 637 | "body": { 638 | "mode": "raw", 639 | "raw": "{\n\t\"symbol\":\"NSE:IDEA-EQ\",\n\t\"qty\":1,\n\t\"type\":1,\n\t\"side\":1,\n\t\"productType\":\"INTRADAY\",\n\t\"limitPrice\":7.9,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":false,\n\t\"stopLoss\":0,\n\t\"takeProfit\":0\n}", 640 | "options": { 641 | "raw": { 642 | "language": "json" 643 | } 644 | } 645 | }, 646 | "url": { 647 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 648 | "protocol": "https", 649 | "host": [ 650 | "api-t1", 651 | "fyers", 652 | "in" 653 | ], 654 | "path": [ 655 | "api", 656 | "v3", 657 | "orders", 658 | "sync" 659 | ] 660 | } 661 | }, 662 | "response": [] 663 | }, 664 | { 665 | "name": "Place Order-Market", 666 | "request": { 667 | "method": "POST", 668 | "header": [ 669 | { 670 | "key": "Authorization", 671 | "type": "text", 672 | "value": "{{appId}}:{{access_token}}" 673 | }, 674 | { 675 | "key": "Content-Type", 676 | "type": "text", 677 | "value": "application/json" 678 | } 679 | ], 680 | "body": { 681 | "mode": "raw", 682 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":2,\n\t\"side\":1,\n\t\"productType\":\"CNC\",\n\t\"limitPrice\":0,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":true,\n\t\"stopLoss\":0,\n\t\"takeProfit\":0\n}", 683 | "options": { 684 | "raw": { 685 | "language": "json" 686 | } 687 | } 688 | }, 689 | "url": { 690 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 691 | "protocol": "https", 692 | "host": [ 693 | "api-t1", 694 | "fyers", 695 | "in" 696 | ], 697 | "path": [ 698 | "api", 699 | "v3", 700 | "orders", 701 | "sync" 702 | ] 703 | } 704 | }, 705 | "response": [] 706 | }, 707 | { 708 | "name": "Place Order-Stop", 709 | "request": { 710 | "method": "POST", 711 | "header": [ 712 | { 713 | "key": "Authorization", 714 | "type": "text", 715 | "value": "{{appId}}:{{access_token}}" 716 | }, 717 | { 718 | "key": "Content-Type", 719 | "type": "text", 720 | "value": "application/json" 721 | } 722 | ], 723 | "body": { 724 | "mode": "raw", 725 | "raw": "{\n\t\"symbol\":\"MCX:SILVERMIC20NOVFUT\",\n\t\"qty\":1,\n\t\"type\":3,\n\t\"side\":1,\n\t\"productType\":\"MARGIN\",\n\t\"limitPrice\":0,\n\t\"stopPrice\":70000,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":0,\n\t\"takeProfit\":0\n}", 726 | "options": { 727 | "raw": { 728 | "language": "json" 729 | } 730 | } 731 | }, 732 | "url": { 733 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 734 | "protocol": "https", 735 | "host": [ 736 | "api-t1", 737 | "fyers", 738 | "in" 739 | ], 740 | "path": [ 741 | "api", 742 | "v3", 743 | "orders", 744 | "sync" 745 | ] 746 | } 747 | }, 748 | "response": [] 749 | }, 750 | { 751 | "name": "Place Order-StopLimit", 752 | "request": { 753 | "method": "POST", 754 | "header": [ 755 | { 756 | "key": "Authorization", 757 | "type": "text", 758 | "value": "{{appId}}:{{access_token}}" 759 | }, 760 | { 761 | "key": "Content-Type", 762 | "type": "text", 763 | "value": "application/json" 764 | } 765 | ], 766 | "body": { 767 | "mode": "raw", 768 | "raw": "{\n\t\"symbol\":\"MCX:SILVERMIC20NOVFUT\",\n\t\"qty\":1,\n\t\"type\":4,\n\t\"side\":1,\n\t\"productType\":\"MARGIN\",\n\t\"limitPrice\":64200,\n\t\"stopPrice\":64201,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":0,\n\t\"takeProfit\":0\n}", 769 | "options": { 770 | "raw": { 771 | "language": "json" 772 | } 773 | } 774 | }, 775 | "url": { 776 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 777 | "protocol": "https", 778 | "host": [ 779 | "api-t1", 780 | "fyers", 781 | "in" 782 | ], 783 | "path": [ 784 | "api", 785 | "v3", 786 | "orders", 787 | "sync" 788 | ] 789 | } 790 | }, 791 | "response": [] 792 | }, 793 | { 794 | "name": "Modify Order-Limit", 795 | "request": { 796 | "method": "PATCH", 797 | "header": [ 798 | { 799 | "key": "Authorization", 800 | "type": "text", 801 | "value": "{{appId}}:{{access_token}}" 802 | }, 803 | { 804 | "key": "Content-Type", 805 | "type": "text", 806 | "value": "application/json" 807 | } 808 | ], 809 | "body": { 810 | "mode": "raw", 811 | "raw": "{\n \"id\":\"52009117318\", \n \"type\":1, \n \"limitPrice\": 200,\n \"qty\":1\n}\n", 812 | "options": { 813 | "raw": { 814 | "language": "json" 815 | } 816 | } 817 | }, 818 | "url": { 819 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 820 | "protocol": "https", 821 | "host": [ 822 | "api-t1", 823 | "fyers", 824 | "in" 825 | ], 826 | "path": [ 827 | "api", 828 | "v3", 829 | "orders", 830 | "sync" 831 | ] 832 | } 833 | }, 834 | "response": [] 835 | }, 836 | { 837 | "name": "Modify Order-Market", 838 | "request": { 839 | "method": "PATCH", 840 | "header": [ 841 | { 842 | "key": "Authorization", 843 | "type": "text", 844 | "value": "{{appId}}:{{access_token}}" 845 | }, 846 | { 847 | "key": "Content-Type", 848 | "type": "text", 849 | "value": "application/json" 850 | } 851 | ], 852 | "body": { 853 | "mode": "raw", 854 | "raw": "{\n \"id\":\"52009117318\", \n \"type\":2, \n \"limitPrice\": 0,\n \"qty\":1\n \n}\n", 855 | "options": { 856 | "raw": { 857 | "language": "json" 858 | } 859 | } 860 | }, 861 | "url": { 862 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 863 | "protocol": "https", 864 | "host": [ 865 | "api-t1", 866 | "fyers", 867 | "in" 868 | ], 869 | "path": [ 870 | "api", 871 | "v3", 872 | "orders", 873 | "sync" 874 | ] 875 | } 876 | }, 877 | "response": [] 878 | }, 879 | { 880 | "name": "Modify Order- QTY", 881 | "request": { 882 | "method": "PATCH", 883 | "header": [ 884 | { 885 | "key": "Authorization", 886 | "type": "text", 887 | "value": "{{appId}}:{{access_token}}" 888 | }, 889 | { 890 | "key": "Content-Type", 891 | "type": "text", 892 | "value": "application/json" 893 | } 894 | ], 895 | "body": { 896 | "mode": "raw", 897 | "raw": "{\n \"id\":\"52009117318\", \n \"type\":2, \n \"qty\":4\n}\n", 898 | "options": { 899 | "raw": { 900 | "language": "json" 901 | } 902 | } 903 | }, 904 | "url": { 905 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 906 | "protocol": "https", 907 | "host": [ 908 | "api-t1", 909 | "fyers", 910 | "in" 911 | ], 912 | "path": [ 913 | "api", 914 | "v3", 915 | "orders", 916 | "sync" 917 | ] 918 | } 919 | }, 920 | "response": [] 921 | }, 922 | { 923 | "name": "Cancel Order", 924 | "request": { 925 | "method": "DELETE", 926 | "header": [ 927 | { 928 | "key": "Authorization", 929 | "type": "text", 930 | "value": "{{appId}}:{{access_token}}" 931 | }, 932 | { 933 | "key": "Content-Type", 934 | "type": "text", 935 | "value": "application/json" 936 | } 937 | ], 938 | "body": { 939 | "mode": "raw", 940 | "raw": "{\n\t\"id\":\"52009117318\"\n}", 941 | "options": { 942 | "raw": { 943 | "language": "json" 944 | } 945 | } 946 | }, 947 | "url": { 948 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 949 | "protocol": "https", 950 | "host": [ 951 | "api-t1", 952 | "fyers", 953 | "in" 954 | ], 955 | "path": [ 956 | "api", 957 | "v3", 958 | "orders", 959 | "sync" 960 | ] 961 | } 962 | }, 963 | "response": [] 964 | } 965 | ] 966 | }, 967 | { 968 | "name": "CO Orders", 969 | "item": [ 970 | { 971 | "name": "Place Order - Limit", 972 | "request": { 973 | "method": "POST", 974 | "header": [ 975 | { 976 | "key": "Authorization", 977 | "type": "text", 978 | "value": "{{appId}}:{{access_token}}" 979 | }, 980 | { 981 | "key": "Content-Type", 982 | "type": "text", 983 | "value": "application/json" 984 | } 985 | ], 986 | "body": { 987 | "mode": "raw", 988 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":1,\n\t\"side\":1,\n\t\"productType\":\"CO\",\n\t\"limitPrice\":200,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":false,\n\t\"stopLoss\":199,\n\t\"takeProfit\":0\n}", 989 | "options": { 990 | "raw": { 991 | "language": "json" 992 | } 993 | } 994 | }, 995 | "url": { 996 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 997 | "protocol": "https", 998 | "host": [ 999 | "api-t1", 1000 | "fyers", 1001 | "in" 1002 | ], 1003 | "path": [ 1004 | "api", 1005 | "v3", 1006 | "orders", 1007 | "sync" 1008 | ] 1009 | } 1010 | }, 1011 | "response": [] 1012 | }, 1013 | { 1014 | "name": "Place Order -Market", 1015 | "request": { 1016 | "method": "POST", 1017 | "header": [ 1018 | { 1019 | "key": "Authorization", 1020 | "type": "text", 1021 | "value": "{{appId}}:{{access_token}}" 1022 | }, 1023 | { 1024 | "key": "Content-Type", 1025 | "type": "text", 1026 | "value": "application/json" 1027 | } 1028 | ], 1029 | "body": { 1030 | "mode": "raw", 1031 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":2,\n\t\"side\":1,\n\t\"productType\":\"CO\",\n\t\"limitPrice\":0,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":198,\n\t\"takeProfit\":0\n}", 1032 | "options": { 1033 | "raw": { 1034 | "language": "json" 1035 | } 1036 | } 1037 | }, 1038 | "url": { 1039 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1040 | "protocol": "https", 1041 | "host": [ 1042 | "api-t1", 1043 | "fyers", 1044 | "in" 1045 | ], 1046 | "path": [ 1047 | "api", 1048 | "v3", 1049 | "orders", 1050 | "sync" 1051 | ] 1052 | } 1053 | }, 1054 | "response": [] 1055 | }, 1056 | { 1057 | "name": "Modify Order - Leg 1", 1058 | "request": { 1059 | "method": "PATCH", 1060 | "header": [ 1061 | { 1062 | "key": "Authorization", 1063 | "type": "text", 1064 | "value": "{{appId}}:{{access_token}}" 1065 | }, 1066 | { 1067 | "key": "Content-Type", 1068 | "type": "text", 1069 | "value": "application/json" 1070 | } 1071 | ], 1072 | "body": { 1073 | "mode": "raw", 1074 | "raw": "{\n \"id\":\"808278287301-CO-1\", \n \"type\":1, \n \"limitPrice\": 202,\n \"qty\":1\n}\n", 1075 | "options": { 1076 | "raw": { 1077 | "language": "json" 1078 | } 1079 | } 1080 | }, 1081 | "url": { 1082 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1083 | "protocol": "https", 1084 | "host": [ 1085 | "api-t1", 1086 | "fyers", 1087 | "in" 1088 | ], 1089 | "path": [ 1090 | "api", 1091 | "v3", 1092 | "orders", 1093 | "sync" 1094 | ] 1095 | } 1096 | }, 1097 | "response": [] 1098 | }, 1099 | { 1100 | "name": "Modify Order - Leg 2", 1101 | "request": { 1102 | "method": "PATCH", 1103 | "header": [ 1104 | { 1105 | "key": "Authorization", 1106 | "type": "text", 1107 | "value": "{{appId}}:{{access_token}}" 1108 | }, 1109 | { 1110 | "key": "Content-Type", 1111 | "type": "text", 1112 | "value": "application/json" 1113 | } 1114 | ], 1115 | "body": { 1116 | "mode": "raw", 1117 | "raw": "{\n \"id\":\"808278287301-CO-2\", \n \"type\":3, \n \"stopPrice\": 199,\n \"qty\":1\n}\n", 1118 | "options": { 1119 | "raw": { 1120 | "language": "json" 1121 | } 1122 | } 1123 | }, 1124 | "url": { 1125 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1126 | "protocol": "https", 1127 | "host": [ 1128 | "api-t1", 1129 | "fyers", 1130 | "in" 1131 | ], 1132 | "path": [ 1133 | "api", 1134 | "v3", 1135 | "orders", 1136 | "sync" 1137 | ] 1138 | } 1139 | }, 1140 | "response": [] 1141 | }, 1142 | { 1143 | "name": "Cancel Order", 1144 | "request": { 1145 | "method": "DELETE", 1146 | "header": [ 1147 | { 1148 | "key": "Authorization", 1149 | "type": "text", 1150 | "value": "{{appId}}:{{access_token}}" 1151 | }, 1152 | { 1153 | "key": "Content-Type", 1154 | "type": "text", 1155 | "value": "application/json" 1156 | } 1157 | ], 1158 | "body": { 1159 | "mode": "raw", 1160 | "raw": "{\n\t\"id\":\"808268324981-CO-1\"\n}", 1161 | "options": { 1162 | "raw": { 1163 | "language": "json" 1164 | } 1165 | } 1166 | }, 1167 | "url": { 1168 | "raw": "https://api-t1.fyers.in/api/v3/orders", 1169 | "protocol": "https", 1170 | "host": [ 1171 | "api", 1172 | "fyers", 1173 | "in" 1174 | ], 1175 | "path": [ 1176 | "api", 1177 | "v2", 1178 | "orders" 1179 | ] 1180 | } 1181 | }, 1182 | "response": [] 1183 | } 1184 | ] 1185 | }, 1186 | { 1187 | "name": "BO Orders", 1188 | "item": [ 1189 | { 1190 | "name": "Place Order-Limit", 1191 | "request": { 1192 | "method": "POST", 1193 | "header": [ 1194 | { 1195 | "key": "Authorization", 1196 | "type": "text", 1197 | "value": "{{appId}}:{{access_token}}" 1198 | }, 1199 | { 1200 | "key": "Content-Type", 1201 | "type": "text", 1202 | "value": "application/json" 1203 | } 1204 | ], 1205 | "body": { 1206 | "mode": "raw", 1207 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":1,\n\t\"side\":1,\n\t\"productType\":\"BO\",\n\t\"limitPrice\":200,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":5,\n\t\"takeProfit\":5\n}", 1208 | "options": { 1209 | "raw": { 1210 | "language": "json" 1211 | } 1212 | } 1213 | }, 1214 | "url": { 1215 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1216 | "protocol": "https", 1217 | "host": [ 1218 | "api-t1", 1219 | "fyers", 1220 | "in" 1221 | ], 1222 | "path": [ 1223 | "api", 1224 | "v3", 1225 | "orders", 1226 | "sync" 1227 | ] 1228 | } 1229 | }, 1230 | "response": [] 1231 | }, 1232 | { 1233 | "name": "Place Order-Market", 1234 | "request": { 1235 | "method": "POST", 1236 | "header": [ 1237 | { 1238 | "key": "Authorization", 1239 | "type": "text", 1240 | "value": "{{appId}}:{{access_token}}" 1241 | }, 1242 | { 1243 | "key": "Content-Type", 1244 | "type": "text", 1245 | "value": "application/json" 1246 | } 1247 | ], 1248 | "body": { 1249 | "mode": "raw", 1250 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":2,\n\t\"side\":1,\n\t\"productType\":\"BO\",\n\t\"limitPrice\":0,\n\t\"stopPrice\":0,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":5,\n\t\"takeProfit\":5\n}", 1251 | "options": { 1252 | "raw": { 1253 | "language": "json" 1254 | } 1255 | } 1256 | }, 1257 | "url": { 1258 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1259 | "protocol": "https", 1260 | "host": [ 1261 | "api-t1", 1262 | "fyers", 1263 | "in" 1264 | ], 1265 | "path": [ 1266 | "api", 1267 | "v3", 1268 | "orders", 1269 | "sync" 1270 | ] 1271 | } 1272 | }, 1273 | "response": [] 1274 | }, 1275 | { 1276 | "name": "Place Order-Stop", 1277 | "request": { 1278 | "method": "POST", 1279 | "header": [ 1280 | { 1281 | "key": "Authorization", 1282 | "type": "text", 1283 | "value": "{{appId}}:{{access_token}}" 1284 | }, 1285 | { 1286 | "key": "Content-Type", 1287 | "type": "text", 1288 | "value": "application/json" 1289 | } 1290 | ], 1291 | "body": { 1292 | "mode": "raw", 1293 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":3,\n\t\"side\":1,\n\t\"productType\":\"BO\",\n\t\"limitPrice\":0,\n\t\"stopPrice\":205,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":5,\n\t\"takeProfit\":5\n}", 1294 | "options": { 1295 | "raw": { 1296 | "language": "json" 1297 | } 1298 | } 1299 | }, 1300 | "url": { 1301 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1302 | "protocol": "https", 1303 | "host": [ 1304 | "api-t1", 1305 | "fyers", 1306 | "in" 1307 | ], 1308 | "path": [ 1309 | "api", 1310 | "v3", 1311 | "orders", 1312 | "sync" 1313 | ] 1314 | } 1315 | }, 1316 | "response": [] 1317 | }, 1318 | { 1319 | "name": "Place Order-Stop Limit", 1320 | "request": { 1321 | "method": "POST", 1322 | "header": [ 1323 | { 1324 | "key": "Authorization", 1325 | "type": "text", 1326 | "value": "{{appId}}:{{access_token}}" 1327 | }, 1328 | { 1329 | "key": "Content-Type", 1330 | "type": "text", 1331 | "value": "application/json" 1332 | } 1333 | ], 1334 | "body": { 1335 | "mode": "raw", 1336 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"qty\":1,\n\t\"type\":4,\n\t\"side\":1,\n\t\"productType\":\"BO\",\n\t\"limitPrice\":205,\n\t\"stopPrice\":206,\n\t\"disclosedQty\":0,\n\t\"validity\":\"DAY\",\n\t\"offlineOrder\":\"False\",\n\t\"stopLoss\":5,\n\t\"takeProfit\":5\n}", 1337 | "options": { 1338 | "raw": { 1339 | "language": "json" 1340 | } 1341 | } 1342 | }, 1343 | "url": { 1344 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1345 | "protocol": "https", 1346 | "host": [ 1347 | "api-t1", 1348 | "fyers", 1349 | "in" 1350 | ], 1351 | "path": [ 1352 | "api", 1353 | "v3", 1354 | "orders", 1355 | "sync" 1356 | ] 1357 | } 1358 | }, 1359 | "response": [] 1360 | }, 1361 | { 1362 | "name": "Modify Order - Leg 1", 1363 | "request": { 1364 | "method": "PATCH", 1365 | "header": [ 1366 | { 1367 | "key": "Authorization", 1368 | "type": "text", 1369 | "value": "{{appId}}:{{access_token}}" 1370 | }, 1371 | { 1372 | "key": "Content-Type", 1373 | "type": "text", 1374 | "value": "application/json" 1375 | } 1376 | ], 1377 | "body": { 1378 | "mode": "raw", 1379 | "raw": "{\n \"id\":\"808278287301-BO-1\", \n \"type\":1, \n \"limitPrice\": 200,\n \"qty\":1\n}\n", 1380 | "options": { 1381 | "raw": { 1382 | "language": "json" 1383 | } 1384 | } 1385 | }, 1386 | "url": { 1387 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1388 | "protocol": "https", 1389 | "host": [ 1390 | "api-t1", 1391 | "fyers", 1392 | "in" 1393 | ], 1394 | "path": [ 1395 | "api", 1396 | "v3", 1397 | "orders", 1398 | "sync" 1399 | ] 1400 | } 1401 | }, 1402 | "response": [] 1403 | }, 1404 | { 1405 | "name": "Modify Order - Leg 2", 1406 | "request": { 1407 | "method": "PATCH", 1408 | "header": [ 1409 | { 1410 | "key": "Authorization", 1411 | "type": "text", 1412 | "value": "{{appId}}:{{access_token}}" 1413 | }, 1414 | { 1415 | "key": "Content-Type", 1416 | "type": "text", 1417 | "value": "application/json" 1418 | } 1419 | ], 1420 | "body": { 1421 | "mode": "raw", 1422 | "raw": "{\n \"id\":\"808278287301-BO-2\", \n \"type\":3, \n \"stopPrice\": 195,\n \"qty\":1\n}\n", 1423 | "options": { 1424 | "raw": { 1425 | "language": "json" 1426 | } 1427 | } 1428 | }, 1429 | "url": { 1430 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1431 | "protocol": "https", 1432 | "host": [ 1433 | "api-t1", 1434 | "fyers", 1435 | "in" 1436 | ], 1437 | "path": [ 1438 | "api", 1439 | "v3", 1440 | "orders", 1441 | "sync" 1442 | ] 1443 | } 1444 | }, 1445 | "response": [] 1446 | }, 1447 | { 1448 | "name": "Modify Order - Leg 3", 1449 | "request": { 1450 | "method": "PATCH", 1451 | "header": [ 1452 | { 1453 | "key": "Authorization", 1454 | "type": "text", 1455 | "value": "{{appId}}:{{access_token}}" 1456 | }, 1457 | { 1458 | "key": "Content-Type", 1459 | "type": "text", 1460 | "value": "application/json" 1461 | } 1462 | ], 1463 | "body": { 1464 | "mode": "raw", 1465 | "raw": "{\n \"id\":\"808278287301-BO-3\", \n \"type\":1, \n \"limitPrice\": 210,\n \"qty\":1\n}\n", 1466 | "options": { 1467 | "raw": { 1468 | "language": "json" 1469 | } 1470 | } 1471 | }, 1472 | "url": { 1473 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1474 | "protocol": "https", 1475 | "host": [ 1476 | "api-t1", 1477 | "fyers", 1478 | "in" 1479 | ], 1480 | "path": [ 1481 | "api", 1482 | "v3", 1483 | "orders", 1484 | "sync" 1485 | ] 1486 | } 1487 | }, 1488 | "response": [] 1489 | }, 1490 | { 1491 | "name": "Cancel Order", 1492 | "request": { 1493 | "method": "DELETE", 1494 | "header": [ 1495 | { 1496 | "key": "Authorization", 1497 | "type": "text", 1498 | "value": "{{appId}}:{{access_token}}" 1499 | }, 1500 | { 1501 | "key": "Content-Type", 1502 | "type": "text", 1503 | "value": "application/json" 1504 | } 1505 | ], 1506 | "body": { 1507 | "mode": "raw", 1508 | "raw": "{\n\t\"id\":\"808268324981-BO-1\"\n}", 1509 | "options": { 1510 | "raw": { 1511 | "language": "json" 1512 | } 1513 | } 1514 | }, 1515 | "url": { 1516 | "raw": "https://api-t1.fyers.in/api/v3/orders/sync", 1517 | "protocol": "https", 1518 | "host": [ 1519 | "api-t1", 1520 | "fyers", 1521 | "in" 1522 | ], 1523 | "path": [ 1524 | "api", 1525 | "v3", 1526 | "orders", 1527 | "sync" 1528 | ] 1529 | } 1530 | }, 1531 | "response": [] 1532 | } 1533 | ] 1534 | }, 1535 | { 1536 | "name": "Multiple Orders", 1537 | "item": [ 1538 | { 1539 | "name": "Place Multiple Order", 1540 | "request": { 1541 | "method": "POST", 1542 | "header": [ 1543 | { 1544 | "key": "Authorization", 1545 | "value": "{{appId}}:{{access_token}}", 1546 | "type": "text" 1547 | } 1548 | ], 1549 | "body": { 1550 | "mode": "raw", 1551 | "raw": "[\n {\"symbol\":\"NSE:SBIN-EQ\",\"qty\":1,\"type\":1,\"side\":1,\"productType\":\"INTRADAY\",\"limitPrice\":190,\"stopPrice\":0,\"disclosedQty\":0,\"validity\":\"DAY\",\"offlineOrder\":\"True\",\"stopLoss\":0,\"takeProfit\":0},\n\n {\"symbol\":\"NSE:SBIN-EQ\",\"qty\":1,\"type\":2,\"side\":1,\"productType\":\"CNC\",\"limitPrice\":0,\"stopPrice\":0,\"disclosedQty\":0,\"validity\":\"DAY\",\"offlineOrder\":\"True\",\"stopLoss\":0,\"takeProfit\":0}\n]", 1552 | "options": { 1553 | "raw": { 1554 | "language": "json" 1555 | } 1556 | } 1557 | }, 1558 | "url": { 1559 | "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", 1560 | "protocol": "https", 1561 | "host": [ 1562 | "api-t1", 1563 | "fyers", 1564 | "in" 1565 | ], 1566 | "path": [ 1567 | "api", 1568 | "v3", 1569 | "multi-order", 1570 | "sync" 1571 | ] 1572 | } 1573 | }, 1574 | "response": [] 1575 | }, 1576 | { 1577 | "name": "Modify Multiple Order", 1578 | "request": { 1579 | "method": "PATCH", 1580 | "header": [ 1581 | { 1582 | "key": "Authorization", 1583 | "value": "{{appId}}:{{access_token}}", 1584 | "type": "text" 1585 | } 1586 | ], 1587 | "body": { 1588 | "mode": "raw", 1589 | "raw": "[\n {\"id\":\"52009117324\", \"type\":1, \"limitPrice\": 196, \"offlineOrder\":\"True\"},\n {\"id\":\"52009117325\", \"type\":1, \"limitPrice\": 196, \"offlineOrder\":\"True\"}\n]", 1590 | "options": { 1591 | "raw": { 1592 | "language": "json" 1593 | } 1594 | } 1595 | }, 1596 | "url": { 1597 | "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", 1598 | "protocol": "https", 1599 | "host": [ 1600 | "api-t1", 1601 | "fyers", 1602 | "in" 1603 | ], 1604 | "path": [ 1605 | "api", 1606 | "v3", 1607 | "multi-order", 1608 | "sync" 1609 | ] 1610 | } 1611 | }, 1612 | "response": [] 1613 | }, 1614 | { 1615 | "name": "Delete Multiple Order", 1616 | "request": { 1617 | "method": "DELETE", 1618 | "header": [ 1619 | { 1620 | "key": "Authorization", 1621 | "value": "{{appId}}:{{access_token}}", 1622 | "type": "text" 1623 | } 1624 | ], 1625 | "body": { 1626 | "mode": "raw", 1627 | "raw": "[\n {\"id\":\"52009117324\"},\n {\"id\":\"52009117325\"}\n]", 1628 | "options": { 1629 | "raw": { 1630 | "language": "json" 1631 | } 1632 | } 1633 | }, 1634 | "url": { 1635 | "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", 1636 | "protocol": "https", 1637 | "host": [ 1638 | "api-t1", 1639 | "fyers", 1640 | "in" 1641 | ], 1642 | "path": [ 1643 | "api", 1644 | "v3", 1645 | "multi-order", 1646 | "sync" 1647 | ] 1648 | } 1649 | }, 1650 | "response": [] 1651 | } 1652 | ] 1653 | } 1654 | ] 1655 | }, 1656 | { 1657 | "name": "Position", 1658 | "item": [ 1659 | { 1660 | "name": "Convert_position", 1661 | "request": { 1662 | "method": "PUT", 1663 | "header": [ 1664 | { 1665 | "key": "Authorization", 1666 | "type": "text", 1667 | "value": "{{appId}}:{{access_token}}" 1668 | }, 1669 | { 1670 | "key": "Content-Type", 1671 | "type": "text", 1672 | "value": "application/json" 1673 | } 1674 | ], 1675 | "body": { 1676 | "mode": "raw", 1677 | "raw": "{\n\t\"symbol\":\"NSE:SBIN-EQ\",\n\t\"positionSide\":1,\n\t\"convertQty\":1,\n\t\"convertFrom\":\"INTRADAY\",\n\t\"convertTo\":\"CNC\"\n}", 1678 | "options": { 1679 | "raw": { 1680 | "language": "json" 1681 | } 1682 | } 1683 | }, 1684 | "url": { 1685 | "raw": "https://api-t1.fyers.in/api/v3/positions", 1686 | "protocol": "https", 1687 | "host": [ 1688 | "api-t1", 1689 | "fyers", 1690 | "in" 1691 | ], 1692 | "path": [ 1693 | "api", 1694 | "v3", 1695 | "positions" 1696 | ] 1697 | } 1698 | }, 1699 | "response": [] 1700 | }, 1701 | { 1702 | "name": "Exit_position", 1703 | "request": { 1704 | "method": "DELETE", 1705 | "header": [ 1706 | { 1707 | "key": "Authorization", 1708 | "value": "{{appId}}:{{access_token}}", 1709 | "type": "text" 1710 | } 1711 | ], 1712 | "body": { 1713 | "mode": "raw", 1714 | "raw": "{\"id\": \"NSE:SBIN-EQ-INTRADAY\"}", 1715 | "options": { 1716 | "raw": { 1717 | "language": "json" 1718 | } 1719 | } 1720 | }, 1721 | "url": { 1722 | "raw": "https://api-t1.fyers.in/api/v3/positions", 1723 | "protocol": "https", 1724 | "host": [ 1725 | "api-t1", 1726 | "fyers", 1727 | "in" 1728 | ], 1729 | "path": [ 1730 | "api", 1731 | "v3", 1732 | "positions" 1733 | ] 1734 | } 1735 | }, 1736 | "response": [] 1737 | }, 1738 | { 1739 | "name": "Exit_all_positions", 1740 | "request": { 1741 | "method": "DELETE", 1742 | "header": [ 1743 | { 1744 | "key": "Authorization", 1745 | "value": "{{appId}}:{{access_token}}", 1746 | "type": "text" 1747 | } 1748 | ], 1749 | "body": { 1750 | "mode": "raw", 1751 | "raw": "{\n \"exit_all\": 1\n}", 1752 | "options": { 1753 | "raw": { 1754 | "language": "json" 1755 | } 1756 | } 1757 | }, 1758 | "url": { 1759 | "raw": "https://api-t1.fyers.in/api/v3/positions", 1760 | "protocol": "https", 1761 | "host": [ 1762 | "api-t1", 1763 | "fyers", 1764 | "in" 1765 | ], 1766 | "path": [ 1767 | "api", 1768 | "v3", 1769 | "positions" 1770 | ] 1771 | } 1772 | }, 1773 | "response": [] 1774 | } 1775 | ] 1776 | } 1777 | ] 1778 | }, 1779 | { 1780 | "name": "Broker Info", 1781 | "item": [ 1782 | { 1783 | "name": "Market Status", 1784 | "request": { 1785 | "method": "GET", 1786 | "header": [ 1787 | { 1788 | "key": "Authorization", 1789 | "value": "{{appId}}:{{access_token}}", 1790 | "type": "text" 1791 | } 1792 | ], 1793 | "url": { 1794 | "raw": "https://api-t1.fyers.in/data/marketStatus", 1795 | "protocol": "https", 1796 | "host": [ 1797 | "api-t1", 1798 | "fyers", 1799 | "in" 1800 | ], 1801 | "path": [ 1802 | "data", 1803 | "marketStatus" 1804 | ] 1805 | }, 1806 | "description": "## Key Meanings\r\n\r\n- EMM_EXM_EXCH_ID\r\n - NSE\r\n - BSE\r\n - MCX\r\n\r\n- EMM_EXCH_SEG\r\n - E => Equity\r\n - D = > Derivatives\r\n - C => Currency\r\n - M => Commodity\r\n\r\n- MARKET_TYPE\r\n - NL - Normal Market\r\n - MS - Morning Session\r\n - ES - Evening Session\r\n\r\n- EMM_STATUS\r\n - CLOSE\r\n - OPEN" 1807 | }, 1808 | "response": [] 1809 | } 1810 | ] 1811 | }, 1812 | { 1813 | "name": "Market Data", 1814 | "item": [ 1815 | { 1816 | "name": "Quotes", 1817 | "request": { 1818 | "method": "GET", 1819 | "header": [ 1820 | { 1821 | "key": "Authorization", 1822 | "value": "{{appId}}:{{access_token}}", 1823 | "type": "text" 1824 | } 1825 | ], 1826 | "url": { 1827 | "raw": "https://api-t1.fyers.in/data/quotes/?symbols=NSE:SBIN-EQ", 1828 | "protocol": "https", 1829 | "host": [ 1830 | "api-t1", 1831 | "fyers", 1832 | "in" 1833 | ], 1834 | "path": [ 1835 | "data", 1836 | "quotes", 1837 | "" 1838 | ], 1839 | "query": [ 1840 | { 1841 | "key": "symbols", 1842 | "value": "NSE:SBIN-EQ" 1843 | } 1844 | ] 1845 | } 1846 | }, 1847 | "response": [] 1848 | }, 1849 | { 1850 | "name": "Market Depth", 1851 | "request": { 1852 | "method": "GET", 1853 | "header": [ 1854 | { 1855 | "key": "Authorization", 1856 | "value": "{{appId}}:{{access_token}}", 1857 | "type": "text" 1858 | } 1859 | ], 1860 | "url": { 1861 | "raw": "https://api-t1.fyers.in/data/depth/?symbol=NSE:SBIN-EQ&ohlcv_flag=1", 1862 | "protocol": "https", 1863 | "host": [ 1864 | "api-t1", 1865 | "fyers", 1866 | "in" 1867 | ], 1868 | "path": [ 1869 | "data", 1870 | "depth", 1871 | "" 1872 | ], 1873 | "query": [ 1874 | { 1875 | "key": "symbol", 1876 | "value": "NSE:SBIN-EQ" 1877 | }, 1878 | { 1879 | "key": "ohlcv_flag", 1880 | "value": "1" 1881 | } 1882 | ] 1883 | }, 1884 | "description": "Market Depth will give you the best 5 bids and asks. If you want only the bids and asks, then you can pass ohlcvFlag = 0" 1885 | }, 1886 | "response": [] 1887 | }, 1888 | { 1889 | "name": "Historical Data", 1890 | "request": { 1891 | "method": "GET", 1892 | "header": [ 1893 | { 1894 | "key": "Authorization", 1895 | "value": "{{appId}}:{{access_token}}", 1896 | "type": "text" 1897 | } 1898 | ], 1899 | "url": { 1900 | "raw": "https://api-t1.fyers.in/data/history?symbol=NSE:SBIN-EQ&resolution=30&date_format=1&range_from=2021-01-01&range_to=2021-01-02&cont_flag=1", 1901 | "protocol": "https", 1902 | "host": [ 1903 | "api-t1", 1904 | "fyers", 1905 | "in" 1906 | ], 1907 | "path": [ 1908 | "data", 1909 | "history" 1910 | ], 1911 | "query": [ 1912 | { 1913 | "key": "symbol", 1914 | "value": "NSE:SBIN-EQ" 1915 | }, 1916 | { 1917 | "key": "resolution", 1918 | "value": "30" 1919 | }, 1920 | { 1921 | "key": "date_format", 1922 | "value": "1" 1923 | }, 1924 | { 1925 | "key": "range_from", 1926 | "value": "2021-01-01" 1927 | }, 1928 | { 1929 | "key": "range_to", 1930 | "value": "2021-01-02" 1931 | }, 1932 | { 1933 | "key": "cont_flag", 1934 | "value": "1" 1935 | } 1936 | ] 1937 | } 1938 | }, 1939 | "response": [] 1940 | } 1941 | ] 1942 | }, 1943 | { 1944 | "name": "Edis", 1945 | "item": [ 1946 | { 1947 | "name": "Tpin Generation", 1948 | "request": { 1949 | "method": "GET", 1950 | "header": [ 1951 | { 1952 | "key": "Authorization", 1953 | "value": "{{appId}}:{{access_token}}", 1954 | "type": "text" 1955 | } 1956 | ], 1957 | "url": { 1958 | "raw": "https://api.fyers.in/api/v2/tpin", 1959 | "protocol": "https", 1960 | "host": [ 1961 | "api", 1962 | "fyers", 1963 | "in" 1964 | ], 1965 | "path": [ 1966 | "api", 1967 | "v2", 1968 | "tpin" 1969 | ] 1970 | } 1971 | }, 1972 | "response": [] 1973 | }, 1974 | { 1975 | "name": "Details", 1976 | "request": { 1977 | "method": "GET", 1978 | "header": [ 1979 | { 1980 | "key": "Authorization", 1981 | "value": "{{appId}}:{{access_token}}", 1982 | "type": "text" 1983 | } 1984 | ], 1985 | "url": { 1986 | "raw": "https://api.fyers.in/api/v2/details", 1987 | "protocol": "https", 1988 | "host": [ 1989 | "api", 1990 | "fyers", 1991 | "in" 1992 | ], 1993 | "path": [ 1994 | "api", 1995 | "v2", 1996 | "details" 1997 | ] 1998 | } 1999 | }, 2000 | "response": [] 2001 | }, 2002 | { 2003 | "name": "index", 2004 | "request": { 2005 | "method": "POST", 2006 | "header": [ 2007 | { 2008 | "key": "Authorization", 2009 | "value": "{{appId}}:{{access_token}}", 2010 | "type": "text" 2011 | } 2012 | ], 2013 | "body": { 2014 | "mode": "raw", 2015 | "raw": "{\"recordLst\": [{\"isin_code\": \"INE313D01013\", \"qty\": 1}]}", 2016 | "options": { 2017 | "raw": { 2018 | "language": "json" 2019 | } 2020 | } 2021 | }, 2022 | "url": { 2023 | "raw": "https://api.fyers.in/api/v2/index", 2024 | "protocol": "https", 2025 | "host": [ 2026 | "api", 2027 | "fyers", 2028 | "in" 2029 | ], 2030 | "path": [ 2031 | "api", 2032 | "v2", 2033 | "index" 2034 | ] 2035 | } 2036 | }, 2037 | "response": [] 2038 | }, 2039 | { 2040 | "name": "Inquiry", 2041 | "request": { 2042 | "method": "POST", 2043 | "header": [ 2044 | { 2045 | "key": "Authorization", 2046 | "value": "{{appId}}:{{access_token}}", 2047 | "type": "text" 2048 | } 2049 | ], 2050 | "body": { 2051 | "mode": "raw", 2052 | "raw": "{\"transactionId\": \"915484108176\"}", 2053 | "options": { 2054 | "raw": { 2055 | "language": "json" 2056 | } 2057 | } 2058 | }, 2059 | "url": { 2060 | "raw": "https://api.fyers.in/api/v2/inquiry", 2061 | "protocol": "https", 2062 | "host": [ 2063 | "api", 2064 | "fyers", 2065 | "in" 2066 | ], 2067 | "path": [ 2068 | "api", 2069 | "v2", 2070 | "inquiry" 2071 | ] 2072 | } 2073 | }, 2074 | "response": [] 2075 | } 2076 | ] 2077 | } 2078 | ], 2079 | "event": [ 2080 | { 2081 | "listen": "prerequest", 2082 | "script": { 2083 | "type": "text/javascript", 2084 | "exec": [ 2085 | "" 2086 | ] 2087 | } 2088 | }, 2089 | { 2090 | "listen": "test", 2091 | "script": { 2092 | "type": "text/javascript", 2093 | "exec": [ 2094 | "" 2095 | ] 2096 | } 2097 | } 2098 | ], 2099 | "variable": [ 2100 | { 2101 | "key": "appId", 2102 | "value": "", 2103 | "type": "string" 2104 | }, 2105 | { 2106 | "key": "access_token", 2107 | "value": "", 2108 | "type": "string" 2109 | } 2110 | ] 2111 | } -------------------------------------------------------------------------------- /v3/Postman V3/FYERS API V3.postman_environment.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "04957345-323d-4cdf-be90-5877080579e5", 3 | "name": "FYERS API V3", 4 | "values": [ 5 | { 6 | "key": "appId", 7 | "value": "{{appId}}", 8 | "enabled": true 9 | }, 10 | { 11 | "key": "redirect_uri", 12 | "value": "{{redirect_uri}}", 13 | "enabled": true 14 | }, 15 | { 16 | "key": "access_token", 17 | "value": "{{access_token}}", 18 | "enabled": true 19 | }, 20 | { 21 | "key": "auth_code", 22 | "value": "{{auth_code}}", 23 | "enabled": true 24 | }, 25 | { 26 | "key": "appId_hash", 27 | "value": "{{appId_hash}}", 28 | "enabled": true 29 | } 30 | ], 31 | "_postman_variable_scope": "environment", 32 | "_postman_exported_at": "2023-08-25T06:00:24.329Z", 33 | "_postman_exported_using": "Postman/10.17.3" 34 | } -------------------------------------------------------------------------------- /v3/Postman V3/FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv: -------------------------------------------------------------------------------- 1 | Code,Error Message,Error Description 2 | ,, 3 | -209,Please provide a valid order number,This error code and error message specifies that the order_id passed is either incorrect or not a valid one for the particular order 4 | -101,Please provide a valid order type,This error code and error message specifes that the Type provided for the particular order is not a valid Type 5 | -305,Only market and limit orders are allowed,This error code and error message specifies that for CO orders only market and limit orders are allowed 6 | -323,Only market and limit orders are allowed,This error code and error message specifies that for BO orders only market and limit orders are allowed 7 | -308,Please provide a valid limitPrice,This error code and error message specifies that a valid LimitPrice value needs to be passed for the particular symbol 8 | -309,Please provide a valid stop price,This error code and error message specifies that a valid stopPrice value needs to be passed for the particular symbol 9 | -310,Please provide a valid order quantity,This error code and error message specifies that the order Qty provided for the symbol is incorrect and need to provide a proper Qty 10 | -311,Please provide a valid stop loss price,This error code and error message specifies that the Stoploss price provided is incorrect for the specified symbol 11 | -313,Please provide a valid order side of either buy or sell,This error code and error message specifies that a valid side either (buy/sell) wasn't send for the symbol 12 | -314,Please provide a valid product type for the order,This error code and error message specifies the Type(Intraday/CNC/Margin) of the symbol was incorrect 13 | -315,Please provide a valid price for stop limit order,This error code and error message specifies that the for the StopLimit order provide a valid stopPrice 14 | -316,Please provide a valid stop loss price,This error code and errror message specifies that for the CO and BO orders the stopLoss key Provided is Incorrect 15 | -323,Please provide a valid stop loss value,This error code and error message specifies that the Stoploss provided is incorrect for the particular order 16 | -325,Please provide a valid target value,This error code and error message specifies that the takeProfit key being passed is incorrect or the value in takeProfit key is inappropriate 17 | -326,Please provide a valid order validity,This error code and error message specifies that the Validity key value provided for the particular order is incorrect 18 | -327,Please provide a valid order disclosed quantity,This error code and error message specifies the disclosed quantity passed for a particular value is incorrect 19 | -328,Please provide a valid order offline flag,This error code and error message specifes that the offline order flag provided is incorrect it should be either true/false is being passed. 20 | ,, 21 | ,, 22 | -201,Connection error. Please try again,This error code and error message specifies that there was some connection issue while processing your request 23 | -202,Connection error. Please try again,This error code specifies that due to some cause the connection timed out. after some time make another request 24 | -204,Connection error. Please try again,This error code specifies due to some http error the request wasnt processed 25 | -205,Connection error. Please try again,This error code specifies due to some reason the market wasnt able to accept or process the request 26 | ,, 27 | ,, 28 | -157,""" """,This error code specifies that the user doesnt exist 29 | -159,Please provide a valid order number,This error code specifies that for the particular order_id provided there is no any orders in the orderbook 30 | -161,This order has already been cancelled,This error code specifies that the order for the particular order_id is already cancelled 31 | -162,This order has already traded,This error code specifies that the order for the particular order_id is already got traded. 32 | -163,"""""",This error code specifies that due to some reason the order modfication wasnt done successfully. 33 | -164,This order has already been rejected,This error code and error message specifies that the order for the particular symbol got rejecteed due to some reason. 34 | ,, 35 | -390,Please provide a valid stop price,This error code and error message specfies that during order placement the stopPrice provided is invalid for the particular symbol 36 | -392,Price should be in multiples of tick size.,This error code and error message specifies that Price you are trading for the symbol doesnt match with the symbol tick size 37 | -353,API Limit exceeded (perSec/perMin/perDay),This error code specifies that the ratelimit for the Api is exceeded 38 | -372,Please provide a valid price.,This error code and error message specifies that the Price provided during orderplacement is invalid 39 | -397,Position quantity is zero,This error code and error message specifies that for the symbol the Position is already Zero. 40 | -398,Looks like you have no open positions.,This error code and error message specifies that the you dont have any open positions in your account. 41 | -399,No pending orders,This error code and error message specifies that you dont have any order which can be cancelled or you dont have any position to close the particular position 42 | -329,We have processed exit positions request. Kindly check positions before taking further action.,This error code and error message specifies that we have made the request to the market to close position but the result havent been updated so for you confirmation we are asking you to check the posotions 43 | ,, 44 | -373,please provide valid permission,This error code and error message specifies that for the particular Api request the app doesnt have the permission. 45 | -374,Please provide authorization code.,This error code and error message specifies that the auth_code passed is not a valid one you need to generate one to generate token 46 | -371,Please provide sha256 hash of appId and app secret,This error code and error message specifies that the app_id hash passed to generate the token is invaliad and you need to provide one with the sha256(app_id:secret_key) 47 | ,, 48 | ,, 49 | -96,An unexpected error occurred. Please contact support.,This error code and error message occurs if there comes an issue while processing the request 50 | -------------------------------------------------------------------------------- /v3/node/account_info/funds.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | fyers.get_funds().then((response) => { 15 | console.log(response) 16 | }).catch((error) => { 17 | console.log(error) 18 | }) -------------------------------------------------------------------------------- /v3/node/account_info/getprofile.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | fyers.get_profile().then((response) => { 15 | console.log(response) 16 | }).catch((error) => { 17 | console.log(error) 18 | }) -------------------------------------------------------------------------------- /v3/node/broker_info/market_status.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | fyers.market_status().then((response) => { 15 | console.log(response) 16 | }).catch((error) => { 17 | console.log(error) 18 | }) -------------------------------------------------------------------------------- /v3/node/login/get_access_token.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | const open = require('opn'); 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | var generateAuthcodeURL = fyers.generateAuthCode(); 12 | 13 | // Open the URL in the default web browser to allow the user to grant access 14 | open(generateAuthcodeURL) 15 | .then(() => { 16 | console.log(`Opened ${generateAuthcodeURL} in your default web browser.`); 17 | }) 18 | .catch((error) => { 19 | console.error('Error occurred:', error); 20 | }); 21 | 22 | 23 | // Define the authorization code and secret key required for generating access token 24 | const auth_code="exyj....." 25 | // Replace with your secret key provided by Fyers 26 | const secretKey = "RJ1W2XG5L4" 27 | 28 | // fyers.generate_access_token({ "secret_key": secretKey, "auth_code": auth_code }).then((response) => { 29 | // console.log(response) 30 | // }).catch((error) => { 31 | // console.log(error) 32 | // }) -------------------------------------------------------------------------------- /v3/node/market_data/depth.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={"symbol":["NSE:SBIN-EQ","NSE:TCS-EQ"],"ohlcv_flag":1} 15 | 16 | fyers.getMarketDepth(inp).then((response) => { 17 | console.log(response) 18 | }).catch((error) => { 19 | console.log(error) 20 | }) -------------------------------------------------------------------------------- /v3/node/market_data/history.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | 15 | var inp={ 16 | "symbol":"NSE:SBIN-EQ", 17 | "resolution":"D", 18 | "date_format":"0", 19 | "range_from":"1622097600", 20 | "range_to":"1622097685", 21 | "cont_flag":"1" 22 | } 23 | 24 | fyers.getHistory(inp).then((response) => { 25 | console.log(response) 26 | }).catch((error) => { 27 | console.log(error) 28 | }) -------------------------------------------------------------------------------- /v3/node/market_data/quotes.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp=["NSE:SBIN-EQ","NSE:TCS-EQ"] 15 | 16 | fyers.getQuotes(inp).then((response) => { 17 | console.log(response) 18 | }).catch((error) => { 19 | console.log(error) 20 | }) -------------------------------------------------------------------------------- /v3/node/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample_codes", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@otplib/core": { 8 | "version": "12.0.1", 9 | "resolved": "https://registry.npmjs.org/@otplib/core/-/core-12.0.1.tgz", 10 | "integrity": "sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA==" 11 | }, 12 | "@otplib/plugin-crypto": { 13 | "version": "12.0.1", 14 | "resolved": "https://registry.npmjs.org/@otplib/plugin-crypto/-/plugin-crypto-12.0.1.tgz", 15 | "integrity": "sha512-qPuhN3QrT7ZZLcLCyKOSNhuijUi9G5guMRVrxq63r9YNOxxQjPm59gVxLM+7xGnHnM6cimY57tuKsjK7y9LM1g==", 16 | "requires": { 17 | "@otplib/core": "^12.0.1" 18 | } 19 | }, 20 | "@otplib/plugin-thirty-two": { 21 | "version": "12.0.1", 22 | "resolved": "https://registry.npmjs.org/@otplib/plugin-thirty-two/-/plugin-thirty-two-12.0.1.tgz", 23 | "integrity": "sha512-MtT+uqRso909UkbrrYpJ6XFjj9D+x2Py7KjTO9JDPhL0bJUYVu5kFP4TFZW4NFAywrAtFRxOVY261u0qwb93gA==", 24 | "requires": { 25 | "@otplib/core": "^12.0.1", 26 | "thirty-two": "^1.0.2" 27 | } 28 | }, 29 | "@otplib/preset-default": { 30 | "version": "12.0.1", 31 | "resolved": "https://registry.npmjs.org/@otplib/preset-default/-/preset-default-12.0.1.tgz", 32 | "integrity": "sha512-xf1v9oOJRyXfluBhMdpOkr+bsE+Irt+0D5uHtvg6x1eosfmHCsCC6ej/m7FXiWqdo0+ZUI6xSKDhJwc8yfiOPQ==", 33 | "requires": { 34 | "@otplib/core": "^12.0.1", 35 | "@otplib/plugin-crypto": "^12.0.1", 36 | "@otplib/plugin-thirty-two": "^12.0.1" 37 | } 38 | }, 39 | "@otplib/preset-v11": { 40 | "version": "12.0.1", 41 | "resolved": "https://registry.npmjs.org/@otplib/preset-v11/-/preset-v11-12.0.1.tgz", 42 | "integrity": "sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg==", 43 | "requires": { 44 | "@otplib/core": "^12.0.1", 45 | "@otplib/plugin-crypto": "^12.0.1", 46 | "@otplib/plugin-thirty-two": "^12.0.1" 47 | } 48 | }, 49 | "asynckit": { 50 | "version": "0.4.0", 51 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 52 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 53 | }, 54 | "axios": { 55 | "version": "1.4.0", 56 | "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", 57 | "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", 58 | "requires": { 59 | "follow-redirects": "^1.15.0", 60 | "form-data": "^4.0.0", 61 | "proxy-from-env": "^1.1.0" 62 | } 63 | }, 64 | "buffer-equal-constant-time": { 65 | "version": "1.0.1", 66 | "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", 67 | "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 68 | }, 69 | "combined-stream": { 70 | "version": "1.0.8", 71 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 72 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 73 | "requires": { 74 | "delayed-stream": "~1.0.0" 75 | } 76 | }, 77 | "delayed-stream": { 78 | "version": "1.0.0", 79 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 80 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" 81 | }, 82 | "ecdsa-sig-formatter": { 83 | "version": "1.0.11", 84 | "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 85 | "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", 86 | "requires": { 87 | "safe-buffer": "^5.0.1" 88 | } 89 | }, 90 | "follow-redirects": { 91 | "version": "1.15.2", 92 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", 93 | "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" 94 | }, 95 | "form-data": { 96 | "version": "4.0.0", 97 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 98 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 99 | "requires": { 100 | "asynckit": "^0.4.0", 101 | "combined-stream": "^1.0.8", 102 | "mime-types": "^2.1.12" 103 | } 104 | }, 105 | "fyers-api-v3": { 106 | "version": "1.0.0", 107 | "resolved": "https://registry.npmjs.org/fyers-api-v3/-/fyers-api-v3-1.0.0.tgz", 108 | "integrity": "sha512-RjOd8GUBrUX6oe7CZ0PolwEsAWozi34NDWrXJSrgQGjbWNLGdrqW4HOX+QAkZ23xB0vEvLODI4EY3WVnR3CsWw==", 109 | "requires": { 110 | "axios": "^1.3.5", 111 | "jsonwebtoken": "^9.0.1", 112 | "ws": "^8.13.0" 113 | } 114 | }, 115 | "is-wsl": { 116 | "version": "1.1.0", 117 | "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", 118 | "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==" 119 | }, 120 | "jsonwebtoken": { 121 | "version": "9.0.1", 122 | "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz", 123 | "integrity": "sha512-K8wx7eJ5TPvEjuiVSkv167EVboBDv9PZdDoF7BgeQnBLVvZWW9clr2PsQHVJDTKaEIH5JBIwHujGcHp7GgI2eg==", 124 | "requires": { 125 | "jws": "^3.2.2", 126 | "lodash": "^4.17.21", 127 | "ms": "^2.1.1", 128 | "semver": "^7.3.8" 129 | } 130 | }, 131 | "jwa": { 132 | "version": "1.4.1", 133 | "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 134 | "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", 135 | "requires": { 136 | "buffer-equal-constant-time": "1.0.1", 137 | "ecdsa-sig-formatter": "1.0.11", 138 | "safe-buffer": "^5.0.1" 139 | } 140 | }, 141 | "jws": { 142 | "version": "3.2.2", 143 | "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", 144 | "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", 145 | "requires": { 146 | "jwa": "^1.4.1", 147 | "safe-buffer": "^5.0.1" 148 | } 149 | }, 150 | "lodash": { 151 | "version": "4.17.21", 152 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 153 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" 154 | }, 155 | "lru-cache": { 156 | "version": "6.0.0", 157 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 158 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 159 | "requires": { 160 | "yallist": "^4.0.0" 161 | } 162 | }, 163 | "mime-db": { 164 | "version": "1.52.0", 165 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 166 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" 167 | }, 168 | "mime-types": { 169 | "version": "2.1.35", 170 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 171 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 172 | "requires": { 173 | "mime-db": "1.52.0" 174 | } 175 | }, 176 | "ms": { 177 | "version": "2.1.3", 178 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 179 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 180 | }, 181 | "opn": { 182 | "version": "6.0.0", 183 | "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", 184 | "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", 185 | "requires": { 186 | "is-wsl": "^1.1.0" 187 | } 188 | }, 189 | "otplib": { 190 | "version": "12.0.1", 191 | "resolved": "https://registry.npmjs.org/otplib/-/otplib-12.0.1.tgz", 192 | "integrity": "sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg==", 193 | "requires": { 194 | "@otplib/core": "^12.0.1", 195 | "@otplib/preset-default": "^12.0.1", 196 | "@otplib/preset-v11": "^12.0.1" 197 | } 198 | }, 199 | "proxy-from-env": { 200 | "version": "1.1.0", 201 | "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", 202 | "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" 203 | }, 204 | "safe-buffer": { 205 | "version": "5.2.1", 206 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 207 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 208 | }, 209 | "semver": { 210 | "version": "7.5.4", 211 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", 212 | "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", 213 | "requires": { 214 | "lru-cache": "^6.0.0" 215 | } 216 | }, 217 | "thirty-two": { 218 | "version": "1.0.2", 219 | "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", 220 | "integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==" 221 | }, 222 | "ws": { 223 | "version": "8.13.0", 224 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", 225 | "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==" 226 | }, 227 | "yallist": { 228 | "version": "4.0.0", 229 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 230 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 231 | } 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /v3/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample_codes", 3 | "version": "1.0.0", 4 | "description": "sample codes for node_js", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "fyers-api-v3": "^1.0.0", 13 | "opn": "^6.0.0", 14 | "otplib": "^12.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v3/node/transaction/orders/cancel_multi_order..js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp =[{ 15 | "id": '808058117761' 16 | }, 17 | { 18 | "id": '808058117762' 19 | }] 20 | 21 | fyers.cancel_multi_order(inp).then((response) => { 22 | console.log(response) 23 | }).catch((error) => { 24 | console.log(error) 25 | }) -------------------------------------------------------------------------------- /v3/node/transaction/orders/cancel_order.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp = { 15 | "id": '808058117761' 16 | } 17 | 18 | fyers.cancel_order(inp).then((response) => { 19 | console.log(response) 20 | }).catch((error) => { 21 | console.log(error) 22 | }) -------------------------------------------------------------------------------- /v3/node/transaction/orders/modify_order.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | "id":'808058117761', 16 | "type":1, 17 | "limitPrice": 61049, 18 | "qty":1 19 | } 20 | 21 | fyers.modify_order(inp).then((response) => { 22 | console.log(response) 23 | }).catch((error) => { 24 | console.log(error) 25 | }) -------------------------------------------------------------------------------- /v3/node/transaction/orders/mulit_order.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp=[{ 15 | "symbol":"NSE:SBIN-EQ", 16 | "qty":1, 17 | "type":2, 18 | "side":1, 19 | "productType":"INTRADAY", 20 | "limitPrice":0, 21 | "stopPrice":0, 22 | "validity":"DAY", 23 | "disclosedQty":0, 24 | "offlineOrder":False, 25 | }, 26 | { 27 | "symbol":"NSE:IDEA-EQ", 28 | "qty":1, 29 | "type":2, 30 | "side":1, 31 | "productType":"INTRADAY", 32 | "limitPrice":0, 33 | "stopPrice":0, 34 | "validity":"DAY", 35 | "disclosedQty":0, 36 | "offlineOrder":False, 37 | },{ 38 | "symbol":"NSE:SBIN-EQ", 39 | "qty":1, 40 | "type":2, 41 | "side":1, 42 | "productType":"INTRADAY", 43 | "limitPrice":0, 44 | "stopPrice":0, 45 | "validity":"DAY", 46 | "disclosedQty":0, 47 | "offlineOrder":False, 48 | }, 49 | { 50 | "symbol":"NSE:IDEA-EQ", 51 | "qty":1, 52 | "type":2, 53 | "side":1, 54 | "productType":"INTRADAY", 55 | "limitPrice":0, 56 | "stopPrice":0, 57 | "validity":"DAY", 58 | "disclosedQty":0, 59 | "offlineOrder":False, 60 | }] 61 | 62 | fyers.place_multi_order(inp).then((response) => { 63 | console.log(response) 64 | }).catch((error) => { 65 | console.log(error) 66 | }) -------------------------------------------------------------------------------- /v3/node/transaction/orders/multi_modify.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp=[{ 15 | "id": "8102710298291", 16 | "type": 1, 17 | "limitPrice": 61049, 18 | "qty": 1 19 | }, 20 | { 21 | "id": "8102710298292", 22 | "type": 1, 23 | "limitPrice": 61049, 24 | "qty": 1 25 | }] 26 | 27 | fyers.modify_multi_order(inp).then((response) => { 28 | console.log(response) 29 | }).catch((error) => { 30 | console.log(error) 31 | }) -------------------------------------------------------------------------------- /v3/node/transaction/orders/place_order.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | "symbol":"NSE:IDEA-EQ", 16 | "qty":1, 17 | "type":2, 18 | "side":1, 19 | "productType":"INTRADAY", 20 | "limitPrice":0, 21 | "stopPrice":0, 22 | "validity":"DAY", 23 | "disclosedQty":0, 24 | "offlineOrder":False, 25 | } 26 | 27 | fyers.place_order(inp).then((response) => { 28 | console.log(response) 29 | }).catch((error) => { 30 | console.log(error) 31 | }) -------------------------------------------------------------------------------- /v3/node/transaction/positions/convert_position.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | "symbol":"NSE:ONGC-EQ-INTRADAY", 16 | "positionSide":1, 17 | "convertQty":1, 18 | "convertFrom":"INTRADAY", 19 | "convertTo":"CNC", 20 | "overnight": 1 21 | } 22 | 23 | fyers.convert_position(inp).then((response) => { 24 | console.log(response) 25 | }).catch((error) => { 26 | console.log(error) 27 | }) -------------------------------------------------------------------------------- /v3/node/transaction/positions/exit_by_id.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | "id":"NSE:SBIN-EQ-BO" 16 | } 17 | 18 | fyers.exit_position(inp).then((response) => { 19 | console.log(response) 20 | }).catch((error) => { 21 | console.log(error) 22 | }) -------------------------------------------------------------------------------- /v3/node/transaction/positions/exit_position.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | "exit_all":1 16 | } 17 | 18 | fyers.exit_position(inp).then((response) => { 19 | console.log(response) 20 | }).catch((error) => { 21 | console.log(error) 22 | }) -------------------------------------------------------------------------------- /v3/node/transaction_info/holdings.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | 15 | fyers.get_holdings().then((response) => { 16 | console.log(response) 17 | }).catch((error) => { 18 | console.log(error) 19 | }) -------------------------------------------------------------------------------- /v3/node/transaction_info/orderbook.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | 15 | fyers.get_orders().then((response) => { 16 | console.log(response) 17 | }).catch((error) => { 18 | console.log(error) 19 | }) -------------------------------------------------------------------------------- /v3/node/transaction_info/orderbook_byID.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | var inp={ 15 | 16 | order_id:"1210408175301" 17 | 18 | } 19 | 20 | fyers.get_filtered_orders(inp).then((response) => { 21 | console.log(response) 22 | }).catch((error) => { 23 | console.log(error) 24 | }) -------------------------------------------------------------------------------- /v3/node/transaction_info/position.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | 15 | fyers.get_positions().then((response) => { 16 | console.log(response) 17 | }).catch((error) => { 18 | console.log(error) 19 | }) -------------------------------------------------------------------------------- /v3/node/transaction_info/tradebook.js: -------------------------------------------------------------------------------- 1 | const FyersAPI = require("fyers-api-v3").fyersModel 2 | 3 | 4 | var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) 5 | // set appID 6 | fyers.setAppId("Qxxxxxx75-1xx") 7 | 8 | // set redirectURL 9 | fyers.setRedirectUrl("https://XXXXX.com") 10 | 11 | // set accessToken 12 | fyers.setAccessToken("eyJ0xxxx") 13 | 14 | 15 | fyers.get_tradebook().then((response) => { 16 | console.log(response) 17 | }).catch((error) => { 18 | console.log(error) 19 | }) -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/data_websocket.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) 12 | console.log(skt.isConnected()) 13 | }) 14 | 15 | skt.on("message",function(message){ 16 | console.log({"TEST":message}) 17 | }) 18 | 19 | skt.on("error",function(message){ 20 | console.log("erroris",message) 21 | }) 22 | 23 | skt.on("close",function(){ 24 | console.log("socket closed") 25 | }) 26 | skt.connect() 27 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/depthUpdate.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"],true) 12 | console.log(skt.isConnected()) 13 | }) 14 | 15 | skt.on("message",function(message){ 16 | console.log({"TEST":message}) 17 | }) 18 | 19 | skt.on("error",function(message){ 20 | console.log("erroris",message) 21 | }) 22 | 23 | skt.on("close",function(){ 24 | console.log("socket closed") 25 | }) 26 | skt.connect() 27 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/indexUpdate.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:NIFTYMIDSELECT-INDEX',"NSE:NIFTYHEALTHCARE-INDEX"]) 12 | console.log(skt.isConnected()) 13 | }) 14 | 15 | skt.on("message",function(message){ 16 | console.log({"TEST":message}) 17 | }) 18 | 19 | skt.on("error",function(message){ 20 | console.log("erroris",message) 21 | }) 22 | 23 | skt.on("close",function(){ 24 | console.log("socket closed") 25 | }) 26 | skt.connect() 27 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/liteSymbolUpdate.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) 12 | skt.mode(skt.LiteMode) 13 | // incase of going back to full mode use 14 | // skt.mode(skt.FullMode) 15 | 16 | console.log(skt.isConnected()) 17 | }) 18 | 19 | skt.on("message",function(message){ 20 | console.log({"TEST":message}) 21 | }) 22 | 23 | skt.on("error",function(message){ 24 | console.log("erroris",message) 25 | }) 26 | 27 | skt.on("close",function(){ 28 | console.log("socket closed") 29 | }) 30 | skt.connect() 31 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/symbolUpdate.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) 12 | console.log(skt.isConnected()) 13 | }) 14 | 15 | skt.on("message",function(message){ 16 | console.log({"TEST":message}) 17 | }) 18 | 19 | skt.on("error",function(message){ 20 | console.log("erroris",message) 21 | }) 22 | 23 | skt.on("close",function(){ 24 | console.log("socket closed") 25 | }) 26 | skt.connect() 27 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/data_socket/unsubscribeUpdate.js: -------------------------------------------------------------------------------- 1 | const DataSocket = require("fyers-api-v3").fyersDataSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("connect",function(){ 11 | skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) 12 | console.log(skt.isConnected()) 13 | }) 14 | 15 | skt.on("message",function(message){ 16 | if(message.ltp>100 &&message.symbol=="NSE:SBIN-EQ"){ 17 | fyersdata.unsubscribe(["NSE:SBIN-EQ"],false) 18 | } 19 | }) 20 | 21 | skt.on("error",function(message){ 22 | console.log("erroris",message) 23 | }) 24 | 25 | skt.on("close",function(){ 26 | console.log("socket closed") 27 | }) 28 | skt.connect() 29 | skt.autoreconnect() -------------------------------------------------------------------------------- /v3/node/websocket/order_socket/onGeneral.js: -------------------------------------------------------------------------------- 1 | var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("error",function (errmsg) { 11 | console.log(errmsg) 12 | }) 13 | 14 | //handle your general messages here 15 | skt.on('general',function (msg) { 16 | console.log(msg) 17 | }) 18 | skt.on('connect',function () { 19 | skt.subscribe([skt.edis,skt.pricealerts]) 20 | console.log(skt.isConnected()) 21 | }) 22 | 23 | skt.on('close',function () { 24 | console.log('closed') 25 | }) 26 | 27 | //handle your order messages here 28 | skt.on('orders',function (msg) { 29 | console.log("orders",msg) 30 | }) 31 | 32 | //handle your trade messages here 33 | skt.on('trades',function (msg) { 34 | console.log('trades',msg) 35 | }) 36 | 37 | //handle your positions messages here 38 | skt.on('positions',function (msg) { 39 | console.log('positions',msg) 40 | }) 41 | 42 | skt.autoreconnect() 43 | skt.connect() 44 | 45 | -------------------------------------------------------------------------------- /v3/node/websocket/order_socket/onOrders.js: -------------------------------------------------------------------------------- 1 | var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("error",function (errmsg) { 11 | console.log(errmsg) 12 | }) 13 | 14 | //handle your general messages here 15 | skt.on('general',function (msg) { 16 | console.log(msg) 17 | }) 18 | skt.on('connect',function () { 19 | skt.subscribe([skt.orderUpdates]) 20 | console.log(skt.isConnected()) 21 | }) 22 | 23 | skt.on('close',function () { 24 | console.log('closed') 25 | }) 26 | 27 | //handle your order messages here 28 | skt.on('orders',function (msg) { 29 | console.log("orders",msg) 30 | }) 31 | 32 | //handle your trade messages here 33 | skt.on('trades',function (msg) { 34 | console.log('trades',msg) 35 | }) 36 | 37 | //handle your positions messages here 38 | skt.on('positions',function (msg) { 39 | console.log('positions',msg) 40 | }) 41 | 42 | skt.autoreconnect() 43 | skt.connect() 44 | 45 | -------------------------------------------------------------------------------- /v3/node/websocket/order_socket/onPosition.js: -------------------------------------------------------------------------------- 1 | var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("error",function (errmsg) { 11 | console.log(errmsg) 12 | }) 13 | 14 | //handle your general messages here 15 | skt.on('general',function (msg) { 16 | console.log(msg) 17 | }) 18 | skt.on('connect',function () { 19 | skt.subscribe([skt.positionUpdates]) 20 | console.log(skt.isConnected()) 21 | }) 22 | 23 | skt.on('close',function () { 24 | console.log('closed') 25 | }) 26 | 27 | //handle your order messages here 28 | skt.on('orders',function (msg) { 29 | console.log("orders",msg) 30 | }) 31 | 32 | //handle your trade messages here 33 | skt.on('trades',function (msg) { 34 | console.log('trades',msg) 35 | }) 36 | 37 | //handle your positions messages here 38 | skt.on('positions',function (msg) { 39 | console.log('positions',msg) 40 | }) 41 | 42 | skt.autoreconnect() 43 | skt.connect() 44 | 45 | -------------------------------------------------------------------------------- /v3/node/websocket/order_socket/ontrade.js: -------------------------------------------------------------------------------- 1 | var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket 2 | 3 | // Replace the sample access token with your actual access token 4 | // access_token format will be "APPID:access_token" 5 | // For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" 6 | const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 7 | 8 | var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") 9 | 10 | skt.on("error",function (errmsg) { 11 | console.log(errmsg) 12 | }) 13 | 14 | //handle your general messages here 15 | skt.on('general',function (msg) { 16 | console.log(msg) 17 | }) 18 | skt.on('connect',function () { 19 | skt.subscribe([skt.tradeUpdates]) 20 | console.log(skt.isConnected()) 21 | }) 22 | 23 | skt.on('close',function () { 24 | console.log('closed') 25 | }) 26 | 27 | //handle your order messages here 28 | skt.on('orders',function (msg) { 29 | console.log("orders",msg) 30 | }) 31 | 32 | //handle your trade messages here 33 | skt.on('trades',function (msg) { 34 | console.log('trades',msg) 35 | }) 36 | 37 | //handle your positions messages here 38 | skt.on('positions',function (msg) { 39 | console.log('positions',msg) 40 | }) 41 | 42 | skt.autoreconnect() 43 | skt.connect() 44 | 45 | -------------------------------------------------------------------------------- /v3/python/account_info/funds.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") 8 | 9 | # Make a request to get the funds information 10 | response = fyers.funds() 11 | print(response) 12 | 13 | -------------------------------------------------------------------------------- /v3/python/account_info/getprofile.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") 8 | 9 | # Make a request to get the user profile information 10 | response = fyers.get_profile() 11 | 12 | # Print the response received from the Fyers API 13 | print(response) 14 | 15 | -------------------------------------------------------------------------------- /v3/python/broker_info/market_status.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | 4 | client_id = "XC4XXXXM-100" 5 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 6 | 7 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 8 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 9 | 10 | 11 | response = fyers.market_status() 12 | print(response) -------------------------------------------------------------------------------- /v3/python/login/get_access_token.py: -------------------------------------------------------------------------------- 1 | moduleName = "getAccessToken" 2 | """ 3 | 1.We need to first install fyers-apiv3(can be installed as 'pip install fyers-apiv3) 4 | 2.We then need to import accesToken module from fyers_api directory(as done below) 5 | 3.We also need to import webbrowser to preform an action while generating authcode 6 | """ 7 | from fyers_apiv3 import fyersModel 8 | import webbrowser 9 | 10 | 11 | def getauthToken(appId, redirect_uri): 12 | functionName = "getauthToken" 13 | """ 14 | :param app_id: "XXXXXXXXXXX" 15 | :param redirect_url: "https://XXXXXX.com" 16 | 1. This function open this url in the browser. 17 | 2. This will ask you to login and will ask you to approve the app if it is not approved already. 18 | 3. Once that is done, it will redirect to a url (added while app creation) with the auth_code. The url will look like 19 | https://www.google.com/?auth_code=eyJ0eXAiOiXXXXXGciOiJIUzI1NiJ9.eyXXXXXXXXXXXXXInN1YiI6ImF1dGhDb2XXXXXXXXXXXXXXXXXX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXVpZCI6ImZhOGNhYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg&user_id=DP00404 20 | 4. You have to take the auth_code from the url and use that token in your generate_access_token function. 21 | """ 22 | response_type="code" 23 | grant_type="authorization_code" 24 | # creating an instance appSession to generate the auth code by passing app id and redirect url as parameter 25 | appSession = fyersModel.SessionModel(client_id=appId,redirect_uri=redirect_uri,response_type=response_type, grant_type=grant_type,state="state",scope="",nonce="") 26 | 27 | # The variable `generateTokenUrl` will have a url like https://uat-api.fyers.in/api/dev/generate-authcode?appId=B8PXXXH8T6&redirectUrl=https%3A%2F%2Fgoogle.com 28 | generateTokenUrl = appSession.generate_authcode() 29 | 30 | # This command is used to open the url in default system brower 31 | webbrowser.open(generateTokenUrl, new=1) 32 | 33 | 34 | def generate_access_token(auth_code, appId, secret_key): 35 | functionName = "generate_access_token" 36 | """ 37 | :param auth_code: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTM1ODY2NzEsInN1YiI6ImF1dGhDb2RlIiwiYXBwX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXXXXXXXXXXXYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg" 38 | :param app_id: "B8PXXXXXXX" 39 | :param secret_key: "XXXXXXKGN0" 40 | :param redirect_url: "https://XXXXXX.com" 41 | :return: access_token: "eyJ0eXAiOiJKV1QiLCXXXX1NiJ9.eyJpYXXXXXXXXXXMsIm5iZiI6MTU5MzU4ODM3MywiZXhwIjoxNTkzNjQ5ODEzLCJpc3MiOiJhcGkuZnllcnMuaW4iLCJzdWIiOiJhY2Nlc3MiLCJhdWQiOiJ4OjAseDoxLHg6MiIsImF0X2hhc2giOiJnQUFBQUFCZV9EcVZIZExMMTAzTVpVN1NYSkZfR2p5R3hidzMtTVVhb0VEMGI0QUVvNjFsR24tREY2OFU5cXhuNzd0UXVoOVVJalYtNm9MVXhINVFfWE1WTEJfRXpROGV2clJmUzlNUXB0Y2J5c2ltN1drWllZTT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQifQ.cAfrj2TxAyb8A_9DfiCb1hLIZg_mH-xvP3Ybnj3a4AE" 42 | 43 | 1.this function takes the param and return the access_token 44 | 2.the access_token created will be used further .(in fyersModel)] 45 | 3. one can get the auth_code from the url generated by getauthToken function (from auth_code= ..... &user_Id=xxxxxx before &) 46 | """ 47 | # creating an instance appSession by passing app id,secret key and redirect url as parameter 48 | appSession = fyersModel.SessionModel(client_id=appId, secret_key=secret_key,grant_type="authorization_code") 49 | 50 | # we need to pass the auth code in set_token method 51 | appSession.set_token(auth_code) 52 | # generate_token function will return us the access token and we store in variable "access_token" 53 | access_token = appSession.generate_token() 54 | return access_token 55 | 56 | 57 | def main(): 58 | """ 59 | Starting Steps. 60 | 1.We first need to uncomment the function getauthToken(appId, redirect_url). 61 | 2.We need to make sure generate_access_token(auth_code, appId, app_secret, redirect_url) func is commented. 62 | 3.We need to run this module code once passing the parameters to getauthToken(appId, redirect_url) func. 63 | 4.We copy the auth_code provided from our browser and store in the variable in "auth_code". 64 | 5.Next we need to uncomment the function generate_access_token(auth_code, appId, app_secret, redirect_url). 65 | 6.Then we need to make sure getauthToken(appId, redirect_url) func is commented. 66 | 7.We run this module again with appropriate parameters. 67 | """ 68 | # The provided redirct url while creating the app 69 | redirect_url = "https://www.google.com/" 70 | 71 | # The app id we get after creating the app 72 | appId = "OCDXXXXXXJ-100" 73 | 74 | # Function to get the auth code and need to be commented while calling the generate_access_token(x,x,x) func. 75 | getauthToken(appId, redirect_url) 76 | 77 | 78 | 79 | 80 | # The app secret we got after creating the app. 81 | app_secret = "BXXXXFM90" 82 | 83 | # the genarted auth code we got from browser after running the getauthToken(x,x) func. 84 | auth_code = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2OTA4NjQwOTAsImV4cCI6MTY5MDg5NDA5MCwibmJmIjoxNjkwODYzNDkwLCJhdWQiOiJbXCJ4OjBcIiwgXCJ4OjFcIiwgXCJ4OjJcIiwgXCJkOjFcIiwgXCJkOjJcIiwgXCJ4OjFcIiwgXCJ4OjBcIl0iLCJzdWIiOiJhdXRoX2NvZGUiLCJkaXNwbGF5X25hbWUiOiJYVjIwOTg2Iiwib21zIjoiSzEiLCJoc21fa2V5IjoiMGE1NTY1NGRhOWRjODUzMTExYzdhYzI0NjM2ZTkyNTQxMTEwYjdjNTJjYzVjYmQxNDAwNjkwNTciLCJub25jZSI6ImJha2EiLCJhcHBfaWQiOiJYQzRFT0Q2N0lNIiwidXVpZCI6IjhjOWEzYjc3YTA3ZDRhNDVhODJiZTI2MjVlMjk3NzgzIiwiaXBBZGRyIjoiMC4wLjAuMCIsInNjb3BlIjoiIn0.31CfyL7lnN5ZEU2-cRjtt8UP3carqt3Vk4YEPNaSBxE" 85 | 86 | # Function to get the access token and need to be commented while calling the getauthToken(x,x) func. 87 | print(generate_access_token(auth_code, appId, app_secret)) 88 | 89 | 90 | if __name__ == '__main__': 91 | main() -------------------------------------------------------------------------------- /v3/python/market_data/depth.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | 4 | client_id = "XC4XXXXM-100" 5 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 6 | 7 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 8 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 9 | 10 | data = { 11 | "symbol":"NSE:SBIN-EQ", 12 | "ohlcv_flag":"1" 13 | } 14 | 15 | response = fyers.depth(data=data) 16 | print(response) 17 | -------------------------------------------------------------------------------- /v3/python/market_data/history.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") 8 | 9 | data = { 10 | "symbol":"NSE:SBIN-EQ", 11 | "resolution":"D", 12 | "date_format":"0", 13 | "range_from":"1688389716", 14 | "range_to":"1691068173", 15 | "cont_flag":"1" 16 | } 17 | 18 | response = fyers.history(data=data) 19 | print(response) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /v3/python/market_data/quotes.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 6 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 7 | 8 | data = { 9 | "symbols":"NSE:SBIN-EQ,NSE:IDEA-EQ" 10 | } 11 | 12 | response = fyers.quotes(data=data) 13 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/cancel_multi_order.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") 8 | 9 | 10 | data = [{ 11 | "id": '808058117761' 12 | }, 13 | { 14 | "id": '808058117762' 15 | }] 16 | 17 | response = fyers.cancel_basket_orders(data=data) 18 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/cancel_order.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") 8 | 9 | 10 | data = {"id":'808058117761'} 11 | 12 | response = fyers.cancel_order(data=data) 13 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/modify_order.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") 8 | 9 | 10 | orderId = "8102710298291" 11 | data = { 12 | "id":orderId, 13 | "type":1, 14 | "limitPrice": 61049, 15 | "qty":1 16 | } 17 | 18 | response = fyers.modify_order(data=data) 19 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/mulit_order.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 6 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 7 | 8 | data = [{ 9 | "symbol":"NSE:SBIN-EQ", 10 | "qty":1, 11 | "type":2, 12 | "side":1, 13 | "productType":"INTRADAY", 14 | "limitPrice":0, 15 | "stopPrice":0, 16 | "validity":"DAY", 17 | "disclosedQty":0, 18 | "offlineOrder":False, 19 | }, 20 | { 21 | "symbol":"NSE:IDEA-EQ", 22 | "qty":1, 23 | "type":2, 24 | "side":1, 25 | "productType":"INTRADAY", 26 | "limitPrice":0, 27 | "stopPrice":0, 28 | "validity":"DAY", 29 | "disclosedQty":0, 30 | "offlineOrder":False, 31 | },{ 32 | "symbol":"NSE:SBIN-EQ", 33 | "qty":1, 34 | "type":2, 35 | "side":1, 36 | "productType":"INTRADAY", 37 | "limitPrice":0, 38 | "stopPrice":0, 39 | "validity":"DAY", 40 | "disclosedQty":0, 41 | "offlineOrder":False, 42 | }, 43 | { 44 | "symbol":"NSE:IDEA-EQ", 45 | "qty":1, 46 | "type":2, 47 | "side":1, 48 | "productType":"INTRADAY", 49 | "limitPrice":0, 50 | "stopPrice":0, 51 | "validity":"DAY", 52 | "disclosedQty":0, 53 | "offlineOrder":False, 54 | }] 55 | 56 | response = fyers.place_basket_orders(data=data) 57 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/multi_modify.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 6 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 7 | 8 | 9 | data = [{ 10 | "id": "8102710298291", 11 | "type": 1, 12 | "limitPrice": 61049, 13 | "qty": 1 14 | }, 15 | { 16 | "id": "8102710298292", 17 | "type": 1, 18 | "limitPrice": 61049, 19 | "qty": 1 20 | }] 21 | 22 | response = fyers.modify_basket_orders(data=data) 23 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/orders/place_order.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 6 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 7 | 8 | data = { 9 | "symbol":"NSE:IDEA-EQ", 10 | "qty":1, 11 | "type":2, 12 | "side":1, 13 | "productType":"INTRADAY", 14 | "limitPrice":0, 15 | "stopPrice":0, 16 | "validity":"DAY", 17 | "disclosedQty":0, 18 | "offlineOrder":False, 19 | } 20 | response = fyers.place_order(data=data) 21 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/positions/convert_position.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | 4 | client_id = "XC4XXXXM-100" 5 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 6 | 7 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 8 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 9 | 10 | 11 | data = { 12 | "symbol":"MCX:SILVERMIC20NOVFUT", 13 | "positionSide":1, 14 | "convertQty":1, 15 | "convertFrom":"INTRADAY", 16 | "convertTo":"CNC" 17 | } 18 | 19 | response = fyers.convert_position(data=data) 20 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/positions/exit_by_id.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | data = { 10 | "id":"NSE:SBIN-EQ-BO" 11 | } 12 | 13 | response = fyers.exit_positions(data=data) 14 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction/positions/exit_position.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | data = { 10 | 11 | } 12 | 13 | response = fyers.exit_positions(data=data) 14 | 15 | print(response) -------------------------------------------------------------------------------- /v3/python/transaction_info/holdings.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") 8 | 9 | response = fyers.holdings() 10 | print(response) 11 | 12 | -------------------------------------------------------------------------------- /v3/python/transaction_info/orderbook.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | response = fyers.orderbook() 10 | print(response) 11 | -------------------------------------------------------------------------------- /v3/python/transaction_info/orderbook_byID.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | orderId = "23080444447604" 10 | data = {"id":orderId} 11 | 12 | response = fyers.orderbook(data=data) 13 | print(response) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /v3/python/transaction_info/position.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | response = fyers.positions() 10 | print(response) 11 | 12 | 13 | -------------------------------------------------------------------------------- /v3/python/transaction_info/tradebook.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3 import fyersModel 2 | 3 | client_id = "XC4XXXXM-100" 4 | access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" 5 | 6 | # Initialize the FyersModel instance with your client_id, access_token, and enable async mode 7 | fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") 8 | 9 | response = fyers.tradebook() 10 | print(response) 11 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/data_websocket_background.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | # Replace the sample access token with your actual access token obtained from Fyers 5 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 6 | 7 | # Create a FyersDataSocket instance with the provided parameters 8 | fyers = data_ws.FyersDataSocket( 9 | access_token=access_token, # Access token in the format "appid:accesstoken" 10 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 11 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 12 | write_to_file=True, # Save response in a log file instead of printing it. 13 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 14 | ) 15 | 16 | # Establish a connection to the Fyers WebSocket 17 | fyers.connect() 18 | 19 | # Specify the data type and symbols you want to subscribe to 20 | data_type = "SymbolUpdate" 21 | # data_type = "DepthUpdate" 22 | 23 | # Subscribe to the specified symbols and data type 24 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 25 | fyers.subscribe(symbols=symbols, data_type=data_type) 26 | 27 | # Keep the socket running to receive real-time data 28 | fyers.keep_running() 29 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/data_websocket_foreground.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | 23 | """ 24 | print("Error:", message) 25 | 26 | 27 | def onclose(message): 28 | """ 29 | Callback function to handle WebSocket connection close events. 30 | """ 31 | print("Connection closed:", message) 32 | 33 | 34 | def onopen(): 35 | """ 36 | Callback function to subscribe to data type and symbols upon WebSocket connection. 37 | 38 | """ 39 | # Specify the data type and symbols you want to subscribe to 40 | data_type = "SymbolUpdate" 41 | # data_type = "DepthUpdate" 42 | 43 | 44 | # Subscribe to the specified symbols and data type 45 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 46 | fyers.subscribe(symbols=symbols, data_type=data_type) 47 | 48 | # Keep the socket running to receive real-time data 49 | fyers.keep_running() 50 | 51 | 52 | # Replace the sample access token with your actual access token obtained from Fyers 53 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 54 | 55 | # Create a FyersDataSocket instance with the provided parameters 56 | fyers = data_ws.FyersDataSocket( 57 | access_token=access_token, # Access token in the format "appid:accesstoken" 58 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 59 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 60 | write_to_file=False, # Save response in a log file instead of printing it. 61 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 62 | on_connect=onopen, # Callback function to subscribe to data upon connection. 63 | on_close=onclose, # Callback function to handle WebSocket connection close events. 64 | on_error=onerror, # Callback function to handle WebSocket errors. 65 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 66 | ) 67 | 68 | # Establish a connection to the Fyers WebSocket 69 | fyers.connect() 70 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/depthUpdate.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | 23 | """ 24 | print("Error:", message) 25 | 26 | 27 | def onclose(message): 28 | """ 29 | Callback function to handle WebSocket connection close events. 30 | """ 31 | print("Connection closed:", message) 32 | 33 | 34 | def onopen(): 35 | """ 36 | Callback function to subscribe to data type and symbols upon WebSocket connection. 37 | 38 | """ 39 | # Specify the data type and symbols you want to subscribe to 40 | data_type = "DepthUpdate" 41 | 42 | # Subscribe to the specified symbols and data type 43 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 44 | fyers.subscribe(symbols=symbols, data_type=data_type) 45 | 46 | # Keep the socket running to receive real-time data 47 | fyers.keep_running() 48 | 49 | 50 | # Replace the sample access token with your actual access token obtained from Fyers 51 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 52 | 53 | # Create a FyersDataSocket instance with the provided parameters 54 | fyers = data_ws.FyersDataSocket( 55 | access_token=access_token, # Access token in the format "appid:accesstoken" 56 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 57 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 58 | write_to_file=False, # Save response in a log file instead of printing it. 59 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 60 | on_connect=onopen, # Callback function to subscribe to data upon connection. 61 | on_close=onclose, # Callback function to handle WebSocket connection close events. 62 | on_error=onerror, # Callback function to handle WebSocket errors. 63 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 64 | ) 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/indexUpdate.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | 23 | """ 24 | print("Error:", message) 25 | 26 | 27 | def onclose(message): 28 | """ 29 | Callback function to handle WebSocket connection close events. 30 | """ 31 | print("Connection closed:", message) 32 | 33 | 34 | def onopen(): 35 | """ 36 | Callback function to subscribe to data type and symbols upon WebSocket connection. 37 | 38 | """ 39 | # Specify the data type and symbols you want to subscribe to 40 | data_type = "SymbolUpdate" 41 | 42 | # Subscribe to the specified symbols and data type 43 | symbols = ["NSE:NIFTY50-INDEX" , "NSE:NIFTYBANK-INDEX"] 44 | fyers.subscribe(symbols=symbols, data_type=data_type) 45 | 46 | # Keep the socket running to receive real-time data 47 | fyers.keep_running() 48 | 49 | 50 | # Replace the sample access token with your actual access token obtained from Fyers 51 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 52 | 53 | # Create a FyersDataSocket instance with the provided parameters 54 | fyers = data_ws.FyersDataSocket( 55 | access_token=access_token, # Access token in the format "appid:accesstoken" 56 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 57 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 58 | write_to_file=False, # Save response in a log file instead of printing it. 59 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 60 | on_connect=onopen, # Callback function to subscribe to data upon connection. 61 | on_close=onclose, # Callback function to handle WebSocket connection close events. 62 | on_error=onerror, # Callback function to handle WebSocket errors. 63 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 64 | ) 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/liteSymbolUpdate.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | 23 | """ 24 | print("Error:", message) 25 | 26 | 27 | def onclose(message): 28 | """ 29 | Callback function to handle WebSocket connection close events. 30 | """ 31 | print("Connection closed:", message) 32 | 33 | 34 | def onopen(): 35 | """ 36 | Callback function to subscribe to data type and symbols upon WebSocket connection. 37 | 38 | """ 39 | # Specify the data type and symbols you want to subscribe to 40 | data_type = "SymbolUpdate" 41 | 42 | # Subscribe to the specified symbols and data type 43 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 44 | fyers.subscribe(symbols=symbols, data_type=data_type) 45 | 46 | # Keep the socket running to receive real-time data 47 | fyers.keep_running() 48 | 49 | 50 | # Replace the sample access token with your actual access token obtained from Fyers 51 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 52 | 53 | # Create a FyersDataSocket instance with the provided parameters 54 | fyers = data_ws.FyersDataSocket( 55 | access_token=access_token, # Access token in the format "appid:accesstoken" 56 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 57 | litemode=True, # Lite mode disabled. Set to True if you want a lite response. 58 | write_to_file=False, # Save response in a log file instead of printing it. 59 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 60 | on_connect=onopen, # Callback function to subscribe to data upon connection. 61 | on_close=onclose, # Callback function to handle WebSocket connection close events. 62 | on_error=onerror, # Callback function to handle WebSocket errors. 63 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 64 | ) 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/symbolUpdate.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | 23 | """ 24 | print("Error:", message) 25 | 26 | 27 | def onclose(message): 28 | """ 29 | Callback function to handle WebSocket connection close events. 30 | """ 31 | print("Connection closed:", message) 32 | 33 | 34 | def onopen(): 35 | """ 36 | Callback function to subscribe to data type and symbols upon WebSocket connection. 37 | 38 | """ 39 | # Specify the data type and symbols you want to subscribe to 40 | data_type = "SymbolUpdate" 41 | 42 | # Subscribe to the specified symbols and data type 43 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 44 | fyers.subscribe(symbols=symbols, data_type=data_type) 45 | 46 | # Keep the socket running to receive real-time data 47 | fyers.keep_running() 48 | 49 | 50 | # Replace the sample access token with your actual access token obtained from Fyers 51 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 52 | 53 | # Create a FyersDataSocket instance with the provided parameters 54 | fyers = data_ws.FyersDataSocket( 55 | access_token=access_token, # Access token in the format "appid:accesstoken" 56 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 57 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 58 | write_to_file=False, # Save response in a log file instead of printing it. 59 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 60 | on_connect=onopen, # Callback function to subscribe to data upon connection. 61 | on_close=onclose, # Callback function to handle WebSocket connection close events. 62 | on_error=onerror, # Callback function to handle WebSocket errors. 63 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 64 | ) 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/data_socket/unsubscribeUpdate.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import data_ws 2 | 3 | 4 | def onmessage(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Response:", message) 13 | # After processing or when you decide to unsubscribe for specific symbol and data_type 14 | # you can use the fyers.unsubscribe() method 15 | 16 | # Example of condition: Unsubscribe when a certain condition is met 17 | if message['symbol']== 'NSE:SBIN-EQ' and message['ltp'] > 610: 18 | # Unsubscribe from the specified symbols and data type 19 | data_type = "SymbolUpdate" 20 | symbols_to_unsubscribe = ['NSE:SBIN-EQ'] 21 | fyers.unsubscribe(symbols=symbols_to_unsubscribe, data_type=data_type) 22 | 23 | 24 | def onerror(message): 25 | """ 26 | Callback function to handle WebSocket errors. 27 | 28 | Parameters: 29 | message (dict): The error message received from the WebSocket. 30 | 31 | 32 | """ 33 | print("Error:", message) 34 | 35 | 36 | def onclose(message): 37 | """ 38 | Callback function to handle WebSocket connection close events. 39 | """ 40 | print("Connection closed:", message) 41 | 42 | 43 | def onopen(): 44 | """ 45 | Callback function to subscribe to data type and symbols upon WebSocket connection. 46 | 47 | """ 48 | # Specify the data type and symbols you want to subscribe to 49 | data_type = "SymbolUpdate" 50 | 51 | # Subscribe to the specified symbols and data type 52 | symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] 53 | fyers.subscribe(symbols=symbols, data_type=data_type) 54 | 55 | # Keep the socket running to receive real-time data 56 | fyers.keep_running() 57 | 58 | 59 | # Replace the sample access token with your actual access token obtained from Fyers 60 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 61 | 62 | # Create a FyersDataSocket instance with the provided parameters 63 | fyers = data_ws.FyersDataSocket( 64 | access_token=access_token, # Access token in the format "appid:accesstoken" 65 | log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. 66 | litemode=False, # Lite mode disabled. Set to True if you want a lite response. 67 | write_to_file=False, # Save response in a log file instead of printing it. 68 | reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. 69 | on_connect=onopen, # Callback function to subscribe to data upon connection. 70 | on_close=onclose, # Callback function to handle WebSocket connection close events. 71 | on_error=onerror, # Callback function to handle WebSocket errors. 72 | on_message=onmessage # Callback function to handle incoming messages from the WebSocket. 73 | ) 74 | 75 | # Establish a connection to the Fyers WebSocket 76 | fyers.connect() 77 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/onGeneral.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | 4 | def onTrade(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Trade Response:", message) 13 | 14 | def onOrder(message): 15 | """ 16 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 17 | 18 | Parameters: 19 | message (dict): The received message from the WebSocket. 20 | 21 | """ 22 | print("Order Response:", message) 23 | 24 | def onPosition(message): 25 | """ 26 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 27 | 28 | Parameters: 29 | message (dict): The received message from the WebSocket. 30 | 31 | """ 32 | print("Position Response:", message) 33 | 34 | def onGeneral(message): 35 | """ 36 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 37 | 38 | Parameters: 39 | message (dict): The received message from the WebSocket. 40 | 41 | """ 42 | print("General Response:", message) 43 | def onerror(message): 44 | """ 45 | Callback function to handle WebSocket errors. 46 | 47 | Parameters: 48 | message (dict): The error message received from the WebSocket. 49 | 50 | 51 | """ 52 | print("Error:", message) 53 | 54 | 55 | def onclose(message): 56 | """ 57 | Callback function to handle WebSocket connection close events. 58 | """ 59 | print("Connection closed:", message) 60 | 61 | 62 | def onopen(): 63 | """ 64 | Callback function to subscribe to data type and symbols upon WebSocket connection. 65 | 66 | """ 67 | # Specify the data type and symbols you want to subscribe to 68 | # data_type = "OnOrders" 69 | # data_type = "OnTrades" 70 | # data_type = "OnPositions" 71 | # data_type = "OnGeneral" 72 | data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 73 | 74 | fyers.subscribe(data_type=data_type) 75 | 76 | # Keep the socket running to receive real-time data 77 | fyers.keep_running() 78 | 79 | 80 | # Replace the sample access token with your actual access token obtained from Fyers 81 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 82 | 83 | # Create a FyersDataSocket instance with the provided parameters 84 | fyers = order_ws.FyersOrderSocket( 85 | access_token=access_token, # Your access token for authenticating with the Fyers API. 86 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 87 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 88 | on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. 89 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 90 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 91 | on_general=onGeneral, # Callback function to handle general events from the WebSocket. 92 | on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. 93 | on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. 94 | on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. 95 | ) 96 | 97 | # Establish a connection to the Fyers WebSocket 98 | fyers.connect() 99 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/onOrders.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | def onOrder(message): 4 | """ 5 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 6 | 7 | Parameters: 8 | message (dict): The received message from the WebSocket. 9 | 10 | """ 11 | print("Order Response:", message) 12 | 13 | 14 | 15 | def onerror(message): 16 | """ 17 | Callback function to handle WebSocket errors. 18 | 19 | Parameters: 20 | message (dict): The error message received from the WebSocket. 21 | 22 | """ 23 | print("Error:", message) 24 | 25 | 26 | def onclose(message): 27 | """ 28 | Callback function to handle WebSocket connection close events. 29 | """ 30 | print("Connection closed:", message) 31 | 32 | 33 | def onopen(): 34 | """ 35 | Callback function to subscribe to data type and symbols upon WebSocket connection. 36 | 37 | """ 38 | # Specify the data type and symbols you want to subscribe to 39 | data_type = "OnOrders" 40 | # data_type = "OnTrades" 41 | # data_type = "OnPositions" 42 | # data_type = "OnGeneral" 43 | # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 44 | 45 | fyers.subscribe(data_type=data_type) 46 | 47 | # Keep the socket running to receive real-time data 48 | fyers.keep_running() 49 | 50 | 51 | # Replace the sample access token with your actual access token obtained from Fyers 52 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 53 | 54 | # Create a FyersDataSocket instance with the provided parameters 55 | fyers = order_ws.FyersOrderSocket( 56 | access_token=access_token, # Your access token for authenticating with the Fyers API. 57 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 58 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 59 | on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. 60 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 61 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 62 | on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. 63 | ) 64 | 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/onPosition.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | def onPosition(message): 4 | """ 5 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 6 | 7 | Parameters: 8 | message (dict): The received message from the WebSocket. 9 | 10 | """ 11 | print("Position Response:", message) 12 | 13 | 14 | def onerror(message): 15 | """ 16 | Callback function to handle WebSocket errors. 17 | 18 | Parameters: 19 | message (dict): The error message received from the WebSocket. 20 | 21 | 22 | """ 23 | print("Error:", message) 24 | 25 | 26 | def onclose(message): 27 | """ 28 | Callback function to handle WebSocket connection close events. 29 | """ 30 | print("Connection closed:", message) 31 | 32 | 33 | def onopen(): 34 | """ 35 | Callback function to subscribe to data type and symbols upon WebSocket connection. 36 | 37 | """ 38 | # Specify the data type and symbols you want to subscribe to 39 | # data_type = "OnOrders" 40 | # data_type = "OnTrades" 41 | data_type = "OnPositions" 42 | # data_type = "OnGeneral" 43 | # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 44 | 45 | fyers.subscribe(data_type=data_type) 46 | 47 | # Keep the socket running to receive real-time data 48 | fyers.keep_running() 49 | 50 | 51 | # Replace the sample access token with your actual access token obtained from Fyers 52 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 53 | 54 | # Create a FyersDataSocket instance with the provided parameters 55 | fyers = order_ws.FyersOrderSocket( 56 | access_token=access_token, # Your access token for authenticating with the Fyers API. 57 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 58 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 59 | on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. 60 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 61 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 62 | on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. 63 | ) 64 | 65 | 66 | # Establish a connection to the Fyers WebSocket 67 | fyers.connect() 68 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/ontrade.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | 4 | def onTrade(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Trade Response:", message) 13 | 14 | 15 | 16 | def onerror(message): 17 | """ 18 | Callback function to handle WebSocket errors. 19 | 20 | Parameters: 21 | message (dict): The error message received from the WebSocket. 22 | 23 | 24 | """ 25 | print("Error:", message) 26 | 27 | 28 | def onclose(message): 29 | """ 30 | Callback function to handle WebSocket connection close events. 31 | """ 32 | print("Connection closed:", message) 33 | 34 | 35 | def onopen(): 36 | """ 37 | Callback function to subscribe to data type and symbols upon WebSocket connection. 38 | 39 | """ 40 | # Specify the data type and symbols you want to subscribe to 41 | # data_type = "OnOrders" 42 | data_type = "OnTrades" 43 | # data_type = "OnPositions" 44 | # data_type = "OnGeneral" 45 | # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 46 | 47 | fyers.subscribe(data_type=data_type) 48 | 49 | # Keep the socket running to receive real-time data 50 | fyers.keep_running() 51 | 52 | 53 | # Replace the sample access token with your actual access token obtained from Fyers 54 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 55 | 56 | # Create a FyersDataSocket instance with the provided parameters 57 | fyers = order_ws.FyersOrderSocket( 58 | access_token=access_token, # Your access token for authenticating with the Fyers API. 59 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 60 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 61 | on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. 62 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 63 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 64 | on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. 65 | ) 66 | 67 | 68 | # Establish a connection to the Fyers WebSocket 69 | fyers.connect() 70 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/order_websocket_background.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | # Replace the sample access token with your actual access token obtained from Fyers 4 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 5 | 6 | # Create a FyersDataSocket instance with the provided parameters 7 | fyers = order_ws.FyersOrderSocket( 8 | access_token=access_token, # Your access token for authenticating with the Fyers API. 9 | write_to_file=True, # A boolean flag indicating whether to write data to a log file or not. 10 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 11 | ) 12 | 13 | # Establish a connection to the Fyers WebSocket 14 | fyers.connect() 15 | 16 | # Specify the data type and symbols you want to subscribe to 17 | # data_type = "OnOrders" 18 | # data_type = "OnTrades" 19 | # data_type = "OnPositions" 20 | # data_type = "OnGeneral" 21 | data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 22 | 23 | fyers.subscribe(data_type=data_type) 24 | 25 | # Keep the socket running to receive real-time data 26 | fyers.keep_running() 27 | -------------------------------------------------------------------------------- /v3/python/websocket/order_socket/order_websocket_foreground.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket import order_ws 2 | 3 | 4 | def onTrade(message): 5 | """ 6 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 7 | 8 | Parameters: 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Trade Response:", message) 13 | 14 | def onOrder(message): 15 | """ 16 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 17 | 18 | Parameters: 19 | message (dict): The received message from the WebSocket. 20 | 21 | """ 22 | print("Order Response:", message) 23 | 24 | def onPosition(message): 25 | """ 26 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 27 | 28 | Parameters: 29 | message (dict): The received message from the WebSocket. 30 | 31 | """ 32 | print("Position Response:", message) 33 | 34 | def onGeneral(message): 35 | """ 36 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 37 | 38 | Parameters: 39 | message (dict): The received message from the WebSocket. 40 | 41 | """ 42 | print("General Response:", message) 43 | 44 | def onerror(message): 45 | """ 46 | Callback function to handle WebSocket errors. 47 | 48 | Parameters: 49 | message (dict): The error message received from the WebSocket. 50 | 51 | 52 | """ 53 | print("Error:", message) 54 | 55 | 56 | def onclose(message): 57 | """ 58 | Callback function to handle WebSocket connection close events. 59 | """ 60 | print("Connection closed:", message) 61 | 62 | 63 | def onopen(): 64 | """ 65 | Callback function to subscribe to data type and symbols upon WebSocket connection. 66 | 67 | """ 68 | # Specify the data type and symbols you want to subscribe to 69 | # data_type = "OnOrders" 70 | # data_type = "OnTrades" 71 | # data_type = "OnPositions" 72 | # data_type = "OnGeneral" 73 | data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" 74 | 75 | fyers.subscribe(data_type=data_type) 76 | 77 | # Keep the socket running to receive real-time data 78 | fyers.keep_running() 79 | 80 | 81 | # Replace the sample access token with your actual access token obtained from Fyers 82 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 83 | 84 | # Create a FyersDataSocket instance with the provided parameters 85 | fyers = order_ws.FyersOrderSocket( 86 | access_token=access_token, # Your access token for authenticating with the Fyers API. 87 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 88 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 89 | on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. 90 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 91 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 92 | on_general=onGeneral, # Callback function to handle general events from the WebSocket. 93 | on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. 94 | on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. 95 | on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. 96 | ) 97 | 98 | # Establish a connection to the Fyers WebSocket 99 | fyers.connect() 100 | -------------------------------------------------------------------------------- /v3/python/websocket/tbt_socket/ondepth.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes 2 | 3 | def on_depth_update(ticker, message): 4 | """ 5 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 6 | 7 | Parameters: 8 | ticker (str): The symbol for which the message is received. 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Depth Response:", ticker, message) 13 | 14 | 15 | def onerror_message( message): 16 | """ 17 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 18 | 19 | Parameters: 20 | message (str): error message from the server 21 | 22 | """ 23 | print("server returned error:", message) 24 | 25 | 26 | def onerror(message): 27 | """ 28 | Callback function to handle WebSocket errors. 29 | 30 | Parameters: 31 | message (dict): The error message received from the WebSocket. 32 | 33 | 34 | """ 35 | print("Error:", message) 36 | 37 | 38 | def onclose(message): 39 | """ 40 | Callback function to handle WebSocket connection close events. 41 | """ 42 | print("Connection closed:", message) 43 | 44 | 45 | def onopen(): 46 | """ 47 | Callback function to subscribe to data type and symbols upon WebSocket connection. 48 | 49 | """ 50 | print("Connection opened") 51 | # Specify the data type and symbols you want to subscribe to 52 | mode = SubscriptionModes.DEPTH 53 | Channel = '1' 54 | # Subscribe to the specified symbols and data type 55 | symbols = ['NSE:NIFTY25MARFUT'] 56 | 57 | fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) 58 | fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) 59 | 60 | # Keep the socket running to receive real-time data 61 | fyers.keep_running() 62 | 63 | 64 | # Replace the sample access token with your actual access token obtained from Fyers 65 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 66 | 67 | fyers = FyersTbtSocket( 68 | access_token=access_token, # Your access token for authenticating with the Fyers API. 69 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 70 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 71 | on_open=onopen, # Callback function to be executed upon successful WebSocket connection. 72 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 73 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 74 | on_depth_update=on_depth_update, # Callback function to handle depth-related events from the WebSocket 75 | on_error_message=onerror_message # Callback function to handle server-related erros from the WebSocket. 76 | ) 77 | 78 | 79 | # Establish a connection to the Fyers WebSocket 80 | fyers.connect() 81 | 82 | -------------------------------------------------------------------------------- /v3/python/websocket/tbt_socket/order_websocket_background.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes 2 | 3 | # Replace the sample access token with your actual access token obtained from Fyers 4 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 5 | 6 | # Create a FyersDataSocket instance with the provided parameters 7 | fyers = FyersTbtSocket( 8 | access_token=access_token, # Your access token for authenticating with the Fyers API. 9 | write_to_file=True, # A boolean flag indicating whether to write data to a log file or not. 10 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 11 | ) 12 | 13 | 14 | # Establish a connection to the Fyers WebSocket 15 | fyers.connect() 16 | 17 | mode = SubscriptionModes.DEPTH 18 | Channel = '1' 19 | # Subscribe to the specified symbols and data type 20 | symbols = ['NSE:NIFTY25MARFUT'] 21 | 22 | fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) 23 | fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) 24 | 25 | # Keep the socket running to receive real-time data 26 | fyers.keep_running() 27 | -------------------------------------------------------------------------------- /v3/python/websocket/tbt_socket/order_websocket_foreground.py: -------------------------------------------------------------------------------- 1 | from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes 2 | 3 | def on_depth_update(ticker, message): 4 | """ 5 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 6 | 7 | Parameters: 8 | ticker (str): The symbol for which the message is received. 9 | message (dict): The received message from the WebSocket. 10 | 11 | """ 12 | print("Depth Response:", ticker, message) 13 | 14 | 15 | def onerror_message( message): 16 | """ 17 | Callback function to handle incoming messages from the FyersDataSocket WebSocket. 18 | 19 | Parameters: 20 | message (str): error message from the server 21 | 22 | """ 23 | print("server returned error:", message) 24 | 25 | 26 | def onerror(message): 27 | """ 28 | Callback function to handle WebSocket errors. 29 | 30 | Parameters: 31 | message (dict): The error message received from the WebSocket. 32 | 33 | 34 | """ 35 | print("Error:", message) 36 | 37 | 38 | def onclose(message): 39 | """ 40 | Callback function to handle WebSocket connection close events. 41 | """ 42 | print("Connection closed:", message) 43 | 44 | 45 | def onopen(): 46 | """ 47 | Callback function to subscribe to data type and symbols upon WebSocket connection. 48 | 49 | """ 50 | print("Connection opened") 51 | # Specify the data type and symbols you want to subscribe to 52 | mode = SubscriptionModes.DEPTH 53 | Channel = '1' 54 | # Subscribe to the specified symbols and data type 55 | symbols = ['NSE:NIFTY25MARFUT'] 56 | 57 | fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) 58 | fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) 59 | 60 | # Keep the socket running to receive real-time data 61 | fyers.keep_running() 62 | 63 | 64 | # Replace the sample access token with your actual access token obtained from Fyers 65 | access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" 66 | 67 | fyers = FyersTbtSocket( 68 | access_token=access_token, # Your access token for authenticating with the Fyers API. 69 | write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. 70 | log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). 71 | on_open=onopen, # Callback function to be executed upon successful WebSocket connection. 72 | on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. 73 | on_error=onerror, # Callback function to handle any WebSocket errors that may occur. 74 | on_depth_update=on_depth_update, # Callback function to handle depth-related events from the WebSocket 75 | on_error_message=onerror_message # Callback function to handle server-related erros from the WebSocket. 76 | ) 77 | 78 | 79 | # Establish a connection to the Fyers WebSocket 80 | fyers.connect() 81 | 82 | --------------------------------------------------------------------------------