Bitcoin Forum

Economy => Speculation => Topic started by: Seal on September 30, 2012, 02:23:18 PM



Title: Seal's automated trading systems
Post by: Seal on September 30, 2012, 02:23:18 PM
Hi all,

I've been lurking for a while now so I would like to share something constructive into my dealings with bitcoin.

I've worked in the world of finance for a number of years and have taken an interest in automated trading systems. In the Bitcoin world there is huge opportunity as the markets are not very efficient. Over the last year, I have developed and successfully run a number of automated trading bots on various brokers.

Here is a screenshot of one of my arbitrage bots:

https://i.imgur.com/UA271.jpg

Certain details have been obscured

There are plenty of trading opportunities within Bitcoin, whatever your investment style. One thing I would recommend, is managing your risk from a broker perspective. In the banking industry, we call this counterparty risk. The biggest threat to your profitability is your broker being hacked / shutting down / running off with your money. As we all unfortunately know, this happens frequently in the Bitcoin world.

In the style of reddit's AMA where visitors can post questions. Go ahead and ask me anything and I will do my best to answer.

This thread was inspired by Goomboo (https://bitcointalk.org/index.php?topic=60501.0) and the sharing of his trading activities.


Title: Re: Seal's automated trading systems
Post by: phungus on October 01, 2012, 12:50:43 PM

So, these trades show you buying on Gox at one price and selling on XXX exchange for a different price and pocketing the difference?

Do the other exchanges always catch up in price?

I'm still trying to put together the mechanics of it in my head, which until recently was not very learned in the ways of brokerage and financial exchange. :-)

-p


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 01:20:52 PM
Yes thats right phungus, the buy side most frequently happens at MtGox and the sell side elsewhere. The difference after fees is your profit and is virtually guaranteed if you can place your orders quick enough. In essence, this is what arbitrage trading is all about.

The broker with the highest volume will almost always attract the best prices (which can be measured by a small spread). MtGox consistently has a higher trading volume then any other broker so leads any price movement. The other exchanges almost always catch up to the price movements that happen on MtGox. This fact alone is enough to profitably trade on the smaller brokers.

One of the first lessons in economics 101 is the theory of supply and demand (http://en.wikipedia.org/wiki/Supply_and_demand). Have a read if you are interested in a solid understanding of the basics.


Title: Re: Seal's automated trading systems
Post by: SkRRJyTC on October 01, 2012, 01:42:46 PM
How do you combat the risk of having monies at lots of different exchanges?

How many different exchanges do you utilize?


Title: Re: Seal's automated trading systems
Post by: molecular on October 01, 2012, 02:12:03 PM
How do you move the FIAT from one exchange to the other and what's the associated cost (fees, moneys frozen up for certain time).


Title: Re: Seal's automated trading systems
Post by: squid on October 01, 2012, 02:27:10 PM
I am assuming having a significant bank roll is relatively important to make a decent amount of profit in this short exchanges. Is this correct?


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 03:05:53 PM
How do you combat the risk of having monies at lots of different exchanges?

How many different exchanges do you utilize?

At different points in time I ran the bot(s) on 4 different exchanges, MtGox, Intersango, CryptoXChange and the ill fated WorldBitcoinExchange  :'(. Trading was done in a number of different currencies.

As I said in my OP, risk came to be one of my biggest threats to profitability. One way I lowered my risk was by increasing the number of exchanges I traded on. I placed a personal limit with each broker of how much I would trust them with and due diligence was always a part of my risk management. Getting in touch with the people running the brokers and asking questions / gauging responses on a number of occasions helped.

Balancing the amount of bitcoin is straightforward as all API's support automatic withdrawals and deposits. Limiting the amount of fiat risk I'm exposed to is more tricky.

Disclaimer: None of the bots are currently active.


Title: Re: Seal's automated trading systems
Post by: thezerg on October 01, 2012, 03:12:51 PM
why aren't they active?


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 03:18:31 PM
How do you move the FIAT from one exchange to the other and what's the associated cost (fees, moneys frozen up for certain time).

Fiat was moved through my personal bank accounts. The fee structure at each broker differs a lot. Some want a percentage, some have a fixed fee for any balance and some are free. This has to be taken into account in the bot's trade execution calculations are performed so that it will never execute an unprofitable trade.

Careful calculations in excel showed me if it was viable to arbitrage the various brokers and the optimum transfer amounts (taken into account risk). e.g. if a broker wanted to charge a $10 fixed fee, then transferring $5000 at a time resulted in a cost of 0.2% of my trading profits; transferring $1000 at a time would equate to a 1% cost of trading profits.

Transfer times are a pain, fiat transfers are sporadic at best with certain brokers taking days to even initiate a transfer. I kept an amount of fiat as reserve in my bank account and would use that as a buffer. Keeping the bot trading depended on keeping the fiat amounts up. Volatility is a good signal of when I would have to step in.


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 03:22:02 PM
I am assuming having a significant bank roll is relatively important to make a decent amount of profit in this short exchanges. Is this correct?

Yes thats right, profitability on overall trading volume is a few % at best. In the real markets, Prop trading (http://en.wikipedia.org/wiki/Proprietary_trading) houses who are the biggest players in high frequency trading / automated trading / arbitrage trading etc... regard 1% profit on trades as a huge figure.


Title: Re: Seal's automated trading systems
Post by: BitcoinRate.com on October 01, 2012, 03:25:35 PM
Nice work!

What language did you write this bot in?

Do execution/calculation speed differences between for example C and slower languages like Python matter in the current Bitcoin market? As in: will your bot be fast enough using Python in executing orders profitably? Or is the slightly slower execution time of Python no problem at all for the foreseeable future?


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 03:42:44 PM
why aren't they active?

I have a few reasons, the main one being that I can't trust most of the brokers besides MtGox for the amounts I want to trade. They are by far the most professional.

Its difficult and expensive it is to operate a good bitcoin brokerage. Profit is hard to come by unless you have massive trading volume and unless you have a large trading volume, your prices will never lead meaning fewer customers. Its a double edged sword which is very unfortunate.

This is compounded by the fact that serious IT security is very expensive and only affordable by the largest brokers. I won't even get started on that topic... ::)


Title: Re: Seal's automated trading systems
Post by: Seal on October 01, 2012, 04:07:22 PM
Nice work!

What language did you write this bot in?

Do execution/calculation speed differences between for example C and slower languages like Python matter in the current Bitcoin market? As in: will your bot be fast enough using Python in executing orders profitably? Or is the slightly slower execution time of Python no problem at all for the foreseeable future?

Thanks BitcoinRate :)

Mine is done in PHP, purely because thats what I'm most experienced in.

No, different languages do not make a difference, in fact PHP is notorious for being one of the slowest languages out there.

My trading engine, calculates if a trade is profitable takes less than 0.00003 seconds. Placing the trade on the other hand using the http calls can take upto and over 1 second which in comparison is an eternity. Execution depends upon the broker's matching engine (some of which are slow).

I was hoping to rewrite my bot in Python someday as I've been teaching myself. I quite like the language!

For those that would like to try their hand at arbitrage trading, I'd encourage you to give it a go. Opportunities are reasonably good still and I regularly see trading opportunities lasting for minutes at a time. Make sure you have some fiat and bitcoin on both brokers to start with and wait for some volatility! Using the websites to place orders are good enough.


Title: Re: Seal's automated trading systems
Post by: BitcoinRate.com on October 01, 2012, 08:55:01 PM
Nice work!

What language did you write this bot in?

Do execution/calculation speed differences between for example C and slower languages like Python matter in the current Bitcoin market? As in: will your bot be fast enough using Python in executing orders profitably? Or is the slightly slower execution time of Python no problem at all for the foreseeable future?

Thanks BitcoinRate :)

Mine is done in PHP, purely because thats what I'm most experienced in.

No, different languages do not make a difference, in fact PHP is notorious for being one of the slowest languages out there.

My trading engine, calculates if a trade is profitable takes less than 0.00003 seconds. Placing the trade on the other hand using the http calls can take upto and over 1 second which in comparison is an eternity. Execution depends upon the broker's matching engine (some of which are slow).

I was hoping to rewrite my bot in Python someday as I've been teaching myself. I quite like the language!

For those that would like to try their hand at arbitrage trading, I'd encourage you to give it a go. Opportunities are reasonably good still and I regularly see trading opportunities lasting for minutes at a time. Make sure you have some fiat and bitcoin on both brokers to start with and wait for some volatility! Using the websites to place orders are good enough.

Thanks for the elaborate response. I was asking since I am most fluent in Python. Having seen how in HFT milliseconds do matter, I was wondering how it was in the Bitcoin world.

I am just now working on building out bitcoinrate.com and getting familiar with the API's of different exchanges. Definitely planning on using those skills to explore other avenues.

Could you elaborate on the volatility. You mean you look for volatility at MTGox?

If volatility is high at MTGox, your data has historically shown that large enough price increases/decreases tend to happen and the lag of other exchanges tends to be enough to be able to exploit arbitrage opportunities?


Title: Re: Seal's automated trading systems
Post by: Seal on October 02, 2012, 07:18:35 AM
Nice work!

What language did you write this bot in?

Do execution/calculation speed differences between for example C and slower languages like Python matter in the current Bitcoin market? As in: will your bot be fast enough using Python in executing orders profitably? Or is the slightly slower execution time of Python no problem at all for the foreseeable future?

Thanks BitcoinRate :)

