Author

Topic: Implementing bitcoin: retrieving the value? (Read 1297 times)

member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
October 16, 2012, 02:07:09 PM
#17
I would like to sell them all at the average price to have a more consistant price.

I think setting your prices based on your costs is a mistake. Your plan risks selling too low and not being able to buy. Commodities and currency traders buy and sell based on a "spot" price. You should too. If you want a more consistent price, then you can just update the prices less frequently.

Atleast I'll run break-even for sure.
In any other case I'll probably make loss.

"Your plan risks selling too low and not being able to buy"
What do you mean?

If the prevailing price rises significantly above your average price:
  • Your price will be too low. People will buy all of your bitcoins and resell them at the higher price.
  • You can't buy because buying at the prevailing price would mean an automatic loss when you sell at your lower average price.

Also, if the prevailing price drops significantly below your average price, you will not be able to sell because your average price will be too high.

Atleast I'll run break-even for sure.

I would like to point out that this statement is a red flag. The flaw here is that what you are really saying is that you won't sell if the prices fall. The real result is that the value of your inventory will continue to fall, so you will still lose money in the end.


People will buy all my bitcoins. so I'll have 0BTC left or something NEAR 0.
So I'll have to buy new bitcoins myself because nobody will sell theirs bitcoins to me -> I have to start from zero BTC again and buy new BTC, so the average price will be re-adjusted and follow the trend of the market I bought them on.

"Also, if the prevailing price drops significantly below your average price, you will not be able to sell because your average price will be too high."
I only expect a rise in the value of bitcoin, at least seen over a long term. If there for some reason is a drop in the bitcoin value I will have to sell at dump-prices.
It's just the risk you take, even you haev that risk. The government could decide that your money is worthless tomorrow.

It's the risk you take with everything, even though bitcoins aren't as stable as a currency backed by the government, I have good hopes for it.
legendary
Activity: 4466
Merit: 3391
I would like to sell them all at the average price to have a more consistant price.

I think setting your prices based on your costs is a mistake. Your plan risks selling too low and not being able to buy. Commodities and currency traders buy and sell based on a "spot" price. You should too. If you want a more consistent price, then you can just update the prices less frequently.

Atleast I'll run break-even for sure.
In any other case I'll probably make loss.

"Your plan risks selling too low and not being able to buy"
What do you mean?

If the prevailing price rises significantly above your average price:
  • Your price will be too low. People will buy all of your bitcoins and resell them at the higher price.
  • You can't buy because buying at the prevailing price would mean an automatic loss when you sell at your lower average price.

Also, if the prevailing price drops significantly below your average price, you will not be able to sell because your average price will be too high.

Atleast I'll run break-even for sure.

I would like to point out that this statement is a red flag. The flaw here is that what you are really saying is that you won't sell if the prices fall. The real result is that the value of your inventory will continue to fall, so you will still lose money in the end.
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
I would like to sell them all at the average price to have a more consistant price.

I think setting your prices based on your costs is a mistake. Your plan risks selling too low and not being able to buy. Commodities and currency traders buy and sell based on a "spot" price. You should too. If you want a more consistent price, then you can just update the prices less frequently.

Atleast I'll run break-even for sure.
In any other case I'll probably make loss.

"Your plan risks selling too low and not being able to buy"
What do you mean?
legendary
Activity: 4466
Merit: 3391
I would like to sell them all at the average price to have a more consistant price.

I think setting your prices based on your costs is a mistake. Your plan risks selling too low and not being able to buy. Commodities and currency traders buy and sell based on a "spot" price. You should too. If you want a more consistent price, then you can just update the prices less frequently.
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
Now, I'm not totally clear on what you are trying to solve, but I think you are making it unnecessarily complicated by keeping track of every time you buy bitcoins. Really, all you need to do is keep track of the total BTC and the total $.

Here is your first example:

