diff --git a/config/api.js b/config/api.js index d348287..f574df9 100644 --- a/config/api.js +++ b/config/api.js @@ -28,6 +28,7 @@ module.exports.API = { rule_list: '/rest/secure/angelbroking/gtt/v1/ruleList', candle_data: '/rest/secure/angelbroking/historical/v1/getCandleData', + market_data : '/rest/secure/angelbroking/market/v1/quote' // "api.token": "/session/token", // "api.token.invalidate": "/session/token", // "api.token.renew": "/session/refresh_token", diff --git a/example/test.js b/example/testsuite.js similarity index 86% rename from example/test.js rename to example/testsuite.js index 46dd0af..d0f3005 100644 --- a/example/test.js +++ b/example/testsuite.js @@ -60,6 +60,10 @@ let smart_api = new SmartAPI({ // // // return smart_api.getOrderBook(); + // smart_api.getOrderBook().then((data)=>{ + // console.log(data); + // }) + // // // return smart_api.getTradeBook(); // // // Portfolio Methods @@ -119,6 +123,21 @@ let smart_api = new SmartAPI({ // // // "fromdate": "2021-02-10 09:00", // // // "todate": "2021-02-10 09:20" // // // }) + + + // Market Data Methods + // smart_api.marketData({ + // "mode": "FULL", + // "exchangeTokens": { + // "NSE": [ + // "3045" + // ] + // } + // }).then((data) => { + // console.log(JSON.stringify(data, null, 2)); + // // console.log(JSON.stringify(data)) + // }); + // }) // .then((data) => { // console.log('PROFILE::', data); @@ -190,32 +209,32 @@ let smart_api = new SmartAPI({ // } // ########################### Socket V2 Sample Code Start Here ########################### -let web_socket = new WebSocketV2({ - jwttoken: 'JWT_TOKEN', - apikey: 'API_KEY', - clientcode: 'Client_code', - feedtype: 'FEED_TYPE', -}); +// let web_socket = new WebSocketV2({ +// jwttoken: 'JWT_TOKEN', +// apikey: 'API_KEY', +// clientcode: 'Client_code', +// feedtype: 'FEED_TYPE', +// }); -web_socket.connect().then(() => { - let json_req = { - correlationID: 'abcde12345', - action: 1, - mode: 2, - exchangeType: 1, - tokens: ['1594'], - }; +// web_socket.connect().then(() => { +// let json_req = { +// correlationID: 'abcde12345', +// action: 1, +// mode: 2, +// exchangeType: 1, +// tokens: ['1594'], +// }; - web_socket.fetchData(json_req); +// web_socket.fetchData(json_req); - web_socket.on('tick', receiveTick); +// web_socket.on('tick', receiveTick); - function receiveTick(data) { - console.log('receiveTick:::::', data); - } +// function receiveTick(data) { +// console.log('receiveTick:::::', data); +// } // setTimeout(() => { // web_socket.close(); // }, 10000); -}); +// }); // ########################### Socket V2 Sample Code End Here ########################### diff --git a/lib/smartapi-connect.js b/lib/smartapi-connect.js index 6d07d68..4f36908 100644 --- a/lib/smartapi-connect.js +++ b/lib/smartapi-connect.js @@ -100,7 +100,7 @@ var SmartApi = function (params) { return response?.data; } } catch (error) { - return null; + return []; } }, (error) => { @@ -114,11 +114,11 @@ var SmartApi = function (params) { errorObj.status = 500; errorObj.message = 'Error'; } - // return errorObj; + return errorObj; - return Promise.reject(errorObj); + // return Promise.reject(errorObj); } catch (error) { - return null; + return []; } } ); @@ -427,6 +427,17 @@ var SmartApi = function (params) { }; }; + /** + * Description + * @method marketData + * @param {object} params + * @param {string} mode + * @param {string} exchangeTokens + */ + self.marketData = function (params){ + return post_request('market_data',params); + }; + /** * Description * @method ruleList