lonestar108 commited on
Commit
13edb8d
·
verified ·
1 Parent(s): 0949511

add buttons to start and stop training, and start and stop trading. in the header add a Paper/Live toggle

Browse files
Files changed (4) hide show
  1. components/navbar.js +10 -4
  2. components/tradingbot-panel.js +28 -4
  3. script.js +40 -1
  4. style.css +5 -0
components/navbar.js CHANGED
@@ -81,11 +81,17 @@ class CustomNavbar extends HTMLElement {
81
  <li><a href="#"><i data-feather="briefcase"></i> Portfolio</a></li>
82
  <li><a href="#"><i data-feather="file-text"></i> Reports</a></li>
83
  </ul>
84
- <div class="user-menu">
85
- <div class="balance">$12,345.67</div>
86
- <div class="avatar">JD</div>
 
 
 
 
 
 
87
  </div>
88
- </nav>
89
  `;
90
  }
91
  }
 
81
  <li><a href="#"><i data-feather="briefcase"></i> Portfolio</a></li>
82
  <li><a href="#"><i data-feather="file-text"></i> Reports</a></li>
83
  </ul>
84
+ <div class="flex items-center gap-4">
85
+ <div class="flex items-center bg-gray-700 rounded-full p-1">
86
+ <button class="px-3 py-1 rounded-full bg-gray-800 text-sm text-white" id="paper-mode">Paper</button>
87
+ <button class="px-3 py-1 rounded-full text-sm text-gray-400" id="live-mode">Live</button>
88
+ </div>
89
+ <div class="user-menu">
90
+ <div class="balance">$12,345.67</div>
91
+ <div class="avatar">JD</div>
92
+ </div>
93
  </div>
94
+ </nav>
95
  `;
96
  }
97
  }