You purchase 10 BTC for $90: BTC = 10, $ = - 90
You purchase  9 BTC for $90: BTC = 19, $ = -180
You purchase  6 BTC for $72: BTC = 25, $ = -252
You purchase  7 BTC for $91: BTC = 32, $ = -343
You sell 5 BTC for $53.59: BTC = 27, $ = -289.41

Here is your second example:

You purchase 10 BTC for  $90: BTC = 10, $ = - 90
You purchase  9 BTC for  $90: BTC = 19, $ = -180
You purchase  6 BTC for  $72: BTC = 25, $ = -252
You purchase  7 BTC for  $91: BTC = 32, $ = -343
You purchase 10 BTC for $115: BTC = 42, $ = -458
You sell 5 BTC for $53.59: BTC = 37, $ = -404.41

Why isn't this enough?
I would like to sell them all at the average price to have a more consistant price.
> with my formula I would sell the 5BTC and evenly deducate it over all bought coins, and the average price WILL NOT CHANGE.

I made some faulty calculations though but last night I finally came to the real deal.


First example:

I purchase 10 BTC for $90: BTC = 10, $ = - 90
I purchase  9 BTC for $90: BTC = 19, $ = -180
I purchase  6 BTC for $72: BTC = 25, $ = -252
I purchase  7 BTC for $91: BTC = 32, $ = -343
--------------------------------------------------------------
I purchased 32 BTC for $343: Average price: $10,71875,  $ = -343

That would actually equal to all the coins I bought at the average price:

I purchase 10 BTC for $107,1875: BTC = 10, $ = - 107,1875
I purchase  9 BTC for $96,46875: BTC = 19, $ = -203,65625
I purchase  6 BTC for $64,3125: BTC = 25, $ = -267,96875
I purchase  7 BTC for $75,03125: BTC = 32, $ = -343
--------------------------------------------------------------
I purchased 32 BTC for $343: Average price: $10,71875,  $ = -343

So now I sell 5BTC:
I purchase 10 BTC for $107,1875: BTC = 10, $ = - 107,1875
I purchase  9 BTC for $96,46875: BTC = 19, $ = -203,65625
I purchase  6 BTC for $64,3125: BTC = 25, $ = -267,96875
I purchase  7 BTC for $75,03125: BTC = 32, $ = -343
--------------------------------------------------------------
I purchased 32 BTC for $343: Average price: $10,71875,  $ = -343
--------------------------------------------------------------
I sell 5 BTC for $53,59375: BTC = 27, $ = -289.40625
--------------------------------------------------------------
I have 27 BTC left for $289.40625: Average price: $10,71875

Now what if I buy another 10 BTC for $11,56?

I purchase 10 BTC for $107,1875: BTC = 10, $ = - 107,1875
I purchase  9 BTC for $96,46875: BTC = 19, $ = -203,65625
I purchase  6 BTC for $64,3125: BTC = 25, $ = -267,96875
I purchase  7 BTC for $75,03125: BTC = 32, $ = -343
--------------------------------------------------------------
I purchased 32 BTC for $343: Average price: $10,71875,  $ = -343
--------------------------------------------------------------
I sell 5 BTC for $53,59375: BTC = 27, $ = -289.40625
--------------------------------------------------------------
I have 27 BTC left for $289.40625: Average price: $10,71875
--------------------------------------------------------------
I purchase  10 BTC for $115,6: BTC = 32, $ = -343
--------------------------------------------------------------
I have 37 BTC for $405,00625: Average price: $10,94611487

Check:
In total I bought 42 BTC for $458,6!
In my inventory I have 37 BTC left for a value of: $405,00625
If I add the 5BTC (which was sold) to it, I should get the price I paid for it.

405,00625 + 53,59375 = 458,6!

You were right though, I only made it complicated by deducating it while actually I should only change the price tags.

I'm going to use this method, it's a variant of what you proposed with  the calculations in my mind.

Thank you to everyone who posted in this thread.
If you wish that I elaborate any part of the above then don't hassle to post!

- Flowz
hero member
Activity: 812
Merit: 1000
mtgox prices are based on supply and demand.

