Basic Script for BN8.1 Advanced Script for BN8.2-3 & BN8+ Achievement in Bitburner.
BN8.1
function round(قيمة) { let signs = ["", "k", "م", "ب", "t"] let which = 0 بينما (قيمة > 999 || قيمة < -999) { value = Math.round(قيمة / 10) / 100 ++which } return value + signs[which] } /** @param {ن.س} نانوثانية */ وظيفة التصدير غير المتزامنة الرئيسية(نانوثانية) { ns.disableLog("ALL") let index = ns.args[0] // should be FSIG or FLCM let history = [] let max_shares = ns.stock.getMaxShares(فِهرِس) let max_history = 40 let fee = 100000 بينما (حقيقي) { let money = (ns.getServerMoneyAvailable("home") - fee) * 0.9 let price = ns.stock.getPrice(فِهرِس) let my_shares = ns.stock.getPosition(فِهرِس)[0] ns.clearLog() لو (history.length > (max_history - 1)) { لو (price > Math.max(...history)) { let buy = Math.floor((مال / price)) لو ((يشتري + my_shares) > max_shares) { buy = max_shares - my_shares } لو (يشتري > 0 && (price * يشتري) > 10000000) { ns.print("Buy(Long): " + ns.stock.buy(فِهرِس, يشتري)) } } else if (price < Math.min(...history)) { لو (my_shares > 0) { ns.print("يبيع(Long): " + ns.stock.sell(فِهرِس, my_shares)) } } } history.splice(0, 0, price) لو (history.length > max_history) { history.pop() } let profit = ns.stock.getSaleGain(فِهرِس, my_shares, "Long") ns.print("Index: " + فِهرِس) ns.print("Max Shares: " + round(max_shares)) ns.print("My Long Shares: " + round(ns.stock.getPosition(فِهرِس)[0])) ns.print("سعر: $" + round(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + round(Math.max(...history))) ns.print("Lowest Price: $" + round(Math.min(...history))) ns.print("-------------------------") ns.print("ربح: $" + round(profit)) ns.print("-------------------------") بينما (price == ns.stock.getPrice(فِهرِس)) { انتظر ns.sleep(100) } } }
BN8.2-3 & BN8 + إنجاز
function round(قيمة) { let signs = ["", "k", "م", "ب", "t", "q"] let which = 0 بينما (قيمة > 999 || قيمة < -999) { value = Math.round(قيمة / 10) / 100 ++which } return value + signs[which] } /** @param {ن.س} نانوثانية */ وظيفة التصدير غير المتزامنة الرئيسية(نانوثانية) { ns.disableLog("ALL") let index = ns.args[0] // should be FSIG or FLCM let history = [] let max_shares = ns.stock.getMaxShares(فِهرِس) let max_history = 40 let fee = 100000 بينما (حقيقي) { let money = (ns.getServerMoneyAvailable("home") - fee) * 0.9 let price = ns.stock.getPrice(فِهرِس) let my_shares = ns.stock.getPosition(فِهرِس)[0] let my_shorts = ns.stock.getPosition(فِهرِس)[2] ns.clearLog() لو (history.length > (max_history - 1)) { لو (price > Math.max(...history)) { لو (my_shorts > 0) { ns.print("يبيع(Short): " + ns.stock.sellShort(فِهرِس, my_shorts)) } let buy = Math.floor((مال / price)) لو ((يشتري + my_shares) > max_shares) { buy = max_shares - my_shares } لو (يشتري > 0 && (price * يشتري) > 10000000) { ns.print("Buy(Long): " + ns.stock.buy(فِهرِس, يشتري)) } } else if (price < Math.min(...history)) { لو (my_shares > 0) { ns.print("يبيع(Long): " + ns.stock.sell(فِهرِس, my_shares)) } لو (my_shorts == 0) { let buy = Math.floor(((ns.getServerMoneyAvailable("home") - fee) / price)) لو (يشتري > max_shares) { buy = max_shares } ns.print("Buy(Short): " + ns.stock.short(فِهرِس, يشتري)) } } } history.splice(0, 0, price) لو (history.length > max_history) { history.pop() } let profit if (my_shares > my_shorts) { profit = ns.stock.getSaleGain(فِهرِس, my_shares, "Long") } else { profit = ns.stock.getSaleGain(فِهرِس, my_shorts, "Short") } ns.print("Index: " + فِهرِس) ns.print("Max Shares: " + round(max_shares)) ns.print("My Long Shares: " + round(ns.stock.getPosition(فِهرِس)[0])) ns.print("My Short Shares: " + round(ns.stock.getPosition(فِهرِس)[2])) ns.print("سعر: $" + round(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + round(Math.max(...history))) ns.print("Lowest Price: $" + round(Math.min(...history))) ns.print("-------------------------") ns.print("ربح: $" + round(profit)) ns.print("-------------------------") بينما (price == ns.stock.getPrice(فِهرِس)) { انتظر ns.sleep(100) } } }
هذا كل ما نشاركه اليوم من أجل هذا بيتبورنر مرشد. تم إنشاء هذا الدليل وكتابته في الأصل بواسطة LorDamned. في حالة فشلنا في تحديث هذا الدليل, يمكنك العثور على آخر تحديث باتباع هذا وصلة.