API function to square-off portfolio (account). The system will filter all OPEN positions present in given portfolio (account) and send a square-off position request for each. APIs are available in AmiBroker, MetaTrader, Excel, Java, C#, Python, HTTP REST.
Note: This function should ideally be used when you want exit all open positions. For example, an intraday trader may want to square-off portfolio before auto-square-off time set by the broker.
Api function will square-off a portfolio on Zerodha, Upstox, AliceBlue, Finvasia, Angel One, Fyers, IIFL, 5Paisa, Profitmart, Mastertrust, Nuvama, Motilal Oswal, Kotak Securities, Zebu, Choice Broking, SAS Online.
Signature
/** * Submits a square-off request for the given account. * Server will square-off all open positions in the given account. * * pseudoAccount - account to which the position belongs * category - position category (DAY, NET). Pass NET if you are not sure. */ function squareOffPortfolio(pseudoAccount, category)
Examples
// Square-off all positions in account ABC123 squareOffPortfolio("ABC123", "NET"); // Square-off all positions in account // defined in chart parameters squareOffPortfolio(AT_ACCOUNT, "NET");
Signature
/** * Submits a square-off request for the given account. * Server will square-off all open positions in the given account. * * pseudoAccount - account to which the position belongs * category - position category (DAY, NET). Pass NET if you are not sure. */ bool squareOffPortfolio(string pseudoAccount, string category)
Example
// Square-off all positions in account ABC123 squareOffPortfolio("ABC123", "NET"); // Square-off all positions in account // defined in chart parameters squareOffPortfolio(AT_ACCOUNT, "NET");
Signature
/** * Submits a square-off portfolio request. * * @param pseudoAccount pseudo account * @param category position category (DAY or NET portfolio to consider) * @return true on successful acceptance of square-off request, false otherwise */ IOperationResponse<Boolean> squareOffPortfolio( final String pseudoAccount, final PositionCategory category);
Example
IOperationResponse<Boolean> response = autotrader.squareOffPortfolio( "ABC123", PositionCategory.NET);
Signature
/// <summary> /// Submits a square-off portfolio request. /// </summary> /// <param name="pseudoAccount"> pseudo account </param> /// <param name="category"> position category (DAY or NET portfolio to consider) </param> /// <returns> true on successful acceptance of square-off request, false otherwise </returns> IOperationResponse<bool?> SquareOffPortfolio( string pseudoAccount, PositionCategory category);
Example
IOperationResponse<bool?> response = autoTrader.SquareOffPortfolio( "XX1234", PositionCategory.NET); if(response.Success()) { Console.WriteLine("Result: {0}", response.Result); } else { Console.WriteLine("Message: {0}", response.Message); }
Signature
def square_off_portfolio(self, \ pseudo_account, position_category):
Example
response = autotrader.square_off_portfolio('XX1234', 'NET') if response.success(): print("Result: {0}".format(response.result)) else: print("Message: {0}".format(response.message))
Example
curl https://api.stocksdeveloper.in/trading/squareOffPortfolio \ -H "api-key: <your_api_key>" \ -d "pseudoAccount=ACC_NAME" \ -d "category=NET"
Response
{ "result":true, "error":null, "message":null, "status":true, "commandId":"9f8b5738-c1aa-4623-b0c5-8df779e0f44d" }
Signature
' Submits a square-off request for the given account. ' Server will square-off all open positions in the given account. ' ' pseudoAccount - account to which the position belongs ' category - position category (DAY, NET). Pass NET if you are not sure. Public Function SquareOffPortfolio(pseudoAccount As String, _ category As String) As Boolean
Example
' Square-off all OPEN positions in account ABC123 SquareOffPortfolio("ABC123", "NET")
Postman is widely used tool for API testing. We have provided below a collection of all of our APIs in postman collection format. Click postman collection to know more about how to use it.
Parameters
- account – pseudo account
- category – position category