1

I am working on a bot that will swap tokens using python. Currently, my bot uses the dexscreener api to continuously retrieve the current price of the token to determine when to sell. However, this is very slow, and due to price volatility, the price changes by the time the transaction occurs.

Is there a way of supporting limit orders using the solana python API, where I can retrieve accurate price information and sell at that exact price?

From my understanding, most current telegram swap bots support limit orders, how do they do it?

1 Answer 1

2

You can look into using an API like Jupiter Swap. The API allows you to create limit orders, swap token and get the current prices of tokens, check out their website for relevant documentation on the API requests.

The API will return an serialized transaction which you will have to decode and then create a versioned transaction from and then you will have to sign it and send it to the blockchain to be executed. Use the solana-py and solders-py libraries.

If you have any more questions or get stuck don't hesitate to respond.

2
  • Thanks for the quick response! To be honest, I was looking to avoid Jupiter. A lot of the tokens I try to buy are quite new (within a few minutes of creation), and I get a lot of errors that that the pool is not found. This doesn't happen when I swap on raydium, it seems to only be an issue on Jupiter Commented Jan 15 at 23:43
  • Oh okay, if it helps maybe you could look into using priorty fees for your transaction that could help speed up the execution on the blockchain. And also I use Defined.fi API for my token data and prices, I don't know how quick they update after a new token is created but it could be worth a shot to check out. Commented Jan 16 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.