It is possible that your dog could have eaten something foreign such as rat or mice poison when you were out on a walk. This could have terrible effects on a dog, as it is designed to kill rodents. There are no home treatments that you can try so be sure to make an appointment to see your vet as soon as possible or call an emergency line. If you are lucky they may operate an emergency house call service and may be able to come out and see you the same day or night.
If your dog has lost its appetite and has not been eating for several days then this makes the problem even more urgent because just like humans, dogs can only survive for a few days without food. Try to make sure that they are drinking water as this could help them. They could be battling an internal infection and the weakness caused by lack of food and dehydration will not be helping. If your dog won’t eat then at least try and make sure that they drink some fresh clean water.
To be honest, you will not know for sure what is wrong with your dog until you have them examined by a vet. They could have eaten something, been bitten by something or even hit by a car and you don’t know it. The sooner you get your dog examined, the sooner you will know and the appropriate treatment can begin.