Pages:
Author

Topic: Bitcoin arbitrage on GitHub: ~2% monthly return, market-neutral long/short - page 6. (Read 38294 times)

newbie
Activity: 49
Merit: 0
Can you please share what is your long-term plan ?
Are you going to use your own money to trade it, will you be looking for outside investors, or are you planning to keep it open source ?

For the moment I focus on the software itself: performance improvements and new features (current list here). As an example I just added a trailing spread that should sensibly increase the return per trade. Once Blackbird is mature enough it would be interesting to see it used by professional investors. A couple of Bitcoin quant traders already asked me many questions about the software so I guess there is an interest in the industry. As for now my goal is to offer the best possible open source Bitcoin arbitrage platform.

And yes my plan is to still keep Blackbird open source. Even though arbitrage is a highly competitive environment and therefore strategies should be kept more or less secret, I still believe it is fine to keep Blackbird open source for the following reason: Blackbird is merely the main engine of the arbitrage implementation. It covers the whole arbitrage logic, the bid/ask prices management, the order executions and verification. So it already covers a big part but to do successfully arbitrage you need more than just the engine. Usual examples:

  • Spread parametrization: do you want few long-term trades with high spread? Many short-term trades with small spread? What will make the best profit on the long run? And how do you adapt the parameters based on market conditions? This is where you can make the difference. It will also depend on your exposure (not the same parameter optimal values whether you trade $100, $10,000 or $1,000,000).

  • Accurate and representative backtesting. This is NEVER trivial, specially with short-term strategies.

  • Overall risk management (e.g. VaR of the strategy).

  • IT-related topics like network optimization but also failover, lost network connections, etc.

So I believe that even if everybody shares the same platform you can still have many edges over the other players. And again an implementation for $100 exposure won't be the same as for $1,000,000.

I am happy to discuss any thoughts on this interesting topic.



One piece of advice, which might be helpful to you:
You will get many more arbitrage opportunities if you constantly work your orders on the less liquid exchange and are prepared to hedge your position on the primary exchange once your orders get filled.
If you will wait for the markets to align themselves so that you can you can send orders to both exchanges, most opportunities will pass you by.

Yes you are right and this is actually current practice in the industry. I would add that you want to avoid to be in a situation where you are 99% executed on the non-liquid one and 0% on the liquid one (0% because the non-liquid is not yet fully filled). In this situation you are not market neutral anymore.

To avoid this situation a good option would be to split your order into many child orders and when a child order in the non-liquid one is fully filled then you execute the same amount on the liquid one. And then you continue with the next child order until they are all completed. Your market risk would then always be the size of a child order. Maybe in a future version...



Please read: If you have troubles installing Blackbird or if you just found a bug please don't post on this thread but open a new issue on the GitHub page instead (link here). Thanks.
newbie
Activity: 49
Merit: 0
Couldn't you be able to also short on OKCoin since they have the borrow feature in the API? It would open a lot more possibilities for arbing, wouldn't it?

Yes, doing short selling on OKCoin will add more opportunities since Bitfinex won't be the only short selling exchange anymore. Unfortunately, the OKCoin API documentation about it is not complete. That being said, if you know how to implement it in C++ or you want to try you are welcome to do a pull request on GitHub.


I'm also curious about what delta limit and aggressive volume stand for in the config?

These two parameters are used to customize the limit orders sent to the exchanges. For obvious risk reasons Blackbird never sends market orders to the exchanges but always limit orders. That being said, how do you define the limit prices in your limit orders? These two parameters help to customize it:

AggressiveVolume
  • true: Blackbird will adapt the limit price to the price that exactly matches the trade's needed liquidity with what is currently available in the exchange order book.
  • false (default): same as above, except that the defined price will be the next entry in the order book to create a kind of a safety net for the trade.
    The difference is that with true the limit price sent to the exchange will be a better one (i.e. more profit on the final trade) but there is a risk that the order is never fully filled because the offered volume at that price is gone. Setting false will generate a less advantageous price but the full order execution should be immediate. This limits the risk of unbalance between the long trade and the short trade.

PriceDeltaLimit
  • If the defined limit price is more than $0.30 disadvantageous regarding the target price then the trade is canceled.
    Example: long trade, target price $381.05, defined limit price $381.42, difference $0.37, trade canceled.

I would strongly suggest to leave these parameters with their default values for the moment.


Please read: If you have troubles installing Blackbird or if you just found a bug please don't post on this thread but open a new issue on the GitHub page instead (link here). Thanks.
newbie
Activity: 1
Merit: 0
Hi!

