Bitcoin Forum
December 02, 2016, 08:31:31 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2]  All
  Print  
Author Topic: Reverse-engineering and documenting Bitcoinica  (Read 2758 times)
dogisland
Sr. Member
****
Offline Offline

Activity: 261



View Profile
July 19, 2012, 12:35:52 PM
 #21

davout, or anyone really. I have a question about the business model, although it may come from a misunderstanding on my part.

Let's say you're offering 10:1 margin.

Just 2 customers for simplicity, both charge there accounts with 1BTC and therefore have 10BTC to play with (due to the 10:1 margin)

Customer A goes long on Bitcoin i.e. Buys 10BTC (remember the 10BTC is borrowed money)
Customer B goes short on Bitcoin i.e. Sells 10BTC.

Now this looks perfectly balanced, as the BTC price moves up and down your position as a bitcoinica clone is flat (Bitclonica ?)

Now say they both close their positions, one of them will be in profit, the other in loss. How do you get the loser to pay their debt ?

In fact, couldn't I just keep opening Bitclonica accounts and go long and short at the same time and never pay off my losing accounts ?

Then my second concern is hedging.

Say you now have 10 customers, 9 are long 1 is short. Let's say the 9 customers are winning how would you effectively hedge your own position ?





1480710691
Hero Member
*
Offline Offline

Posts: 1480710691

View Profile Personal Message (Offline)

Ignore
1480710691
Reply with quote  #2

1480710691
Report to moderator
1480710691
Hero Member
*
Offline Offline

Posts: 1480710691

View Profile Personal Message (Offline)

Ignore
1480710691
Reply with quote  #2

1480710691
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
hazek
Legendary
*
Offline Offline

Activity: 1078


View Profile
July 19, 2012, 02:20:07 PM
 #22

How do you get the loser to pay their debt ?

You liquidate his position before his account runs out of money. Simple really. The only problem appears when you can't liquidate him fast enough..