you could also consider basing your prices on customer supply and demand, which would probably naturally end up being something similar to mtgox's prices without actually relying on a connection to mtgox.
legendary
Activity: 4466
Merit: 3391
Now, I'm not totally clear on what you are trying to solve, but I think you are making it unnecessarily complicated by keeping track of every time you buy bitcoins. Really, all you need to do is keep track of the total BTC and the total $.

Here is your first example:

You purchase 10 BTC for $90: BTC = 10, $ = - 90
You purchase  9 BTC for $90: BTC = 19, $ = -180
You purchase  6 BTC for $72: BTC = 25, $ = -252
You purchase  7 BTC for $91: BTC = 32, $ = -343
You sell 5 BTC for $53.59: BTC = 27, $ = -289.41

Here is your second example:

You purchase 10 BTC for  $90: BTC = 10, $ = - 90
You purchase  9 BTC for  $90: BTC = 19, $ = -180
You purchase  6 BTC for  $72: BTC = 25, $ = -252
You purchase  7 BTC for  $91: BTC = 32, $ = -343
You purchase 10 BTC for $115: BTC = 42, $ = -458
You sell 5 BTC for $53.59: BTC = 37, $ = -404.41

Why isn't this enough?
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
Average price of current inventory is of whole current inventory.

You don't need to keep track of which bars of chocolate you got at which price, just the total number you have now and the total price those you have now cost you, from which the avarage price is just total divided by number of bars.

Same for any item, you can do it for your dollars too, how much total bitcoins did your current inventory of dollars cost you.

If you do really kee inventory of bars of chocolate or whatever you sell, you can skip the dollars entirely, and just keep track of how many bitcoins your current inventory cost you. When you buy more you convert to fiat to buy, sure, but plug into your inventory system the amount of bitcoins you paid not ow much that happened at the time to be in dollars.

That way you know how much the thing in your inventory actually cost you in bitcoins.

Problem is as bitcoins keep going up in value, your old inventory will look more and more expensive that way, which is why it works better to use "bad money" than "good money" for such things. Accept bitcoins if anyone is fool enough to sell you any but express your prices in inflatacoins such as devcoins or groupcoins that are less liable to go up in price.

Or fiat, since it is kind of a prototypical inflatacoin.

If you are not forced to use some pre-written inventory system that assumes things only have prices in one currency, you could track the total dollars your inventory cost you and the total bitcoins that same iinventory cost you and use both figures to whip up bitcoin prices for stuff based on how well heeeled the customer looks, how in a hurry they are, and o the other hand also how bullish you are about bitcoins that day.

You could even have dynamic deals: "Today we have to oder from suppliers in fiat, so today's special we give a deal for people who pay in fiat!" or "Today's special, discount for those who pay in bitcoin!" Depending on which you need most of by the end of the day or week or whatever to meet your own needs.

-MarkM-


I want to be able to add money to the inventory dynamicly.
So if I bought some bitcoins and I sell some of them but I still have some left over.
Now I want to buy a few more bitcoins but I can't just add them to the list of all coins I have bought (used to calculate the avg) withouth deducating the coins I already sold.

I'm thinking of doing it this way:
I keep track off all coins I buy and at which price.
When I sell coins, I deducate the sold coins from the OLDEST coins I bought.
> This raises a few problems again..
>> OR NOT!

The calculations below are in-correct! I have the correct one but it's rather complicated! 3 Post below this one there is a simple and correct formula which is the best way to do this!

I found out the whole formula, hip hip hoorah!

I purchase:
--------------------------------
10BTC      @ $9      = $90
9BTC      @ $10      = $90
6BTC      @ $12      = $72
7BTC      @ $13      = $91
----------------------------------
32BTC      @ $10.71875     = $343

Let's call the avg price 'X'.

I sell for example 5BTC @ X = $53.59375
So I should have this left over: $343 - $53.59375 =  $289.40625.

(90 - 1,25X) + (90-1,25X) + (72-1,25X) + (91-1,25X) = $289.40625

Now I need to deducate my records evenly.
--------------------------------
Y1BTC     @ $9        = $(90 - 1,25X)= $76,6015625      ->  Y1 = (90 - 1,25X)/9   = 8,511284722
Y2BTC     @ $10      = $(90 - 1,25X) = $76,6015625     ->  Y2 = (90 - 1,25X)/10 = 7,66015625
Y3BTC     @ $12      = $(72 - 1,25X) = $58.6015625     ->  Y3 = (72 - 1,25X)/12 = 4,883463542
Y4BTC     @ $13      = $(91 - 1,25X) = $77,6015625    ->  Y4 = (91 - 1,25X)/13 = 5,969350962
--------------------------------
YBTC       @ $X                                 = $289.40625

Let's do the check, all Y-values added together should be (32BTC - 5BTC) = 27BTC.
27BTC x 10.71875 = $289.40625

Y equals to 27,02425548
> I rounded off my numbers in the calculation of Y1,2,3,4, so this will be an issue I'll have to work on.

Now:
--------------------------------
10BTC      @ $9      = $90
9BTC      @ $10      = $90
6BTC      @ $12      = $72
7BTC      @ $13      = $91
10BTC    @ $11.5    = $115
----------------------------------
42BTC      @ $10.9047619     = $458

So I had sold 5BTC so this is the inventory:

--------------------------------
8,511284722BTC      @ $9      = $76,6015625
7,66015625BTC      @ $10      = $76,6015625
4,883463542BTC      @ $12      = $58.6015625
5,969350962BTC      @ $13      = $77,6015625
10BTC                      @ $11.5    = $115
----------------------------------
37,02BTC      @ $10.92399379     = $404.40625

so in theory if I add the sold amount to it it should be back at the price I bought it.
5BTC             @ $10.71875         =  $53.59375

= $458! (=> price for which I bought all the coins!)

Damn right mothafucka.

Only have to solve the rouding issue now.
legendary
Activity: 2940
Merit: 1090
October 14, 2012, 02:26:10 AM
#9
Average price of current inventory is of whole current inventory.

You don't need to keep track of which bars of chocolate you got at which price, just the total number you have now and the total price those you have now cost you, from which the avarage price is just total divided by number of bars.

Same for any item, you can do it for your dollars too, how much total bitcoins did your current inventory of dollars cost you.

If you do really keep inventory of bars of chocolate or whatever you sell, you can skip the dollars entirely, and just keep track of how many bitcoins your current inventory cost you. When you buy more you convert to fiat to buy, sure, but plug into your inventory system the amount of bitcoins you paid not ow much that happened at the time to be in dollars.

That way you know how much the thing in your inventory actually cost you in bitcoins.

Problem is as bitcoins keep going up in value, your old inventory will look more and more expensive that way, which is why it works better to use "bad money" than "good money" for such things. Accept bitcoins if anyone is fool enough to sell you any but express your prices in inflatacoins such as devcoins or groupcoins that are less liable to go up in price.

Or fiat, since it is kind of a prototypical inflatacoin.

If you are not forced to use some pre-written inventory system that assumes things only have prices in one currency, you could track the total dollars your inventory cost you and the total bitcoins that same iinventory cost you and use both figures to whip up bitcoin prices for stuff based on how well heeeled the customer looks, how in a hurry they are, and o the other hand also how bullish you are about bitcoins that day.

You could even have dynamic deals: "Today we have to oder from suppliers in fiat, so today's special we give a deal for people who pay in fiat!" or "Today's special, discount for those who pay in bitcoin!" Depending on which you need most of by the end of the day or week or whatever to meet your own needs.

-MarkM-
legendary
Activity: 4466
Merit: 3391
October 13, 2012, 05:27:05 PM
#8
I'm working on an exchange site that will exchange bitcoins with fiat currency, so the money will go in and out fast.
I keep track of all coins I buy and at which price.
I will only release the coins for exchange if the value of the price I bought them is met.

I just have no idea about how customers are going to react to the prices I offer..
When the bitcoins sky-rocket  to $15 for a day or two on MtGox I can keep that price under control since I make an average of the prices of the week before.
When the bitcoins drop to a price of $11 people will dump their coins at me since my price will still be high.

I dislike the fact that I base my system on an already existign market MtGox. Does anyone has any suggestions towards this, how I could do it else?

It has it's pro's and contra's but I think that's how I'm going to roll.

Normally, it is done by using a spread, you offer to buy and sell at different prices and you make your profit off the difference. Your risk is the change in the value of your inventory, so you want to keep that as low as possible. The more volume/liquidity, the less risk there is for you, you can make the spread smaller and that makes you more competitive. If you can't match up buyers and sellers, then you have to increase the spread to decrease your risk, but that makes you less competitive. It is kind of a chicken and egg problem, which is solved by exposing yourself to some risk.
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
October 13, 2012, 05:05:00 PM
#7
You have 20 bitcoins that cost 11.50 each on average.

-MarkM-


Then a problem occurs when selling.
If I sell 5 coins, I would have to deducate it evenly over all the records of bought coins to keep the price as it is.

Code:
It is really important look at this example:

10B    @    $10
10B    @     $12

I sell 20B at $11.

I buy another:

10B    @      $13

I have to sold the 20B  for $220. I can't just add the 10B to the already sold pile so I have to erase those. So I sell them at $13/each.


OR imagine this:
I sell 2B at $11 (of pile of 10B at $10 and 10B at $12), this would result: in 18B x $11 = $198

I can also deducate this evenly:

9B @ $10 = $90
9B @ $12 =  $108
                 + $198

Matches perfectly.

Not a problem untill this:


9B @ $12  =  108
7B @ $10  = 70
-------------------
16B @ 11,125 = 178

I would have to sell 16 BTC at $11,125 to get $178.

If I sell 3 BTC, I would have to deducate x-B over 9B and 6B to keep up with the correct rate. If I deducate 1,5B over 9B and 7B I become a new avg of $11,1538 and that sells for $145.

13B @ 11,125 = 144.625 (left)

(Getting close there!)

Now how do I deducate 3B evenly across both 9B and 6B so I come to an average when deducated of $11,125?

(9 - (3- 7/9)) * 12 = $86,000004
(7 - (3 - 7/9)) * 10 = $58.333333
                                =  $144.3338

Getting closer, I hope someone can sprinkle light on the algorithm.


Or should I think the whole other way?
Should I keep a record of all bitcoins bought and all bitcoins sold.
But then when I buy new bitcoins I must have sold all the "old" ones.
Then buy a new batch of bitcoins, and wait again untill they are all sold.
That looks impractical to me though :/
legendary
Activity: 2940
Merit: 1090
October 13, 2012, 01:57:42 PM
#6
You have 20 bitcoins that cost 11.50 each on average.

-MarkM-
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
October 13, 2012, 11:10:51 AM
#5
What exactly are you going to be selling? As options depend a lot on that.

But yeah keeping track of what the average price was of your current inventory of coins is one way I have considered for figuring out how much to have a computer program consider a coin to be worth.

Another way could be to track the slope of the curve, anticipating based on how the average price has been rising, expecting it to continue to rise, and maybe taking into account people are stupid to be parting with bitcoins for only two digit values in dollars unless they are day-trading or whatever-timespan trading seeking to cash in on ups and downs instead of putting coins away for their grandchildrens' college fund.

If you take that latter view then snap up coins anywhere anyhow that you can afford to, trying as much as possible to only ever part with "bad money" not with the "good money" that is bitcoins.

-MarkM-


I'm thinking of exchanging to a fiat currency.

I was wondering though, take a look at this situation:
--------------------------
|  10   |  BTC  | $11 |
|  10   |  BTC  | $12 |
--------------------------
(This is what I bought: 10 BTC at $11 and 10 BTC at $12)

Let's pretend I'm selling at $12.10 and someone wants to buy 10 bitcoins.

Which price do I scrap off the list? I maximize profit if I sell the coins I bought at $11 but it's risky to not sell the coins I bought at $12 since  the price might drop to $11.80 and rarely reach the $12 anymore which keeps the coins trapped since I don't want to sell them lower then I bought them. (This is purely theory)
The system I already mentiond of keeping records of the average price of mtgox and base mine on the last 28 records will keep control of this situation though.
legendary
Activity: 2940
Merit: 1090
October 13, 2012, 06:32:38 AM
#4
What exactly are you going to be selling? As options depend a lot on that.

But yeah keeping track of what the average price was of your current inventory of coins is one way I have considered for figuring out how much to have a computer program consider a coin to be worth.

Another way could be to track the slope of the curve, anticipating based on how the average price has been rising, expecting it to continue to rise, and maybe taking into account people are stupid to be parting with bitcoins for only two digit values in dollars unless they are day-trading or whatever-timespan trading seeking to cash in on ups and downs instead of putting coins away for their grandchildrens' college fund.

If you take that latter view then snap up coins anywhere anyhow that you can afford to, trying as much as possible to only ever part with "bad money" not with the "good money" that is bitcoins.

-MarkM-
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
October 13, 2012, 06:16:32 AM
#3
Well yeah usually the longer you wait the more you get for bitcoins.

There have been some transient periods during which that has not appeared true for short spans, but that has tended to be an artifact of not waiting long enough.

So basically hold on to them as long as you darn well can, spending any fiat that comes in rather than spending any bitcoins, until you are absolutely forced to dip into your bitcoins.

Accepting some "bad money" such as fiat as well as accepting bitcoins obviously helps with this.

There are also altcoins that are suitable for use as "bad money" in that sense, as their daemons function the same way the bitcoin daemon does thus are trivial to accept if you already accept bitcoins, and you can (at least some of them; those suitable, in effect) sell them directly for fiat instead of using them to buy more bitcoins if you find your sales in fiat are not enough to fill your "bad money" needs.

-MarkM-


I'm working on an exchange site that will exchange bitcoins with fiat currency, so the money will go in and out fast.
I keep track of all coins I buy and at which price.
I will only release the coins for exchange if the value of the price I bought them is met.

I just have no idea about how customers are going to react to the prices I offer..
When the bitcoins sky-rocket  to $15 for a day or two on MtGox I can keep that price under control since I make an average of the prices of the week before.
When the bitcoins drop to a price of $11 people will dump their coins at me since my price will still be high.

I dislike the fact that I base my system on an already existign market MtGox. Does anyone has any suggestions towards this, how I could do it else?

It has it's pro's and contra's but I think that's how I'm going to roll.


This keeps me s
legendary
Activity: 2940
Merit: 1090
October 13, 2012, 05:59:56 AM
#2
Well yeah usually the longer you wait the more you get for bitcoins.

There have been some transient periods during which that has not appeared true for short spans, but that has tended to be an artifact of not waiting long enough.

So basically hold on to them as long as you darn well can, spending any fiat that comes in rather than spending any bitcoins, until you are absolutely forced to dip into your bitcoins.

Accepting some "bad money" such as fiat as well as accepting bitcoins obviously helps with this.

There are also altcoins that are suitable for use as "bad money" in that sense, as their daemons function the same way the bitcoin daemon does thus are trivial to accept if you already accept bitcoins, and you can (at least some of them; those suitable, in effect) sell them directly for fiat instead of using them to buy more bitcoins if you find your sales in fiat are not enough to fill your "bad money" needs.

-MarkM-
member
Activity: 114
Merit: 10
Bitcoin = Money for the people, by the people.
October 13, 2012, 05:42:53 AM
#1
Hello,

I would like your input on this subject.

If you were to sell goods and accept bitcoins for it, what would be the best way to retrieve the optimal value $/bitcoin?

MtGox is trading at (Weighted Avg:) $12.03129
While others like FastCash4Bitcoins is buying at $11.46

I was thinking of storing the weighted avg into a database (each six hour period) for a week long, and calculate a stable price from that to accept bitcoins with.

- Flowz
 
Jump to: