Bitcoin Forum
December 06, 2016, 08:34:11 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: BTC/USD futures settled in BTC exchange (alpha version)  (Read 1851 times)
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 09, 2011, 03:30:20 PM
 #1

Old forum thread for context: http://forum.bitcoin.org/index.php?topic=5529.0

Current version works with a single type of contract: capped BTC/USD futures settled in BTC, with MtGox used as a spot price.

Here's what it means, how it works and why it makes sense:

Let's say Alice wants to sell 100 BTC for 30 USD each on a certain date (like 2011-06-15) and Bob wants to buy it. However they do not want to deal with USD because it is messy (not anonymous! subject to regulations!) and instead agree to settle in bitcoins. I.e. instead of giving Alice 30*100 = 3000 USD Bob will give her an equivalent in BTC.

Of course they need to decide what is equivalent. For example, they can agree on smoothed out MtGox price, like 24h average.

1. If MtGox price goes to 40 by the settlement date then Bob owes Alice 3000 USD / 40 = 75 BTC.

2. If it goes to 25 then it is 3000 / 25 = 120 BTC.

So in the first scenario Bob gives Alice 75 BTC and she give him 100 BTC back (amount of BTC sold). So if Bob agreed to buy at 30 BTC/USD but price went up to 40 BTC/USD he have earned 25 BTC and instead of sending money back and forth Alice can send him this sum and they'll be settled.

Likewise, if price goes down (Bob bought BTC for higher price then real price is) Bob has a 20 BTC loss and needs to send this to Alice.

So you can see this as a bet where parties agree to pay each other depending on external conditions, but in theory if Alice actually wants to buy USD she can jump to MtGox, do the trade and get them.

But as bitcoins are kinda anonymous it is hard to enforce this contract (if Bob have lost the bet he will pretend he is dead), so Alice and Bob ask a trusted 3rd party -- let's call him killerstorm -- to make sure that agreement is enforced.

