Note that the current price is hard coded (38) since it is not supplied, it would need to be supplied in another table which would be joined to the stocks table, but the principle is the same.
create table stocks (stock varchar2(10),shares number, price number);
insert into stocks values('A', 100, 50);
insert into stocks values('A', -20, 60);
insert into stocks values('A', 50, 40);
select stock, sum(shares) number_of_shares, round(sum(shares*price)/sum(shares),2) average_price,
sum(shares*price) amount_paid, sum(shares*38) value,
round((sum(shares*38)-sum(shares*price))/sum(shares*price)*100,2)||'%' rate_of_return
from stocks
group by stock
STOCK NUMBER_OF_SHARES AVERAGE_PRICE AMOUNT_PAID VALUE RETURN
A 130 44.62 5800 4940 -14.83%