It is illegal when you use information that are available to you because of your position/job that is not available to the public to make a profit (even intend to make a profit).
If you think about it, profit is generated from the loss of other people that do not have access to such information. Therefore, it is not ethical and of course, it is not legal.