components/tradingbot-panel.js CHANGED
@@ -80,9 +80,16 @@ class TradingBotPanel extends HTMLElement {
80
  </style>
81
  <div class="panel-header">
82
  <div class="panel-title">RL Trading Bot Trainer</div>
 
 
 
 
 
 
 
 
83
  </div>
84
-
85
- <div class="form-group">
86
  <label for="bot-strategy">Strategy</label>
87
  <select id="bot-strategy">
88
  <option value="qlearning">Q-Learning</option>
@@ -125,9 +132,26 @@ class TradingBotPanel extends HTMLElement {
125
  <i data-feather="stop-circle"></i> Stop
126
  </button>
127
  </div>
128
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  <div class="metrics">
130
- <div class="metric-row">
131
  <span class="metric-label">Current Episode:</span>
132
  <span class="metric-value" id="current-episode">0/100</span>
133
  </div>
 
80
  </style>
81
  <div class="panel-header">
82
  <div class="panel-title">RL Trading Bot Trainer</div>
83
+ <div class="flex gap-2">
84
+ <button class="px-2 py-1 bg-gray-700 rounded text-xs hover:bg-gray-600" id="start-trading">
85
+ <i data-feather="play"></i> Start
86
+ </button>
87
+ <button class="px-2 py-1 bg-gray-700 rounded text-xs hover:bg-gray-600" id="stop-trading" disabled>
88
+ <i data-feather="stop-circle"></i> Stop
89
+ </button>
90
+ </div>
91
  </div>
92
+ <div class="form-group">
 
93
  <label for="bot-strategy">Strategy</label>
94
  <select id="bot-strategy">
95
  <option value="qlearning">Q-Learning</option>
 
132
  <i data-feather="stop-circle"></i> Stop
133
  </button>
134
  </div>
135
+ <div class="mt-4 border-t border-gray-700 pt-4">
136
+ <h4 class="text-sm font-medium mb-2">Trading Status</h4>
137
+ <div class="bg-gray-700 rounded p-2 text-sm">
138
+ <div class="flex justify-between mb-1">
139
+ <span>Current Position:</span>
140
+ <span id="current-position">None</span>
141
+ </div>
142
+ <div class="flex justify-between mb-1">
143
+ <span>Last Action:</span>
144
+ <span id="last-action">-</span>
145
+ </div>
146
+ <div class="flex justify-between">
147
+ <span>Running:</span>
148
+ <span id="running-status">No</span>
149
+ </div>
150
+ </div>
151
+ </div>
152
+
153
  <div class="metrics">
154
+ <div class="metric-row">
155
  <span class="metric-label">Current Episode:</span>
156
  <span class="metric-value" id="current-episode">0/100</span>
157
  </div>
script.js CHANGED
@@ -79,11 +79,14 @@ function stopTrainingBot() {
79
  document.getElementById('stop-training').disabled = true;
80
  document.getElementById('training-status').textContent = 'Stopped';
81
  }
82
-
83
  // Initialize bot controls
84
  document.addEventListener('DOMContentLoaded', () => {
85
  const startBtn = document.getElementById('start-training');
86
  const stopBtn = document.getElementById('stop-training');
 
 
 
 
87
 
88
  if (startBtn) {
89
  startBtn.addEventListener('click', startTrainingBot);
@@ -92,6 +95,42 @@ document.addEventListener('DOMContentLoaded', () => {
92
  if (stopBtn) {
93
  stopBtn.addEventListener('click', stopTrainingBot);
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  });
96
  // Simulate live price updates
97
  function startLivePrices() {
 
79
  document.getElementById('stop-training').disabled = true;
80
  document.getElementById('training-status').textContent = 'Stopped';
81
  }
 
82
  // Initialize bot controls
83
  document.addEventListener('DOMContentLoaded', () => {
84
  const startBtn = document.getElementById('start-training');
85
  const stopBtn = document.getElementById('stop-training');
86
+ const startTradingBtn = document.getElementById('start-trading');
87
+ const stopTradingBtn = document.getElementById('stop-trading');
88
+ const paperModeBtn = document.getElementById('paper-mode');
89
+ const liveModeBtn = document.getElementById('live-mode');
90
 
91
  if (startBtn) {
92
  startBtn.addEventListener('click', startTrainingBot);
 
95
  if (stopBtn) {
96
  stopBtn.addEventListener('click', stopTrainingBot);
97
  }
98
+
99
+ // Trading buttons
100
+ if (startTradingBtn) {
101
+ startTradingBtn.addEventListener('click', () => {
102
+ startTradingBtn.disabled = true;
103
+ stopTradingBtn.disabled = false;
104
+ document.getElementById('running-status').textContent = 'Yes';
105
+ document.getElementById('last-action').textContent = 'Started trading';
106
+ });
107
+ }
108
+
109
+ if (stopTradingBtn) {
110
+ stopTradingBtn.addEventListener('click', () => {
111
+ startTradingBtn.disabled = false;
112
+ stopTradingBtn.disabled = true;
113
+ document.getElementById('running-status').textContent = 'No';
114
+ document.getElementById('last-action').textContent = 'Stopped trading';
115
+ });
116
+ }
117
+
118
+ // Paper/Live toggle
119
+ if (paperModeBtn && liveModeBtn) {
120
+ paperModeBtn.addEventListener('click', () => {
121
+ paperModeBtn.classList.add('bg-gray-800', 'text-white');
122
+ paperModeBtn.classList.remove('text-gray-400');
123
+ liveModeBtn.classList.remove('bg-gray-800', 'text-white');
124
+ liveModeBtn.classList.add('text-gray-400');
125
+ });
126
+
127
+ liveModeBtn.addEventListener('click', () => {
128
+ liveModeBtn.classList.add('bg-gray-800', 'text-white');
129
+ liveModeBtn.classList.remove('text-gray-400');
130
+ paperModeBtn.classList.remove('bg-gray-800', 'text-white');
131
+ paperModeBtn.classList.add('text-gray-400');
132
+ });
133
+ }
134
  });
135
  // Simulate live price updates
136
  function startLivePrices() {
style.css CHANGED
@@ -71,6 +71,11 @@ body {
71
  50% { opacity: 0; }
72
  100% { opacity: 1; }
73
  }
 
 
 
 
 
74
  /* Custom table styling */
75
  table {
76
  border-collapse: separate;
 
71
  50% { opacity: 0; }
72
  100% { opacity: 1; }
73
  }
74
+ /* Trading mode toggle */
75
+ #paper-mode, #live-mode {
76
+ transition: all 0.2s ease;
77
+ }
78
+
79
  /* Custom table styling */
80
  table {
81
  border-collapse: separate;