diff --git a/Postman/FYERS_MyAPI.postman_collection.json b/v3/Postman V3/FYERS API V3.postman_collection.json similarity index 83% rename from Postman/FYERS_MyAPI.postman_collection.json rename to v3/Postman V3/FYERS API V3.postman_collection.json index 489dc2c..8d69c0e 100644 --- a/Postman/FYERS_MyAPI.postman_collection.json +++ b/v3/Postman V3/FYERS API V3.postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "44278865-819a-4daf-9d7a-5fbf0084b39c", - "name": "FYERS API V2", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "_postman_id": "5edc3d4e-b012-4b20-9f45-d9931201985b", + "name": "FYERS API V3", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "24894415" }, "item": [ { @@ -17,16 +18,16 @@ "method": "GET", "header": [], "url": { - "raw": "https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state&scope=openid&nonce=sample_nonce", + "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", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "generate-authcode" ], "query": [ @@ -79,16 +80,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/validate-authcode", + "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "validate-authcode" ] }, @@ -107,16 +108,16 @@ "method": "GET", "header": [], "url": { - "raw": "https://api.fyers.in/api/v2/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", + "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", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "generate-authcode" ], "query": [ @@ -174,16 +175,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/validate-authcode", + "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "validate-authcode" ] }, @@ -202,16 +203,16 @@ "method": "GET", "header": [], "url": { - "raw": "https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state", + "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", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "generate-authcode" ], "query": [ @@ -255,16 +256,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/validate-authcode", + "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "validate-authcode" ] }, @@ -283,16 +284,16 @@ "method": "GET", "header": [], "url": { - "raw": "https://api.fyers.in/api/v2/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", + "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", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "generate-authcode" ], "query": [ @@ -350,16 +351,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/validate-authcode", + "raw": "https://api-t1.fyers.in/api/v3/validate-authcode", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "validate-authcode" ] }, @@ -386,16 +387,16 @@ } ], "url": { - "raw": "https://api.fyers.in/api/v2/profile", + "raw": "https://api-t1.fyers.in/api/v3/profile", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "profile" ] } @@ -414,57 +415,21 @@ } ], "url": { - "raw": "https://api.fyers.in/api/v2/funds", + "raw": "https://api-t1.fyers.in/api/v3/funds", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "funds" ] } }, "response": [] - }, - { - "name": "Funds with filter", - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "type": "text", - "value": "{{appId}}:{{access_token}}" - } - ], - "url": { - "raw": "https://api.fyers.in/api/v2/funds?id=10,9", - "protocol": "https", - "host": [ - "api", - "fyers", - "in" - ], - "path": [ - "api", - "v2", - "funds" - ], - "query": [ - { - "key": "id", - "value": "10,9", - "description": "You can pass either 1 number of multiple numbers by comma seperated. Eg: 10,9,5" - } - ] - }, - "description": "The possible filter values are as follows:\r\n1 => \r\n2 => \r\n3 => \r\n4 => \r\n5 => \r\n6 => \r\n7 => \r\n8 => \r\n9 => \r\n10 =>" - }, - "response": [] } ] }, @@ -480,54 +445,25 @@ "key": "Authorization", "type": "text", "value": "{{appId}}:{{access_token}}" - } - ], - "url": { - "raw": "https://api.fyers.in/api/v2/tradebook", - "protocol": "https", - "host": [ - "api", - "fyers", - "in" - ], - "path": [ - "api", - "v2", - "tradebook" - ] - } - }, - "response": [] - }, - { - "name": "Tradebook with filter", - "request": { - "method": "GET", - "header": [ + }, { - "key": "Authorization", - "value": "{{appId}}:{{access_token}}", + "key": "version", + "value": "3", "type": "text" } ], "url": { - "raw": "https://api.fyers.in/api/v2/tradebook?id=sample_data", + "raw": "https://api-t1.fyers.in/api/v3/tradebook", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "tradebook" - ], - "query": [ - { - "key": "id", - "value": "sample_data" - } ] } }, @@ -542,54 +478,25 @@ "key": "Authorization", "type": "text", "value": "{{appId}}:{{access_token}}" - } - ], - "url": { - "raw": "https://api.fyers.in/api/v2/holdings", - "protocol": "https", - "host": [ - "api", - "fyers", - "in" - ], - "path": [ - "api", - "v2", - "holdings" - ] - } - }, - "response": [] - }, - { - "name": "Holdings with filter", - "request": { - "method": "GET", - "header": [ + }, { - "key": "Authorization", - "value": "{{appId}}:{{access_token}}", + "key": "version", + "value": "3", "type": "text" } ], "url": { - "raw": "https://api.fyers.in/api/v2/holdings?symbol=sample_data", + "raw": "https://api-t1.fyers.in/api/v3/holdings", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "holdings" - ], - "query": [ - { - "key": "symbol", - "value": "sample_data" - } ] } }, @@ -604,19 +511,24 @@ "key": "Authorization", "type": "text", "value": "{{appId}}:{{access_token}}" + }, + { + "key": "version", + "value": "3", + "type": "text" } ], "url": { - "raw": "https://api.fyers.in/api/v2/positions", + "raw": "https://api-t1.fyers.in/api/v3/positions", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "positions" ] } @@ -632,19 +544,24 @@ "key": "Authorization", "type": "text", "value": "{{appId}}:{{access_token}}" + }, + { + "key": "version", + "value": "3", + "type": "text" } ], "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "orders" ] } @@ -660,25 +577,30 @@ "key": "Authorization", "value": "{{appId}}:{{access_token}}", "type": "text" + }, + { + "key": "version", + "value": "3", + "type": "text" } ], "url": { - "raw": "https://api.fyers.in/api/v2/orders?id=sample_data", + "raw": "https://api-t1.fyers.in/api/v3/orders?id=230XXXXXXX4267", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "orders" ], "query": [ { "key": "id", - "value": "sample_data" + "value": "230XXXXXXX4267" } ] } @@ -714,7 +636,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"symbol\":\"MCX:SILVERMIC20NOVFUT\",\n\t\"qty\":1,\n\t\"type\":1,\n\t\"side\":1,\n\t\"productType\":\"INTRADAY\",\n\t\"limitPrice\":64200,\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}", + "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}", "options": { "raw": { "language": "json" @@ -722,17 +644,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -756,7 +679,7 @@ ], "body": { "mode": "raw", - "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}", + "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}", "options": { "raw": { "language": "json" @@ -764,17 +687,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -806,17 +730,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -848,17 +773,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -867,7 +793,7 @@ { "name": "Modify Order-Limit", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -890,17 +816,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -909,7 +836,7 @@ { "name": "Modify Order-Market", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -932,17 +859,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -951,7 +879,7 @@ { "name": "Modify Order- QTY", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -974,17 +902,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1016,17 +945,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1055,7 +985,7 @@ ], "body": { "mode": "raw", - "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}", + "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}", "options": { "raw": { "language": "json" @@ -1063,17 +993,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1105,17 +1036,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1124,7 +1056,7 @@ { "name": "Modify Order - Leg 1", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1147,17 +1079,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1166,7 +1099,7 @@ { "name": "Modify Order - Leg 2", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1189,17 +1122,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1231,7 +1165,7 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders", "protocol": "https", "host": [ "api", @@ -1278,17 +1212,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1320,17 +1255,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1362,17 +1298,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1404,17 +1341,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1423,7 +1361,7 @@ { "name": "Modify Order - Leg 1", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1446,17 +1384,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1465,7 +1404,7 @@ { "name": "Modify Order - Leg 2", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1488,17 +1427,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1507,7 +1447,7 @@ { "name": "Modify Order - Leg 3", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1530,17 +1470,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1572,17 +1513,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders", + "raw": "https://api-t1.fyers.in/api/v3/orders/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders" + "v3", + "orders", + "sync" ] } }, @@ -1614,17 +1556,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders-multi", + "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders-multi" + "v3", + "multi-order", + "sync" ] } }, @@ -1633,7 +1576,7 @@ { "name": "Modify Multiple Order", "request": { - "method": "PUT", + "method": "PATCH", "header": [ { "key": "Authorization", @@ -1651,17 +1594,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders-multi", + "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders-multi" + "v3", + "multi-order", + "sync" ] } }, @@ -1688,51 +1632,18 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/orders-multi", - "protocol": "https", - "host": [ - "api", - "fyers", - "in" - ], - "path": [ - "api", - "v2", - "orders-multi" - ] - } - }, - "response": [] - }, - { - "name": "Get Multiple Order", - "request": { - "method": "GET", - "header": [ - { - "key": "Authorization", - "value": "{{appId}}:{{access_token}}", - "type": "text" - } - ], - "url": { - "raw": "https://api.fyers.in/api/v2/orders-multi?id=52009117325,52009117324", + "raw": "https://api-t1.fyers.in/api/v3/multi-order/sync", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", - "orders-multi" - ], - "query": [ - { - "key": "id", - "value": "52009117325,52009117324" - } + "v3", + "multi-order", + "sync" ] } }, @@ -1771,16 +1682,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/positions", + "raw": "https://api-t1.fyers.in/api/v3/positions", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "positions" ] } @@ -1808,16 +1719,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/positions", + "raw": "https://api-t1.fyers.in/api/v3/positions", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "positions" ] } @@ -1837,7 +1748,7 @@ ], "body": { "mode": "raw", - "raw": "{}", + "raw": "{\n \"exit_all\": 1\n}", "options": { "raw": { "language": "json" @@ -1845,16 +1756,16 @@ } }, "url": { - "raw": "https://api.fyers.in/api/v2/positions", + "raw": "https://api-t1.fyers.in/api/v3/positions", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ "api", - "v2", + "v3", "positions" ] } @@ -1880,17 +1791,16 @@ } ], "url": { - "raw": "https://api.fyers.in/api/v2/market-status", + "raw": "https://api-t1.fyers.in/data/marketStatus", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ - "api", - "v2", - "market-status" + "data", + "marketStatus" ] }, "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" @@ -1914,16 +1824,15 @@ } ], "url": { - "raw": "https://api.fyers.in/data-rest/v2/quotes/?symbols=NSE:SBIN-EQ", + "raw": "https://api-t1.fyers.in/data/quotes/?symbols=NSE:SBIN-EQ", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ - "data-rest", - "v2", + "data", "quotes", "" ], @@ -1949,16 +1858,15 @@ } ], "url": { - "raw": "https://api.fyers.in/data-rest/v2/depth/?symbol=NSE:SBIN-EQ&ohlcv_flag=1", + "raw": "https://api-t1.fyers.in/data/depth/?symbol=NSE:SBIN-EQ&ohlcv_flag=1", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ - "data-rest", - "v2", + "data", "depth", "" ], @@ -1989,18 +1897,16 @@ } ], "url": { - "raw": "https://api.fyers.in/data-rest/v2/history/?symbol=NSE:SBIN-EQ&resolution=30&date_format=1&range_from=2021-01-01&range_to=2021-01-02&cont_flag=1", + "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", "protocol": "https", "host": [ - "api", + "api-t1", "fyers", "in" ], "path": [ - "data-rest", - "v2", - "history", - "" + "data", + "history" ], "query": [ { @@ -2169,5 +2075,37 @@ } ] } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "appId", + "value": "", + "type": "string" + }, + { + "key": "access_token", + "value": "", + "type": "string" + } ] -} +} \ No newline at end of file diff --git a/Postman/FYERS_MyAPI.postman_environment.json b/v3/Postman V3/FYERS API V3.postman_environment.json similarity index 73% rename from Postman/FYERS_MyAPI.postman_environment.json rename to v3/Postman V3/FYERS API V3.postman_environment.json index 2bfa1c5..e7d24a4 100644 --- a/Postman/FYERS_MyAPI.postman_environment.json +++ b/v3/Postman V3/FYERS API V3.postman_environment.json @@ -1,6 +1,6 @@ { - "id": "4c13a74d-2580-4955-acce-9155b11f4eba", - "name": "FYERS API V2", + "id": "04957345-323d-4cdf-be90-5877080579e5", + "name": "FYERS API V3", "values": [ { "key": "appId", @@ -29,6 +29,6 @@ } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2021-08-19T09:07:17.067Z", - "_postman_exported_using": "Postman/8.10.0" -} + "_postman_exported_at": "2023-08-25T06:00:24.329Z", + "_postman_exported_using": "Postman/10.17.3" +} \ No newline at end of file diff --git a/Postman/FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv b/v3/Postman V3/FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv similarity index 100% rename from Postman/FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv rename to v3/Postman V3/FYERS_MyAPI - API Error Codes and Messages - Sheet1.csv diff --git a/v3/node/account_info/funds.js b/v3/node/account_info/funds.js new file mode 100644 index 0000000..b5400ec --- /dev/null +++ b/v3/node/account_info/funds.js @@ -0,0 +1,18 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +fyers.get_funds().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/account_info/getprofile.js b/v3/node/account_info/getprofile.js new file mode 100644 index 0000000..8204e2d --- /dev/null +++ b/v3/node/account_info/getprofile.js @@ -0,0 +1,18 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +fyers.get_profile().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/broker_info/market_status.js b/v3/node/broker_info/market_status.js new file mode 100644 index 0000000..600a5e3 --- /dev/null +++ b/v3/node/broker_info/market_status.js @@ -0,0 +1,18 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +fyers.market_status().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/login/get_access_token.js b/v3/node/login/get_access_token.js new file mode 100644 index 0000000..2d6da07 --- /dev/null +++ b/v3/node/login/get_access_token.js @@ -0,0 +1,32 @@ +const FyersAPI = require("fyers-api-v3").fyersModel +const open = require('opn'); + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +var generateAuthcodeURL = fyers.generateAuthCode(); + +// Open the URL in the default web browser to allow the user to grant access +open(generateAuthcodeURL) + .then(() => { + console.log(`Opened ${generateAuthcodeURL} in your default web browser.`); + }) + .catch((error) => { + console.error('Error occurred:', error); + }); + + +// Define the authorization code and secret key required for generating access token +const auth_code="exyj....." +// Replace with your secret key provided by Fyers +const secretKey = "RJ1W2XG5L4" + +// fyers.generate_access_token({ "secret_key": secretKey, "auth_code": auth_code }).then((response) => { +// console.log(response) +// }).catch((error) => { +// console.log(error) +// }) \ No newline at end of file diff --git a/v3/node/market_data/depth.js b/v3/node/market_data/depth.js new file mode 100644 index 0000000..eb06c00 --- /dev/null +++ b/v3/node/market_data/depth.js @@ -0,0 +1,20 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={"symbol":["NSE:SBIN-EQ","NSE:TCS-EQ"],"ohlcv_flag":1} + +fyers.getMarketDepth(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/market_data/history.js b/v3/node/market_data/history.js new file mode 100644 index 0000000..76b61d3 --- /dev/null +++ b/v3/node/market_data/history.js @@ -0,0 +1,28 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + + +var inp={ + "symbol":"NSE:SBIN-EQ", + "resolution":"D", + "date_format":"0", + "range_from":"1622097600", + "range_to":"1622097685", + "cont_flag":"1" +} + +fyers.getHistory(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/market_data/quotes.js b/v3/node/market_data/quotes.js new file mode 100644 index 0000000..480f1ec --- /dev/null +++ b/v3/node/market_data/quotes.js @@ -0,0 +1,20 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp=["NSE:SBIN-EQ","NSE:TCS-EQ"] + +fyers.getQuotes(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/package-lock.json b/v3/node/package-lock.json new file mode 100644 index 0000000..81eb91b --- /dev/null +++ b/v3/node/package-lock.json @@ -0,0 +1,233 @@ +{ + "name": "sample_codes", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@otplib/core": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/core/-/core-12.0.1.tgz", + "integrity": "sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA==" + }, + "@otplib/plugin-crypto": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/plugin-crypto/-/plugin-crypto-12.0.1.tgz", + "integrity": "sha512-qPuhN3QrT7ZZLcLCyKOSNhuijUi9G5guMRVrxq63r9YNOxxQjPm59gVxLM+7xGnHnM6cimY57tuKsjK7y9LM1g==", + "requires": { + "@otplib/core": "^12.0.1" + } + }, + "@otplib/plugin-thirty-two": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/plugin-thirty-two/-/plugin-thirty-two-12.0.1.tgz", + "integrity": "sha512-MtT+uqRso909UkbrrYpJ6XFjj9D+x2Py7KjTO9JDPhL0bJUYVu5kFP4TFZW4NFAywrAtFRxOVY261u0qwb93gA==", + "requires": { + "@otplib/core": "^12.0.1", + "thirty-two": "^1.0.2" + } + }, + "@otplib/preset-default": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/preset-default/-/preset-default-12.0.1.tgz", + "integrity": "sha512-xf1v9oOJRyXfluBhMdpOkr+bsE+Irt+0D5uHtvg6x1eosfmHCsCC6ej/m7FXiWqdo0+ZUI6xSKDhJwc8yfiOPQ==", + "requires": { + "@otplib/core": "^12.0.1", + "@otplib/plugin-crypto": "^12.0.1", + "@otplib/plugin-thirty-two": "^12.0.1" + } + }, + "@otplib/preset-v11": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/preset-v11/-/preset-v11-12.0.1.tgz", + "integrity": "sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg==", + "requires": { + "@otplib/core": "^12.0.1", + "@otplib/plugin-crypto": "^12.0.1", + "@otplib/plugin-thirty-two": "^12.0.1" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, + "ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "fyers-api-v3": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fyers-api-v3/-/fyers-api-v3-1.0.0.tgz", + "integrity": "sha512-RjOd8GUBrUX6oe7CZ0PolwEsAWozi34NDWrXJSrgQGjbWNLGdrqW4HOX+QAkZ23xB0vEvLODI4EY3WVnR3CsWw==", + "requires": { + "axios": "^1.3.5", + "jsonwebtoken": "^9.0.1", + "ws": "^8.13.0" + } + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==" + }, + "jsonwebtoken": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz", + "integrity": "sha512-K8wx7eJ5TPvEjuiVSkv167EVboBDv9PZdDoF7BgeQnBLVvZWW9clr2PsQHVJDTKaEIH5JBIwHujGcHp7GgI2eg==", + "requires": { + "jws": "^3.2.2", + "lodash": "^4.17.21", + "ms": "^2.1.1", + "semver": "^7.3.8" + } + }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "opn": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", + "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", + "requires": { + "is-wsl": "^1.1.0" + } + }, + "otplib": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/otplib/-/otplib-12.0.1.tgz", + "integrity": "sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg==", + "requires": { + "@otplib/core": "^12.0.1", + "@otplib/preset-default": "^12.0.1", + "@otplib/preset-v11": "^12.0.1" + } + }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "thirty-two": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", + "integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==" + }, + "ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/v3/node/package.json b/v3/node/package.json new file mode 100644 index 0000000..eca94f0 --- /dev/null +++ b/v3/node/package.json @@ -0,0 +1,16 @@ +{ + "name": "sample_codes", + "version": "1.0.0", + "description": "sample codes for node_js", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "fyers-api-v3": "^1.0.0", + "opn": "^6.0.0", + "otplib": "^12.0.1" + } +} diff --git a/v3/node/transaction/orders/cancel_multi_order..js b/v3/node/transaction/orders/cancel_multi_order..js new file mode 100644 index 0000000..0f3d1a6 --- /dev/null +++ b/v3/node/transaction/orders/cancel_multi_order..js @@ -0,0 +1,25 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp =[{ + "id": '808058117761' +}, +{ + "id": '808058117762' +}] + +fyers.cancel_multi_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/orders/cancel_order.js b/v3/node/transaction/orders/cancel_order.js new file mode 100644 index 0000000..066381e --- /dev/null +++ b/v3/node/transaction/orders/cancel_order.js @@ -0,0 +1,22 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp = { + "id": '808058117761' +} + +fyers.cancel_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/orders/modify_order.js b/v3/node/transaction/orders/modify_order.js new file mode 100644 index 0000000..d8843a7 --- /dev/null +++ b/v3/node/transaction/orders/modify_order.js @@ -0,0 +1,25 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + "id":'808058117761', + "type":1, + "limitPrice": 61049, + "qty":1 +} + +fyers.modify_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/orders/mulit_order.js b/v3/node/transaction/orders/mulit_order.js new file mode 100644 index 0000000..3ceb03e --- /dev/null +++ b/v3/node/transaction/orders/mulit_order.js @@ -0,0 +1,66 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp=[{ + "symbol":"NSE:SBIN-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}, +{ + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +},{ + "symbol":"NSE:SBIN-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}, +{ + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}] + +fyers.place_multi_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/orders/multi_modify.js b/v3/node/transaction/orders/multi_modify.js new file mode 100644 index 0000000..f209a9d --- /dev/null +++ b/v3/node/transaction/orders/multi_modify.js @@ -0,0 +1,31 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp=[{ + "id": "8102710298291", + "type": 1, + "limitPrice": 61049, + "qty": 1 +}, +{ + "id": "8102710298292", + "type": 1, + "limitPrice": 61049, + "qty": 1 +}] + +fyers.modify_multi_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/orders/place_order.js b/v3/node/transaction/orders/place_order.js new file mode 100644 index 0000000..efd2616 --- /dev/null +++ b/v3/node/transaction/orders/place_order.js @@ -0,0 +1,31 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +} + +fyers.place_order(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/positions/convert_position.js b/v3/node/transaction/positions/convert_position.js new file mode 100644 index 0000000..7233289 --- /dev/null +++ b/v3/node/transaction/positions/convert_position.js @@ -0,0 +1,27 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + "symbol":"NSE:ONGC-EQ-INTRADAY", + "positionSide":1, + "convertQty":1, + "convertFrom":"INTRADAY", + "convertTo":"CNC", + "overnight": 1 + } + +fyers.convert_position(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/positions/exit_by_id.js b/v3/node/transaction/positions/exit_by_id.js new file mode 100644 index 0000000..3117f96 --- /dev/null +++ b/v3/node/transaction/positions/exit_by_id.js @@ -0,0 +1,22 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + "id":"NSE:SBIN-EQ-BO" +} + +fyers.exit_position(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction/positions/exit_position.js b/v3/node/transaction/positions/exit_position.js new file mode 100644 index 0000000..3d91b78 --- /dev/null +++ b/v3/node/transaction/positions/exit_position.js @@ -0,0 +1,22 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({ path: "/path/to/where/logs/to/be/saved" }) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + "exit_all":1 +} + +fyers.exit_position(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction_info/holdings.js b/v3/node/transaction_info/holdings.js new file mode 100644 index 0000000..238d04b --- /dev/null +++ b/v3/node/transaction_info/holdings.js @@ -0,0 +1,19 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + + +fyers.get_holdings().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction_info/orderbook.js b/v3/node/transaction_info/orderbook.js new file mode 100644 index 0000000..0ad0e71 --- /dev/null +++ b/v3/node/transaction_info/orderbook.js @@ -0,0 +1,19 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + + +fyers.get_orders().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction_info/orderbook_byID.js b/v3/node/transaction_info/orderbook_byID.js new file mode 100644 index 0000000..fb1c568 --- /dev/null +++ b/v3/node/transaction_info/orderbook_byID.js @@ -0,0 +1,24 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + +var inp={ + + order_id:"1210408175301" + +} + +fyers.get_filtered_orders(inp).then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction_info/position.js b/v3/node/transaction_info/position.js new file mode 100644 index 0000000..9124ffd --- /dev/null +++ b/v3/node/transaction_info/position.js @@ -0,0 +1,19 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + + +fyers.get_positions().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/transaction_info/tradebook.js b/v3/node/transaction_info/tradebook.js new file mode 100644 index 0000000..67d877a --- /dev/null +++ b/v3/node/transaction_info/tradebook.js @@ -0,0 +1,19 @@ +const FyersAPI = require("fyers-api-v3").fyersModel + + +var fyers = new FyersAPI({path:"/path/to/where/logs/to/be/saved"}) +// set appID +fyers.setAppId("Qxxxxxx75-1xx") + +// set redirectURL +fyers.setRedirectUrl("https://XXXXX.com") + +// set accessToken +fyers.setAccessToken("eyJ0xxxx") + + +fyers.get_tradebook().then((response) => { + console.log(response) +}).catch((error) => { + console.log(error) +}) \ No newline at end of file diff --git a/v3/node/websocket/data_socket/data_websocket.js b/v3/node/websocket/data_socket/data_websocket.js new file mode 100644 index 0000000..a1c4914 --- /dev/null +++ b/v3/node/websocket/data_socket/data_websocket.js @@ -0,0 +1,27 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + console.log({"TEST":message}) +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/data_socket/depthUpdate.js b/v3/node/websocket/data_socket/depthUpdate.js new file mode 100644 index 0000000..640b078 --- /dev/null +++ b/v3/node/websocket/data_socket/depthUpdate.js @@ -0,0 +1,27 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"],true) +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + console.log({"TEST":message}) +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/data_socket/indexUpdate.js b/v3/node/websocket/data_socket/indexUpdate.js new file mode 100644 index 0000000..1bce181 --- /dev/null +++ b/v3/node/websocket/data_socket/indexUpdate.js @@ -0,0 +1,27 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:NIFTYMIDSELECT-INDEX',"NSE:NIFTYHEALTHCARE-INDEX"]) +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + console.log({"TEST":message}) +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/data_socket/liteSymbolUpdate.js b/v3/node/websocket/data_socket/liteSymbolUpdate.js new file mode 100644 index 0000000..5ab72e0 --- /dev/null +++ b/v3/node/websocket/data_socket/liteSymbolUpdate.js @@ -0,0 +1,31 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) +skt.mode(skt.LiteMode) +// incase of going back to full mode use +// skt.mode(skt.FullMode) + +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + console.log({"TEST":message}) +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/data_socket/symbolUpdate.js b/v3/node/websocket/data_socket/symbolUpdate.js new file mode 100644 index 0000000..a1c4914 --- /dev/null +++ b/v3/node/websocket/data_socket/symbolUpdate.js @@ -0,0 +1,27 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + console.log({"TEST":message}) +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/data_socket/unsubscribeUpdate.js b/v3/node/websocket/data_socket/unsubscribeUpdate.js new file mode 100644 index 0000000..8241c17 --- /dev/null +++ b/v3/node/websocket/data_socket/unsubscribeUpdate.js @@ -0,0 +1,29 @@ +const DataSocket = require("fyers-api-v3").fyersDataSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt= DataSocket.getInstance(accesstoken,"path/where/logs/to/be/saved") + +skt.on("connect",function(){ +skt.subscribe(['NSE:IDEA-EQ',"NSE:SBIN-EQ"]) +console.log(skt.isConnected()) +}) + +skt.on("message",function(message){ + if(message.ltp>100 &&message.symbol=="NSE:SBIN-EQ"){ + fyersdata.unsubscribe(["NSE:SBIN-EQ"],false) + } +}) + +skt.on("error",function(message){ + console.log("erroris",message) +}) + +skt.on("close",function(){ + console.log("socket closed") +}) +skt.connect() +skt.autoreconnect() \ No newline at end of file diff --git a/v3/node/websocket/order_socket/onGeneral.js b/v3/node/websocket/order_socket/onGeneral.js new file mode 100644 index 0000000..712f038 --- /dev/null +++ b/v3/node/websocket/order_socket/onGeneral.js @@ -0,0 +1,44 @@ +var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") + +skt.on("error",function (errmsg) { + console.log(errmsg) +}) + +//handle your general messages here +skt.on('general',function (msg) { + console.log(msg) +}) +skt.on('connect',function () { + skt.subscribe([skt.edis,skt.pricealerts]) + console.log(skt.isConnected()) +}) + +skt.on('close',function () { + console.log('closed') +}) + +//handle your order messages here +skt.on('orders',function (msg) { + console.log("orders",msg) +}) + +//handle your trade messages here +skt.on('trades',function (msg) { + console.log('trades',msg) +}) + +//handle your positions messages here +skt.on('positions',function (msg) { + console.log('positions',msg) +}) + +skt.autoreconnect() +skt.connect() + diff --git a/v3/node/websocket/order_socket/onOrders.js b/v3/node/websocket/order_socket/onOrders.js new file mode 100644 index 0000000..40e9e98 --- /dev/null +++ b/v3/node/websocket/order_socket/onOrders.js @@ -0,0 +1,44 @@ +var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") + +skt.on("error",function (errmsg) { + console.log(errmsg) +}) + +//handle your general messages here +skt.on('general',function (msg) { + console.log(msg) +}) +skt.on('connect',function () { + skt.subscribe([skt.orderUpdates]) + console.log(skt.isConnected()) +}) + +skt.on('close',function () { + console.log('closed') +}) + +//handle your order messages here +skt.on('orders',function (msg) { + console.log("orders",msg) +}) + +//handle your trade messages here +skt.on('trades',function (msg) { + console.log('trades',msg) +}) + +//handle your positions messages here +skt.on('positions',function (msg) { + console.log('positions',msg) +}) + +skt.autoreconnect() +skt.connect() + diff --git a/v3/node/websocket/order_socket/onPosition.js b/v3/node/websocket/order_socket/onPosition.js new file mode 100644 index 0000000..d2dbbce --- /dev/null +++ b/v3/node/websocket/order_socket/onPosition.js @@ -0,0 +1,44 @@ +var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") + +skt.on("error",function (errmsg) { + console.log(errmsg) +}) + +//handle your general messages here +skt.on('general',function (msg) { + console.log(msg) +}) +skt.on('connect',function () { + skt.subscribe([skt.positionUpdates]) + console.log(skt.isConnected()) +}) + +skt.on('close',function () { + console.log('closed') +}) + +//handle your order messages here +skt.on('orders',function (msg) { + console.log("orders",msg) +}) + +//handle your trade messages here +skt.on('trades',function (msg) { + console.log('trades',msg) +}) + +//handle your positions messages here +skt.on('positions',function (msg) { + console.log('positions',msg) +}) + +skt.autoreconnect() +skt.connect() + diff --git a/v3/node/websocket/order_socket/ontrade.js b/v3/node/websocket/order_socket/ontrade.js new file mode 100644 index 0000000..0b264aa --- /dev/null +++ b/v3/node/websocket/order_socket/ontrade.js @@ -0,0 +1,44 @@ +var fyersOrderSocket= require("fyers-api-v3").fyersOrderSocket + +// Replace the sample access token with your actual access token +// access_token format will be "APPID:access_token" +// For example : access_token = "7N***X38S-100:eyJ0eXA****************PSv0bLiHOqW5SI" +const accesstoken = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +var skt=new fyersOrderSocket(accesstoken,"path/where/logs/to/be/saved") + +skt.on("error",function (errmsg) { + console.log(errmsg) +}) + +//handle your general messages here +skt.on('general',function (msg) { + console.log(msg) +}) +skt.on('connect',function () { + skt.subscribe([skt.tradeUpdates]) + console.log(skt.isConnected()) +}) + +skt.on('close',function () { + console.log('closed') +}) + +//handle your order messages here +skt.on('orders',function (msg) { + console.log("orders",msg) +}) + +//handle your trade messages here +skt.on('trades',function (msg) { + console.log('trades',msg) +}) + +//handle your positions messages here +skt.on('positions',function (msg) { + console.log('positions',msg) +}) + +skt.autoreconnect() +skt.connect() + diff --git a/v3/python/account_info/funds.py b/v3/python/account_info/funds.py new file mode 100644 index 0000000..a4b1c7b --- /dev/null +++ b/v3/python/account_info/funds.py @@ -0,0 +1,12 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") + +# Make a request to get the funds information +response = fyers.funds() +print(response) + diff --git a/v3/python/account_info/getprofile.py b/v3/python/account_info/getprofile.py new file mode 100644 index 0000000..ffa91af --- /dev/null +++ b/v3/python/account_info/getprofile.py @@ -0,0 +1,14 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") + +# Make a request to get the user profile information +response = fyers.get_profile() + +# Print the response received from the Fyers API +print(response) + diff --git a/v3/python/broker_info/market_status.py b/v3/python/broker_info/market_status.py new file mode 100644 index 0000000..6fd1323 --- /dev/null +++ b/v3/python/broker_info/market_status.py @@ -0,0 +1,12 @@ +from fyers_apiv3 import fyersModel + + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + + +response = fyers.market_status() +print(response) \ No newline at end of file diff --git a/v3/python/login/get_access_token.py b/v3/python/login/get_access_token.py new file mode 100644 index 0000000..99f1bbd --- /dev/null +++ b/v3/python/login/get_access_token.py @@ -0,0 +1,91 @@ +moduleName = "getAccessToken" +""" + 1.We need to first install fyers-apiv3(can be installed as 'pip install fyers-apiv3) + 2.We then need to import accesToken module from fyers_api directory(as done below) + 3.We also need to import webbrowser to preform an action while generating authcode +""" +from fyers_apiv3 import fyersModel +import webbrowser + + +def getauthToken(appId, redirect_uri): + functionName = "getauthToken" + """ + :param app_id: "XXXXXXXXXXX" + :param redirect_url: "https://XXXXXX.com" + 1. This function open this url in the browser. + 2. This will ask you to login and will ask you to approve the app if it is not approved already. + 3. Once that is done, it will redirect to a url (added while app creation) with the auth_code. The url will look like + https://www.google.com/?auth_code=eyJ0eXAiOiXXXXXGciOiJIUzI1NiJ9.eyXXXXXXXXXXXXXInN1YiI6ImF1dGhDb2XXXXXXXXXXXXXXXXXX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXVpZCI6ImZhOGNhYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg&user_id=DP00404 + 4. You have to take the auth_code from the url and use that token in your generate_access_token function. + """ + response_type="code" + grant_type="authorization_code" + # creating an instance appSession to generate the auth code by passing app id and redirect url as parameter + appSession = fyersModel.SessionModel(client_id=appId,redirect_uri=redirect_uri,response_type=response_type, grant_type=grant_type,state="state",scope="",nonce="") + + # 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 + generateTokenUrl = appSession.generate_authcode() + + # This command is used to open the url in default system brower + webbrowser.open(generateTokenUrl, new=1) + + +def generate_access_token(auth_code, appId, secret_key): + functionName = "generate_access_token" + """ + :param auth_code: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTM1ODY2NzEsInN1YiI6ImF1dGhDb2RlIiwiYXBwX2lkIjoiQjhQV0xWSDhUNiIsImlzcyI6ImFwaS5sb2dpbi5meWVycy5pbiIsImF1ZCI6WyJ4OjAiLCJ4OjEiLCJ4OjIiXSwidXXXXXXXXXXXYjE3ZWU4OTQzMGRhZjA1YWUxNDI2YWVkYzI4IiwiaXBBZGRyIjoiMjIzLjIzMy40Mi40NiIsImRpc3BsYXlfbmFtZSI6IkRQMDA0MDQiLCJpYXQiOjE1OTM1ODYzNzEsIm5iZiI6MTU5MzU4NjM3MX0.IMJHzQGHQgyXt_XN0AgDrMN1keR4qolFFKO6cyXTnTg" + :param app_id: "B8PXXXXXXX" + :param secret_key: "XXXXXXKGN0" + :param redirect_url: "https://XXXXXX.com" + :return: access_token: "eyJ0eXAiOiJKV1QiLCXXXX1NiJ9.eyJpYXXXXXXXXXXMsIm5iZiI6MTU5MzU4ODM3MywiZXhwIjoxNTkzNjQ5ODEzLCJpc3MiOiJhcGkuZnllcnMuaW4iLCJzdWIiOiJhY2Nlc3MiLCJhdWQiOiJ4OjAseDoxLHg6MiIsImF0X2hhc2giOiJnQUFBQUFCZV9EcVZIZExMMTAzTVpVN1NYSkZfR2p5R3hidzMtTVVhb0VEMGI0QUVvNjFsR24tREY2OFU5cXhuNzd0UXVoOVVJalYtNm9MVXhINVFfWE1WTEJfRXpROGV2clJmUzlNUXB0Y2J5c2ltN1drWllZTT0iLCJkaXNwbGF5X25hbWUiOiJQSVlVU0ggUkFKRU5EUkEgS0FQU0UiLCJmeV9pZCI6IkRQMDA0MDQifQ.cAfrj2TxAyb8A_9DfiCb1hLIZg_mH-xvP3Ybnj3a4AE" + + 1.this function takes the param and return the access_token + 2.the access_token created will be used further .(in fyersModel)] + 3. one can get the auth_code from the url generated by getauthToken function (from auth_code= ..... &user_Id=xxxxxx before &) + """ + # creating an instance appSession by passing app id,secret key and redirect url as parameter + appSession = fyersModel.SessionModel(client_id=appId, secret_key=secret_key,grant_type="authorization_code") + + # we need to pass the auth code in set_token method + appSession.set_token(auth_code) + # generate_token function will return us the access token and we store in variable "access_token" + access_token = appSession.generate_token() + return access_token + + +def main(): + """ + Starting Steps. + 1.We first need to uncomment the function getauthToken(appId, redirect_url). + 2.We need to make sure generate_access_token(auth_code, appId, app_secret, redirect_url) func is commented. + 3.We need to run this module code once passing the parameters to getauthToken(appId, redirect_url) func. + 4.We copy the auth_code provided from our browser and store in the variable in "auth_code". + 5.Next we need to uncomment the function generate_access_token(auth_code, appId, app_secret, redirect_url). + 6.Then we need to make sure getauthToken(appId, redirect_url) func is commented. + 7.We run this module again with appropriate parameters. + """ + # The provided redirct url while creating the app + redirect_url = "https://www.google.com/" + + # The app id we get after creating the app + appId = "OCDXXXXXXJ-100" + + # Function to get the auth code and need to be commented while calling the generate_access_token(x,x,x) func. + getauthToken(appId, redirect_url) + + + + + # The app secret we got after creating the app. + app_secret = "BXXXXFM90" + + # the genarted auth code we got from browser after running the getauthToken(x,x) func. + auth_code = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkubG9naW4uZnllcnMuaW4iLCJpYXQiOjE2OTA4NjQwOTAsImV4cCI6MTY5MDg5NDA5MCwibmJmIjoxNjkwODYzNDkwLCJhdWQiOiJbXCJ4OjBcIiwgXCJ4OjFcIiwgXCJ4OjJcIiwgXCJkOjFcIiwgXCJkOjJcIiwgXCJ4OjFcIiwgXCJ4OjBcIl0iLCJzdWIiOiJhdXRoX2NvZGUiLCJkaXNwbGF5X25hbWUiOiJYVjIwOTg2Iiwib21zIjoiSzEiLCJoc21fa2V5IjoiMGE1NTY1NGRhOWRjODUzMTExYzdhYzI0NjM2ZTkyNTQxMTEwYjdjNTJjYzVjYmQxNDAwNjkwNTciLCJub25jZSI6ImJha2EiLCJhcHBfaWQiOiJYQzRFT0Q2N0lNIiwidXVpZCI6IjhjOWEzYjc3YTA3ZDRhNDVhODJiZTI2MjVlMjk3NzgzIiwiaXBBZGRyIjoiMC4wLjAuMCIsInNjb3BlIjoiIn0.31CfyL7lnN5ZEU2-cRjtt8UP3carqt3Vk4YEPNaSBxE" + + # Function to get the access token and need to be commented while calling the getauthToken(x,x) func. + print(generate_access_token(auth_code, appId, app_secret)) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/v3/python/market_data/depth.py b/v3/python/market_data/depth.py new file mode 100644 index 0000000..4012865 --- /dev/null +++ b/v3/python/market_data/depth.py @@ -0,0 +1,16 @@ +from fyers_apiv3 import fyersModel + + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = { + "symbol":"NSE:SBIN-EQ", + "ohlcv_flag":"1" +} + +response = fyers.depth(data=data) +print(response) diff --git a/v3/python/market_data/history.py b/v3/python/market_data/history.py new file mode 100644 index 0000000..9549c95 --- /dev/null +++ b/v3/python/market_data/history.py @@ -0,0 +1,22 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") + +data = { + "symbol":"NSE:SBIN-EQ", + "resolution":"D", + "date_format":"0", + "range_from":"1688389716", + "range_to":"1691068173", + "cont_flag":"1" +} + +response = fyers.history(data=data) +print(response) + + + diff --git a/v3/python/market_data/quotes.py b/v3/python/market_data/quotes.py new file mode 100644 index 0000000..e84232f --- /dev/null +++ b/v3/python/market_data/quotes.py @@ -0,0 +1,13 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = { + "symbols":"NSE:SBIN-EQ,NSE:IDEA-EQ" +} + +response = fyers.quotes(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/cancel_multi_order.py b/v3/python/transaction/orders/cancel_multi_order.py new file mode 100644 index 0000000..f048c0d --- /dev/null +++ b/v3/python/transaction/orders/cancel_multi_order.py @@ -0,0 +1,18 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") + + +data = [{ + "id": '808058117761' +}, +{ + "id": '808058117762' +}] + +response = fyers.cancel_basket_orders(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/cancel_order.py b/v3/python/transaction/orders/cancel_order.py new file mode 100644 index 0000000..fc09b97 --- /dev/null +++ b/v3/python/transaction/orders/cancel_order.py @@ -0,0 +1,13 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, is_async=False, token=access_token, log_path="") + + +data = {"id":'808058117761'} + +response = fyers.cancel_order(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/modify_order.py b/v3/python/transaction/orders/modify_order.py new file mode 100644 index 0000000..e3a930b --- /dev/null +++ b/v3/python/transaction/orders/modify_order.py @@ -0,0 +1,19 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") + + +orderId = "8102710298291" +data = { + "id":orderId, + "type":1, + "limitPrice": 61049, + "qty":1 +} + +response = fyers.modify_order(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/mulit_order.py b/v3/python/transaction/orders/mulit_order.py new file mode 100644 index 0000000..8645394 --- /dev/null +++ b/v3/python/transaction/orders/mulit_order.py @@ -0,0 +1,57 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = [{ + "symbol":"NSE:SBIN-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}, +{ + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +},{ + "symbol":"NSE:SBIN-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}, +{ + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +}] + +response = fyers.place_basket_orders(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/multi_modify.py b/v3/python/transaction/orders/multi_modify.py new file mode 100644 index 0000000..3feabb4 --- /dev/null +++ b/v3/python/transaction/orders/multi_modify.py @@ -0,0 +1,23 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + + +data = [{ + "id": "8102710298291", + "type": 1, + "limitPrice": 61049, + "qty": 1 +}, +{ + "id": "8102710298292", + "type": 1, + "limitPrice": 61049, + "qty": 1 +}] + +response = fyers.modify_basket_orders(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/orders/place_order.py b/v3/python/transaction/orders/place_order.py new file mode 100644 index 0000000..1612439 --- /dev/null +++ b/v3/python/transaction/orders/place_order.py @@ -0,0 +1,21 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = { + "symbol":"NSE:IDEA-EQ", + "qty":1, + "type":2, + "side":1, + "productType":"INTRADAY", + "limitPrice":0, + "stopPrice":0, + "validity":"DAY", + "disclosedQty":0, + "offlineOrder":False, +} +response = fyers.place_order(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/positions/convert_position.py b/v3/python/transaction/positions/convert_position.py new file mode 100644 index 0000000..f843c4d --- /dev/null +++ b/v3/python/transaction/positions/convert_position.py @@ -0,0 +1,20 @@ +from fyers_apiv3 import fyersModel + + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + + +data = { + "symbol":"MCX:SILVERMIC20NOVFUT", + "positionSide":1, + "convertQty":1, + "convertFrom":"INTRADAY", + "convertTo":"CNC" +} + +response = fyers.convert_position(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/positions/exit_by_id.py b/v3/python/transaction/positions/exit_by_id.py new file mode 100644 index 0000000..f2eb565 --- /dev/null +++ b/v3/python/transaction/positions/exit_by_id.py @@ -0,0 +1,14 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = { + "id":"NSE:SBIN-EQ-BO" +} + +response = fyers.exit_positions(data=data) +print(response) \ No newline at end of file diff --git a/v3/python/transaction/positions/exit_position.py b/v3/python/transaction/positions/exit_position.py new file mode 100644 index 0000000..86164a9 --- /dev/null +++ b/v3/python/transaction/positions/exit_position.py @@ -0,0 +1,15 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +data = { + +} + +response = fyers.exit_positions(data=data) + +print(response) \ No newline at end of file diff --git a/v3/python/transaction_info/holdings.py b/v3/python/transaction_info/holdings.py new file mode 100644 index 0000000..92d8b6c --- /dev/null +++ b/v3/python/transaction_info/holdings.py @@ -0,0 +1,11 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=True, log_path="") + +response = fyers.holdings() +print(response) + diff --git a/v3/python/transaction_info/orderbook.py b/v3/python/transaction_info/orderbook.py new file mode 100644 index 0000000..e8ff8ac --- /dev/null +++ b/v3/python/transaction_info/orderbook.py @@ -0,0 +1,10 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +response = fyers.orderbook() +print(response) diff --git a/v3/python/transaction_info/orderbook_byID.py b/v3/python/transaction_info/orderbook_byID.py new file mode 100644 index 0000000..7f3cc2f --- /dev/null +++ b/v3/python/transaction_info/orderbook_byID.py @@ -0,0 +1,16 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +orderId = "23080444447604" +data = {"id":orderId} + +response = fyers.orderbook(data=data) +print(response) + + + diff --git a/v3/python/transaction_info/position.py b/v3/python/transaction_info/position.py new file mode 100644 index 0000000..ffcc8e5 --- /dev/null +++ b/v3/python/transaction_info/position.py @@ -0,0 +1,12 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +response = fyers.positions() +print(response) + + diff --git a/v3/python/transaction_info/tradebook.py b/v3/python/transaction_info/tradebook.py new file mode 100644 index 0000000..607ecea --- /dev/null +++ b/v3/python/transaction_info/tradebook.py @@ -0,0 +1,10 @@ +from fyers_apiv3 import fyersModel + +client_id = "XC4XXXXM-100" +access_token = "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g" + +# Initialize the FyersModel instance with your client_id, access_token, and enable async mode +fyers = fyersModel.FyersModel(client_id=client_id, token=access_token,is_async=False, log_path="") + +response = fyers.tradebook() +print(response) diff --git a/v3/python/websocket/data_socket/data_websocket_background.py b/v3/python/websocket/data_socket/data_websocket_background.py new file mode 100644 index 0000000..e4a683a --- /dev/null +++ b/v3/python/websocket/data_socket/data_websocket_background.py @@ -0,0 +1,28 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=True, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() + +# Specify the data type and symbols you want to subscribe to +data_type = "SymbolUpdate" +# data_type = "DepthUpdate" + +# Subscribe to the specified symbols and data type +symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] +fyers.subscribe(symbols=symbols, data_type=data_type) + +# Keep the socket running to receive real-time data +fyers.keep_running() diff --git a/v3/python/websocket/data_socket/data_websocket_foreground.py b/v3/python/websocket/data_socket/data_websocket_foreground.py new file mode 100644 index 0000000..10fa8bc --- /dev/null +++ b/v3/python/websocket/data_socket/data_websocket_foreground.py @@ -0,0 +1,69 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "SymbolUpdate" + # data_type = "DepthUpdate" + + + # Subscribe to the specified symbols and data type + symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/data_socket/depthUpdate.py b/v3/python/websocket/data_socket/depthUpdate.py new file mode 100644 index 0000000..9ab2015 --- /dev/null +++ b/v3/python/websocket/data_socket/depthUpdate.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "DepthUpdate" + + # Subscribe to the specified symbols and data type + symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/data_socket/indexUpdate.py b/v3/python/websocket/data_socket/indexUpdate.py new file mode 100644 index 0000000..507686a --- /dev/null +++ b/v3/python/websocket/data_socket/indexUpdate.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "SymbolUpdate" + + # Subscribe to the specified symbols and data type + symbols = ["NSE:NIFTY50-INDEX" , "NSE:NIFTYBANK-INDEX"] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/data_socket/liteSymbolUpdate.py b/v3/python/websocket/data_socket/liteSymbolUpdate.py new file mode 100644 index 0000000..fbbf909 --- /dev/null +++ b/v3/python/websocket/data_socket/liteSymbolUpdate.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "SymbolUpdate" + + # Subscribe to the specified symbols and data type + symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=True, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/data_socket/symbolUpdate.py b/v3/python/websocket/data_socket/symbolUpdate.py new file mode 100644 index 0000000..f423e88 --- /dev/null +++ b/v3/python/websocket/data_socket/symbolUpdate.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "SymbolUpdate" + + # Subscribe to the specified symbols and data type + symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/data_socket/unsubscribeUpdate.py b/v3/python/websocket/data_socket/unsubscribeUpdate.py new file mode 100644 index 0000000..ef5fa88 --- /dev/null +++ b/v3/python/websocket/data_socket/unsubscribeUpdate.py @@ -0,0 +1,76 @@ +from fyers_apiv3.FyersWebsocket import data_ws + + +def onmessage(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Response:", message) + # After processing or when you decide to unsubscribe for specific symbol and data_type + # you can use the fyers.unsubscribe() method + + # Example of condition: Unsubscribe when a certain condition is met + if message['symbol']== 'NSE:SBIN-EQ' and message['ltp'] > 610: + # Unsubscribe from the specified symbols and data type + data_type = "SymbolUpdate" + symbols_to_unsubscribe = ['NSE:SBIN-EQ'] + fyers.unsubscribe(symbols=symbols_to_unsubscribe, data_type=data_type) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "SymbolUpdate" + + # Subscribe to the specified symbols and data type + symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ'] + fyers.subscribe(symbols=symbols, data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = data_ws.FyersDataSocket( + access_token=access_token, # Access token in the format "appid:accesstoken" + log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory. + litemode=False, # Lite mode disabled. Set to True if you want a lite response. + write_to_file=False, # Save response in a log file instead of printing it. + reconnect=True, # Enable auto-reconnection to WebSocket on disconnection. + on_connect=onopen, # Callback function to subscribe to data upon connection. + on_close=onclose, # Callback function to handle WebSocket connection close events. + on_error=onerror, # Callback function to handle WebSocket errors. + on_message=onmessage # Callback function to handle incoming messages from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/order_socket/onGeneral.py b/v3/python/websocket/order_socket/onGeneral.py new file mode 100644 index 0000000..0fb84a6 --- /dev/null +++ b/v3/python/websocket/order_socket/onGeneral.py @@ -0,0 +1,98 @@ +from fyers_apiv3.FyersWebsocket import order_ws + + +def onTrade(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Trade Response:", message) + +def onOrder(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Order Response:", message) + +def onPosition(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Position Response:", message) + +def onGeneral(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("General Response:", message) +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + # data_type = "OnOrders" + # data_type = "OnTrades" + # data_type = "OnPositions" + # data_type = "OnGeneral" + data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + + fyers.subscribe(data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_general=onGeneral, # Callback function to handle general events from the WebSocket. + on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. + on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. + on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/order_socket/onOrders.py b/v3/python/websocket/order_socket/onOrders.py new file mode 100644 index 0000000..64b2dda --- /dev/null +++ b/v3/python/websocket/order_socket/onOrders.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import order_ws + +def onOrder(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Order Response:", message) + + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + data_type = "OnOrders" + # data_type = "OnTrades" + # data_type = "OnPositions" + # data_type = "OnGeneral" + # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + + fyers.subscribe(data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/order_socket/onPosition.py b/v3/python/websocket/order_socket/onPosition.py new file mode 100644 index 0000000..32f0211 --- /dev/null +++ b/v3/python/websocket/order_socket/onPosition.py @@ -0,0 +1,67 @@ +from fyers_apiv3.FyersWebsocket import order_ws + +def onPosition(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Position Response:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + # data_type = "OnOrders" + # data_type = "OnTrades" + data_type = "OnPositions" + # data_type = "OnGeneral" + # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + + fyers.subscribe(data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/order_socket/ontrade.py b/v3/python/websocket/order_socket/ontrade.py new file mode 100644 index 0000000..39f9fcb --- /dev/null +++ b/v3/python/websocket/order_socket/ontrade.py @@ -0,0 +1,69 @@ +from fyers_apiv3.FyersWebsocket import order_ws + + +def onTrade(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Trade Response:", message) + + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + # data_type = "OnOrders" + data_type = "OnTrades" + # data_type = "OnPositions" + # data_type = "OnGeneral" + # data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + + fyers.subscribe(data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/order_socket/order_websocket_background.py b/v3/python/websocket/order_socket/order_websocket_background.py new file mode 100644 index 0000000..8ff4d97 --- /dev/null +++ b/v3/python/websocket/order_socket/order_websocket_background.py @@ -0,0 +1,26 @@ +from fyers_apiv3.FyersWebsocket import order_ws + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=True, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() + +# Specify the data type and symbols you want to subscribe to +# data_type = "OnOrders" +# data_type = "OnTrades" +# data_type = "OnPositions" +# data_type = "OnGeneral" +data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + +fyers.subscribe(data_type=data_type) + +# Keep the socket running to receive real-time data +fyers.keep_running() diff --git a/v3/python/websocket/order_socket/order_websocket_foreground.py b/v3/python/websocket/order_socket/order_websocket_foreground.py new file mode 100644 index 0000000..56929f0 --- /dev/null +++ b/v3/python/websocket/order_socket/order_websocket_foreground.py @@ -0,0 +1,99 @@ +from fyers_apiv3.FyersWebsocket import order_ws + + +def onTrade(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Trade Response:", message) + +def onOrder(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Order Response:", message) + +def onPosition(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("Position Response:", message) + +def onGeneral(message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (dict): The received message from the WebSocket. + + """ + print("General Response:", message) + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + # Specify the data type and symbols you want to subscribe to + # data_type = "OnOrders" + # data_type = "OnTrades" + # data_type = "OnPositions" + # data_type = "OnGeneral" + data_type = "OnOrders,OnTrades,OnPositions,OnGeneral" + + fyers.subscribe(data_type=data_type) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = order_ws.FyersOrderSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_connect=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_general=onGeneral, # Callback function to handle general events from the WebSocket. + on_orders=onOrder, # Callback function to handle order-related events from the WebSocket. + on_positions=onPosition, # Callback function to handle position-related events from the WebSocket. + on_trades=onTrade # Callback function to handle trade-related events from the WebSocket. +) + +# Establish a connection to the Fyers WebSocket +fyers.connect() diff --git a/v3/python/websocket/tbt_socket/ondepth.py b/v3/python/websocket/tbt_socket/ondepth.py new file mode 100644 index 0000000..56272a4 --- /dev/null +++ b/v3/python/websocket/tbt_socket/ondepth.py @@ -0,0 +1,81 @@ +from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes + +def on_depth_update(ticker, message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + ticker (str): The symbol for which the message is received. + message (dict): The received message from the WebSocket. + + """ + print("Depth Response:", ticker, message) + + +def onerror_message( message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (str): error message from the server + + """ + print("server returned error:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + print("Connection opened") + # Specify the data type and symbols you want to subscribe to + mode = SubscriptionModes.DEPTH + Channel = '1' + # Subscribe to the specified symbols and data type + symbols = ['NSE:NIFTY25MARFUT'] + + fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) + fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +fyers = FyersTbtSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_open=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_depth_update=on_depth_update, # Callback function to handle depth-related events from the WebSocket + on_error_message=onerror_message # Callback function to handle server-related erros from the WebSocket. +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() + diff --git a/v3/python/websocket/tbt_socket/order_websocket_background.py b/v3/python/websocket/tbt_socket/order_websocket_background.py new file mode 100644 index 0000000..f790509 --- /dev/null +++ b/v3/python/websocket/tbt_socket/order_websocket_background.py @@ -0,0 +1,26 @@ +from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +# Create a FyersDataSocket instance with the provided parameters +fyers = FyersTbtSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=True, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() + +mode = SubscriptionModes.DEPTH +Channel = '1' +# Subscribe to the specified symbols and data type +symbols = ['NSE:NIFTY25MARFUT'] + +fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) +fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) + +# Keep the socket running to receive real-time data +fyers.keep_running() diff --git a/v3/python/websocket/tbt_socket/order_websocket_foreground.py b/v3/python/websocket/tbt_socket/order_websocket_foreground.py new file mode 100644 index 0000000..56272a4 --- /dev/null +++ b/v3/python/websocket/tbt_socket/order_websocket_foreground.py @@ -0,0 +1,81 @@ +from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes + +def on_depth_update(ticker, message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + ticker (str): The symbol for which the message is received. + message (dict): The received message from the WebSocket. + + """ + print("Depth Response:", ticker, message) + + +def onerror_message( message): + """ + Callback function to handle incoming messages from the FyersDataSocket WebSocket. + + Parameters: + message (str): error message from the server + + """ + print("server returned error:", message) + + +def onerror(message): + """ + Callback function to handle WebSocket errors. + + Parameters: + message (dict): The error message received from the WebSocket. + + + """ + print("Error:", message) + + +def onclose(message): + """ + Callback function to handle WebSocket connection close events. + """ + print("Connection closed:", message) + + +def onopen(): + """ + Callback function to subscribe to data type and symbols upon WebSocket connection. + + """ + print("Connection opened") + # Specify the data type and symbols you want to subscribe to + mode = SubscriptionModes.DEPTH + Channel = '1' + # Subscribe to the specified symbols and data type + symbols = ['NSE:NIFTY25MARFUT'] + + fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode) + fyers.switchChannel(resume_channels=[Channel], pause_channels=[]) + + # Keep the socket running to receive real-time data + fyers.keep_running() + + +# Replace the sample access token with your actual access token obtained from Fyers +access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo" + +fyers = FyersTbtSocket( + access_token=access_token, # Your access token for authenticating with the Fyers API. + write_to_file=False, # A boolean flag indicating whether to write data to a log file or not. + log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory). + on_open=onopen, # Callback function to be executed upon successful WebSocket connection. + on_close=onclose, # Callback function to be executed when the WebSocket connection is closed. + on_error=onerror, # Callback function to handle any WebSocket errors that may occur. + on_depth_update=on_depth_update, # Callback function to handle depth-related events from the WebSocket + on_error_message=onerror_message # Callback function to handle server-related erros from the WebSocket. +) + + +# Establish a connection to the Fyers WebSocket +fyers.connect() +