Wrote a bit here about shorting on OKCoin but realized I just misinterpreted your example so I edited it out. But couldn't you be able to also short on OKCoin since they have the borrow feature in the API? It would open a lot more possibilities for arbing, wouldn't it?

I'm also curious about what delta limit and aggressive volume stand for in the config?

Great job with the software!
legendary
Activity: 1064
Merit: 1000
I have had this program working for about two days now on Ubuntu 14.0.4 (or whatever the latest is, I got it two days ago).  Then I keep getting this error.  Ive compiled it on two different computers but still get the following:


ubuntu@ubuntu:~/blackbird$ ./blackbird
Blackbird Bitcoin Arbitrage
DISCLAIMER: USE THE SOFTWARE AT YOUR OWN RISK.

[ Targets ]
   Spread to enter: 0.20%
   Spread to exit: -0.20%

[ Current balances ]
   Bitfinex:   0.00 USD   0.000000 BTC
   OKCoin:   0.00 USD   0.000000 BTC
   Bitstamp:   0.00 USD   0.056127 BTC
   Gemini:   0.00 USD   0.000000 BTC
   Kraken:   0.00 USD   0.000000 BTC
   ItBit:   0.00 USD   0.000000 BTC

[ Cash exposure ]
   TEST cash used
   Value: $25.00

[ 11/05/2015 00:10:51 ]
   Bitfinex:    385.18 / 391.70
   OKCoin:    391.20 / 394.97
   Bitstamp:    389.82 / 391.00
   Gemini:    415.00 / 420.28
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:



Any ideas on How to troubleshoot this?


It worries me that you are considering putting your BTC into something, and you cannot troubleshoot something this trivial. Please re-read all the documentation and have a good understanding of the system you are using.

Code:
uname -a

will help you resolve:

Quote
I have had this program working for about two days now on Ubuntu 14.0.4 (or whatever the latest is, I got it two days ago). 

and will also help us understand statements such as:

Quote
Ive compiled it on two different computers ....

so that the people you are asking for help are not left pondering what OS you might have tried to compile on.
newbie
Activity: 1
Merit: 0
I have had this program working for about two days now on Ubuntu 14.0.4 (or whatever the latest is, I got it two days ago).  Then I keep getting this error.  Ive compiled it on two different computers but still get the following:


ubuntu@ubuntu:~/blackbird$ ./blackbird
Blackbird Bitcoin Arbitrage
DISCLAIMER: USE THE SOFTWARE AT YOUR OWN RISK.

[ Targets ]
   Spread to enter: 0.20%
   Spread to exit: -0.20%

[ Current balances ]
   Bitfinex:   0.00 USD   0.000000 BTC
   OKCoin:   0.00 USD   0.000000 BTC
   Bitstamp:   0.00 USD   0.056127 BTC
   Gemini:   0.00 USD   0.000000 BTC
   Kraken:   0.00 USD   0.000000 BTC
   ItBit:   0.00 USD   0.000000 BTC

[ Cash exposure ]
   TEST cash used
   Value: $25.00

[ 11/05/2015 00:10:51 ]
   Bitfinex:    385.18 / 391.70
   OKCoin:    391.20 / 394.97
   Bitstamp:    389.82 / 391.00
   Gemini:    415.00 / 420.28
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:
'[' or '{' expected near '<'. Retrying...
Error with JSON:



Any ideas on How to troubleshoot this?
legendary
Activity: 1064
Merit: 1000
Hello Butor,

Thanks for sharing this software, it´s great idea how to trade BTC right now. I was trying to install and launch it through Ubuntu but I wasn´t successful. After typing "make" this message occurs:

src/bitfinex.cpp: In function ‘bool Bitfinex::isOrderComplete(CURL*, Parameters, int)’:
src/bitfinex.cpp:91:73: error: ‘json_boolean_value’ was not declared in this scope
   bool isComplete = !json_boolean_value(json_object_get(root, "is_live"));

Could anybody advice me what to do? I would really appreciate it as I am interested in this project and not really good Linux user.

Thanks in advance.

Install lib Jansson  that should fix the issue.
Code:
apt-get install libjansson-dev
Let me know if it persists.

Thank you Siameze. The question was actually also asked on GitHub (direct link to the issue here).
You need to install Jansson v2.7 as json_boolean_value doesn't exist in the previous versions.




I had forgot to turn on issue tracking and did not see that, thank you! It has run for me without issue though as I already had the necessary libs. Wink
newbie
Activity: 49
Merit: 0
Hello Butor,

Thanks for sharing this software, it´s great idea how to trade BTC right now. I was trying to install and launch it through Ubuntu but I wasn´t successful. After typing "make" this message occurs:

