As I understand it, if you are doing mining as a business then you treat your mining hardware, electricity costs etc as business costs to be subtracted from your income when figuring your profit. If you buy some BTC at $100 and sell at $150 your profit is $50, as you would expect. Similarly if it costs you $100 to mine bitcoins that you then sell at $150 your profit is also $50.