@Moderator_3 We can do that for buying but for selling all 4 might be at the same time or at different times according to their targets. this cannot be done. As we are buying 4 different strike prices and selling after 20 points profit which depends on a lot of things whether it will be sold at the same time or not.
rozodkarbharat
@rozodkarbharat
Best posts made by rozodkarbharat
Latest posts made by rozodkarbharat
-
RE: Status 403 in generateSession
-
Status 403 in generateSession
@Moderator_1 @Moderator_2 @Moderator_3 I am using smartapi-javascript And placing 4 order at same time. Every time while placing order generateSession is called. But Sometime generate session is giving Status 403 and out of 4 2 or 3 order are getting placed. What is solution for this?
-
facing priblem in placeorder smartapi-javascript
@admin @Moderator_1 @Moderator_2 @Moderator_3 Please reply on my query
https://smartapi.angelbroking.com/topic/4276/inconsistent-behaviour-of-smartapi-javascript-for-the-same-input-showing-jwt-token-error-and-sometime-working-fine -
inconsistent behaviour of smartapi-javascript for the same input showing jwt-token error and sometime working fine.
for the PlaceOrder function below, if I pass the same input it gives a jwt-token error sometimes and sometimes it works fine.
'
let { SmartAPI } = require("smartapi-javascript");
const totp = require("totp-generator");const PlaceOrder = async ({ apikey, user_id, totp_secret, password,tradingsymbol,Qty,transactiontype,symboltoken }) => {
try { const token = totp(totp_secret); let smart_api = new SmartAPI({ api_key: apikey, }); let data = await smart_api .generateSession(user_id, password, token) .then(() => { return smart_api.placeOrder({ "variety": "NORMAL", "tradingsymbol": tradingsymbol, "symboltoken": symboltoken, "transactiontype": transactiontype, "exchange": "NFO", "ordertype": "MARKET", "producttype": "CARRYFORWARD", "duration": "DAY", "price": "0", "squareoff": "0", "stoploss": "0", "quantity": Qty }) }) .catch((err) => { console.log("error generating" , err) return {} }); return data; } catch (err) { console.log(err.message); return {} }
}'
I tried to to debug the error it shows problem in
'node_modules\smartapi-javascript\lib\smartapi-connect.js:178:40'even generateSession method in node modules is getting every parameter right it throws error which is catch block
'self.generateSession = function (client_code, password, totp) {
let params = {
clientcode: client_code,
password: password,
totp: totp,
};
let token_data = post_request('user_login', params);token_data .then((response) => { if (response.status) { // console.log(response.data.jwtToken) self.setClientCode(client_code); self.setAccessToken(response.data.jwtToken); self.setPublicToken(response.data.refreshToken); } }) .catch(function (err) { throw err; }); return token_data; };
'
This breaks the code and I am trying to place an order for multiple brokers and multiple users but because of this, the whole code breaks.
please give some solution for this.