Bitburner Basic Stock Market Guide

Bitburner Basic Stock Market Guide 1 - steamsplay.com
Bitburner Basic Stock Market Guide 1 - steamsplay.com

A brief guide and simple working script to get you started with Bitburner Stock Market.
 

The Beginning

I knew nothing about the stock market, except that it was like gambling. I also have a terrible record of gambling – I always lose. I reached a point where I was spending 3t+ each augment (. They increase exponentially for every one you buy, but) and E3t were the most I could make each day hacking. I have 40 augments and I want to make sure I get that achievement. Realizing it would take forever, and considering how expensive each augment was, I needed a better method to make money. I decided to learn how Bitburner lets me play the stock market. Plus, it's all virtual. What can I lose?
 
 
The stock market isn’t like gambling in a slot machine or casino. It doesn’t rely on luck to win. The stock market is a seashore with its ebbs, flows and patterns that can be mathematically predicted to make profit. This is how corporations and people make money on the stock exchange and it's actually legal. It is not possible to do that in a casino. I have heard that it could lead to serious financial problems. Market data is information about a stock’s history. It can be purchased to create mathematical buying or selling strategies.
 
 
 

The Very Basics

Here are the basics:
 
 
What is a position?
 
A position is the number of stocks owned or controlled by a player in a given company. A player becomes a position by placing a buy-order. Your progress through the game will determine whether you have open positions that are either long or short. Initially, you only have access long stocks. But later, you'll be able purchase short stocks (.
 
 
What are short and long stocks?
 
Long positions are the purchase of stock with the expectation that it will rise in value. Short positions make money when the price of the underlying security falls. Short stocks include securities that are borrowed, then sold, and then bought back hopefully at lower prices.
 
 
You can find more details in the game docs.
https://bitburner.readthedocs.io/en/latest/basicgameplay/stockmarket.html – [readthedocs.io]
 
 
 
 

The Bitburner Stock Market

You will first need to navigate to the Stock Market using the map. It is accessible from all cities.
 
 
WSE Account – costs 200m and is required to gain access to the stock exchange. This will add the Stock Market under the left menu, "World"
 
Market Data TIX API Access – Access to API functions that allow you to purchase/sell stocks and other stock-related tasks costs 5 billion
 
 
Four Sigma (4S) market data access – Access to 4S Forecast data is available at a cost of 1b I read somewhere that the 4S data will increase your profit 60%. That is what we require right now.
 
Four Sigma (4S) Market API Access Access to the API will cost 25b. This allows you access the TIX functions that need 4S Market Data Access.
 
 
To begin with, you will want to purchase all market access stuff at once if you have the funds. Hacking is a great way to make money by the time you have the stock market. More hacking xp equals more servers that can be hacked = more money and more hacking exp). You'll need to do it again later, once you know more. Now, the goal is to make as much cash as possible to purchase as many initial augments and learn how the stock exchange works. Remember that once you have an augment, your entire cash will disappear and you will need to start over. Also, the more money you put into the market, the more profit you'll make.
 
 
 

The Codez

After searching the web for any information, I was able to compile a script using the best code available from many different authors. I created the script to help me learn. The script is simple and easy to follow, but retains the original logic and math. I have also found formulas that a data scientist has provided for no 4S access. These formulas claim to work but I'll save them for later, maybe a more sophisticated guide. I have left in the short stock code I found, wrapped it in a flag so you can toggle it in Globals header. This flag is untested so you should be careful if you use it later.
 
 
The script will use as much money possible to buy as many favorable stock as possible in order to make as much profit as possible. When there is a massive market boom, I have seen it use as much 1q to buy stocks. I had 40t when the script was started in the morning. It made 150t in the afternoon by just letting the script run continuously. At the time of writing, I have purchased 35 augments (. Only 5 more are needed!) at 45q each. I'm currently making about 10q per day using this script. There is an achievement to make 2Q(Q not), but this script takes too long so more stock market magic would be required or some other cheat. You can also influence stock markets through hacking/growing and stock purchases. This script is only scratching the surface of all you could do to make more money.
 
 
I recommend watching the script for a few more days. Get a good understanding of the stock market's behavior – it's essentially a series of 'ebbs or tides'. Save your game file before you start if there are any problems or you just want the option to go back. You should see debug messages. You can add more to see the details. You can also see your portfolio in the stockmarket menu. This will show you how much each position has brought you, and under Stats General Money' you can see the total amount you've made on the stock markets. If you panic, you can just kill the script, and then sell everything. You won't lose much – except for commission fees.
 
 



General Display Output Script:

 
Stock Position -> How much stock do you have in the position?
 
4S Forcast What the 4S forecasts in the next market "tick" for the stock.
 
Current Stock Worth: The amount of money that you currently have in stocks.
 
Current Net Worth: The actual amount you have now, if you kill the script or sell everything. This is more your current "bank" than your overview display money or total value with everything in the stock exchange.
 
 

/** @param {NS} ns */export async function main(ns) {
 // Logging
 ns.disableLog('ALL');
 //ns.disableLog('sleep');
 //ns.disableLog('getServerMoneyAvailable');
 ns.tail();

 // Globals
 const scriptTimer = 2000; // Time script waits
 const moneyKeep = 1000000000; // Failsafe Money
 const stockBuyOver_Long = 0.60; // Buy stocks when forcast is over this % 
 const stockBuyUnder_Short = 0.40; // Buy shorts when forcast is under this % 
 const stockVolatility = 0.05; // Stocks must be under this volatility 
 const minSharePercent = 5;
 const maxSharePercent = 1.00;
 const sellThreshold_Long = 0.55; // Sell Long when chance of increasing is under this
 const sellThreshold_Short = 0.40; // Sell Short when chance of increasing is under this
 const shortUnlock = false; // Set true when short stocks are available to player

 // Functions
 function buyPositions(stock) {
 let position = ns.stock.getPosition(stock);
 let maxShares = (ns.stock.getMaxShares(stock) * maxSharePercent) - position[0];
 let maxSharesShort = (ns.stock.getMaxShares(stock) * maxSharePercent) - position[2];
 let askPrice = ns.stock.getAskPrice(stock);
 let forecast = ns.stock.getForecast(stock);
 let volatilityPercent = ns.stock.getVolatility(stock);
 let playerMoney = ns.getPlayer().money;


 // Look for Long Stocks to buy
 if (forecast >= stockBuyOver_Long && volatilityPercent <= stockVolatility) {
 if (playerMoney - moneyKeep > ns.stock.getPurchaseCost(stock, minSharePercent, "Long")) {
 let shares = Math.min((playerMoney - moneyKeep - 100000) / askPrice, maxShares);
 let boughtFor = ns.stock.buyStock(stock, shares);

 if (boughtFor > 0) {
 ns.print('Bought ' + shares + ' Long shares of ' + stock + ' for ' + ns.nFormat(boughtFor, '$0.000a'));
 }
 }
 }

 // Look for Short Stocks to buy
 if (shortUnlock) {
 if (forecast <= stockBuyUnder_Short && volatilityPercent <= stockVolatility) {
 if (playerMoney - moneyKeep > ns.stock.getPurchaseCost(stock, minSharePercent, "Short")) {
 let shares = Math.min((playerMoney - moneyKeep - 100000) / askPrice, maxSharesShort);
 let boughtFor = ns.stock.buyShort(stock, shares);

 if (boughtFor > 0) {
 ns.print('Bought ' + shares + ' Short shares of ' + stock + ' for ' + ns.nFormat(boughtFor, '$0.000a'));
 }
 }
 }
 }
 }

 function sellIfOutsideThreshdold(stock) {
 let position = ns.stock.getPosition(stock);
 let forecast = ns.stock.getForecast(stock);

 if (position[0] > 0) {
 ns.print(stock + ' 4S Forcast -> ' + forecast.toFixed(2));

 // Check if we need to sell Long stocks
 if (forecast < sellThreshold_Long) {
 let soldFor = ns.stock.sellStock(stock, position[0]);

 ns.print('Sold ' + stock + ' Long shares of ' + stock + ' for ' + ns.nFormat(soldFor, '$0.000a'));
 }
 }

 if (shortUnlock) {
 if (position[2] > 0) {
 ns.print(stock + ' 4S Forcast -> ' + forecast.toFixed(2));

 // Check if we need to sell Short stocks
 if (forecast > sellThreshold_Short) {
 let soldFor = ns.stock.sellShort(stock, position[2]);

 ns.print('Sold ' + stock + ' Short shares of ' + stock + ' for ' + ns.nFormat(soldFor, '$0.000a'));
 }
 }
 }
 }


 // Main Loop
 while (true) {
 // Get stocks in order of favorable forcast
 let orderedStocks = ns.stock.getSymbols().sort(function (a, b) { return Math.abs(0.5 - ns.stock.getForecast(b)) - Math.abs(0.5 - ns.stock.getForecast(a)); })
 let currentWorth = 0;

 ns.print("-------------------------------");
 ns.print('Current Forceasts:');

 for (const stock of orderedStocks) {
 const position = ns.stock.getPosition(stock);

 if (position[0] > 0 || position[2] > 0) {
 ns.print(stock + ' Position -> ' + position[0]);

 // Check if we need to sell
 sellIfOutsideThreshdold(stock);
 }

 // Check if we should buy
 buyPositions(stock);

 // Track out current profit over time...
 if (position[0] > 0 || position[2] > 0) {
 let longShares = position[0];
 let longPrice = position[1];
 let shortShares = position[2];
 let shortPrice = position[3];
 let bidPrice = ns.stock.getBidPrice(stock);

 // Calculate profit
 let profit = longShares * (bidPrice - longPrice) - (2 * 100000);
 let profitShort = shortShares * Math.abs(bidPrice - shortPrice) - (2 * 100000);

 // Calculate net worth
 currentWorth += profitShort + profit + (longShares * longPrice) + (shortShares * shortPrice);
 }
 }

 // Output Script Status
 ns.print('Current Stock Worth: ' + ns.nFormat(currentWorth, '$0.000a'));
 ns.print('Current Net Worth: ' + ns.nFormat(currentWorth + ns.getPlayer().money, '$0.000a'));
 ns.print(new Date().toLocaleTimeString() + ' - Running...');

 await ns.sleep(scriptTimer);
 }
}

 
 
 

The Bugz

Netscript's numeral.js library has a bug that doesn't display q after formatting numbers beyond 't'. This is noted in the Bitburner source code and the developer has created his own function (formatReallyBigNumber) to display q+ values properly in the Bitburner Overview display. If you find this annoying, you can add the functions to the script. However, I wanted to keep the script as simple and straightforward as possible.
https://github.com/danielyxie/bitburner/blob/5dc9ac040aeb410ef97294f1d545137ff98cd5bf/src/ui/numeralFormat.ts – [github.com]
 
 
You also see the message briefly when the script buys/sells. Then it disappears in the log text. It's still there – I can get it back to display briefly by fiddling around with the options and UI. This makes me suspect that it's a bug within the UI rather then the script. It's possible that someone else has figured it out and posted a comment to suggest a possible solution.
 
 
 

The Final

Good Luck on Your Journey Through the Bitburner Stock Market !
 
 
Please leave any comments.

 
 

 
 
Hope you enjoy the post for Bitburner Basic Stock Market Guide, If you think we should update the post or something is wrong please let us know via comment and we will fix it how fast as possible! Thank you and have a great day!
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*