Basisscript voor BN8.1 Geavanceerd script voor BN8.2-3 & BN8+ Prestatie in Bitburner.
BN8.1
functie ronde (waarde) { let tekens = ["", "k", "m", "b", "t"] let die = 0 while (waarde > 999 || waarde < -999) { waarde = Math. round(value / 10) / 100 ++welke } return waarde + tekens[die] } /** @param {NS} ns */ export async function main(ns) { ns.disableLog("ALL") let index = ns.args[0] // moet FSIG of FLCM zijn let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 while (true) { let money = (ns.getServerMoneyAvailable( "home") - vergoeding) * 0.9 let prijs = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] ns.clearLog() if (history.length > (max_history - 1) ) { if (prijs > Math.max(...geschiedenis)) { let buy = Math.floor((geld / prijs)) if ((buy + my_shares) > max_shares) { buy = max_shares - my_shares } if (kopen > 0 && (prijs * kopen) > 10000000) { ns.print("Buy(Long): " + ns.stock.buy(index, buy)) } } else if (prijs < Math.min(...history )) { if (my_shares > 0) { ns.print("Sell(Long): " + ns.stock.sell(index, my_shares)) } } } history.splice(0, 0, price) if (history.length > max_history) { history.pop() } let profit = ns.stock.getSaleGain(index, my_shares, "Long") ns.print("Index: " + index) ns.print("Max. aandelen: " + round(max_shares)) ns.print("Mijn lange aandelen: " + round(ns.stock.getPosition(index)[0])) ns.print("Prijs : $" + round(price)) ns.print("Geschiedenis opgeslagen: " + history.length) ns.print("Hoogste prijs: $" + round(Math.max(...history))) ns.print ("Laagste prijs: $" + round(Math.min(...history))) ns.print("------------------------ -") ns.print("Winst: $" + ronde(winst)) ns.print("-------------------------") while (prijs == ns.stock.getPrice(index)) { wacht op ns.sleep(100) } } }
BN8.2-3 & BN8 + prestatie
functie round(value) { let tekens = ["", "k", "m", "b", "t", "q"] let die = 0 while (waarde > 999 || waarde < -999) { value = Math.round(value / 10) / 100 ++who } return value + signs[who] } /** @param {NS} ns */ export async function main(ns) { ns.disableLog("ALL" ) let index = ns.args [0] // moet FSIG of FLCM zijn let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 while (true) { let money = ( ns.getServerMoneyAvailable("home") - vergoeding) * 0.9 let prijs = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] let my_shorts = ns.stock.getPosition(index)[ 2] ns.clearLog() if (history.length > (max_history - 1)) { if (price > Math.max(...history)) { if (my_shorts > 0) { ns.print("Verkopen(Short) ): " + ns.stock.sellShort(index, my_shorts)) } let buy = Math.floor((geld / prijs)) if ((buy + my_shares) > max_shares) { buy = max_shares - my_shares } if (kopen > 0 && (prijs * kopen) > 10000000) { ns.print("Koop (Lang): " + ns.stock.buy(inde x, kopen)) } } else if (prijs < Math.min(...history)) { if (my_shares > 0) { ns.print("Sell(Long): " + ns.stock.sell(index, my_shares)) } if (my_shorts == 0) { let buy = Math.floor(((ns.getServerMoneyAvailable("home") - fee) / price)) if (buy > max_shares) { buy = max_shares } ns.print ("Buy(Short): " + ns.stock.short(index, buy)) } } } history.splice(0, 0, price) if (history.length > max_history) { history.pop() } let winst if (my_shares > my_shorts) { profit = ns.stock.getSaleGain(index, my_shares, "Long") } else { profit = ns.stock.getSaleGain(index, my_shorts, "Short") } ns.print("Index: " + index) ns.print("Max. aandelen: " + round(max_shares)) ns.print("Mijn lange aandelen: " + round(ns.stock.getPosition(index)[0])) ns.print(" Mijn Short Shares: " + round(ns.stock.getPosition(index)[2])) ns.print("Prijs: $" + round(price)) ns.print("Geschiedenis opgeslagen: " + history.length) ns.print("Hoogste prijs: $" + round(Math.max(...geschiedenis))) ns.print("Laagste prijs: $" + round(Math.min(...geschiedenis))) ns. afdrukken(" -------------------------") ns.print("Winst: $" + ronde(winst)) ns.print("--- ----------------------") while (price == ns.stock.getPrice(index)) { wait ns.sleep(100) } } }
Dat is alles wat we hiervoor vandaag delen Bitbrander gids. Deze handleiding is oorspronkelijk gemaakt en geschreven door HeerDamned. Als we deze handleiding niet kunnen bijwerken, kunt u de laatste update vinden door deze te volgen link.