Square Off API


  • I am able to place order. But after than if I want to exit it, is there any API available to exit it?


  • @admin
    public void main() throws SmartAPIException {
    try{
    // PROVIDE YOUR API KEY HERE
    SmartConnect smartConnect = new SmartConnect("XXXX");
    User user = smartConnect.generateSession("XXXX","XXXX");

    	 smartConnect.setAccessToken(user.getAccessToken());
                 smartConnect.setUserId(user.getUserId());
    	// ;  
    

    ///////// Above is partial Code of class//////
    Error:

    	 Exception: Attempt to invoke virtual method 'java.lang.String com.angelbroking.smartapi.models.User.getAccessToken()' on a null object reference
    

    12-21 14:56:40.986 3779 3779 W System.err


  • @Harman08 said in Square Off API:

    also your JAVA CODE is not working in android Studio, All people are getting Null pointer Exception while getting USER TOKEN . After generating a session request .TOKEN method is giving NULL VALUE, Please look at this problem also

    post your request(java) here.


  • @admin IF possible, please Either provide us SQUARE OFF FUNCTION as a java code.
    or provide us a SQUARE OFF logic.
    also your JAVA CODE is not working in android Studio, All people are getting Null pointer Exception while getting USER TOKEN . After generating a session request .TOKEN method is giving NULL VALUE, Please look at this problem also


  • @Harman08 said in Square Off API:

    Why are u not releasing SQUARE OFF FEATURE. see I am doing ALGO TRADING using TRADING VIEW webhook ,Probably there are many trends which don't exit smooth as others so ,It gives us multiple signals while exiting,
    SUPPOSE BUY was previous order ,IF I do EXIT using reverse transaction like TRANSACTION.SELL it will exit my trade on first signal ,if second EXIT signal comes it will buy which makes a non sense.thats why square off is required, if NO position was there it will not execute any order but if i do reverse it will buy or sell

    ok we have noted your requirement.


  • @admin Why are u not releasing SQUARE OFF FEATURE. see I am doing ALGO TRADING using TRADING VIEW webhook ,Probably there are many trends which don't exit smooth as others so ,It gives us multiple signals while exiting,
    SUPPOSE BUY was previous order ,IF I do EXIT using reverse transaction like TRANSACTION.SELL it will exit my trade on first signal ,if second EXIT signal comes it will buy which makes a non sense.thats why square off is required, if NO position was there it will not execute any order but if i do reverse it will buy or sell


  • @vragency007 rest same qty etc..


  • @admin Reverse means only "transactiontype":"BUY" will be replaced with "transactiontype":"SELL". Only this change or any other changes in request payload?


  • @vragency007 said in Square Off API:

    I am able to place order. But after than if I want to exit it, is there any API available to exit it?

    HI, You need to get the position book and execute exact reverse order to exit positions.