Killerstorm will take money both from Alice and Bob and hold it as a reserve. At the date of settlement he will compute who owes whom how much and will move money, returning unused reserves. But now we have to deal with situation that reserves are finite and need to be available at date of agreement, not at date of settlement. Each party's profit is limited by reserve his counterparty have made and his loss is limited by reserve he made. So each party is interested in making his reserve as small as possible while conterparty's reserve is adequate. (Also it is possible that they don't have that much BTC on agreement date so reserve percentage limits contract amount.)

Reserve amounts define price range in which settlement will be exact. For example, if Bob reserves 20 BTC and Alice reserves 25 BTC then they can settle exactly as long as price is in 25..40 USD-per-BTC range. If it shots to 45, for example, Bob will get only part of his possible profit. This is why we call them capped futures.

(Note that it doesn't make sense to reserve more than 100% of contract amount for seller -- seller never takes loss higher than what he sells. Buyer's loss in BTC is potentially unbound, though -- if BTC price drops to, say, 0.01 he would need lots of BTC to settle the contract.)

So, as you might have guessed, I made a service which implements this kind of trading. It is not 100% ready yet, but at least it can accept orders, make contracts, calculate spot price and do the settlements. So I think it is usable.

But I run it on testnet for now. So instead of bitcoins it works with testcoins. Also, withdrawals are disabled. But I'll promise I'll send all testcoins I've received to the faucet. Smiley

EDIT: Due to apparent lack of interest in testnet version I've switched it to real bitcoins, but please not deposit more than a few cents -- software is not well tested yet. Minimal order is 0.001 so even one cent is enough for testing.

So here is it: http://killerstorm.xen.prgmr.com:31337/st/main.html (apparently, it is a temporary URL).

And here is how you can test it:

1. Go to http://killerstorm.xen.prgmr.com:31337/st/main.html, choose login/password and click register.

2. It it works you'll see your account (empty) and address to fill it. Note it is a TESTnet address, not Bitcoin address. If you don't have testcoins you can get them from the Faucet http://testnet.freebitcoins.appspot.com/. Then you have to wait for a single confirmation, ~10 minutes and hit 'update balance'. (Note: if server sees your transaction address will change, but it will show money only when 1 confirmation is made). (Sometimes if bitcoind hangs my server hangs too, so if it doesn't work please retry some time later.)

3. Meanwhile you can explore 'order book' (probably empty at start) and spot price sections.

4. Once you've got money on balance go to My Orders and hit 'place new order' button. You will see a dialog which is fairly obvious. Maturity is in days, e.g. +1 is next day. Price is how much USD you think one BTC will cost. Seller/buyer reserve percentage is relative to order amount in BTC, e.g. 100 BTC contract with 50% percentage means that 50 BTC is reserved. Placing order costs you 0.0001 (t)BTC. Once you place it it can be filled partially from orders currently in order book and the rest will show up in 'my orders'. When exchange sees orders in different directions which agree in price it destroys them and creates corresponding contracts. Go to 'my contracts' to see them.

5. At around 00:01 UTC (GMT) settlement will be made. Orders and contracts will be wiped, you will get money on balance and you'll see how much you've earned/lost

So, testing will take about 10 minutes to move money and <24h to see settlement. (Hmm, if you people do not like that and want to try trading part faster I can give some fake amount to each new account and set up more frequent settlements.)

On the technical side it is implemented via JSON-RPC so you can write a bot or make an alternative client.

If there is enough interest I will launch server working with real BTC (EDIT: done!), but as it is an 'alpha'-quality version I would recommend depositing no more than 0.02 BTC Smiley

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
1481013251
Hero Member
*
Offline Offline

Posts: 1481013251

View Profile Personal Message (Offline)

Ignore
1481013251
Reply with quote  #2

1481013251
Report to moderator
1481013251
Hero Member
*
Offline Offline

Posts: 1481013251

View Profile Personal Message (Offline)

Ignore
1481013251
Reply with quote  #2

1481013251
Report to moderator
1481013251
Hero Member
*
Offline Offline

Posts: 1481013251

View Profile Personal Message (Offline)

Ignore
1481013251
Reply with quote  #2

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

Posts: 1481013251

View Profile Personal Message (Offline)

Ignore
1481013251
Reply with quote  #2

1481013251
Report to moderator
1481013251
Hero Member
*
Offline Offline

Posts: 1481013251

View Profile Personal Message (Offline)

Ignore
1481013251
Reply with quote  #2

1481013251
Report to moderator
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 09, 2011, 03:33:27 PM
 #2

'Capped futures' with full reserves are generally useful for making bets about short-term bitcoin price moves while still keeping bitcoins.

It is of limited use in case you're a merchant who accepts BTC and would like to hedge against possible price drop before he cashes out into USD: the need to make upfront reserve makes it less attractive. But if you keep some sum in BTC as a reserve you can use it for a futures contract with, say, 25% seller reserve and 50% buyer reserve, it would be better than nothing, I think. Or if you do settlements frequently (each day instead of each week) you don't need that much for reserves.

I'm planning to implement capped options next: using options you pay one-time, fixed price and enjoy protection against BTC exchange rate drops (within certain limits).

Current version is not friendly to arbitragers and market makers because you need to make individual reserve for each contract.

I'm going to fix it in the next version: if you'll have contracts going into opposite directions for a single settlement date they will essentially cancel out and you won't need to reserve for a second one. (Moreover, your currently reserved money can be freed up!)

And, finally, I'm going to implement contracts which won't need full reserves and won't be capped, but will be based on trust and insurance. Also I can implement reservation/settlements in USD (and other currencies) but only if I'll find a partner who will handle financial part 'coz I don't want to deal with official currencies myself. (Oppressive gov't etc.)

Long term plans include trading on other currencies and pretty much everything you can assign monetary value to. All it needs is a reliable way to assign spot price which cannot be easily manipulated.

There are things called prediction markets where you can even trade on events.

One particular thing which should be interesting to Bitcoin miners is betting on Bitcoin mining difficulty: when you buy a mining rig you invest your money and expect certain money flow. If difficulty goes too high they won't return their investment. So we can issue a swap contract which will exchange a variable Bitcoin cash flow which one gets from mining for a fixed cash flow at a certain difficulty. So, essentially, you can sell your hashrate on the market and get a fixed profit no matter where difficulty goes.

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 09, 2011, 09:33:30 PM
 #3

I've switched it to use real Bitcoins in hope to get some attention (I've got like 10 people registered and looked around but nobody bothered to deposit testcoins). Seriously, WTF, announcement of upcoming project got much more attention than a working service...

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
dacoinminster
Legendary
*
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
June 10, 2011, 12:21:31 AM
 #4

Don't despair yet! I'm poking around the site right now.

Edit: I deposited 0.03 BTC. I placed a "buy" order at $30 for 0.03 BTC with maturity +1. I think that should be attractive to anyone wanting to short bitcoins since (I think) I am offering a higher settlement price than the current price.

Questions:

 - If someone takes the other side of my bet, what time do you settle the contract tomorrow?
 - It looks like I can't cancel the bet and put a longer maturity on it?
 - You say you charge a fee to place a bet, but I was able to wager the entire 0.03 BTC I deposited. Shouldn't the fee have been subtracted first?

killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 10, 2011, 12:52:34 AM
 #5

Thank you!

BTW, there is a know bug: if you leave browser for a long time session will expire, but UI won't tell you. So just reload page if it acts strangely and re-login. Also I've noticed sometimes bitcoind hangs and then site hangs too, then I'll need to restart it manually...

Quote
If someone takes the other side of my bet, what time do you settle the contract tomorrow?

2011-06-11 00:01 GMT

Quote
It looks like I can't cancel the bet and put a longer maturity on it?

Yep I see this as a deficiency too. I'll add a button to cancel order, but not contract.

But you'll be able to effectively cancel contract by doing a contract in opposite direction... Some time in future.

Quote
You say you charge a fee to place a bet, but I was able to wager the entire 0.03 BTC I deposited. Shouldn't the fee have been subtracted first?

If you set 50% reserve for buyer then you need only 0.015 BTC to place 0.03 BTC order plus 0.0001 in a fee. So you have 0.0149 for another order. (Keep in mind that there will be another fee and possible rounding effects.)

Note that service does simple sanity checks for orders but you can still issue many orders even if their total sum of reserves exceeds balance you have. In other words, actual reservation is made for contracts. It is a feature... or a bug.

Exchange does additional checks when orders are filled so wrong orders would not hurt.

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
dacoinminster
Legendary
*
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
June 10, 2011, 01:20:39 PM
 #6

A few more comments:

 - I think it would be better to take your commission out of the trade/contract than out of the order. If for no other reason, do it that way because that is the way real exchanges do it.

 - It's after midnight GMT, but my order is still live. Is the maturity date not decided until someone takes the other side? People are going to want to set the maturity date at the time they place the order, IMHO

 - You really ought to seed the exchange with some orders of your own money, even if they are not attractive orders (buys below the spot, sells above the spot). Otherwise people will assume that you don't trust the exchange with your own money.

 - Have you considered posting bond to increase your trustworthiness? (see how I did it in my "futures" thread in my sig)

 - You're going to need your own domain name before people will take this service seriously

Thanks for doing this!

killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 10, 2011, 05:20:25 PM
 #7

- I think it would be better to take your commission out of the trade/contract than out of the order. If for no other reason, do it that way because that is the way real exchanges do it.

My intent was to prevent order spam like creating tons of small silly orders or something like that. You can do that but you need to pay for it.
I see how commission might be frustrating if order did not work, but I guess it will be less of an issue when exchange goes more lively.

Fee is tiny anyway.

What do you think about making reservation at time of making order? My rationale for not making reservation is to help market makers who would make orders in different directions: if one order is filled then they won't need reserves for another one.
Also people might try to place orders on different dates to see which one works.

But maybe it is better to make sure that there is enough reserves for orders all the time. And then if, say, market makers want it other way this over-commit feature can be enabled for them specifically.

Quote
- It's after midnight GMT, but my order is still live. Is the maturity date not decided until someone takes the other side? People are going to want to set the maturity date at the time they place the order, IMHO

You've placed your order on 2011-06-10 00:27:26. Currently time is 2011-06-10 17:00:21.
It will expire at 2011-06-11 00:01.

http://wwp.greenwichmeantime.com/

Quote
- You really ought to seed the exchange with some orders of your own money, even if they are not attractive orders (buys below the spot, sells above the spot). Otherwise people will assume that you don't trust the exchange with your own money.

Yep, I see. Other people pointed that out too.

A problem is that I have only 0.02 BTC and buying them is kinda of PITA Smiley

But my hope was that people would be more eager to play with a few bitcents.

Anyway I'll try to populate it with my own money for the beta release.

Quote
- Have you considered posting bond to increase your trustworthiness? (see how I did it in my "futures" thread in my sig)

Thanks, that's a good idea.

Quote
- You're going to need your own domain name before people will take this service seriously

Yep, I see. But the ugly URL kinda warns people that software is of alpha quality and they shouldn't send tons of money here Smiley

Quote
Thanks for doing this!

Thank you too.

As you probably noticed, there is one more user. He have almost made a contract with you, but he set 100% seller reserve requirement instead of 50% default, so it did not work.

I think exchange should have created contract anyway because when seller sets reserve percent to 100% this means that he would reserve up to 100%, but reserving less shouldn't be a problem.

So I think it should have made contract with 50%/50% reserves even seller could pay more. But I just haven't implemented this logic yet.

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
bitoption
Jr. Member
*
Offline Offline

Activity: 56


View Profile WWW
June 10, 2011, 08:15:02 PM
 #8

Many of the uses cases for this could be done at the bitoption market as well.

----** In Beta: The First Bitcoin Options Market ----**

Explanation and discussion: http://forum.bitcoin.org/index.php?topic=9611.0

API Developer Thread:
http://forum.bitcoin.org/index.php?topic=14194.0

-----------------------------------------------------------
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 10, 2011, 09:14:04 PM
 #9

We've got a first contract!

There was a bug that orders were not matches properly. I've fixed it and then I canceled and placed again dacoinminster's order.

Since the other guy had sell @28 it was matched with dacoinminster's order and resulting contracts are are at 28. So dacoinminster got a better deal.

This is a feature: when you place an order you might get better price than you're asking. Contacts are always created at prices of orders which are already in order book.

I apologize to dacoinminster's counter-party: if there was no bug in code and orders were processed in order they were placed he'd get sell @30. But, well, sell at 28 was his choice...

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 11, 2011, 07:52:27 AM
 #10

And we've got a settlement at 26.823286 spot price (due to 24h average it didn't drop very fast).

