Update plateform summary
This commit is contained in:
@@ -1904,6 +1904,41 @@ export class DataClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<TopStrategiesViewModel>(null as any);
|
||||
}
|
||||
|
||||
data_GetTopStrategiesByRoi(): Promise<TopStrategiesByRoiViewModel> {
|
||||
let url_ = this.baseUrl + "/Data/GetTopStrategiesByRoi";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: RequestInit = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json"
|
||||
}
|
||||
};
|
||||
|
||||
return this.transformOptions(options_).then(transformedOptions_ => {
|
||||
return this.http.fetch(url_, transformedOptions_);
|
||||
}).then((_response: Response) => {
|
||||
return this.processData_GetTopStrategiesByRoi(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processData_GetTopStrategiesByRoi(response: Response): Promise<TopStrategiesByRoiViewModel> {
|
||||
const status = response.status;
|
||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||
if (status === 200) {
|
||||
return response.text().then((_responseText) => {
|
||||
let result200: any = null;
|
||||
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as TopStrategiesByRoiViewModel;
|
||||
return result200;
|
||||
});
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
return response.text().then((_responseText) => {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<TopStrategiesByRoiViewModel>(null as any);
|
||||
}
|
||||
|
||||
data_GetUserStrategies(agentName: string | null | undefined): Promise<UserStrategyDetailsViewModel[]> {
|
||||
let url_ = this.baseUrl + "/Data/GetUserStrategies?";
|
||||
if (agentName !== undefined && agentName !== null)
|
||||
@@ -4554,6 +4589,17 @@ export interface StrategyPerformance {
|
||||
pnL?: number;
|
||||
}
|
||||
|
||||
export interface TopStrategiesByRoiViewModel {
|
||||
topStrategiesByRoi?: StrategyRoiPerformance[] | null;
|
||||
}
|
||||
|
||||
export interface StrategyRoiPerformance {
|
||||
strategyName?: string | null;
|
||||
roi?: number;
|
||||
pnL?: number;
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
export interface UserStrategyDetailsViewModel {
|
||||
name?: string | null;
|
||||
state?: BotStatus;
|
||||
@@ -4585,9 +4631,9 @@ export interface PlatformSummaryViewModel {
|
||||
volumeChange24h?: number;
|
||||
openInterestChange24h?: number;
|
||||
positionCountChange24h?: number;
|
||||
volumeByAsset?: { [key: string]: number; } | null;
|
||||
positionCountByAsset?: { [key: string]: number; } | null;
|
||||
positionCountByDirection?: { [key: string]: number; } | null;
|
||||
volumeByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
|
||||
positionCountByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
|
||||
positionCountByDirection?: { [key in keyof typeof TradeDirection]?: number; } | null;
|
||||
lastUpdated?: Date;
|
||||
last24HourSnapshot?: Date;
|
||||
}
|
||||
|
||||
@@ -944,6 +944,17 @@ export interface StrategyPerformance {
|
||||
pnL?: number;
|
||||
}
|
||||
|
||||
export interface TopStrategiesByRoiViewModel {
|
||||
topStrategiesByRoi?: StrategyRoiPerformance[] | null;
|
||||
}
|
||||
|
||||
export interface StrategyRoiPerformance {
|
||||
strategyName?: string | null;
|
||||
roi?: number;
|
||||
pnL?: number;
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
export interface UserStrategyDetailsViewModel {
|
||||
name?: string | null;
|
||||
state?: BotStatus;
|
||||
@@ -975,9 +986,9 @@ export interface PlatformSummaryViewModel {
|
||||
volumeChange24h?: number;
|
||||
openInterestChange24h?: number;
|
||||
positionCountChange24h?: number;
|
||||
volumeByAsset?: { [key: string]: number; } | null;
|
||||
positionCountByAsset?: { [key: string]: number; } | null;
|
||||
positionCountByDirection?: { [key: string]: number; } | null;
|
||||
volumeByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
|
||||
positionCountByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
|
||||
positionCountByDirection?: { [key in keyof typeof TradeDirection]?: number; } | null;
|
||||
lastUpdated?: Date;
|
||||
last24HourSnapshot?: Date;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import React, {useEffect, useState} from 'react'
|
||||
import useApiUrlStore from '../../app/store/apiStore'
|
||||
import {DataClient, type PlatformSummaryViewModel, type TopStrategiesViewModel} from '../../generated/ManagingApi'
|
||||
import {
|
||||
DataClient,
|
||||
type PlatformSummaryViewModel,
|
||||
type TopStrategiesByRoiViewModel,
|
||||
type TopStrategiesViewModel
|
||||
} from '../../generated/ManagingApi'
|
||||
|
||||
function PlatformSummary({ index }: { index: number }) {
|
||||
const { apiUrl } = useApiUrlStore()
|
||||
const [platformData, setPlatformData] = useState<PlatformSummaryViewModel | null>(null)
|
||||
|
||||
const [topStrategies, setTopStrategies] = useState<TopStrategiesViewModel | null>(null)
|
||||
const [topStrategiesByRoi, setTopStrategiesByRoi] = useState<TopStrategiesByRoiViewModel | null>(null)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
@@ -18,13 +24,15 @@ function PlatformSummary({ index }: { index: number }) {
|
||||
const client = new DataClient({}, apiUrl)
|
||||
|
||||
// Fetch all platform data in parallel
|
||||
const [platform, top] = await Promise.all([
|
||||
const [platform, top, topRoi] = await Promise.all([
|
||||
client.data_GetPlatformSummary(),
|
||||
client.data_GetTopStrategies()
|
||||
client.data_GetTopStrategies(),
|
||||
client.data_GetTopStrategiesByRoi()
|
||||
])
|
||||
|
||||
setPlatformData(platform)
|
||||
setTopStrategies(top)
|
||||
setTopStrategiesByRoi(topRoi)
|
||||
} catch (err) {
|
||||
setError('Failed to fetch platform data')
|
||||
console.error('Error fetching platform data:', err)
|
||||
@@ -164,17 +172,17 @@ function PlatformSummary({ index }: { index: number }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Top 3 Rising (placeholder - using same data for now) */}
|
||||
{/* Top 3 Rising (by ROI) */}
|
||||
<div className="bg-base-200 rounded-lg p-6">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<span className="text-2xl">📈</span>
|
||||
<h3 className="text-lg font-semibold text-gray-400">Top 3 Rising</h3>
|
||||
<h3 className="text-lg font-semibold text-gray-400">Top 3 by ROI</h3>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{topStrategies?.topStrategies?.slice(0, 3).map((strategy, index) => (
|
||||
{topStrategiesByRoi?.topStrategiesByRoi?.slice(0, 3).map((strategy, index) => (
|
||||
<div key={index} className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center">
|
||||
<div className="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center">
|
||||
<span className="text-xs font-bold text-white">
|
||||
{strategy.strategyName?.charAt(0) || 'S'}
|
||||
</span>
|
||||
@@ -183,49 +191,22 @@ function PlatformSummary({ index }: { index: number }) {
|
||||
<div className="text-sm text-white font-medium">
|
||||
{strategy.strategyName || '[Strategy Name]'}
|
||||
</div>
|
||||
<div className="text-xs text-gray-400">📧</div>
|
||||
<div className="text-xs text-gray-400">
|
||||
Vol: {formatCurrency(strategy.volume || 0)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-red-500">🔴</span>
|
||||
<span className="text-sm text-white">1,200</span>
|
||||
<div className="text-right">
|
||||
<div className={`text-sm font-bold ${(strategy.roi || 0) >= 0 ? 'text-green-500' : 'text-red-500'}`}>
|
||||
{(strategy.roi || 0) >= 0 ? '+' : ''}{strategy.roi?.toFixed(2) || 0}%
|
||||
</div>
|
||||
<div className={`text-xs ${(strategy.pnL || 0) >= 0 ? 'text-green-400' : 'text-red-400'}`}>
|
||||
{(strategy.pnL || 0) >= 0 ? '+' : ''}{formatCurrency(strategy.pnL || 0)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)) || (
|
||||
<div className="text-gray-500 text-sm">No rising strategies found</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Top 3 Strategies */}
|
||||
<div className="bg-base-200 rounded-lg p-6">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<span className="text-2xl">⚡</span>
|
||||
<h3 className="text-lg font-semibold text-gray-400">Top 3 Strategies</h3>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{topStrategies?.topStrategies?.slice(0, 3).map((strategy, index) => {
|
||||
// Calculate a mock percentage for display
|
||||
const percentage = Math.abs((strategy.pnL || 0) / 100 * 10).toFixed(0)
|
||||
return (
|
||||
<div key={index} className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-8 h-8 bg-yellow-500 rounded-full flex items-center justify-center">
|
||||
<span className="text-xs font-bold text-black">⚡</span>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm text-white font-medium">
|
||||
{strategy.strategyName || '[Strategy Name]'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-green-500 text-sm font-bold">
|
||||
+{percentage}%
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}) || (
|
||||
<div className="text-gray-500 text-sm">No strategies found</div>
|
||||
<div className="text-gray-500 text-sm">No ROI data available</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user