You are here: Trading System Programming > Reference > Classes > Account > Account Methods > getPositionQuantity

getPositionQuantity

This method calculates and returns position quantity for a given symbol and position type.

Syntax

var getPositionQuantity(symbol, positionType);

Parameters

symbol

String value representing a symbol for which to calculate the quantity.

 

positionType

One of the position types.

Return Value

If the method successfully finds the data for a given symbol and position type, it calculates position's quantity and returns a floating value. If no data is found, the method returns 0.

Remarks

This method is typically used to quickly figure out the quantity for a given symbol.

Example

The following example demonstrates the use of getPositionQuantity() method.

 

function start()

{

//if there is an open position for current symbol, do not process anything

 

//get the symbol that's attached to current trading system

var symbol;

if(getSymbol(symbol) == true)

{

var account = getAccount();

if(account.getPositionQuantity(symbol, POSITIONTYPE_LONG) > 0.00)

return;

}

 

//continue processing...

}

 

 


Copyright © 2006-2009 ActiveTick LLC