src/bitfinex.cpp: In function ‘bool Bitfinex::isOrderComplete(CURL*, Parameters, int)’:
src/bitfinex.cpp:91:73: error: ‘json_boolean_value’ was not declared in this scope
   bool isComplete = !json_boolean_value(json_object_get(root, "is_live"));

Could anybody advice me what to do? I would really appreciate it as I am interested in this project and not really good Linux user.

Thanks in advance.

Install lib Jansson  that should fix the issue.
Code:
apt-get install libjansson-dev
Let me know if it persists.

Thank you Siameze. The question was actually also asked on GitHub (direct link to the issue here).
You need to install Jansson v2.7 as json_boolean_value doesn't exist in the previous versions.

legendary
Activity: 1064
Merit: 1000
Hello Butor,

Thanks for sharing this software, it´s great idea how to trade BTC right now. I was trying to install and launch it through Ubuntu but I wasn´t successful. After typing "make" this message occurs:

src/bitfinex.cpp: In function ‘bool Bitfinex::isOrderComplete(CURL*, Parameters, int)’:
src/bitfinex.cpp:91:73: error: ‘json_boolean_value’ was not declared in this scope
   bool isComplete = !json_boolean_value(json_object_get(root, "is_live"));

Could anybody advice me what to do? I would really appreciate it as I am interested in this project and not really good Linux user.

Thanks in advance.

Install lib Jansson  that should fix the issue.
Code:
apt-get install libjansson-dev
Let me know if it persists.
sr. member
Activity: 323
Merit: 250
Butor,

What you are doing seems very interesting.
Can you please share what is your long-term plan ?
Are you going to use your own money to trade it, will you be looking for outside investors, or are you planning to keep it open source ?

One piece of advice, which might be helpful to you:
You will get many more arbitrage opportunities if you constantly work your orders on the less liquid exchange and are prepared to hedge your position on the primary exchange once your orders get filled.
If you will wait for the markets to align themselves so that you can you can send orders to both exchanges, most opportunities will pass you by.
newbie
Activity: 49
Merit: 0
Have you been considering running your strategy on btc trading in more than one currency, e.g. BTC/USD and BTC/EUR ?
This way it's likely you will find more price inefficiencies, although you will be adding EUR/USD currency risk (which can be hedged as well).

Yes it's part of our future development plans and the currency conversion will add an extra layer of complexity between the exchanges, so the inefficiency (and thus arbitrage opportunities) will increase. As you mentioned the currency risk will need to be hedged. That's definitely something we will do, we just need to find the time to implement it in Blackbird.

For now we focus on the BTC/USD inefficiencies between US/EU exchanges and Asian exchanges. We just added the new US exchange Gemini to our system (GitHub link here).

sr. member
Activity: 323
Merit: 250
Have you been considering running your strategy on btc trading in more than one currency, e.g. BTC/USD and BTC/EUR ?

This way it's likely you will find more price inneficiencies, although you will be adding EUR/USD currency risk (which can be hedged as well).
newbie
Activity: 49
Merit: 0
2% is not bad at all.There is the possibility to earn more, but always has a risk. As far as I know, arbitrage is 100% secure (if there is something like that) as you only buy/sell when profit is assured.

Just to clarify: the advantage of our strategy is that it eliminates market risk. If the Bitcoin price suddenly drops from $400 to $50 the strategy won't be impacted by this event at all. It's completely independent. Similarly, if the price suddenly rallies from $400 to $800 we unfortunately won't profit from that rally, as we are still independent from the market.

That's why we call it a market-neutral strategy. But please be aware that there are other risks (liquidity risk for example).
newbie
Activity: 49
Merit: 0
Love the work you've done on this and very thoughtful of you to make it open source.

Thank you.


What volatility do you deem efficient enough to use blackbird to trade?

The simple answer is: the higher the better. On the Bitcoin Volatility Index you can follow the 30-day volatility, which is currently 1.44%. This is pretty low. Historically we started to get interesting spreads when the volatility was above 4.00%. I would say that 4.00% was a good volatility for the empirical default parameters SPREAD_ENTRY=0.0030 and SPREAD_EXIT=-0.0040. Now with the current low volatility we are trying to narrow the spread parameters: less spreads but more trades on a shorter timeframe.


While you were already entered into a long and short position have you ever had the short positioned margin be called?  I suppose in that case you're long position would make up for the loss but does blackbird take that transaction into account?

That's a good point and no Blackbird doesn't take into account margin calls for the moment. That being said, the way Blackbird is implemented always makes the initial margin at 100%. Since you can leverage on the short selling exchanges (e.g. 2.5:1) the risk of margin calls stays low. But yes ideally we should take it into account.


