It sounds as if it has a swim bladder problem. The swim bladder is a sac situated in the anterior abdomen which allows the fish to maintain buoyancy at different levels in the water through gas diffusion. Basically water quality and diet are usually to blame. Try giving live food or pre-soaking the dry flakes and make sure the water is sufficiently oxygenated and clean. In fact you can withhold food for several days to allow the fish to empty its digestive tract, which may cure the problem.