ok now its faster
This commit is contained in:
@@ -136,10 +136,11 @@ impl TradingBot {
|
||||
|
||||
self.equity_history.push(snapshot.clone());
|
||||
|
||||
// Keep last 7 trading days of equity data (1 snapshot per minute).
|
||||
// Keep last 7 trading days of equity data (4 snapshots per minute at 15s intervals).
|
||||
const SNAPSHOTS_PER_MINUTE: usize = 4;
|
||||
const MINUTES_PER_HOUR: usize = 60;
|
||||
const DAYS_TO_KEEP: usize = 7;
|
||||
const MAX_SNAPSHOTS: usize = DAYS_TO_KEEP * HOURS_PER_DAY * MINUTES_PER_HOUR;
|
||||
const MAX_SNAPSHOTS: usize = DAYS_TO_KEEP * HOURS_PER_DAY * MINUTES_PER_HOUR * SNAPSHOTS_PER_MINUTE;
|
||||
|
||||
if self.equity_history.len() > MAX_SNAPSHOTS {
|
||||
let start = self.equity_history.len() - MAX_SNAPSHOTS;
|
||||
|
||||
@@ -73,7 +73,7 @@ pub const TRAILING_STOP_ACTIVATION: f64 = 0.12;
|
||||
pub const TRAILING_STOP_DISTANCE: f64 = 0.07;
|
||||
|
||||
// Trading intervals
|
||||
pub const BOT_CHECK_INTERVAL_SECONDS: u64 = 60;
|
||||
pub const BOT_CHECK_INTERVAL_SECONDS: u64 = 15;
|
||||
pub const BARS_LOOKBACK: usize = 100;
|
||||
|
||||
// Backtest defaults
|
||||
|
||||
@@ -250,7 +250,7 @@ const HTML_TEMPLATE: &str = r#"<!DOCTYPE html>
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
x: { grid: { color: 'rgba(255,255,255,0.05)' }, ticks: { color: '#888', maxTicksLimit: 10 } },
|
||||
x: { grid: { color: 'rgba(255,255,255,0.05)' }, ticks: { color: '#888', maxTicksLimit: 20 } },
|
||||
y: { grid: { color: 'rgba(255,255,255,0.05)' }, ticks: { color: '#888', callback: v => '$' + v.toLocaleString() } }
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ async fn api_equity() -> Json<EquityResponse> {
|
||||
if let Ok(content) = std::fs::read_to_string(&*LIVE_EQUITY_FILE) {
|
||||
if let Ok(data) = serde_json::from_str::<Vec<EquitySnapshot>>(&content) {
|
||||
if !data.is_empty() {
|
||||
const MAX_DATAPOINTS_TO_SHOW: usize = 240; // 4 hours of data (1 per minute)
|
||||
const MAX_DATAPOINTS_TO_SHOW: usize = 960; // 4 hours of data (4 per minute at 15s intervals)
|
||||
let start_index = if data.len() > MAX_DATAPOINTS_TO_SHOW {
|
||||
data.len() - MAX_DATAPOINTS_TO_SHOW
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user