Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
59 changes: 39 additions & 20 deletions example/test.js → example/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 ###########################
19 changes: 15 additions & 4 deletions lib/smartapi-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var SmartApi = function (params) {
return response?.data;
}
} catch (error) {
return null;
return [];
}
},
(error) => {
Expand All @@ -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 [];
}
}
);
Expand Down Expand Up @@ -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
Expand Down