Author

Topic: Spot/Futures Arbitrage (with some bots source code) (Read 6311 times)

member
Activity: 112
Merit: 10
Any updates?
hero member
Activity: 674
Merit: 500
A. No, which is why I made the distinction between different arbs.  Arbitrage is risk free in pure form but in practice it refers to buy and selling near simultaneously to a net closed position.  There are no risks involved once the buying and selling are completed.

B. Risk arb is just as I explained which I may have done badly but Wikipedia entry is even worse.  Risk arb isn't just about mergers and what hedge funds do.  It is buy and selling a security with the same risk characterics but not resulting in closed positions.  The open position means that there are somewhere, something that can blow up your arb position.  There is still some sort of risk.  You are just taking advantage of price discrepancies of one sort or another.  THIS WAS THE POINT OF MY POST.  ARBITRAGE AS IS PRACTICED STILL HAS RISKS AND I JUST WANTED TO POINT THAT OUT.  Sorry, for yelling, but you need to think through the question "how does this blow up in my face?"

C. I have been a member of a variety of those exchanges and have done various forms of arbitrage.  Surprisingly, I am now an academic or a few months short of it technically.

There is no question about your education, especially when you provide correct answers now (which contradict to what you said one post earlier) Smiley

And btw, nitpicking, you are still slightly wrong in the point A. In real world in spot/futures arbitrage there still is a risk that the trader can't manage to keep up his margin to a level preventing forced liquidation of his open positions in case of a big and rapid market movement against one side of his position in futures.

For the readers who are following this topic, I will quote "Options, Futures and other Derivatives" by John C. Hull book, Chapter 1, section 1.9:
Quote
Arbitrageurs are a third important group of participants in futures... market. Arbitrage involves locking in a riskless profit by simulteneously entering into transactions in two or more markets.

full member
Activity: 163
Merit: 100

Classical Arbitrage
Wikipedia explanation: http://en.wikipedia.org/wiki/Spot-future_parity
Basically, arbitraging means that you get the profit no matter which way the price moves. Futures arbitrage is a way of taking advantage from price difference of the underlying asset and the price of its futures contract.
Every futures contract gets mispriced from time to time and arbitragers can profit from that.
Actually, to be pedantic, pure arbitrage is the near simultaneous buying and selling of a security.  What you are going for is risk arbitrage.  Risk arbitrage is different in that positions in securities are still open which can lead to exposure to other sources of problems.

Sorry, but to be pedantic, I have to answer Smiley
a. Arbitrage (in economics and finance) is the practice of taking advantage of a price difference between two or more markets [1]
b. Risk arbitrage is a totally different thing that you are trying to explain to me. One way of defining Risk arbitrage is given in [2], and confirmed in [1] too.
c. What I am describing is the known for many decades spot/futures arbitrage. See second paragraph in section Examples of [1] for an example involving american stock exchanges.


References
1. http://en.wikipedia.org/wiki/Arbitrage
2. http://en.wikipedia.org/wiki/Risk_arbitrage
I realize Wikipedia may not be scientifically correct, however I consider these specific articles above to be good enough for referencing.
A. No, which is why I made the distinction between different arbs.  Arbitrage is risk free in pure form but in practice it refers to buy and selling near simultaneously to a net closed position.  There are no risks involved once the buying and selling are completed.

B. Risk arb is just as I explained which I may have done badly but Wikipedia entry is even worse.  Risk arb isn't just about mergers and what hedge funds do.  It is buy and selling a security with the same risk characterics but not resulting in closed positions.  The open position means that there are somewhere, something that can blow up your arb position.  There is still some sort of risk.  You are just taking advantage of price discrepancies of one sort or another.  THIS WAS THE POINT OF MY POST.  ARBITRAGE AS IS PRACTICED STILL HAS RISKS AND I JUST WANTED TO POINT THAT OUT.  Sorry, for yelling, but you need to think through the question "how does this blow up in my face?"

C. I have been a member of a variety of those exchanges and have done various forms of arbitrage.  Surprisingly, I am now an academic or a few months short of it technically.
hero member
Activity: 674
Merit: 500

Classical Arbitrage
Wikipedia explanation: http://en.wikipedia.org/wiki/Spot-future_parity
Basically, arbitraging means that you get the profit no matter which way the price moves. Futures arbitrage is a way of taking advantage from price difference of the underlying asset and the price of its futures contract.
Every futures contract gets mispriced from time to time and arbitragers can profit from that.
Actually, to be pedantic, pure arbitrage is the near simultaneous buying and selling of a security.  What you are going for is risk arbitrage.  Risk arbitrage is different in that positions in securities are still open which can lead to exposure to other sources of problems.

