If you’re a corporate insider like a director or anyone who may be privy to private information like the exchange of shares in your company’s stock, it’s vital you understand what is and isn’t considered illegal insider trading. It’s also important to know how the government looks for market violations and the consequences of being convicted.

The following are definitions of the two types of insider trading:

Legal — This is when employees buy or sell shares from their own corporation, following all laws and regulations pertaining to securities. This trading is required to be properly filed with the U.S. Securities and Exchange Commission (SEC) within mandated periods of time.

Illegal — It’s illegal for someone who has not-yet-publicized information about the corporation’s imminent market value to buy or sell shares themselves or tip someone else off to this insider information. The SEC hunts down cases of illegal insider trading to keep people from profiting from an unfair advantage. This also protects the market and the public’s confidence in it.

The SEC uses a variety of methods to track insider trading, including market surveillance tools monitoring important corporate developments and earning reports. The SEC often flags suspicious activities and starts investigating instances when an insider gains from a particularly big trade, since many insiders want to maximize their profits rather than settling for a small advantage. SEC officials are also often given tips about who may have been insider trading. Tips can come from disgruntled investors, other traders, whistleblowers and media muckrakers.

What to do if you’re accused

If you face charges of illegal insider trading, you should know that, if convicted, the crime can be punished by fines of up to $5 million and a maximum prison sentence of 20 years. These charges can also significantly damage your career and reputation. It’s important you get an experienced defense attorney to fight on your behalf so you get the fairest treatment under the law.