legendary
Activity: 1064
Merit: 1000
2% is not bad at all.There is the possibility to earn more, but always has a risk. As far as I know, arbitrage is 100% secure (if there is something like that) as you only buy/sell when profit is assured.

Worst case scenario is not earning anything. Am I right?


I don't consider it bad, especially when it is so easy to use this particular software. Almost like doing nothing for a 2-3% return.

Any trading has it's risk, part of the fun of it. There is also a big difference between the latest "ponzi investment scam game" and arbitrage. If it isn't obvious from my signature, I enjoy options trading too and there are a fair number of places to do this as well. Smiley
hero member
Activity: 770
Merit: 500
✪ NEXCHANGE | BTC, LTC, ETH & DOGE ✪
2% is not bad at all.There is the possibility to earn more, but always has a risk. As far as I know, arbitrage is 100% secure (if there is something like that) as you only buy/sell when profit is assured.

Worst case scenario is not earning anything. Am I right?
legendary
Activity: 1064
Merit: 1000
2% monthly return is quite low profit.  Smiley People trying to get more profit as far as I know  Grin


Maybe one of those HYIP mentioned in your trust references will yield more, then again some people prefer a legit 2% profit as opposed to insane one-time yields.
hero member
Activity: 658
Merit: 500
2% monthly return is quite low profit.  Smiley People trying to get more profit as far as I know  Grin
newbie
Activity: 1
Merit: 0
Hi Butor,

Love the work you've done on this and very thoughtful of you to make it open source.  A couple of questions.

1.) What volatility do you deem efficient enough to use blackbird to trade?

2.) While you were alraedy entered into a long and short position have you ever had the short positioned margin be called?  I suppose in that case you're long position would make up for the loss but does blackbird take that transaction into account?
newbie
Activity: 49
Merit: 0

Any updates on the software as of may/june?

Hi Lawk,

Currently we are working on improving the code itself. No new features but lots of code improvements for better performance and stability. Thanks to a great contributor, Julian Miller, who made many improvements to the code, we have now a better version of Blackbird which is under validation. You can check the details of his work on his GitHub pull request and this will be merged to the main code very soon as everything looks good so far.

Also, we are working on new ideas to optimize the arbitrage mechanism. The current Bitcoin market conditions are not ideal for exchange arbitrage: the low volatility means a more efficient market and thus less arbitrage opportunities. Two examples of new features: trailing stop and parameter adjustments based on the volatility.

Another idea: to do the arbitrage between Bitcoin exchanges in different currencies: the extra layer of currency conversion generates more inefficiencies that can be captured as opportunities. This will be an interesting implementation challenge because we will need to add the real-time currency rate into the spread calculation.


newbie
Activity: 49
Merit: 0
Hi Mattsun,

So much thanks for you detailed answer! It really gives me a brand new perspective of btc arbitrage.
You're welcome. I'm glad it can help you to understand how arbitrage works.


1. How fast is your trading? I believe c++ is fast, but using API to do trade is mostly network bound ( I assume your algorithms don't take very much time...). Are there any special tricks that makes you trading bot fast other than multi-threading pulling real-time data (and use websocket stream wherever you can)?
By default Blackbird gets the prices from the exchanges and analyzes all the spreads every 5 seconds. That 5-second loop is pretty large but it's a simple parameter that you can adjust depending on your machine and Internet connection speed. You shouldn't get any latency issues with the parameter by default and the system can handle temporary network issues: if there is an network problem the system will stop the analysis and check the market data connection every two seconds.
Also, a contributor just found some promising C++ optimizations to make Blackbird more robust and faster. Thanks to him. This will be part of a future release. But if you have some network or C++ knowledge and have some optimization ideas, please reach out on the GitHub page! We use cURL to handle the HTTP requests.


2. Have you considered using some machine learning or statistics algorithm to train the bot? Such as using historical data to predict the trend the exchange price, or decide spreadEntry and spreadExit dynamically?
Absolutely. As I said in a previous post, we are going to dynamically adapt SpreadEnter and SpreadExit based on the short-term volatility. We are also going to use some historical data, however note that it's very tricky to train a system on historical prices because you never know what were the volumes of the historical bids and asks. This can lead to very inaccurate simulations.
Let's say that at a given time, the BTC bid price is $130.00 on a given exchange. It means that a trader is ready to buy some Bitcoin at $130.00. That's great, but how many Bitcoin? 0.10 BTC or 10,000.00 BTC? That makes a huge difference! I won't go into too much details but as a general advice: be always very careful when you backtest a strategy on historical prices only, specially for short-term strategies on illiquid markets like it's the case with Blackbird.

Pages:
Jump to: