Simulating the Impact of UASF / BIP148 on Bitcoin

By | June 8, 2017

To get a better prediction of UASF impact on bitcoin, I wrote a quick and dirty bitcoin network simulator, which you can find here on GitHub. After playing around with all kinds of hash rate distributions and UASF/non-UASF nodes, my first conclusion is, that there is almost no impact  of UASF nodes on bitcoin, if their amount is below 80%.
But there are some more interesting results, I want to share. You can find the CSV files I've used in the examples folder.

net1.csv:
This basically simulates the bitcoin network as of current state. There are 30% of SegWit signalling miners, and roughly 10% UASF nodes. When UASF starts on August 1st and hash rate and UASF node distribution keeps the same, no chain split will occur. The bitcoin network remains intact.

net2.csv:
This example assumes a mining pool with hashing power of 5%, while the hashing power of SegWit signaling pools drops to 25%, the amount of UASF nodes is still 10%. This leads to a chain split, where the UASF pool mines on a minority chain, all other miners including SegWit signalling miners are on the main chain.

net3.csv:
Let's increase the amount of UASF nodes to 50%. The hash rate distribution is untouched as in net2.csv: 25% SegWit signalling, 5% UASF. As already stated, there is still no impact of UASF nodes on bitcoin, because UASF nodes are below 80%. We get the same result as of net2.csv, but slightly more reorgs an orphaned blocks.

net4.csv:
UASF nodes are at 80%. Something happens. All non-UASF miners including SegWit signalling miners mine on different chains. The bitcoin network seems to be corrupted.

net5.csv:
UASF nodes at 90%, USAF miners at 5%, SegWit signalling at 25%. Some magic happens. All miners are on the main chain, and it is a SegWit chain. Miners not signalling SegWit have a lot of reorgs, and of course all their mined blocks are worthless.

net6.csv:
Assumes that all SegWit signalling miners become UASF miners. So we have 30% UASF miners. Further we put the UASF nodes at 50%.  Result is a chain split, where UASF miners mine on there own minority chain.

net7.csv:
80% UASF nodes, 30% UASF miners, no SegWit signalling miners. UASF and non-UASF chains are abreast. Non-UASF miners have a lot of reorgs and orphaned blocks.

net8.csv:
70% UASF nodes, 49% UASF miners results in a chain split.

net9.csv:
70% UASF nodes, 40% UASF miners and 10% SegWit signalling miners. Again there is a chain split where SegWit signalling miners are on the main chain.

net10.csv:
100% UASF nodes, 0% SegWit signalling miners and 0% UASF miners. All miners are mining on their own chain, because they are surrounded by UASF nodes.

How to Setup a Bitcoin BIP148/UASF Node on FreeBSD

By | May 22, 2017

Assuming you have a fresh FreeBSD (or a jail) installed, and you are logged in as root, download the latest version of BIP148 enabled bitcoin sources from here as .tar.gz file and untar it.  As of writing it is v0.14.1-uasfsegwit0.3.tar.gz.

fetch https://github.com/UASF/bitcoin/archive/v0.14.1-uasfsegwit0.3.tar.gz
tar xzvf v0.14.1-uasfsegwit0.3.tar.gz
cd bitcoin-0.14.1-uasfsegwit0.3

Next the documentation in ./doc/build-unix.md tells us which packages we have to install to compile bitcoin. Let's install them:

pkg install autoconf automake libtool pkgconf
pkg install boost-libs openssl libevent
pkg install gmake

And now compile and install bitcoind:

./autogen.sh 
./configure --without-gui --without-miniupnpc --disable-wallet
gmake
gmake install

Now start bitcoind

bitcoind -daemon

Make sure your server is reachable over port 8333.

To check your node go to bitnode and enter the ip address of your node. You should get a result similar to this:

 

SeSim - First Pre-Alpha

By | March 26, 2017

Now you can download a first rudimentary version of SeSim, the Stock Exchange Simulator as announced here.
It was tested under Windows and Linux.
You can download the jar file uSeSim_001_alpha.jar which you can run, if java is installed on your computer.
To play around with, create first a strategy, by going to edit->strategies, pressing the "new" button. Chose RandomTraderA and enter some values. Then goto edit->traders and add some traders using your strategy.
And now hit the run button to let them trade.

Have fun and stay tuned, because more updates will follow.

Bitcoin vs. Gold

By | March 10, 2017

Bitcoin was raising, and the price for one Bitcoin is now around the same as for one ounce of gold.

So isn't it insane to pay for one Bitcoin as much as for one ounce of gold?

According to this article there are currently between 155,244 tonnes and 2.5 million tonnes of gold in the world. Nobody knows how much gold is actually there. In the opposite for Bitcoin we know exactly, how many coins are in the world. Currently there are around 17 million Bitcoins, but there will never be more than 21 million Bitcoins for sure.

Taking the minimum amount of gold (155,244 tonnes) converting it to ounces  (5,476,076,856 ) and setting it in relation to the maxim number of Bitcoins (21,000,000) we note, that there are 260 ounces of gold for every Bitcoin in the world.

This means: to get real price equality between Bitcoin and gold, the price of Bitcoin has still to raise 260 times from now on. And that's just the worst case, if there are actually "only" 155,244 tonnes of gold in the world. If there were 2 million tonnes of gold, the price for on Bitcoin should rise more than 3000 times.

