Each exchange has it’s own protocol for how to interact with it, so you won’t be able to use the Solana CLI by itself. The DEX you are using would have to offer a CLI, or else provide provide an SDK ( like many do ) so that you can perform the actions you need to programmatically from, for instance, a Node.js program running on your machine.
You could see if the project has an SDK on GitHub maybe? What DEX are you using?