I've put in my 0.01 BTC and earned 0.0005 BTC through buy 0.0074 at 25.

dacoinminster lost some money on his buy at 28 and the other guy earned a little bit from this two contracts.

So it totally works

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
xkrysis
Newbie
*
Offline Offline

Activity: 11


View Profile
June 11, 2011, 05:24:14 PM
 #11

I was the counter party.  What happened to my sell orders at 30 that I placed first?  I put those in first, attempting to match his.  When they weren't matched I put the others in just for tests and to see if anyone else would take them.

This is a neat idea though.

I'd like to see being able to reset my password as well as withdraw =)
killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 11, 2011, 11:31:04 PM
 #12

I was the counter party.  What happened to my sell orders at 30 that I placed first?

Here's a history of your orders:

2011-06-10 15:03:29 sell 0.03 30 +1 100 50
2011-06-10 15:04:39 sell 0.05 28 +1 50 50
2011-06-10 15:05:16 sell 0.04 25 +1 75 75
2011-06-10 18:58:53 sell 0.03 30 +1 50 50

Current version of exchange requires same reserve percentage for both parties so (0.05 28 +1 50 50) order matched while (0.03 30 +1 100 50) did not.

Even though there was a fuck up on my side (they did not match automatically until I fixed the bug) result is the same.


Quote
I'd like to see being able to reset my password

Sending new password to email? It is not very secure, you know...

But I guess I'll add an optional email field and password resets would be handled manually.


Quote
as well as withdraw =)

I guess withdraws will be manual until I'll get enough BTC to cover potential loss on txn fees. (And hopefully upcoming bitcoind versions will allow better management for txn fees.)

But I guess I'll add a button to add withdraws into a queue for manual review and execution.

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
xkrysis
Newbie
*
Offline Offline

Activity: 11


View Profile
June 12, 2011, 02:44:30 AM
 #13

Ah, I didn't realize the matching code required the same percentages, but I can see the difficulties in reconciling two orders placed with differing percentages.  The way it is currently does kindof allow for a fair amount of permutations for a given order price.

As far as the password reset, I meant (and wasn't clear) just being able to change my password.  Although a reset password function (say a temp password good for 1 hour) will probably be necessary at some point as your userbase grows.

dacoinminster
Legendary
*
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
June 21, 2011, 03:41:49 PM
 #14

I put in a buy order at $14. Come and get it shorts!

edit: You can only see it if you choose Maturity +30.

KillerStorm, how do we see ALL orders in the order book?

killerstorm
Legendary
*
Offline Offline

Activity: 994



View Profile
June 21, 2011, 03:56:22 PM
 #15

I've changed it, now it shows all orders, as there is not too much activity for now Smiley

Note to 'shorters': you can double your coins on contract with dacoinminster if exchange rate drops below 9.33 in 30 days. Perhaps I should add a calculator... And, well, an easy to use UI.

colored coins proof-of-concept: private currencies, stock/bond p2p exchange

Tips and donations: 16v13Fa9cPmfFzpm9mmbWwAkXY4gyY6uh4
Pages: [1]
  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!