Denis Mbugua commited on
Commit
4c2987e
·
1 Parent(s): 4e2d1a9

update packages

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -8,6 +8,7 @@ from database import read_log
8
  import threading
9
  from trading_floor import run_every_n_minutes
10
  import asyncio
 
11
 
12
  mapper = {
13
  "trace": Color.WHITE,
@@ -166,9 +167,24 @@ class TraderView:
166
  self.trader.get_holdings_df(),
167
  self.trader.get_transactions_df(),
168
  )
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  def start_trading_floor():
171
  """Run trading floor in a separate thread"""
 
 
 
172
  asyncio.run(run_every_n_minutes())
173
 
174
  # Start trading floor in background thread
 
8
  import threading
9
  from trading_floor import run_every_n_minutes
10
  import asyncio
11
+ import os
12
 
13
  mapper = {
14
  "trace": Color.WHITE,
 
167
  self.trader.get_holdings_df(),
168
  self.trader.get_transactions_df(),
169
  )
170
+ # --- Add this setup block ---
171
+ MEMORY_DIR = "memory"
172
+ def setup_directories():
173
+ """Ensures the directory for the libSQL databases exists."""
174
+ if not os.path.exists(MEMORY_DIR):
175
+ try:
176
+ os.makedirs(MEMORY_DIR, exist_ok=True)
177
+ print(f"Created directory: {MEMORY_DIR}/")
178
+ except OSError as e:
179
+ # Important: Log the error if directory creation fails (e.g., due to permissions)
180
+ print(f"Error creating directory {MEMORY_DIR}: {e}")
181
+ raise
182
 
183
  def start_trading_floor():
184
  """Run trading floor in a separate thread"""
185
+ # 1. Ensure the directory is ready
186
+ setup_directories()
187
+ # 2. Proceed with running the agents
188
  asyncio.run(run_every_n_minutes())
189
 
190
  # Start trading floor in background thread