0

I want to get the offer id based on the offer price and cancel that offer. How I can do that using python SDK?

1
+50

You can get a list of existing offers submitted by a particular account with the following methods: offers().for_seller(self.account_id)

Example code:

offers = server.offers().for_seller(self.account_id).call()
offers = offers['_embedded']['records']

You will get following values: offer_id, offer_code, offer_amount, offer_price

print(json.dumps(offers, indent = 4))

Next, you can import data to pandas dataframe using a loop. Now you are ready to retrieve values you're looking for using conditional statements, something like:

if offer_price == x:
    print(f"{offer_id})

To cancel the offer you will need to submit a transaction with a retrieved offer_id, but use amount equal to 0 (price is not important), for example:

transaction_builder.append_manage_sell_offer_op(selling_asset, selling_issuer, buying_asset, buying_issuer, '0.0', '1.0', offer_id)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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