fyers-api-v3 1.3.4 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config/config.js CHANGED
@@ -1,29 +1,30 @@
1
- module.exports.Config = {
2
- "API":"https://api.fyers.in/api/v2",
3
- "SYNC_API":"https://api-t1.fyers.in/api/v3",
4
- "data_Api": "https://api.fyers.in/data-rest/v2",
5
- "data_Api1": "https://api-t1.fyers.in/data",
6
- "HSM_SOCKET": "wss://socket.fyers.in/hsm/v1-5/prod",
7
- "Order_SOCKET": "wss://socket.fyers.in/trade/v3",
8
- "get_profile" : "/profile",
9
- "tradebook" : "/tradebook",
10
- "positions" : "/positions",
11
- "holdings" : "/holdings",
12
- "convertPosition" : "/positions",
13
- "funds" : "/funds",
14
- "gtt_orders_sync":"/gtt/orders/sync",
15
- "gtt_orders":"/gtt/orders",
16
- "orders" : "/orders",
17
- "orders_sync" : "/orders/sync",
18
- "multileg_orders_sync" : "/multileg/orders/sync",
19
- "orderStatus" : "/order-status",
20
- "marketStatus" : "/marketStatus",
21
- "auth" : "/generate-authcode",
22
- "generateAccessToken" : "/validate-authcode",
23
- "exitPositions" : "/positions",
24
- "multi_orders" : "/multi-order/sync",
25
- "history" : "/history",
26
- "quotes" : "/quotes",
27
- "market_depth" : "/depth",
28
- "optionChain" : "/options-chain-v3"
29
- }
1
+ module.exports.Config = {
2
+ "API":"https://api.fyers.in/api/v2",
3
+ "SYNC_API":"https://api-t1.fyers.in/api/v3",
4
+ "data_Api": "https://api.fyers.in/data-rest/v2",
5
+ "data_Api1": "https://api-t1.fyers.in/data",
6
+ "HSM_SOCKET": "wss://socket.fyers.in/hsm/v1-5/prod",
7
+ "Order_SOCKET": "wss://socket.fyers.in/trade/v3",
8
+ "get_profile" : "/profile",
9
+ "tradebook" : "/tradebook",
10
+ "positions" : "/positions",
11
+ "holdings" : "/holdings",
12
+ "convertPosition" : "/positions",
13
+ "funds" : "/funds",
14
+ "gtt_orders_sync":"/gtt/orders/sync",
15
+ "gtt_orders":"/gtt/orders",
16
+ "orders" : "/orders",
17
+ "orders_sync" : "/orders/sync",
18
+ "multileg_orders_sync" : "/multileg/orders/sync",
19
+ "orderStatus" : "/order-status",
20
+ "marketStatus" : "/marketStatus",
21
+ "auth" : "/generate-authcode",
22
+ "generateAccessToken" : "/validate-authcode",
23
+ "exitPositions" : "/positions",
24
+ "multi_orders" : "/multi-order/sync",
25
+ "history" : "/history",
26
+ "quotes" : "/quotes",
27
+ "market_depth" : "/depth",
28
+ "optionChain" : "/options-chain-v3",
29
+ "logout" : "/logout"
30
+ }
@@ -1,37 +1,37 @@
1
- class ErrorHandler {
2
- #genricErrorStructure = {s: 'error', code: 500, message: 'Genric Error'}
3
-
4
-
5
- constructor(errorObject) {
6
- this.errorObject = errorObject
7
- }
8
-
9
- getError() {
10
- if (this.errorObject && this.errorObject.response && this.errorObject.response.data) {
11
- return this.errorObject.response.data;
12
- } else if (this.errorObject && (this.errorObject.code === 'ENOTFOUND')) {
13
- return this.setError(this.errorObject.errno, this.errorObject.code)
14
- }else if(this.errorObject.code){
15
- return this.setError(null, this.errorObject.code)
16
- } else if(this.errorObject){
17
- return this.setError(null, this.errorObject)
18
- } {
19
- return this.#genricErrorStructure
20
- }
21
- }
22
-
23
-
24
- setError(code, message) {
25
- if(code){
26
- this.#genricErrorStructure.code = code
27
- }
28
- if(message){
29
- this.#genricErrorStructure.message = message
30
- }
31
-
32
- return this.#genricErrorStructure
33
- }
34
-
35
- }
36
-
1
+ class ErrorHandler {
2
+ #genricErrorStructure = {s: 'error', code: 500, message: 'Genric Error'}
3
+
4
+
5
+ constructor(errorObject) {
6
+ this.errorObject = errorObject
7
+ }
8
+
9
+ getError() {
10
+ if (this.errorObject && this.errorObject.response && this.errorObject.response.data) {
11
+ return this.errorObject.response.data;
12
+ } else if (this.errorObject && (this.errorObject.code === 'ENOTFOUND')) {
13
+ return this.setError(this.errorObject.errno, this.errorObject.code)
14
+ }else if(this.errorObject.code){
15
+ return this.setError(null, this.errorObject.code)
16
+ } else if(this.errorObject){
17
+ return this.setError(null, this.errorObject)
18
+ } {
19
+ return this.#genricErrorStructure
20
+ }
21
+ }
22
+
23
+
24
+ setError(code, message) {
25
+ if(code){
26
+ this.#genricErrorStructure.code = code
27
+ }
28
+ if(message){
29
+ this.#genricErrorStructure.message = message
30
+ }
31
+
32
+ return this.#genricErrorStructure
33
+ }
34
+
35
+ }
36
+
37
37
  module.exports = ErrorHandler;
