chief-gant / SplinterlandsTraderBot

A trading bot written in Python that makes a profit by buying underpriced cards and quickly reselling them.
18 stars 0 forks source link

Bot Crashes when Buying #11

Closed knightblaster closed 2 years ago

knightblaster commented 2 years ago

Hey,

So the Bot keeps buying the same card: Djinn Apprentice from the same person, for a price that is 7 times too high. After making the purchase, the bot crashes with the following message which just repeats unless I manually kill the process: The card couldnt be posted, retrying.

chief-gant commented 2 years ago

Hey! So, checking the code, the only way you should get the error would be inmediately after you see a message such as:

Successfully bought in XX sec!

For what I could see in your user history, there's this recurrent issue of the bot trying to buy a post with a "faulty" price, "NaN", which might indicate that the card is no longer available. This however would be unrelated to the error you're referring to (The card couldnt be posted, retrying).

I would ask you to confirm if you actually received the message Successfully bought... before the The card couldnt be posted, retrying in order to pinpoint the error. Although I guess you had an infinite amount of the couldnt be posted message and you might not have been able to read the other one anyway. I will however work on a fix to prevent the bot from purchasing faulty cards with "NaN" as price.

If we assume you actually had the Successfully bought... message, there would be two issues to solve:

  1. Not being able to post the card you just bought. To prevent this I might add a waiting time period after the purchase in order to give the blockchain enough time to properly process the purchase.
  2. Trying to buy faulty cards. This should be an easy check before buying.
chief-gant commented 2 years ago

Following my assumptions, I took the liberty to fix it and pushed a new version. This one introduces fixes for both problems:

  1. Not being able to post the card you just bought.

Now it waits for 10 seconds between purchasing and posting. A couple of things to note:

2.Trying to buy faulty cards.

Now the bot will simply ignore posts with NaN as the price. I actually missed this possible bug entirely because I didn't know the full extent of NaN's behaviour. If you want to know, for example, all comparisons return False with NaN. For example:

num = float("NaN") # Now num is NaN
num > 10 # returns False
num <= 10 # also returns False!
num == num # also returns False! #mindblown
chief-gant commented 2 years ago

I will keep the issue open until you try the latest version out and confirm that it's working properly.

chief-gant commented 2 years ago

I will close the issue as, although I haven't had an actual confirmation, according to what I gather from your blockchain operations it seems the problem has been solved. Feel free to reopen this issue if needed.

knightblaster commented 2 years ago

Hey sorry for the late confirmation on this... I have been traveling. But yes it seems like the update worked, so thanks a lot for that!! :)