The STT is not a allowable expenses means you cant deduct if you classify under Capital Gain. If you Claim at Lower tax rate for your gain then STT is not a Cost. And you Can classify this activity for an Investor.
For a Trader who classify under Business & profession chosen the normal tax rate , so all the expenses associated with the trading can be claimed. So STT is a cost here which can be deducted from the Income.
1000 shares of ICICI bought for 250 and sold for 270. Charges 550 (in this STT 520) Realized profit 19450 (not 20000)
In your example if you are Investor you need to pay tax on 20000-30= 19970 Capital Gain tax @ special rate.
If You a Trader you will add this Income to Normal Income and income will be 19450