My personality type: INTJ - please forgive my weaknesses (Not naturally in tune with others feelings; may be insensitive at times, tend to respond to conflict with logic and reason, tend to believe I'm always right)

If however you enjoyed my post: 15j781DjuJeVsZgYbDVt2NZsGrWKRWFHpp
dogisland
Sr. Member
****
Offline Offline

Activity: 261



View Profile
July 19, 2012, 03:22:05 PM
 #23

How do you get the loser to pay their debt ?

You liquidate his position before his account runs out of money. Simple really. The only problem appears when you can't liquidate him fast enough..

But you've extended him a loan of 10BTC against his 1BTC. So are you saying you liquidate him at 1BTC of losses ?
runlinux
Hero Member
*****
Offline Offline

Activity: 567



View Profile WWW
July 19, 2012, 03:33:43 PM
 #24

^^ yup

davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
July 19, 2012, 03:39:37 PM
 #25

How do you get the loser to pay their debt ?

You liquidate his position before his account runs out of money. Simple really. The only problem appears when you can't liquidate him fast enough..

But you've extended him a loan of 10BTC against his 1BTC. So are you saying you liquidate him at 1BTC of losses ?

With 1:1 leverage you can let the customer have a 100% loss basically.
With 10:1 leverage, you need to force-liquidate the position as soon as there is a small price movement in the opposite direction of the postion in order to *at least* get the amount that was loaned. The house reimburses itself and the customer loses everything.

hazek
Legendary
*
Offline Offline

Activity: 1078


View Profile
July 19, 2012, 04:03:07 PM
 #26

How do you get the loser to pay their debt ?

You liquidate his position before his account runs out of money. Simple really. The only problem appears when you can't liquidate him fast enough..

But you've extended him a loan of 10BTC against his 1BTC. So are you saying you liquidate him at 1BTC of losses ?

No, you do it even sooner, because if you do it at 1BTC losses then you risk not being able to liquidate fast enough and you as the exchange incur losses from his position.

My personality type: INTJ - please forgive my weaknesses (Not naturally in tune with others feelings; may be insensitive at times, tend to respond to conflict with logic and reason, tend to believe I'm always right)

If however you enjoyed my post: 15j781DjuJeVsZgYbDVt2NZsGrWKRWFHpp
dooglus
Legendary
*
Offline Offline

Activity: 1988



View Profile
July 20, 2012, 06:24:23 AM
 #27

What if you only have one customer.  He deposits 1 BTC and shorts at 10x leverage.  Then the price of Bitcoin drops by a factor of 10 and he closes his position.

His balance is now 100 BTC.  Where do you get the coins from to pay him?

dogisland
Sr. Member
****
Offline Offline

Activity: 261



View Profile
July 20, 2012, 09:31:40 AM
 #28

What if you only have one customer.  He deposits 1 BTC and shorts at 10x leverage.  Then the price of Bitcoin drops by a factor of 10 and he closes his position.

His balance is now 100 BTC.  Where do you get the coins from to pay him?

Yes. I was thinking about this too. It's where hedging comes in.

Here's how I think it works. You would have 2 hedging accounts one in $ the other in BTC (Because we are buying and selling against the dollar). These accounts would be at MtGox

i.e. Dollar account $10,000
Bitcoin account 10,000BTC

To perfectly hedge each trade we have to buy and sell from our hedging accounts to match the trade.

So in your example. He deposits 1BTC and sells (goes short) x10 on BTC. So he is short 10BTC.

The Bitcoinica clone would also have to sell 10BTC, i.e. convert 10BTC from the bitcoin account into the dollar account.

That way if the price falls the profit the trader makes is made up by the gains in the dollar account.

Can anyone correct my logic here ?

dooglus
Legendary
*
Offline Offline

Activity: 1988



View Profile
July 20, 2012, 06:34:53 PM
 #29

Here's how I think it works. You would have 2 hedging accounts one in $ the other in BTC (Because we are buying and selling against the dollar). These accounts would be at MtGox

i.e. Dollar account $10,000
Bitcoin account 10,000BTC

To perfectly hedge each trade we have to buy and sell from our hedging accounts to match the trade.

So in your example. He deposits 1BTC and sells (goes short) x10 on BTC. So he is short 10BTC.

The Bitcoinica clone would also have to sell 10BTC, i.e. convert 10BTC from the bitcoin account into the dollar account.

That way if the price falls the profit the trader makes is made up by the gains in the dollar account.

Can anyone correct my logic here ?

That makes sense, and is I guess how it worked.

Assuming the price of BTC started at $10 and ended at $1, when the customer closes his position you can buy back the 100 BTC for the $100 you made by selling 10 BTC when the customer first shorted, so you end up with $10k and 10k BTC again.

The problem is that now your 10k BTC are worth only $10k, whereas before they were worth $100k.  You've lost $90,000 on the deal by being long BTC while the price crashed.  Maybe this is why Bitcoinica borrowed BTC from customers, so they wouldn't be exposed to the currency risk.

dogisland
Sr. Member
****
Offline Offline

Activity: 261



View Profile
July 21, 2012, 10:52:46 AM
 #30

Here's how I think it works. You would have 2 hedging accounts one in $ the other in BTC (Because we are buying and selling against the dollar). These accounts would be at MtGox

i.e. Dollar account $10,000
Bitcoin account 10,000BTC

To perfectly hedge each trade we have to buy and sell from our hedging accounts to match the trade.

So in your example. He deposits 1BTC and sells (goes short) x10 on BTC. So he is short 10BTC.

The Bitcoinica clone would also have to sell 10BTC, i.e. convert 10BTC from the bitcoin account into the dollar account.

That way if the price falls the profit the trader makes is made up by the gains in the dollar account.

Can anyone correct my logic here ?

That makes sense, and is I guess how it worked.

Assuming the price of BTC started at $10 and ended at $1, when the customer closes his position you can buy back the 100 BTC for the $100 you made by selling 10 BTC when the customer first shorted, so you end up with $10k and 10k BTC again.

The problem is that now your 10k BTC are worth only $10k, whereas before they were worth $100k.  You've lost $90,000 on the deal by being long BTC while the price crashed.  Maybe this is why Bitcoinica borrowed BTC from customers, so they wouldn't be exposed to the currency risk.

That risk can be lessened by matching trades.  So for every person that goes long 1BTC you need another person to go short 1BTC so your position is flat.

I'm not sure if Bitcoinica did it this way or not. So as a user you say to the system I want to go long BTC. Your trade is only fulfilled when it is matches with the opposite trade.

If a match is not found the trade goes unfulfilled. I guess you could use the price to encourage people to trade one way or the other.

This is a complicated risky business.
dooglus
Legendary
*
Offline Offline

Activity: 1988



View Profile
July 21, 2012, 07:19:41 PM
 #31

That risk can be lessened by matching trades.  So for every person that goes long 1BTC you need another person to go short 1BTC so your position is flat.

I'm not sure if Bitcoinica did it this way or not. So as a user you say to the system I want to go long BTC. Your trade is only fulfilled when it is matches with the opposite trade.

If a match is not found the trade goes unfulfilled. I guess you could use the price to encourage people to trade one way or the other.

This is a complicated risky business.

Sure, you can reduce the risk by matching trades, which is why in my example they only had 1 customer...

But even with matched trades, it the price moves too far you end up liquidating the losers' positions (you pretty much break even on those - you can use the money they lose to pay the winners, and keep the spread for yourself) but then you're left with an unbalanced book.  The winners still have positions which now aren't matched by anyone taking the opposite position, since they've been liquidated and so I guess you have to pass their positions on to your hedging accounts at gox.

EnergyVampire
Full Member
***
Offline Offline

Activity: 210



View Profile
July 21, 2012, 08:44:37 PM
 #32

I'm not sure if I'm reading the pasty correctly: http://pastie.org/4257541

Was Bitcoinica logging into MtGox every 5 seconds?

talpan
Full Member
***
Offline Offline

Activity: 228


View Profile
July 23, 2012, 09:00:52 PM
 #33

Hey,

thank you all for sharing!
I will be looking into it, and probably rebuilding it in PHP.

Let's see how it goes Smiley


the best,
talpan
davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
July 23, 2012, 09:03:42 PM
 #34

I'm not sure if I'm reading the pasty correctly: http://pastie.org/4257541

Was Bitcoinica logging into MtGox every 5 seconds?
Yep, to fetch the orderbook and compute their ticker buy and sell prices.

EnergyVampire
Full Member
***
Offline Offline

Activity: 210



View Profile
July 24, 2012, 12:06:56 AM
 #35

I'm not sure if I'm reading the pasty correctly: http://pastie.org/4257541

Was Bitcoinica logging into MtGox every 5 seconds?
Yep, to fetch the orderbook and compute their ticker buy and sell prices.

Considering that all this data is available from MtGox, Intersango, and most exchanges with no authentication required...

Is there an advantage to authenticating 17,280 per day to collect the same public information?

davout
Legendary
*
Offline Offline

Activity: 1358


1davout


View Profile WWW
July 24, 2012, 12:18:23 AM
 #36

The information changes all the time and the call to fetch it is not authenticated.
What bothers you exactly ?

EnergyVampire
Full Member
***
Offline Offline

Activity: 210



View Profile
July 24, 2012, 12:27:57 AM
 #37

The information changes all the time and the call to fetch it is not authenticated.
What bothers you exactly ?


Okay, so Bitcoinica wasn't actually logging in (authenticating) every 5 seconds. I guess that's the part that gave me the "Deer in headlights" confusion.  Cheesy

Thanks for clarifying this for me, davout.

Pages: « 1 [2]  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!