Basic Script for BN8.1 Advanced Script for BN8.2-3 & BN8+ Achievement in Bitburner.
BN8.1
function round(valeur) { let signs = ["", "k", "m", "b", "t"] let which = 0 alors que (valeur > 999 || valeur < -999) { value = Math.round(valeur / 10) / 100 ++lequel } return value + signes[lequel] } /** @param {Ns} ns */ export async function main(ns) { ns.disableLog("TOUS") let index = ns.args[0] // should be FSIG or FLCM let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 alors que (vrai) { let money = (ns.getServerMoneyAvailable("maison") - frais) * 0.9 let price = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] ns.clearLog() si (history.length > (max_history - 1)) { si (price > Math.max(...history)) { let buy = Math.floor((argent / price)) si ((acheter + my_shares) > max_shares) { buy = max_shares - my_shares } si (acheter > 0 && (price * acheter) > 10000000) { ns.print("Acheter(Long): " + ns.stock.buy(index, acheter)) } } Sinon si (price < Math.min(...history)) { si (my_shares > 0) { ns.print("Vendre(Long): " + ns.stock.sell(index, my_shares)) } } } history.splice(0, 0, price) si (history.length > max_history) { history.pop() } let profit = ns.stock.getSaleGain(index, my_shares, "Long") ns.print("Index: " + index) ns.print("Max Shares: " + rond(max_shares)) ns.print("My Long Shares: " + rond(ns.stock.getPosition(index)[0])) ns.print("Prix: $" + rond(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + rond(Math.max(...history))) ns.print("Lowest Price: $" + rond(Math.min(...history))) ns.print("-------------------------") ns.print("Profit: $" + rond(profit)) ns.print("-------------------------") alors que (price == ns.stock.getPrice(index)) { attendre le ns(100) } } }
BN8.2-3 & BN8 + Réalisation
function round(valeur) { let signs = ["", "k", "m", "b", "t", "q"] let which = 0 alors que (valeur > 999 || valeur < -999) { value = Math.round(valeur / 10) / 100 ++lequel } return value + signes[lequel] } /** @param {Ns} ns */ export async function main(ns) { ns.disableLog("TOUS") let index = ns.args[0] // should be FSIG or FLCM let history = [] let max_shares = ns.stock.getMaxShares(index) let max_history = 40 let fee = 100000 alors que (vrai) { let money = (ns.getServerMoneyAvailable("maison") - frais) * 0.9 let price = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[0] let my_shorts = ns.stock.getPosition(index)[2] ns.clearLog() si (history.length > (max_history - 1)) { si (price > Math.max(...history)) { si (my_shorts > 0) { ns.print("Vendre(Court): " + ns.stock.sellShort(index, my_shorts)) } let buy = Math.floor((argent / price)) si ((acheter + my_shares) > max_shares) { buy = max_shares - my_shares } si (acheter > 0 && (price * acheter) > 10000000) { ns.print("Acheter(Long): " + ns.stock.buy(index, acheter)) } } Sinon si (price < Math.min(...history)) { si (my_shares > 0) { ns.print("Vendre(Long): " + ns.stock.sell(index, my_shares)) } si (my_shorts == 0) { let buy = Math.floor(((ns.getServerMoneyAvailable("maison") - frais) / price)) si (acheter > max_shares) { buy = max_shares } ns.print("Acheter(Court): " + ns.stock.short(index, acheter)) } } } history.splice(0, 0, price) si (history.length > max_history) { history.pop() } let profit if (my_shares > my_shorts) { profit = ns.stock.getSaleGain(index, my_shares, "Long") } autre { profit = ns.stock.getSaleGain(index, my_shorts, "Court") } ns.print("Index: " + index) ns.print("Max Shares: " + rond(max_shares)) ns.print("My Long Shares: " + rond(ns.stock.getPosition(index)[0])) ns.print("My Short Shares: " + rond(ns.stock.getPosition(index)[2])) ns.print("Prix: $" + rond(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + rond(Math.max(...history))) ns.print("Lowest Price: $" + rond(Math.min(...history))) ns.print("-------------------------") ns.print("Profit: $" + rond(profit)) ns.print("-------------------------") alors que (price == ns.stock.getPrice(index)) { attendre le ns(100) } } }
C'est tout ce que nous partageons aujourd'hui pour cela Brûleur de bits guide. Ce guide a été initialement créé et rédigé par LorDamned. Si nous ne parvenons pas à mettre à jour ce guide, vous pouvez trouver la dernière mise à jour en suivant ceci lien.