Well, people sometimes learned from their mistakes and realized they wrong. Perhaps at that time you feel greedy and want to gain more in gambling. Because actually gambling is not for making money but the interpretation of most gamblers is making money, not for the fun activity. Indeed, in this post, --you already had found the answer. Gambling of what you can afford to lose is the first rule to implement to your self because that is only self-discipline.
Be careful of this attitude that you can't sleep as a gambler because you are chasing your losses. Perhaps, this is the reason why you become addicted to gambling without knowing your self because all you know is a habit.
Being a compulsive gambler is very hard to control. When you are continuously win on the gamble and then your urge to play more that you will end up to lose, will give you more regret and like what the title of this thread, it will cause you to have a difficulty in sleeping. But in that case, you will learn from your mistake that you should always need to control yourself.