Avg. Price is empty


if i use IbController, I can get the Avg. Cost, but not the Avg.Price.
Avg.Price is always empty.

ibc = GetTradingInterface("IB"); 
AvgC=ibc.getPositionInfo(Name(),"Avg. Cost");
AvgP=ibc.getPositionInfo(Name(),"Avg. Price");

Click on IBController in the TASK bar and display position list and look if "Avg. Cost column is empty or not. If it is it means that TWS did not send that data via API.

IB delivers Avg. Cost in "Portfolio".
But they do not deliver Avg. Price in "Portfolio", that is in "Executions".
So what I tried now to get the Avg. Price is:

AvgP=ibc.GetExecInfo(BuyOrderID,"Avg. Price")

But the result is also: {Empty}

1 Like

Hi, i used following code to get the data from TWS portfolio.

But the result is empty.

ibc = GetTradingInterface("IB"); 

AvgPrice=ibc.GetPositionInfo(Name(),"[INR]Avg Price");
BaseCost=ibc.GetPositionInfo(Name(),"[INR]Cost Basis");
CMV=ibc.GetPositionInfo(Name(),"[INR]Market Value");
CChangeV=ibc.GetPositionInfo(Name(),"[INR]Change"); //current change in Value
CChangeP=ibc.GetPositionInfo(Name(),"[INR]Change %"); //current change in Percent
DPro=ibc.GetPositionInfo(Name(),"[INR]Daily P&L"); //Daily P&L
DProP=ibc.GetPositionInfo(Name(),"[INR]Daily P&L %"); //Daily P&L in Percent
UnrPro=ibc.GetPositionInfo(Name(),"[INR]Unrealized P&L"); //Unrealised P&L

 NetCash= ibc.GetAccountValue("[INR]NetLiquidationByCurrency");

 for( i = 0; ( NetAmt = StrExtract( NetCash, i ) ) != ""; i++ ) 
   printf( "%gn", StrToNum( NetAmt ) );