Sorry, but to be pedantic, I have to answer Smiley
a. Arbitrage (in economics and finance) is the practice of taking advantage of a price difference between two or more markets [1]
b. Risk arbitrage is a totally different thing that you are trying to explain to me. One way of defining Risk arbitrage is given in [2], and confirmed in [1] too.
c. What I am describing is the known for many decades spot/futures arbitrage. See second paragraph in section Examples of [1] for an example involving american stock exchanges.


References
1. http://en.wikipedia.org/wiki/Arbitrage
2. http://en.wikipedia.org/wiki/Risk_arbitrage
I realize Wikipedia may not be scientifically correct, however I consider these specific articles above to be good enough for referencing.
full member
Activity: 163
Merit: 100


Classical Arbitrage
Wikipedia explanation: http://en.wikipedia.org/wiki/Spot-future_parity
Basically, arbitraging means that you get the profit no matter which way the price moves. Futures arbitrage is a way of taking advantage from price difference of the underlying asset and the price of its futures contract.
Every futures contract gets mispriced from time to time and arbitragers can profit from that.
Actually, to be pedantic, pure arbitrage is the near simultaneous buying and selling of a security.  What you are going for is risk arbitrage.  Risk arbitrage is different in that positions in securities are still open which can lead to exposure to other sources of problems.  Even further, theoretical arbitrage is valuation based on models and the buying and selling of securities is based on these.  You want to to do the second.  The common risk referenced in risk arb is direction risk which is how you want to use it.  There is still tremendous risk after a position is put on though.  Interest rate risk, pin risk, credit risk and final settlement price manipulation can all affect the outcome and lead to ruin.  Oh yeah, a lot direction risk arb still carry directional risk.  Can you guess why?
Quote
For example, right now average rate of BTC/USD futures at ICBIT is $14.66 and spot price at MtGox is $13.30, hence the difference being $1.30 !



Both ways will get you profit.
As it's already noted, it's not necessary to wait till futures settlement. Many (the vast majority of traders on fiat-money exchanges for example) trade futures spread instead: open arbitrage positions when the spread is high, close arbitrage positions when the spread is low.

