Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

feat: Migrate Trading Tab to new adapter architecture (WIP)

tilakpatel22c0f7421a927d
diff --git a/fincept-terminal-desktop/src/brokers/crypto/hyperliquid/HyperLiquidAdapter.ts b/fincept-terminal-desktop/src/brokers/crypto/hyperliquid/HyperLiquidAdapter.ts
index 1d1274217..dee735d85 100644
--- a/fincept-terminal-desktop/src/brokers/crypto/hyperliquid/HyperLiquidAdapter.ts
+++ b/fincept-terminal-desktop/src/brokers/crypto/hyperliquid/HyperLiquidAdapter.ts
@@ -6,14 +6,14 @@
* Note: Simulates market orders with 5% max slippage limit orders
*/
-import { BaseExchangeAdapter } from './BaseExchangeAdapter';
-import {
+import { BaseExchangeAdapter } from '../BaseExchangeAdapter';
+import type {
ExchangeConfig,
OrderType,
OrderSide,
OrderParams,
ExchangeCapabilities,
-} from './types';
+} from '../types';
export class HyperLiquidAdapter extends BaseExchangeAdapter {
constructor(config?: Partial<ExchangeConfig>) {
diff --git a/fincept-terminal-desktop/src/brokers/crypto/index.ts b/fincept-terminal-desktop/src/brokers/crypto/index.ts
index 43a94b0aa..aea950628 100644
--- a/fincept-terminal-desktop/src/brokers/crypto/index.ts
+++ b/fincept-terminal-desktop/src/brokers/crypto/index.ts
@@ -12,7 +12,7 @@ export { KrakenAdapter } from './kraken/KrakenAdapter';
export { HyperLiquidAdapter } from './hyperliquid/HyperLiquidAdapter';
// Paper Trading exports
-export * from './paper-trading';
+export * ;
// Exchange registry
import { KrakenAdapter } from './kraken/KrakenAdapter';
diff --git a/fincept-terminal-desktop/src/brokers/crypto/kraken/KrakenAdapter.ts b/fincept-terminal-desktop/src/brokers/crypto/kraken/KrakenAdapter.ts
index 4a24e97d8..79ca091d5 100644
--- a/fincept-terminal-desktop/src/brokers/crypto/kraken/KrakenAdapter.ts
+++ b/fincept-terminal-desktop/src/brokers/crypto/kraken/KrakenAdapter.ts
@@ -6,14 +6,14 @@
*/
import ccxt from 'ccxt';
-import { BaseExchangeAdapter } from './BaseExchangeAdapter';
-import {
+import { BaseExchangeAdapter } from '../BaseExchangeAdapter';
+import type {
ExchangeConfig,
OrderType,
OrderSide,
OrderParams,
ExchangeCapabilities,
-} from './types';
+} from '../types';
export class KrakenAdapter extends BaseExchangeAdapter {
constructor(config?: Partial<ExchangeConfig>) {
diff --git a/fincept-terminal-desktop/src/components/tabs/TradingTab.tsx b/fincept-terminal-desktop/src/components/tabs/TradingTab.tsx
index 09689f58d..b82d702ec 100644
--- a/fincept-terminal-desktop/src/components/tabs/TradingTab.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/TradingTab.tsx
@@ -1,7 +1,8 @@
// File: src/components/tabs/TradingTab.tsx
// Unified trading tab with multi-provider support and paper trading
+// Uses new broker adapter architecture
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef, useCallback } from 'react';
import { Activity, TrendingUp } from 'lucide-react';
import { ProviderSwitcher } from './trading/ProviderSwitcher';
import { PaperTradingPanel } from './trading/PaperTradingPanel';
@@ -11,14 +12,16 @@ import { TradesFeed } from './trading/TradesFeed';
import { OrderForm } from './trading/OrderForm';
import { PositionsTable } from './trading/PositionsTable';
import { useProviderContext } from '../../contexts/ProviderContext';
-import { usePaperTrading } from '../../hooks/usePaperTrading';
import { useWebSocket } from '../../hooks/useWebSocket';
import { getWebSocketManager } from '../../services/websocket';
-import type { OrderRequest } from '../../types/trading';
+import { createExchangeAdapter } from '../../brokers/crypto';
+import { createPaperTradingAdapter } from '../../paper-trading';
+import type { IExchangeAdapter } from '../../brokers/crypto/types';
+import type { Position } from 'ccxt';
// Symbol configurations per provider
const KRAKEN_PAIRS = ['BTC/USD', 'ETH/USD', 'SOL/USD', 'AVAX/USD', 'MATIC/USD'];
-const HYPERLIQUID_SYMBOLS = ['BTC', 'ETH', 'SOL', 'AVAX', 'MATIC'];
+const HYPERLIQUID_SYMBOLS = ['BTC/USDC:USDC', 'ETH/USDC:USDC', 'SOL/USDC:USDC', 'AVAX/USDC:USDC', 'MATIC/USDC:USDC'];
// Bloomberg color scheme
const BLOOMBERG_COLORS = {
@@ -39,11 +42,19 @@ export function TradingTab() {
const [isResetting, setIsResetting] = useState(false);
const [currentTime, setCurrentTime] = useState(new Date());
const [isConnected, setIsConnected] = useState(false);
+ const [positions, setPositions] = useState<Position[]>([]);
+ const [balance, setBalance] = useState<number>(0);
+ const [totalPnL, setTotalPnL] = useState<number>(0);
+ const [isLoading, setIsLoading] = useState(false);
// Get symbols based on active provider
const popularSymbols = activeProvider === 'kraken' ? KRAKEN_PAIRS : HYPERLIQUID_SYMBOLS;
const [selectedSymbol, setSelectedSymbol] = useState(popularSymbols[0]);
+ // Adapter refs
+ const realAdapterRef = useRef<IExchangeAdapter | null>(null);
+ const paperAdapterRef = useRef<IExchangeAdapter | null>(null);
+
// Initialize WebSocket connection for active provider
useEffect(() => {
const manager = getWebSocketManager();
@@ -93,16 +104,127 @@ export function TradingTab() {
return () => clearInterval(timer);
}, []);
- // Paper trading hook
- const {
- portfolio,
- positions,
- orders,
- isLoading: isPaperTradingLoading,
- placeOrder,
- closePosition,
- resetPortfolio
- } = usePaperTrading({ portfolioId: portfolioId || undefined });
+ // Initialize real adapter when provider changes
+ useEffect(() => {
+ const initAdapter = async () => {
+ try {
+ // Cleanup old adapter
+ if (realAdapterRef.current) {
+ await realAdapterRef.current.disconnect();
+ }
+
+ // Create new adapter
+ realAdapterRef.current = createExchangeAdapter(activeProvider);
+ await realAdapterRef.current.connect();
+ console.log(`[TradingTab] ${activeProvider} adapter connected`);
+ } catch (error) {
+ console.error(`[TradingTab] Failed to initialize ${activeProvider} adapter:`, error);
+ }
+ };
+
+ initAdapter();
+
+ return () => {
+ if (realAdapterRef.current) {
+ realAdapterRef.current.disconnect();
+ }
+ };
+ }, [activeProvider]);
+
+ // Initialize paper trading adapter when portfolio is created
+ useEffect(() => {
+ const initPaperTrading = async () => {
+ if (!portfolioId || !realAdapterRef.current) {
+ if (paperAdapterRef.current) {
+ await paperAdapterRef.current.disconnect();
+ paperAdapterRef.current = null;
+ }
+ setPositions([]);
+ setBalance(0);
+ setTotalPnL(0);
+ return;
+ }
+
+ try {
+ setIsLoading(true);
+
+ // Create paper trading adapter
+ paperAdapterRef.current = createPaperTradingAdapter(
+ {
+ portfolioId,
+ portfolioName: `${activeProvider.toUpperCase()} Paper Trading`,
+ provider: activeProvider,
+ assetClass: 'crypto',
+ initialBalance: 100000,
+ currency: 'USD',
+ fees: {
+ maker: activeProvider === 'kraken' ? 0.0002 : 0.0002,
+ taker: activeProvider === 'kraken' ? 0.0005 : 0.0005,
+ },
+ slippage: {
+ market: 0.001,
+ limit: 0,
+ },
+ enableMarginTrading: true,
+ defaultLeverage: 1,
+ maxLeverage: activeProvider === 'hyperliquid' ? 50 : 5,
+ },
+ realAdapterRef.current
+ );
+
+ await paperAdapterRef.current.connect();
+ console.log('[TradingTab] Paper trading adapter connected');
+
+ // Load initial data
+ await refreshPaperTradingData();
+ } catch (error) {
+ console.error('[TradingTab] Failed to initialize paper trading:', error);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ initPaperTrading();
+
+ return () => {
+ if (paperAdapterRef.current) {
+ paperAdapterRef.current.disconnect();
+ }
+ };
+ }, [portfolioId, activeProvider]);
+
+ // Refresh paper trading data
+ const refreshPaperTradingData = useCallback(async () => {
+ if (!paperAdapterRef.current) return;
+
+ try {
+ const [balanceData, positionsData] = await Promise.all([
+ paperAdapterRef.current.fetchBalance(),
+ paperAdapterRef.current.fetchPositions(),
+ ]);
+
+ // Calculate balance and P&L
+ const usdBalance = balanceData.free?.['USD'] || balanceData.free?.['USDC'] || 100000;
+ const unrealizedPnL = positionsData.reduce((sum, p) => sum + (p.unrealizedPnl || 0), 0);
+
+ setBalance(usdBalance);
+ setPositions(positionsData);
+ setTotalPnL(unrealizedPnL);
+ } catch (error) {
+ console.error('[TradingTab] Failed to refresh paper trading data:', error);
+ }
+ }, []);
+
+ // Auto-refresh positions every 5 seconds
+ useEffect(() => {
+ if (!portfolioId) return;
+
+ const interval = setInterval(() => {
+ refreshPaperTradingData();
+ }, 5000);
+
+ return () => clearInterval(interval);
+ }, [portfolioId, refreshPaperTradingData]);
// Get current price from ticker
const { message: tickerMessage } = useWebSocket(
@@ -113,22 +235,77 @@ export function TradingTab() {
const currentPrice = tickerMessage?.data?.last || tickerMessage?.data?.close || tickerMessage?.data?.mid;
+ // Handle portfolio creation
+ const handlePortfolioChange = useCallback((newPortfolioId: string | null) => {
+ setPortfolioId(newPortfolioId);
+ }, []);
+
// Handle order placement
- const handlePlaceOrder = async (order: OrderRequest) => {
- if (!portfolioId) {
+ const handlePlaceOrder = async (order: {
+ symbol: string;
+ side: 'buy' | 'sell';
+ type: string;
+ quantity: number;
+ price?: number;
+ stopPrice?: number;
+ }) => {
+ if (!portfolioId || !paperAdapterRef.current) {
throw new Error('Paper trading not enabled');
}
- const result = await placeOrder(order);
-
- if (!result.success) {
- throw new Error(result.error || 'Failed to place order');
+ try {
+ setIsLoading(true);
+
+ await paperAdapterRef.current.createOrder(
+ order.symbol,
+ order.type as any,
+ order.side,
+ order.quantity,
+ order.price,
+ order.stopPrice ? { stopPrice: order.stopPrice } : undefined
+ );
+
+ // Refresh data
+ await refreshPaperTradingData();
+ } catch (error) {
+ console.error('[TradingTab] Failed to place order:', error);
+ throw error;
+ } finally {
+ setIsLoading(false);
}
};
// Handle position close
const handleClosePosition = async (positionId: string) => {
- await closePosition(positionId);
+ if (!portfolioId || !paperAdapterRef.current) return;
+
+ try {
+ setIsLoading(true);
+
+ // Find position to close
+ const position = positions.find((p) => p.id === positionId);
+ if (!position) {
+ throw new Error('Position not found');
+ }
+
+ // Close position by placing opposite order
+ const closeSide = position.side === 'long' ? 'sell' : 'buy';
+ await paperAdapterRef.current.createOrder(
+ position.symbol,
+ 'market',
+ closeSide,
+ Math.abs(position.contracts || 0),
+ undefined,
+ { reduceOnly: true }
+ );
+
+ // Refresh data
+ await refreshPaperTradingData();
+ } catch (error) {
+ console.error('[TradingTab] Failed to close position:', error);
+ } finally {
+ setIsLoading(false);
+ }
};
// Handle portfolio reset
@@ -137,7 +314,16 @@ export function TradingTab() {
setIsResetting(true);
try {
- await resetPortfolio();
+ // For now, just recreate the adapter
+ // TODO: Implement proper reset in PaperTradingDatabase
+ if (paperAdapterRef.current) {
+ await paperAdapterRef.current.disconnect();
+ }
+
+ // Trigger re-initialization
+ const currentId = portfolioId;
+ setPortfolioId(null);
+ setTimeout(() => setPortfolioId(currentId), 100);
} finally {
setIsResetting(false);
}
@@ -200,9 +386,9 @@ export function TradingTab() {
{/* Paper Trading Panel */}
<PaperTradingPanel
portfolioId={portfolioId}
- balance={portfolio?.balance}
- totalPnL={portfolio?.totalPnL}
- onPortfolioChange={setPortfolioId}
+ balance={balance}
+ totalPnL={totalPnL}
+ onPortfolioChange={handlePortfolioChange}
onReset={handleReset}
isResetting={isResetting}
/>
@@ -255,7 +441,7 @@ export function TradingTab() {
</div>
<input
type="text"
- placeholder={activeProvider === 'kraken' ? 'BTC/USD' : 'BTC'}
+ placeholder={activeProvider === 'kraken' ? 'BTC/USD' : 'BTC/USDC:USDC'}
value={selectedSymbol}
onChange={(e) => setSelectedSymbol(e.target.value.toUpperCase())}
style={{
@@ -323,7 +509,7 @@ export function TradingTab() {
<PositionsTable
positions={positions}
onClosePosition={handleClosePosition}
- isLoading={isPaperTradingLoading}
+ isLoading={isLoading}
/>
)}
</div>
@@ -344,7 +530,7 @@ export function TradingTab() {
symbol={selectedSymbol}
currentPrice={currentPrice}
onPlaceOrder={handlePlaceOrder}
- isLoading={isPaperTradingLoading}
+ isLoading={isLoading}
/>
)}
@@ -392,11 +578,7 @@ export function TradingTab() {
<span style={{ color: GREEN }}>● PAPER TRADING ACTIVE</span>
<span style={{ marginLeft: '8px' }}>|</span>
<span style={{ marginLeft: '8px' }}>
- {positions.filter(p => p.status === 'open').length} Open Position{positions.filter(p => p.status === 'open').length !== 1 ? 's' : ''}
- </span>
- <span style={{ marginLeft: '8px' }}>|</span>
- <span style={{ marginLeft: '8px' }}>
- {orders.filter(o => o.status === 'pending').length} Pending Order{orders.filter(o => o.status === 'pending').length !== 1 ? 's' : ''}
+ {positions.length} Open Position{positions.length !== 1 ? 's' : ''}
</span>
</>
) : (
diff --git a/fincept-terminal-desktop/src/components/tabs/trading/PaperTradingPanel.tsx b/fincept-terminal-desktop/src/components/tabs/trading/PaperTradingPanel.tsx
index 333ac45bb..143a1eff2 100644
--- a/fincept-terminal-desktop/src/components/tabs/trading/PaperTradingPanel.tsx
+++ b/fincept-terminal-desktop/src/components/tabs/trading/PaperTradingPanel.tsx
@@ -1,9 +1,9 @@
// File: src/components/tabs/trading/PaperTradingPanel.tsx
// Paper trading control panel with toggle and portfolio display
-import React, { useState, useEffect } from 'react';
-import { useCreatePaperPortfolio } from '../../../hooks/usePaperTrading';
+import React, { useState } from 'react';
import { useProviderContext } from '../../../contexts/ProviderContext';
+import { paperTradingDatabase } from '../../../paper-trading';
interface PaperTradingPanelProps {
portfolioId: string | null;
@@ -23,21 +23,30 @@ export function PaperTradingPanel({
isResetting
}: PaperTradingPanelProps) {
const [enabled, setEnabled] = useState(!!portfolioId);
- const { createPortfolio, isCreating } = useCreatePaperPortfolio();
+ const [isCreating, setIsCreating] = useState(false);
const { activeProvider } = useProviderContext();
const handleToggle = async () => {
if (!enabled) {
// Enable paper trading - create new portfolio
- const newPortfolioId = await createPortfolio(
- `${activeProvider.toUpperCase()} Paper Trading`,
- activeProvider,
- 100000
- );
+ setIsCreating(true);
+ try {
+ const newPortfolioId = crypto.randomUUID();
+
+ await paperTradingDatabase.createPortfolio({
+ id: newPortfolioId,
+ name: `${activeProvider.toUpperCase()} Paper Trading`,
+ provider: activeProvider,
+ initialBalance: 100000,
+ currency: 'USD',
+ });
- if (newPortfolioId) {
setEnabled(true);
onPortfolioChange(newPortfolioId);
+ } catch (error) {
+ console.error('[PaperTradingPanel] Failed to create portfolio:', error);
+ } finally {
+ setIsCreating(false);
}
} else {
// Disable paper trading
diff --git a/fincept-terminal-desktop/src/hooks/usePaperTrading.ts b/fincept-terminal-desktop/src/hooks/usePaperTrading.ts
deleted file mode 100644
index f0fb26fa4..000000000
--- a/fincept-terminal-desktop/src/hooks/usePaperTrading.ts
+++ /dev/null
@@ -1,258 +0,0 @@
-// File: src/hooks/usePaperTrading.ts
-// React hook for paper trading functionality
-
-import { useState, useEffect, useCallback, useRef } from 'react';
-import { createPaperTradingService } from '../services/trading';
-import type {
- VirtualPortfolio,
- Position,
- Order,
- OrderRequest,
- OrderResult
-} from '../types/trading';
-
-interface UsePaperTradingOptions {
- portfolioId?: string;
- autoRefreshInterval?: number; // milliseconds, default 1000
-}
-
-interface UsePaperTradingReturn {
- portfolio: VirtualPortfolio | null;
- positions: Position[];
- orders: Order[];
- isLoading: boolean;
- error: string | null;
- placeOrder: (order: OrderRequest) => Promise<OrderResult>;
- cancelOrder: (orderId: string) => Promise<boolean>;
- closePosition: (positionId: string) => Promise<boolean>;
- resetPortfolio: () => Promise<boolean>;
- refresh: () => Promise<void>;
-}
-
-export function usePaperTrading(
- options: UsePaperTradingOptions = {}
-): UsePaperTradingReturn {
- const { portfolioId, autoRefreshInterval = 1000 } = options;
-
- const [portfolio, setPortfolio] = useState<VirtualPortfolio | null>(null);
- const [positions, setPositions] = useState<Position[]>([]);
- const [orders, setOrders] = useState<Order[]>([]);
- const [isLoading, setIsLoading] = useState(false);
- const [error, setError] = useState<string | null>(null);
-
- const serviceRef = useRef(createPaperTradingService());
- const refreshIntervalRef = useRef<NodeJS.Timeout | null>(null);
-
- // Load portfolio data
- const loadPortfolio = useCallback(async () => {
- if (!portfolioId) {
- setPortfolio(null);
- setPositions([]);
- setOrders([]);
- return;
- }
-
- try {
- const service = serviceRef.current;
- await service.initialize();
-
- const [portfolioData, positionsData, ordersData] = await Promise.all([
- service.getPortfolio(portfolioId),
- service.getPositions(portfolioId, 'all'),
- service.getOrders(portfolioId)
- ]);
-
- setPortfolio(portfolioData);
- setPositions(positionsData);
- setOrders(ordersData);
- setError(null);
- } catch (err) {
- console.error('[usePaperTrading] Failed to load portfolio:', err);
- setError(err instanceof Error ? err.message : 'Failed to load portfolio');
- }
- }, [portfolioId]);
-
- // Initial load
- useEffect(() => {
- setIsLoading(true);
- loadPortfolio().finally(() => setIsLoading(false));
- }, [loadPortfolio]);
-
- // Auto-refresh positions (for real-time P&L updates)
- useEffect(() => {
- if (!portfolioId || !autoRefreshInterval) return;
-
- refreshIntervalRef.current = setInterval(() => {
- loadPortfolio();
- }, autoRefreshInterval);
-
- return () => {
- if (refreshIntervalRef.current) {
- clearInterval(refreshIntervalRef.current);
- }
- };
- }, [portfolioId, autoRefreshInterval, loadPortfolio]);
-
- // Place order
- const placeOrder = useCallback(async (order: OrderRequest): Promise<OrderResult> => {
- if (!portfolioId) {
- return { success: false, error: 'No portfolio selected' };
- }
-
- setIsLoading(true);
- try {
- const service = serviceRef.current;
- const result = await service.placeOrder(portfolioId, order);
-
- if (result.success) {
- // Refresh data
- await loadPortfolio();
- }
-
- setError(null);
- return result;
- } catch (err) {
- const errorMsg = err instanceof Error ? err.message : 'Failed to place order';
- setError(errorMsg);
- return { success: false, error: errorMsg };
- } finally {
- setIsLoading(false);
- }
- }, [portfolioId, loadPortfolio]);
-
- // Cancel order
- const cancelOrder = useCallback(async (orderId: string): Promise<boolean> => {
- setIsLoading(true);
- try {
- const service = serviceRef.current;
- const success = await service.cancelOrder(orderId);
-
- if (success) {
- await loadPortfolio();
- }
-
- setError(null);
- return success;
- } catch (err) {
- console.error('[usePaperTrading] Failed to cancel order:', err);
- setError(err instanceof Error ? err.message : 'Failed to cancel order');
- return false;
- } finally {
- setIsLoading(false);
- }
- }, [loadPortfolio]);
-
- // Close position
- const closePosition = useCallback(async (positionId: string): Promise<boolean> => {
- setIsLoading(true);
- try {
- const service = serviceRef.current;
- const success = await service.closePosition(positionId);
-
- if (success) {
- await loadPortfolio();
- }
-
- setError(null);
- return success;
- } catch (err) {
- console.error('[usePaperTrading] Failed to close position:', err);
- setError(err instanceof Error ? err.message : 'Failed to close position');
- return false;
- } finally {
- setIsLoading(false);
- }
- }, [loadPortfolio]);
-
- // Reset portfolio
- const resetPortfolio = useCallback(async (): Promise<boolean> => {
- if (!portfolioId) return false;
-
- setIsLoading(true);
- try {
- const service = serviceRef.current;
- const success = await service.resetPortfolio(portfolioId);
-
- if (success) {
- await loadPortfolio();
- }
-
- setError(null);
- return success;
- } catch (err) {
- console.error('[usePaperTrading] Failed to reset portfolio:', err);
- setError(err instanceof Error ? err.message : 'Failed to reset portfolio');
- return false;
- } finally {
- setIsLoading(false);
- }
- }, [portfolioId, loadPortfolio]);
-
- // Manual refresh
- const refresh = useCallback(async () => {
- setIsLoading(true);
- await loadPortfolio();
- setIsLoading(false);
- }, [loadPortfolio]);
-
- // Cleanup on unmount
- useEffect(() => {
- return () => {
- serviceRef.current.cleanup();
- if (refreshIntervalRef.current) {
- clearInterval(refreshIntervalRef.current);
- }
- };
- }, []);
-
- return {
- portfolio,
- positions,
- orders,
- isLoading,
- error,
- placeOrder,
- cancelOrder,
- closePosition,
- resetPortfolio,
- refresh
- };
-}
-
-/**
- * Hook for creating a new paper trading portfolio
- */
-export function useCreatePaperPortfolio() {
- const [isCreating, setIsCreating] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const serviceRef = useRef(createPaperTradingService());
-
- const createPortfolio = useCallback(async (
- name: string,
- provider: string,
- initialBalance: number = 100000
- ): Promise<string | null> => {
- setIsCreating(true);
- setError(null);
-
- try {
- const service = serviceRef.current;
- await service.initialize();
-
- const portfolioId = await service.createPortfolio(name, provider, initialBalance);
- return portfolioId;
- } catch (err) {
- console.error('[useCreatePaperPortfolio] Failed to create portfolio:', err);
- setError(err instanceof Error ? err.message : 'Failed to create portfolio');
- return null;
- } finally {
- setIsCreating(false);
- }
- }, []);
-
- return {
- createPortfolio,
- isCreating,
- error
- };
-}
diff --git a/fincept-terminal-desktop/src/paper-trading/OrderMatchingEngine.ts b/fincept-terminal-desktop/src/paper-trading/OrderMatchingEngine.ts
index 8708aa47e..d4561c47c 100644
--- a/fincept-terminal-desktop/src/paper-trading/OrderMatchingEngine.ts
+++ b/fincept-terminal-desktop/src/paper-trading/OrderMatchingEngine.ts
@@ -6,7 +6,7 @@
*/
import type { Ticker, OrderBook } from 'ccxt';
-import type { IExchangeAdapter, OrderType, OrderSide, OrderParams, Order } from '../types';
+import type { IExchangeAdapter, OrderType, OrderSide, OrderParams, Order } from '../brokers/crypto/types';
import type {
PaperTradingConfig,
PaperTradingOrder,
@@ -16,7 +16,7 @@ import type {
} from './types';
import { paperTradingDatabase } from './PaperTradingDatabase';
import { PaperTradingBalance } from './PaperTradingBalance';
-import { InsufficientFunds } from '../types';
+import { InsufficientFunds } from '../brokers/crypto/types';
export class OrderMatchingEngine {
private balanceManager: PaperTradingBalance;
diff --git a/fincept-terminal-desktop/src/paper-trading/PaperTradingBalance.ts b/fincept-terminal-desktop/src/paper-trading/PaperTradingBalance.ts
index 58042eafe..c509c1649 100644
--- a/fincept-terminal-desktop/src/paper-trading/PaperTradingBalance.ts
+++ b/fincept-terminal-desktop/src/paper-trading/PaperTradingBalance.ts
@@ -12,8 +12,8 @@ import type {
MarginRequirement,
LiquidationCheck,
} from './types';
-import type { OrderSide } from '../types';
-import { InsufficientFunds } from '../types';
+import type { OrderSide } from '../brokers/crypto/types';
+import { InsufficientFunds } from '../brokers/crypto/types';
import { paperTradingDatabase } from './PaperTradingDatabase';
export class PaperTradingBalance {
diff --git a/fincept-terminal-desktop/src/paper-trading/PaperTradingDatabase.ts b/fincept-terminal-desktop/src/paper-trading/PaperTradingDatabase.ts
index dcd8ca0c7..2e10f2e6a 100644
--- a/fincept-terminal-desktop/src/paper-trading/PaperTradingDatabase.ts
+++ b/fincept-terminal-desktop/src/paper-trading/PaperTradingDatabase.ts
@@ -5,7 +5,7 @@
* Uses existing paper_trading_* tables from sqliteService
*/
-import { sqliteService } from '../../../services/sqliteService';
+import { sqliteService } from '../services/sqliteService';
import type {
PaperTradingPortfolio,
PaperTradingPosition,
@@ -16,7 +16,7 @@ import type {
DBOrder,
DBTrade,
} from './types';
-import type { Order, OrderSide } from '../types';
+import type { Order, OrderSide } from '../brokers/crypto/types';
export class PaperTradingDatabase {
// ============================================================================