Mine is done in PHP, purely because thats what I'm most experienced in.

No, different languages do not make a difference, in fact PHP is notorious for being one of the slowest languages out there.

My trading engine, calculates if a trade is profitable takes less than 0.00003 seconds. Placing the trade on the other hand using the http calls can take upto and over 1 second which in comparison is an eternity. Execution depends upon the broker's matching engine (some of which are slow).

I was hoping to rewrite my bot in Python someday as I've been teaching myself. I quite like the language!

For those that would like to try their hand at arbitrage trading, I'd encourage you to give it a go. Opportunities are reasonably good still and I regularly see trading opportunities lasting for minutes at a time. Make sure you have some fiat and bitcoin on both brokers to start with and wait for some volatility! Using the websites to place orders are good enough.

Thanks for the elaborate response. I was asking since I am most fluent in Python. Having seen how in HFT milliseconds do matter, I was wondering how it was in the Bitcoin world.

I am just now working on building out bitcoinrate.com and getting familiar with the API's of different exchanges. Definitely planning on using those skills to explore other avenues.

Could you elaborate on the volatility. You mean you look for volatility at MTGox?

If volatility is high at MTGox, your data has historically shown that large enough price increases/decreases tend to happen and the lag of other exchanges tends to be enough to be able to exploit arbitrage opportunities?

