Basic Script for BN8.1 Advanced Script for BN8.2-3 & BN8+ Achievement in Bitburner.
BN8.1
function round(값) { let signs = ["", "k", "중", "비", "티"] let which = 0 ~하는 동안 (값 > 999 || 값 < -999) { value = Math.round(값 / 10) / 100 ++어느 } return value + 손짓[어느] } /** @param {NS} ns */ 비동기 함수 메인 내보내기(ns) { ns.disableLog("모두") 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 ~하는 동안 (진실) { let money = (ns.getServerMoneyAvailable("집") - 요금) * 0.9 let price = ns.stock.getPrice(index) let my_shares = ns.stock.getPosition(index)[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("구입하다(긴): " + ns.stock.buy(index, 구입하다)) } } else if (price < Math.min(...history)) { 만약에 (my_shares > 0) { ns.print("팔다(긴): " + ns.stock.sell(index, my_shares)) } } } history.splice(0, 0, price) 만약에 (history.length > max_history) { history.pop() } let profit = ns.stock.getSaleGain(index, my_shares, "긴") ns.print("Index: " + index) ns.print("Max Shares: " + 둥근(max_shares)) ns.print("My Long Shares: " + 둥근(ns.stock.getPosition(index)[0])) ns.print("가격: $" + 둥근(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + 둥근(Math.max(...history))) ns.print("Lowest Price: $" + 둥근(Math.min(...history))) ns.print("-------------------------") ns.print("이익: $" + 둥근(이익)) ns.print("-------------------------") ~하는 동안 (price == ns.stock.getPrice(index)) { ns.sleep을 기다리세요(100) } } }
BN8.2-3 & BN8 + 성취
function round(값) { let signs = ["", "k", "중", "비", "티", "큐"] let which = 0 ~하는 동안 (값 > 999 || 값 < -999) { value = Math.round(값 / 10) / 100 ++어느 } return value + 손짓[어느] } /** @param {NS} ns */ 비동기 함수 메인 내보내기(ns) { ns.disableLog("모두") 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 ~하는 동안 (진실) { let money = (ns.getServerMoneyAvailable("집") - 요금) * 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() 만약에 (history.length > (max_history - 1)) { 만약에 (price > Math.max(...history)) { 만약에 (my_shorts > 0) { ns.print("팔다(짧은): " + ns.stock.sellShort(index, my_shorts)) } let buy = Math.floor((돈 / price)) 만약에 ((구입하다 + my_shares) > max_shares) { buy = max_shares - my_shares } 만약에 (구입하다 > 0 && (price * 구입하다) > 10000000) { ns.print("구입하다(긴): " + ns.stock.buy(index, 구입하다)) } } else if (price < Math.min(...history)) { 만약에 (my_shares > 0) { ns.print("팔다(긴): " + ns.stock.sell(index, my_shares)) } 만약에 (my_shorts == 0) { let buy = Math.floor(((ns.getServerMoneyAvailable("집") - 요금) / price)) 만약에 (구입하다 > max_shares) { buy = max_shares } ns.print("구입하다(짧은): " + ns.stock.short(index, 구입하다)) } } } history.splice(0, 0, price) 만약에 (history.length > max_history) { history.pop() } let profit if (my_shares > my_shorts) { profit = ns.stock.getSaleGain(index, my_shares, "긴") } 또 다른 { profit = ns.stock.getSaleGain(index, my_shorts, "짧은") } ns.print("Index: " + index) ns.print("Max Shares: " + 둥근(max_shares)) ns.print("My Long Shares: " + 둥근(ns.stock.getPosition(index)[0])) ns.print("My Short Shares: " + 둥근(ns.stock.getPosition(index)[2])) ns.print("가격: $" + 둥근(price)) ns.print("History saved: " + history.length) ns.print("Highest Price: $" + 둥근(Math.max(...history))) ns.print("Lowest Price: $" + 둥근(Math.min(...history))) ns.print("-------------------------") ns.print("이익: $" + 둥근(이익)) ns.print("-------------------------") ~하는 동안 (price == ns.stock.getPrice(index)) { ns.sleep을 기다리세요(100) } } }