Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Calculate ActiveMining income and value
- clear
- clc
- format compact
- % User inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Print interval
- % Options: day, week
- printInterval = 'week';
- % Amount of shares owned by user:
- amountShares = 114425;
- % Total dividend paid (btc):
- dividendPaid = 660;
- % Current bitcoin price:
- btcStartPrice = 1000;
- % Expect bitcoin price [YEARS, PRICE]:
- btcFuturePrice = [2,100000];
- % Current bitcoin mining difficulty:
- startDiff = 609482679.89;
- % Current bitcoin block height:
- blockHeightStart = 271267;
- % Blocks to run simulation:
- run = blockHeightStart + 24 * 6 * 7 * 4 * 12 * 2;
- % Estimated difficulty increase next target: (%)
- percentIncreaseBegin = 25;
- % Estimated difficulty increase in [BLOCKS_RETARGET, PERCENT]:
- % (make this higher than current increase if you think the network will be
- % increasing even faster today, and less if you think the network would
- % have plateaued)
- percentIncreaseFuture = [24*2,25];
- % Expected return on investment for calculating share price: (months)
- ROIMonth = 18;
- % Pool fee in percent
- poolPercent = 3;
- % Percent of mining income reinvested in the business:
- reinvestment = 80;
- % Dividend payment time: (days)
- dividendPeriod = 7;
- % Starting fiat reserves
- fiatReserves = 1000000;
- % Current cost of a TH/s:
- % (I divide the 24th/s miner by 148,000)
- THsPriceStart = 6200;
- % Price of a TH/s [YEARS, USD]
- % (If you expect the price per TH/s to drop)
- THsFuturePrice = [2,2000];
- % Time to buy chips with reinvested money (weeks):
- reinvestTime = 4;
- % Print out parameters
- printOutSwitch = [...
- true,...% Week (DO NOT MODIFY)
- false,...% Block number
- true,...% Next percentage increase
- false,...% Average block time
- true,...% Hashrate
- false,...% Block reward
- true,...% Bitcoin price
- false,...% Day of the week (DO NOT MODIFY)
- true,...% ActiveMining hashrate!
- true,...% All time dividend earnings
- true,...% Share earnings this period
- ];
- % If day is true from print out at the top
- % then force printOutSwitch to print days
- if strcmp(printInterval,'day') == 1
- printOutSwitch(8) = true;
- elseif strcmp(printInterval,'week') == 1
- printOutSwitch(1) = true;
- end
- % Do not edit below this line %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Constant variables %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Bitcoin variables
- retargetBlock = 2016;
- rewardHalving = 210000;
- btcReward = 50;
- adjustTime = 10; % minutes
- % ActiveMining variables
- amountSharesTotal = 25000000;
- specialDividendShares = 10000000;
- specialDividendExpire = 0.0025;
- hasSpecialDividendBeenPaid = false;
- % Program %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Setup beginning conditions:
- % Network hashrate:
- hashrate = simpleHashrateCalc(5,startDiff,(adjustTime - adjustTime/100*percentIncreaseBegin));
- % Get amount of TH/s ActiveMining can buy:
- activeTHs = fiatReserves/THsPriceStart;
- fiatReserves = 0;
- % Set up TH/s variables
- logTHsRatio = log(THsFuturePrice(2)/THsPriceStart);
- THsPriceDays = (THsFuturePrice(1) * 365);
- THsPrice = THsPriceStart;
- % Starting week
- week = 0;
- % Starting day
- day = 0;
- % Amount of minutes in one week
- weekMinutes = 60 * 24 * 7;
- % Amount of minutes in one day
- dayMinutes = 60 * 24;
- % ActiveMining shares
- shareDividendAllTime = 0;
- perShareThisPeriod = 0;
- % The difference in percentage for each difficulty retarget
- differencePercentChange = (percentIncreaseBegin - percentIncreaseFuture(2))/percentIncreaseFuture(1);
- % Starting percentage increase
- percentIncrease = percentIncreaseBegin;
- % Initialize minutes variables
- amountMinutesWeek = 0;
- amountMinutesDay = 0;
- ActiveMiningMinutes = 0;
- minuteLength = (100 - percentIncrease)/100 * 10;
- printOut = false; % Initialize printing variable
- currentDifficulty = startDiff;
- % Bitcoin price variables
- logPriceRatio = log(btcFuturePrice(2)/btcStartPrice);
- btcPriceYears = btcFuturePrice(1);
- btcPriceDays = btcPriceYears * 365;
- btcPrice = btcStartPrice;
- % Bitcoins mined at beginning of simulation
- dividendAccumalation = dividendPaid;
- % Quickly get the block reward up to speed
- for blockHeight = 1:(blockHeightStart - 1)
- if mod(blockHeight, rewardHalving) == 0
- btcReward = btcReward / 2;
- end
- end
- % Primary loop (Run for each and everyblock on the network
- for blockHeight = blockHeightStart : run
- % If it's time for a retarget change the difficulty increase
- if mod(blockHeight,retargetBlock) == 0
- if percentIncrease > (percentIncreaseFuture(2) + differencePercentChange)
- percentIncrease = percentIncrease - differencePercentChange;
- else
- percentIncrease = percentIncreaseFuture(2);
- end
- currentDifficulty = currentDifficulty + ( currentDifficulty / 100 * percentIncrease );
- hashrate = simpleHashrateCalc(5,currentDifficulty,(adjustTime - adjustTime/100*percentIncrease));
- minuteLength = (100 - percentIncrease)/100 * 10;
- end
- % Work out how many minutes so far
- amountMinutesWeek = amountMinutesWeek + minuteLength;
- amountMinutesDay = amountMinutesDay + minuteLength;
- % ActiveMining has it's own minute ticker because we want to be able to
- % adjust dividend and other timings if needed
- ActiveMiningMinutes = ActiveMiningMinutes + minuteLength;
- if amountMinutesDay >= dayMinutes
- % Reset the amount of minutes
- amountMinutesDay = 0;
- % Increment the day
- day = day + 1;
- % Print out if needed
- if strcmp(printInterval,'day') == 1
- printOut = true;
- end
- % Change the bitcoin price
- btcPrice = btcStartPrice * exp(day / btcPriceDays * logPriceRatio);
- % Change the TH/s purchase price
- THsPrice = THsPriceStart * exp(day / THsPriceDays * logTHsRatio);
- % Pay dividend per the dividend period
- if mod(day, dividendPeriod) == 0
- if shareDividendAllTime >= specialDividendExpire && hasSpecialDividendBeenPaid == false
- hasSpecialDividendBeenPaid = true;
- end
- if hasSpecialDividendBeenPaid == false
- perShareThisPeriod = dividendAccumalation / specialDividendShares;
- elseif hasSpecialDividendBeenPaid == true
- perShareThisPeriod = dividendAccumalation / amountSharesTotal;
- end
- shareDividendAllTime = shareDividendAllTime + perShareThisPeriod;
- dividendAccumalation = 0;
- end
- end
- if amountMinutesWeek >= weekMinutes
- % Reset the amount of minutes
- amountMinutesWeek = 0;
- % Increment the week
- week = week + 1;
- % Print out if needed
- if strcmp(printInterval,'week') == 1
- printOut = true;
- end
- % Calculate reinvestment of TH/s
- if mod(week, reinvestTime) == 0
- activeTHs = activeTHs + ( fiatReserves / THsPrice );
- fiatReserves = 0;
- end
- end
- % Block reward
- if mod(blockHeight, rewardHalving) == 0
- btcReward = btcReward / 2;
- end
- % ActiveMining %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Get our percentage of Bitcoins mined
- ourShare = (activeTHs / hashrate) * btcReward;
- ourShare = ourShare - ( ourShare / 100 ) * poolPercent;
- % Accumalation of shareholders dividend
- thisAccumalation = ourShare - (ourShare / (100 / reinvestment));
- % Turn the reinvestment amount into fiat
- reinvestedCoins = ourShare - thisAccumalation;
- fiatReserves = fiatReserves + (reinvestedCoins * btcPrice);
- reinvestedCoins = 0;
- dividendAccumalation = dividendAccumalation + thisAccumalation;
- % At this point we now know:
- % activeTHs = Our hashrate
- % shareDividendAllTime = How much each share has earned
- % perShareThisPeriod = this current period earnings
- % purchase, special dividend, per share accumalation
- % instantaneous share value, actual share value (trend of 52 week)
- % multiply instant, actual, per share, for entire holdings
- %
- % END OF ACTIVEMINING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Print out information
- if printOut == true
- % Turn off print out until it's selected again
- printOut = false;
- if printOutSwitch(1) == true
- fprintf('Week %3i: -----\n',week)
- end
- if printOutSwitch(2) == true
- fprintf(' Block No. %2i \n',blockHeight)
- end
- if printOutSwitch(3) == true
- fprintf(' Next percent increase: %4.2f \n',percentIncrease)
- end
- if printOutSwitch(4) == true
- fprintf(' Block time avg. %4.2f \n',minuteLength)
- end
- if printOutSwitch(5) == true
- fprintf(' Hashrate: %8.0f TH/s \n', hashrate)
- end
- if printOutSwitch(6) == true
- fprintf(' Block reward: %4.2f btc \n', btcReward)
- end
- if printOutSwitch(7) == true
- fprintf(' Bitcoin price: %4.2f usd \n', btcPrice)
- end
- if printOutSwitch(8) == true
- fprintf(' Day: %2i \n', day)
- end
- if printOutSwitch(9) == true
- fprintf(' ActM Hashrate: %6.0f & Percent: %3.0f \n', activeTHs, (activeTHs/hashrate)*100)
- end
- if printOutSwitch(10) == true
- fprintf(' Dividend Earned in Total: Share: %12.8f($%6.2f), Holdings: %12.8f($%6.2f) \n',...
- shareDividendAllTime,...
- shareDividendAllTime * btcPrice,...
- shareDividendAllTime * amountShares,...
- shareDividendAllTime * amountShares * btcPrice)
- end
- if printOutSwitch(11) == true
- fprintf(' Dividend Earn this Period: Share: %12.8f($%6.2f), Holdings: %12.8f($%6.2f) \n',...
- perShareThisPeriod,...
- perShareThisPeriod * btcPrice,...
- perShareThisPeriod * amountShares,...
- perShareThisPeriod * amountShares * btcPrice)
- end
- fprintf('\n')
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement