unable to get positions data

sky6
i want to update mysql table from kite- >positions() response.
Please suggest i am not able to retrieve data from obj class
my code is

$array= $kite->positions();
//print_r($kite->positions()); - it is showing result but not giving any result in below script
foreach ($array as $obj){
echo "Product : " . $obj->product . "";

$tsymbol =$obj->tradingsymbol;
$exch = $obj->exchange;
$qty = $obj->quantity;
$price = $obj->average_price;
$bqty = $obj->buy_quantity;
$bprice = $obj->buy_price;
$sqty = $obj->sell_quantity;
$sprice = $obj->sell_price;
$netbuyamount = $obj->net_buy_amount_m2m;
$netsellamount = $obj->net_sell_amount_m2m;
$m2m = $obj->m2m;

echo "".$exch."".$tsymbol ."".$product."".$qty."".$price."LTP".$m2m."-";
}

please tell what is the mistake? i am able to get holding data with same script but not able to get position data. thanks
  • Kailash
    The positions payload has two parent keys, "net" and "day". So the loop should be like this:


    foreach($array->net as $obj) { ...


    Also, there is no "net_buy_amount_m2m" field. It'd just be $obj->buy_m2m.
  • sky6
    thanks, now it is working
This discussion has been closed.