So isn't it insane to sell one Bitcoin for  the same price as for one ounce of gold?

SeSim - Stock Exchange Simulator

By | February 19, 2017

Earning money by day trading is considered to be extremely hard. I've often read that about 95% of people who attempt day trading will lose money. This might be true and coincidences with my observations among people I know, because I don't know anybody who is able to make money by day trading.

But who are these 5% of people making money by day trading ? Do they really exist?

Sometimes I believe the only people making money by day trading are people writing about day trading or people teaching other people in day trading or people selling software for day trading or any other people doing things related to day trading but actually don't do day trading.

Do these 5% really exist?
If they exist, they are already rich, for sure, because they are the successful day traders, and if they still keep on day trading, they have a lot of power  to move the market.

So there was the question: What if I was one of these 5%? What if I was mighty? What if I had a nearly  unlimited amount of money? What if I had such a huge amount of money, that my orders will move the market? How does it feel to move the market by placing huge orders? What can I achieve by placing big orders?

Because it's very hard to jump out from the 95%  to the upper 5%  in real live, I decided to write a little piece of software which simulates real live market situations while cheating me into the upper 5% of day traders with a lot of money.

The program is called SeSim - The Stock Exchange Simulator. It is open source. You can download the source code from github. The software is still under development, but basic functionality is already given.

In the future I will write more about it here, how to us it, how to install it.

Stay tuned.

Day Trading and Commission Fees

By | December 25, 2016

Imagine you were a day trader, and you make in average one trade per day on 200 days a year.
Further imagine you have to pay a commission fee of $10 when buying shares, and again you have to pay a commission fee of $10 when selling shares, which is effectively $20 per trade.

So you can simply calculate: You will pay $4,000 per year in commission fees.
Or in other words: You have to make with your trades a profit of at least $4,000 a year to make no losses.

And now take a look at your account balance.
If  you start with $1,000, you have to have a yearly performance of 500%, which would results in a profit of $4,000, only to pay the commission fees. You are only on the winning side, if your performance is better than 500%.

If you start with $10,000 you have to raise your account only 40% up ($14,000), to pay the commission fees to make no loss, but still no win.

And last: If you start width $100,000, your performance has to be at 4%, to pay the commission fees.

So remember: Your biggest enemy are neither the other traders, nor the trend or whatever, your biggest enemy in dat trading are the commission fees in relation to your trading capital.

Integer Factorization Using Backtracking with Erlang

By | December 18, 2016

In an earlier post I showed an algorithm to factorize integers using backtracking. The algorithm was implemented in python. Here we have now the same thing in erlang.

To run the code, copy the script and save it to a file named "factorize.erl".

Then enter a shell and compile the module using the following command:

$erlc factorize.erl

Now you can factorize an integer (in our example 129) with this command:

$escript factorize.beam 129
[3,43]

It seams, the erlang version is much faster than the python version.

Here is the Erlang code.

Have fun!

 

-module(factorize).

-export([
	 main/1
	]).


getbit(X, N) ->
    (X bsr N) band 1.


setbit(X, N, 1) ->
    X bor (1 bsl N);
setbit(X, N, 0) ->
    X band (bnot (1 bsl N)).


bitcmp(_I1, _I2, _N, _N)->
    0;
bitcmp(I1, I2, N, I)->
    B1=getbit(I1, I),
    B2=getbit(I2, I),
    if
	B1 /= B2 ->
	    B1 - B2;
	true ->
	    bitcmp(I1, I2, N, I + 1)
    end.

bitcmp(I1, I2, N) ->
    bitcmp(I1, I2, N, 0).

fac_check(I, 1, _I2, P, _Bits) when P == I ->
    false;
fac_check(I, _I1, 1, P, _Bits) when P == I ->
    false;
fac_check(I, _I1, _I2, P, _Bits) when P > I ->
    false;
fac_check(I, _I1, _I2, P, _Bits) when P == I ->
    true;
fac_check(I, _I1, _I2, P, Bits) ->
    bitcmp(I, P, Bits).


fac_check(I, I1, I2, Bits) ->
    fac_check(I, I1, I2, I1 * I2, Bits).

 
fac_run(I, _I1, _I2, _N, 4) ->
    [I];
fac_run(I, I1, I2, N, B) ->
    B1 = getbit(B, 0),
    B2 = getbit(B, 1),
    I1N = setbit(I1, N, B1),
    I2N = setbit(I2, N, B2),

    R = fac_check(I, I1N, I2N, N + 1),

    case R of
	true ->
	    lists:append(factorize(I1N), factorize(I2N));
	0 ->
	    F=fac_run(I, I1N, I2N, N+1, 0),
	    if 
		F =/= [I] ->
		    F;
		true ->
		    fac_run(I, I1, I2, N, B + 1)
	    end;
	_ ->
	    fac_run(I, I1, I2, N, B + 1)
    end.
    


fac_run(I, I1, I2) ->
    fac_run(I, I1, I2, 0, 0).
    

factorize (I) ->
    lists:sort(fac_run(I, 0, 0)).

main(Val) ->
    [X]=Val, 
    R=factorize(list_to_integer(X)),
    io:write(R),
    io:format("~n").