package/index.js CHANGED
@@ -1,9 +1,11 @@
1
- "use strict";
2
-
3
- var fyersModel =require("./apiService/apiService.js");
4
- var fyersDataSocket =require("./HSM/datasocket.min.js");
5
- var fyersOrderSocket =require("./ordersocket/fyersSocket.js");
6
-
7
- module.exports.fyersModel = fyersModel;
8
- module.exports.fyersDataSocket = fyersDataSocket;
9
- module.exports.fyersOrderSocket = fyersOrderSocket;
1
+ "use strict";
2
+
3
+ var fyersModel =require("./apiService/apiService.js");
4
+ var fyersDataSocket =require("./HSM/datasocket.min.js");
5
+ var fyersOrderSocket =require("./ordersocket/fyersSocket.js");
6
+ var fyersTbtSocket = require("./tbtsocket/tbtSocket.js");
7
+
8
+ module.exports.fyersModel = fyersModel;
9
+ module.exports.fyersDataSocket = fyersDataSocket;
10
+ module.exports.fyersOrderSocket = fyersOrderSocket;
11
+ module.exports.fyersTbtSocket = fyersTbtSocket;
package/logger/log.js CHANGED
@@ -1,62 +1,62 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- class Logger {
5
- constructor(logDirectory = process.cwd(),logflag=true) {
6
- const currentDate = new Date().toISOString().slice(0, 10);
7
- this.logFileName = `${currentDate}.log`;
8
- this.logFilePath = path.join(logDirectory, this.logFileName);
9
- this.logflag=logflag
10
- }
11
-
12
- log(level, message, data, functionName) {
13
- if (!this.logflag){
14
- return
15
- }
16
- const logEntry = {
17
- level,
18
- datetime: new Date().toISOString(),
19
- message,
20
- data,
21
- functionName,
22
- };
23
-
24
- const logString = JSON.stringify(logEntry) + '\n';
25
-
26
- fs.appendFile(this.logFilePath, logString, (err) => {
27
- if (err) {
28
- console.error('Failed to write to log file:', err);
29
- }
30
- });
31
- }
32
-
33
- debug(message, data, functionName) {
34
- this.log('debug', message, data, functionName);
35
- }
36
-
37
- info(message, data, functionName) {
38
- this.log('info', message, data, functionName);
39
- }
40
-
41
- warn(message, data, functionName) {
42
- this.log('warn', message, data, functionName);
43
- }
44
-
45
- error(message, data, functionName) {
46
- this.log('error', message, data, functionName);
47
- }
48
- }
49
-
50
- // Usage example
51
- // const logger = new Logger(undefined); // Log file will be created in the current working directory with the name "YYYY-MM-DD.log"
52
- // logger.debug('Debug message', { example: 'data' }, 'myFunction');
53
- // logger.info('Info message', null, 'myFunction');
54
- // logger.warn('Warning message', { example: 'data' }, 'myFunction');
55
- // logger.error('Error message', { example: 'data' }, 'myFunction');
56
-
57
- // const customLogDirectory = '/home/nihar/fyers_project/node SDK/logger';
58
- // const customLogger = new Logger(customLogDirectory);
59
- // customLogger.debug('Custom debug message', null, 'myFunction');
60
- // customLogger.info('Custom info message', { example: 'data' }, 'myFunction');
61
-
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ class Logger {
5
+ constructor(logDirectory = process.cwd(),logflag=true) {
6
+ const currentDate = new Date().toISOString().slice(0, 10);
7
+ this.logFileName = `${currentDate}.log`;
8
+ this.logFilePath = path.join(logDirectory, this.logFileName);
9
+ this.logflag=logflag
10
+ }
11
+
12
+ log(level, message, data, functionName) {
13
+ if (!this.logflag){
14
+ return
15
+ }
16
+ const logEntry = {
17
+ level,
18
+ datetime: new Date().toISOString(),
19
+ message,
20
+ data,
21
+ functionName,
22
+ };
23
+
24
+ const logString = JSON.stringify(logEntry) + '\n';
25
+
26
+ fs.appendFile(this.logFilePath, logString, (err) => {
27
+ if (err) {
28
+ console.error('Failed to write to log file:', err);
29
+ }
30
+ });
31
+ }
32
+
33
+ debug(message, data, functionName) {
34
+ this.log('debug', message, data, functionName);
35
+ }
36
+
37
+ info(message, data, functionName) {
38
+ this.log('info', message, data, functionName);
39
+ }
40
+
41
+ warn(message, data, functionName) {
42
+ this.log('warn', message, data, functionName);
43
+ }
44
+
45
+ error(message, data, functionName) {
46
+ this.log('error', message, data, functionName);
47
+ }
48
+ }
49
+
50
+ // Usage example
51
+ // const logger = new Logger(undefined); // Log file will be created in the current working directory with the name "YYYY-MM-DD.log"
52
+ // logger.debug('Debug message', { example: 'data' }, 'myFunction');
53
+ // logger.info('Info message', null, 'myFunction');
54
+ // logger.warn('Warning message', { example: 'data' }, 'myFunction');
55
+ // logger.error('Error message', { example: 'data' }, 'myFunction');
56
+
57
+ // const customLogDirectory = '/home/nihar/fyers_project/node SDK/logger';
58
+ // const customLogger = new Logger(customLogDirectory);
59
+ // customLogger.debug('Custom debug message', null, 'myFunction');
60
+ // customLogger.info('Custom info message', { example: 'data' }, 'myFunction');
61
+
62
62
  module.exports = Logger