Its not lag of an exchange which makes the prices follow MtGox. Its the people placing orders on the other exchanges not knowing that the price has suddenly changed on MtGox (for better or worse). Most of these people won't care as they are not traders but just want to acquire bitcoin at a price which seems reasonable to them.

I don't actively look for volatility as its something out of my control. I just wait for times of volatility (which often means high volume) as arbitrage opportunities become more frequent. When this happens, I make more of an effort to monitor the bots and each of their trades.


Title: Re: Seal's automated trading systems
Post by: thezerg on October 02, 2012, 11:55:19 PM
why aren't they active?

I have a few reasons, the main one being that I can't trust most of the brokers besides MtGox for the amounts I want to trade. They are by far the most professional.

Its difficult and expensive it is to operate a good bitcoin brokerage. Profit is hard to come by unless you have massive trading volume and unless you have a large trading volume, your prices will never lead meaning fewer customers. Its a double edged sword which is very unfortunate.

This is compounded by the fact that serious IT security is very expensive and only affordable by the largest brokers. I won't even get started on that topic... ::)

Yes, my non-quantitative assessment is that the risk of holding money on these exchanges outweighs the profit that can be extracted from arbitration. 

Also, in a bullish trending market, the portion of the cycle time the $ spends in fiat is significant -- you miss out on the BTC price appreciation which may be significantly more then the arb profit since moving the fiat takes days.


Title: Re: Seal's automated trading systems
Post by: phungus on October 03, 2012, 11:26:07 AM

Dwolla was really good for moving fiat when it was working correctly. One could move USD between Tradehill and MtGox instantly.

And then that dried up...

-p


Title: Re: Seal's automated trading systems
Post by: Kontakt on October 04, 2012, 02:10:35 AM
I wrote half of one of these bots in Python, just a CampBX buy/sell bot. I never finished it though, because with the capital I could muster, it just wasn't profitable. I would need 20 cent arbitration just to cover my fees. Still have the code for that if anyone wants to see it. Never got around to working out an algorithm for it.


Title: Re: Seal's automated trading systems
Post by: Seal on October 04, 2012, 05:37:57 AM
Also, in a bullish trending market, the portion of the cycle time the $ spends in fiat is significant -- you miss out on the BTC price appreciation which may be significantly more then the arb profit since moving the fiat takes days.

There are ways around this, my method was to keep a btc 'float' amount which is always fixed. However much btc I would buy on one broker, I would sell on the other, keeping this float level the same. Profits were taken out of the fiat.

A crude analogy is a corner shop owner keeping a fixed amount of change in his till every night and taking out his profits. This will lower risk slightly.

Be careful not to mix up arbitrage trading with trading market movements... with arbitrage you are hoping for good market movement regardless of direction as this equals profit. If you are trading market movements or investing, then you will be betting for a the price to go up or down in the same direction your bet is.


Title: Re: Seal's automated trading systems
Post by: thezerg on October 04, 2012, 06:52:19 PM
yes, my issue is a bull (or bear) trending market means that the average of exchange A - exchange B over time is non-zero, in other words the opportunities tend to be in the same direction.  So I have to move the BTC and USD back around which is instant for the BTC but takes days for the USD.



Title: Re: Seal's automated trading systems
Post by: Seal on October 07, 2012, 11:48:25 AM
yes, my issue is a bull (or bear) trending market means that the average of exchange A - exchange B over time is non-zero, in other words the opportunities tend to be in the same direction.  So I have to move the BTC and USD back around which is instant for the BTC but takes days for the USD.

Thats very true, the buy side will always be cheapest at MtGox. The sell side at the less liquid broker so you will always be transferring Fiat. Bitcoin can be automatically balanced by your bot if it tracks your bitcoin trading activity. The Fiat balance always requires manual rebalancing through your bank, if you have a buffer amount then its manageable to always have your bot running even if the fiat will take 2-3 days to arrive.