Project Tradebot V: testing
Wednesday 04 May 2016
I’ve coded by tradebot, now I’m testing: the moment of truth.
With a somewhat functional bot coded (I’m assuming there will be plenty of bugs to discover yet), it’s time to try it out and see how - and whether - it performs.
For testing, I’ll obviously be minimising risk and using small amounts of BTC - just 10 Bitshares’ worth at a time (around $0.06). I’ve decided BTS-BTC is the best market for now, thanks to its good liquidity and not-too-crazy swings - which is, admittedly, a relative term when you’re talking about alts.
I’ve also decided to select a relatively broad range within which to trade, to reduce the likelihood of the price moving outside it. For now, I’m going to space my tranches 5 satoshis apart, though I guess there’s no reason it shouldn’t be less, even 1 satoshi. The spread is also a matter for optimisation. Intuitively, the smaller movements I can exploit, the more trades there will be and the better I’ll do - markets being fractal and all that. The limits to this logic include the fact that I have to pay a trading fee of 0.15%. With Bitshares at 1400 sats, I would have to sell at 1403 before I started making profits. As a starting point, I’m going to set a 19 satoshi spread. That gives me profit of roughly 1% on each buy/sell (for that tranche), at that level. It will represent a different proportion at higher/lower prices.
Metal Mickey, 1980s TV icon but not much of a trader to my knowledge
So: my strategy will be to place 80 orders of 10 BTS, spaced at 5 satoshis apart, covering a range of 400 satoshis. Current price (at the time of writing) is 1403-4 sats, so if I cover the space between 1200 and 1600 that should be pretty good.
I’m starting with 0.1 BTC in my account, and I buy exactly 0.05 BTC of BTS. I set it going for 24 hours (with the parameter 86400 in the command line). And… wait.
Slowly, the feed of trades appears. My output info includes whether it’s a bid or ask placed, the level it’s placed at, time, and the total number of trades so far. At 1% on each tranche traded, I’ll need to make 160 trades - a buy and a sell being two - to reach 1% of my initial outlay, or 16,000 to reach 100% ROI. (It would be less with a narrower range, but that would be more risky.) I have no idea what I should expect in the course of a day, and I know one day won’t be representative of another. It’s also worth noting that in an ideal world, the bot would either run long-term, or I’d close out trades above my initial buy price for BTS at the end, so I’m not stuck with a larger number (hopefully) of coins that are valued at a lower price.
In the first 10 minutes, 18 trades are placed. If this carries on, I can expect a total of around 2600 trades a day, or 1300 buy/sell pairs, which would be a very healthy 16% ROI. That seems a little too good to be true, which means either my maths is off, this flurry of activity isn’t going to be continued, or I’ve made some other sort of mistake somewhere. (The last option, which I refuse to contemplate at this point, is that this time next year, I’ll be a millionaire.) It’s hard to see exactly what’s going on, because although I can view a list of my open orders on Polo, there’s money tied up at different bid/ask prices so it’s unclear what my running total is at the current price.
20 minutes in, it’s 30 trades. In the first hour, 67, which means if it carries on it will take less than two and a half hours to reach 1% ROI. (The Bank of England base rate is currently 0.5% per annum, so this a nice amount.) So far, conditions are pretty good; the price hasn’t strayed too far from the starting point, giving me no immediate worries it will drop out of range.
There are periods where it’s frustratingly slow, with no trades or movement of more than a few satoshis for minutes on end. Then you get several at once. A little over an hour in, there’s a massive spike down, a huge sell that fills all my bids to 1200 and falls out of the bottom of my range. At that point it looks like I’ve had it and won’t be placing any more orders until the price comes back up, but the counter-bounce promptly fills the corresponding asks, and after just 90 minutes my trades are up to an impressive 150.
It starts well, but the afternoon is very quiet. Then the connection to Poloniex drops out in the evening, meaning I have to restart. I really want a full day of results, minimum, before I draw any conclusions. And that, it turns out, is harder than expected.
It seems my initial good fortune was just that. I happened to hit an exceptionally high-volume period of trading. After this, volumes and volatility die right down. Moreover, my bot keeps crashing - sometimes because Poloniex's connection fails, sometimes because my connection is flaky, and sometimes because something I've coded turns up an error under certain conditions. There are also numerous weirdnesses to do with Polo's API, even when it is working; trades appear in strange orders, and duplicates show up. It's not clear to me whether this is down to my code or something else, and it makes me a little uneasy.
Early results suggest the overall approach could work. Although I've generated just about every error possible, the one thing my bot hasn't done is lose money by making bad trades. But it's going to take some more rigorous testing and much better tolerance to bad conditions before I put in a larger sum of money.
Next up, debugging - and in particular, making the bot far more robust against conditions outside of my control, like Poloniex breaking the connection. I can't afford to have factors like that crash the software.
comments powered by Disqus