Arbitraging with bitcoins is not harder than arbitraging on fiat-money exchanges, even simpler, but you need to understand a few important points:
1. BTCUSD futures contracts price is in USD, however profit/loss is accounted in BTC. Every contract is for $10. This makes it a bit harder to understand, but it makes it very easy to arbitrage (you have the same price scale: US dollars per 1 bitcoin). Contract explained here: https://icbit.se/BUH3
2. To buy/sell contracts on ICBIT you only need bitcoins. Marginal trading is available at no additional cost.
3. To buy/sell BTC on MtGox, you need to either have US dollars, or to have BTC which you want to sell in exchange for US dollars.
4. If you want to get your profit in US dollars, you may need to convert it to US dollars on some exchange (might be using ICBIT's exchange section, but it lacks volume now).

I agree it isn't harder that's because you are not dealing with interest rate.  There isn't a viable one to base it on as the Bitcoin equivalent of Broker/Dealers aren't sophisticated enough yet.  Arbitrage is profitable in the regulated securities market because of leverage.  Otherwise, opportunity would present itself a lot more in these markets.  Arb will exist until somebody in the Bitcoin universe can figure out how to do it more efficiently.

Honestly, I'm too worried about credit risk to put too much money into it.  I'll just buy an odd bitcoin here and there and play BJ.
hero member
Activity: 674
Merit: 500
I am try to write programm, but have not full information about api.
Exemple of problem: when i subscribed to chanell 'orderbook_BUH3', i dont recieve  messages about available orders!
Who can help me??? (I using socket.io in node.js)


Try to put the following code in a simple html file, open it up with your browser and check whether it works, try to see what messages you get, etc.

Code:


full member
Activity: 124
Merit: 100
I am try to write programm, but have not full information about api.
Exemple of problem: when i subscribed to chanell 'orderbook_BUH3', i dont recieve  messages about available orders!
Who can help me??? (I using socket.io in node.js)
full member
Activity: 131
Merit: 100
no code no fun Grin
hero member
Activity: 674
Merit: 500
Reference library for accessing ICBIT and MtGox APIs using node.js: https://github.com/icbit/trader.nodejs
Other stuff: To Be Added

Disclaimer: Always check and understand the code yourself before using it! Neither ICBIT nor its founders are liable for your profits or losses made using the above code. ICBIT API is subject to change, make sure to watch ICBIT website's API page and its official Twitter channel for possible announcements about API changes!
hero member
Activity: 674
Merit: 500
Hello,
in this thread I would like to discuss spot/futures arbitrage basic ideas, provide reference implementations and listen to your suggestions.

Classical Arbitrage
Wikipedia explanation: http://en.wikipedia.org/wiki/Spot-future_parity
Basically, arbitraging means that you get the profit no matter which way the price moves. Futures arbitrage is a way of taking advantage from price difference of the underlying asset and the price of its futures contract.
Every futures contract gets mispriced from time to time and arbitragers can profit from that.
For example, right now average rate of BTC/USD futures at ICBIT is $14.66 and spot price at MtGox is $13.30, hence the difference being $1.30 !

How to actually get profit from that? Two ways exist:
1. "Long the basis":
 a. Buy BTC on MtGox for USD (which you own) and sell futures contracts on ICBIT.
 b. Close positions (buy futures contracts on ICBIT and sell BTC on MtGox) when the futures spread (spot/futures price difference) changed enough for you to get profit.
or
 c. Wait till futures contract is settled and sell BTC on MtGox

2. "Short the basis":
 a. Sell BTC (which you own) on MtGox for USD and buy futures contracts on ICBIT
 b. Close positions (sell futures contracts on ICBIT and buy BTC on MtGox back) when the futures spread (spot/futures price difference) changed enough for you to get profit.
or
 c. Wait till futures contract is settled and buy BTC on MtGox

Both ways will get you profit.
As it's already noted, it's not necessary to wait till futures settlement. Many (the vast majority of traders on fiat-money exchanges for example) trade futures spread instead: open arbitrage positions when the spread is high, close arbitrage positions when the spread is low.

Arbitraging with bitcoins is not harder than arbitraging on fiat-money exchanges, even simpler, but you need to understand a few important points:
1. BTCUSD futures contracts price is in USD, however profit/loss is accounted in BTC. Every contract is for $10. This makes it a bit harder to understand, but it makes it very easy to arbitrage (you have the same price scale: US dollars per 1 bitcoin). Contract explained here: https://icbit.se/BUH3
2. To buy/sell contracts on ICBIT you only need bitcoins. Marginal trading is available at no additional cost.
3. To buy/sell BTC on MtGox, you need to either have US dollars, or to have BTC which you want to sell in exchange for US dollars.
4. If you want to get your profit in US dollars, you may need to convert it to US dollars on some exchange (might be using ICBIT's exchange section, but it lacks volume now).

Example:
John opens his arbitrage position by buying 100 BTC on MtGox spending $1330, and selling 133 futures contracts on ICBIT for $14.66 (requiring a maintenance deposit of 14 BTC on his account there).
Some hours later the prices converge a bit, with MtGox being at $13.8, and ICBIT being $14.0.
So John buys back 133 futures contracts for $14.00 providing him positive variation margin on ICBIT equal to Profit = ((1 / 14.0 - 1 / 14.66) * -10) * -133 =  4.277 BTC (converted to US dollars that's $59)
and sells his position on MtGox which gives him $1380, plus $59 on ICBIT's account in BTC, thus totalling in $109 profit.

Another example:
John opens his arbitrage position by buying 100 BTC on MtGox spending $1330, and selling 133 futures contracts on ICBIT for $14.66 (requiring a maintenance deposit of 14 BTC on his account there).
Some days later the contract is settled on the sport price at MtGox being $13.0.
So John gets his 133 futures contracts settled on $13.00 providing him positive variation margin on ICBIT equal to Profit = ((1 / 13.0 - 1 / 14.66) * -10) * -133 =  11.585 BTC (converted to US dollars that's $150)
and sells his position on MtGox which gives him $1300 (a loss of $30 bucks) and $150 on ICBIT's account in BTC, thus totalling in $120 profit.

The basic idea is, wherever market moves, your profit is guaranteed.

Capt. Obvious suggests that automated arbitrage would be the best Smiley I will edit this post to add information about actual automated trading bots and API discussion, but before I do that, please let me know if you have any questions about the above.
Jump to: