1

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:

  1. The currently outstanding buy orders (though a few seconds old and without timestamps)
  2. The currently outstanding sell orders
  3. 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

  1. 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)
  2. An average of 3 lowest/highest -- This had the same problem with outliers
  3. 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?

3 Answers 3

0

I had been thinking about this lately and haven't explored this option at ALL but I'm thinking out loud here because nobody has replied in 8 days.

So what if you took the average of the top orders 1 - 5, then the average of the top orders 2 - 6, the average of 3 - 7, ect. Out of THOSE orders you then calculated the average again to arrive at your sell point? The process could be repeated as nessecary to find an average of averages that hover around the top of the buy points.

Thoughts?

1
  • Look at my answer. The key is not just the price, but the volume of the order, and the volume that you are wanting to trad
    – Earlz
    Commented Feb 3, 2014 at 21:52
0

It took quite a bit of thinking, but here is how you arrive at a "buy instantly" or "sell instantly" price.

Lets say you have buy orders:

  1. buy 100LTC at 5BTC
  2. buy 50LTC at 4BTC
  3. buy 200LTC at 3BTC

And sell orders:

  1. sell 100LTC at 6BTC
  2. sell 500LTC at 7BTC
  3. sell 100LTC at 8BTC

and so on.

We can gain a lot from this simple set of orders. For one, the market depth chart becomes very useful when looking at this data. So, you could say that the market spread is 1BTC in this case, because buy and sell orders are separated by 1BTC

Now, lets say we have 125LTC we want to sell. The way you would pick the best sell instant price is to look at the buy orders. Looks like you could sell your first 100LTC at 5BTC and the remaining 25LTC at 4BTC. So, 5BTC should be your max rate. Depending on the API you are using, you might want to place two separate orders at different prices or place one with the max price assumed.

It works the same way with buying. IF you want to buy 650LTC, you would be able to buy the first 100LTC at 6BTC, and then the next 500LTC at 7BTC and the last 50LTC at 8BTC. So, your max price would be 8BTC. Although your actual price would vary quite a lot. It depends on what service and API you're using as to how to best place such an order spanning prices.

For Cryptsy you would place such a buy order as just one order of 650LTC at 8BTC. Crypsty automatically chooses the best price for you, so you would have this effect. However, it's not guaranteed to work this way. If you got the order list, and someone was to buy up 50BTC at 6BTC, then your expected price would end up being wrong. If you want a price guarantee, you should place exact matching orders to the order book. Following this method though, you have a high likelyhood of an order not completing as well, or taking longer than expected, such as if you buy 100LTC at 6BTC, but someone bought 50LTC already. Crypsty by default would wait a while before completing the partial order. (assuming no other sell orders were placed at that price)

It's actually a really simple concept, but it took me a few days to actually wrap my head around it for some reason. Hopefully if other people have the same problem, maybe this post will clear things up for them

0

A market maker will always match orders. You must have someone who wants to buy at the price you wish to sell, and visa-versa. If you put in a low price to sell at, you aren't guaranteed to sell at that price. Granted, the market maker may fill other buy orders that are higher than what you are asking, but, again, it's not guaranteed.

The key to high-volume buy-sell bots is to look for volume. More volume means a bigger market and more opportunities to buy and sell. There are a number of websites, like Cluedex.com, that rank markets and determine which are trending at any given time, and also give some indication of momentum. Using this data, you can determine which markets you are more likely to trade more quickly. Then, it's just a matter of getting the bid/ask price and selling/buying on those prices.

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.