I'm using the Cryptsy API with a bot. So far, my bot's problem is that when it decides it needs to buy or sell a coin (not just bitcoin), I always seem to compute a price that is way too low or high. The data I have access to is:
- The currently outstanding buy orders (though a few seconds old and without timestamps)
- The currently outstanding sell orders
- The previous 20 trades that were executed on the market
From all of this data, is there an existing algorithm to compute a price that will almost always buy or sell? My bot's priority is to have fast trades(like, less than a minute for execution), even if the price is not the best.
Cryptsy themselves compute a pretty good number in their web UI (the default ask/bid price), but I don't see that value exposed in their API. Where does this ask/bid price come from?
For reference, I've tried a few things with little success
- Highest buy price/Lowest sell price -- This tends to catch outliers and results in me placing an overly optimistic bid that only one buyer/seller was willing to pay (and because my data is seconds old, apparently somone else picks it up)
- An average of 3 lowest/highest -- This had the same problem with outliers
- Lowest buy price/Highest sell price -- This is extremely pessimistic and results in me paying ridiculous prices that are unreasonable
How can I compute a good ask/bid price from this set of data I have?