package/obfuscate.js CHANGED
@@ -1,25 +1,25 @@
1
- const fs = require('fs');
2
- const JavaScriptObfuscator = require('javascript-obfuscator');
3
-
4
- const inputFilePath = './HSM/datasocket.js';
5
- const outputFilePath = './HSM/datasocket.min.js';
6
-
7
- const inputFileContent = fs.readFileSync(inputFilePath, 'utf8');
8
-
9
- const obfuscationResult = JavaScriptObfuscator.obfuscate(inputFileContent, {
10
- compact: true,
11
- controlFlowFlattening: true,
12
- controlFlowFlatteningThreshold: 1,
13
- numbersToExpressions: true,
14
- simplify: true,
15
- shuffleStringArray: true,
16
- splitStrings: true,
17
- splitStringsChunkLength: 10,
18
- stringArray: true,
19
- stringArrayThreshold: 1,
20
- transformObjectKeys: true,
21
- });
22
-
23
- fs.writeFileSync(outputFilePath, obfuscationResult.getObfuscatedCode(), 'utf8');
24
-
1
+ const fs = require('fs');
2
+ const JavaScriptObfuscator = require('javascript-obfuscator');
3
+
4
+ const inputFilePath = './HSM/datasocket.js';
5
+ const outputFilePath = './HSM/datasocket.min.js';
6
+
7
+ const inputFileContent = fs.readFileSync(inputFilePath, 'utf8');
8
+
9
+ const obfuscationResult = JavaScriptObfuscator.obfuscate(inputFileContent, {
10
+ compact: true,
11
+ controlFlowFlattening: true,
12
+ controlFlowFlatteningThreshold: 1,
13
+ numbersToExpressions: true,
14
+ simplify: true,
15
+ shuffleStringArray: true,
16
+ splitStrings: true,
17
+ splitStringsChunkLength: 10,
18
+ stringArray: true,
19
+ stringArrayThreshold: 1,
20
+ transformObjectKeys: true,
21
+ });
22
+
23
+ fs.writeFileSync(outputFilePath, obfuscationResult.getObfuscatedCode(), 'utf8');
24
+
25
25
  console.log('Obfuscation completed.');