Guest User

Untitled

a guest
Nov 11th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const prompt = require("prompt-sync")({ sigint: true });
  2.  
  3. let currentProtocol = {
  4.     startingAccount: 500,
  5.     _liveTotal: 500, // Internal storage for live account total
  6.    
  7.     get baseAccount() {
  8.         return this.startingAccount;
  9.     },
  10.    
  11.     set baseAccount(bufferAdjustmentValue) {
  12.         this.startingAccount += bufferAdjustmentValue;
  13.     },
  14.    
  15.     get liveAccountTotal() {
  16.         return this._liveTotal;
  17.     },
  18.    
  19.     set liveAccountTotal(pnl = 0) {
  20.         this._liveTotal = this.startingAccount + pnl;
  21.     },
  22.    
  23.     get mlpd() {
  24.         return this.baseAccount / 2;
  25.     },
  26.    
  27.     get mlpt() {
  28.         return this.mlpd / 5;
  29.     },
  30.    
  31.     get nextRiskUnit() {
  32.         return this.mlpt * 2;
  33.     },
  34.    
  35.     get goalRiskAdjustmentBuffer() {
  36.         return this.nextRiskUnit * 5;
  37.     },
  38.    
  39.     get currentBuffer() {
  40.         return this.liveAccountTotal - this.baseAccount;
  41.     },
  42.    
  43.     get currentPercentOfGoalBuffer() {
  44.         return (this.currentBuffer / this.goalRiskAdjustmentBuffer) * 100;
  45.     },
  46. };
  47.  
  48. function bufferAdjustment() {
  49.     if (currentProtocol.currentBuffer >= currentProtocol.goalRiskAdjustmentBuffer ||
  50.         currentProtocol.currentBuffer <= -currentProtocol.mlpd) {
  51.        
  52.         console.log("\n🎯 BUFFER ADJUSTMENT TRIGGERED!");
  53.         console.log(`Previous Base Account: ${currentProtocol.baseAccount}`);
  54.         console.log(`Buffer Amount: ${currentProtocol.currentBuffer}`);
  55.        
  56.         currentProtocol.baseAccount = currentProtocol.currentBuffer;
  57.         currentProtocol._liveTotal = currentProtocol.startingAccount; // Reset live total to new base
  58.        
  59.         console.log(`New Base Account: ${currentProtocol.baseAccount}`);
  60.         console.log(`Buffer Reset to: ${currentProtocol.currentBuffer}\n`);
  61.     }
  62. }
  63.  
  64. console.log("=== Initial Protocol State ===");
  65. for (let [key, value] of Object.entries(currentProtocol)) {
  66.     if (!key.startsWith('_')) { // Don't show internal properties
  67.         console.log(`${key}: ${typeof value === 'number' ? value.toFixed(2) : value}`);
  68.     }
  69. }
  70.  
  71. let inputPnl = +prompt("\nEnter P&L (profit/loss from base): ");
  72. currentProtocol.liveAccountTotal = inputPnl;
  73.  
  74. console.log("\n=== After P&L Update ===");
  75. for (let [key, value] of Object.entries(currentProtocol)) {
  76.     if (!key.startsWith('_')) {
  77.         console.log(`${key}: ${typeof value === 'number' ? value.toFixed(2) : value}`);
  78.     }
  79. }
  80.  
  81. bufferAdjustment();
  82.  
  83. console.log("\n=== Final Protocol State ===");
  84. for (let [key, value] of Object.entries(currentProtocol)) {
  85.     if (!key.startsWith('_')) {
  86.         console.log(`${key}: ${typeof value === 'number' ? value.toFixed(2) : value}`);
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment