feat: add position history API and frontend integration

- Add /positions/history API endpoint
- Add position history types and API client
- Add translations for position history page
- Integrate PositionHistory component in App
This commit is contained in:
tinkle-community
2025-12-28 21:05:18 +08:00
parent 1c32c2ab08
commit d74867c220
5 changed files with 250 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ import type {
DebateMessage,
DebateVote,
DebatePersonalityInfo,
PositionHistoryResponse,
} from '../types'
import { CryptoService } from './crypto'
import { httpClient } from './httpClient'
@@ -775,4 +776,13 @@ export const api = {
const token = localStorage.getItem('auth_token')
return new EventSource(`${API_BASE}/debates/${debateId}/stream?token=${token}`)
},
// Position History API
async getPositionHistory(traderId: string, limit: number = 100): Promise<PositionHistoryResponse> {
const result = await httpClient.get<PositionHistoryResponse>(
`${API_BASE}/positions/history?trader_id=${traderId}&limit=${limit}`
)
if (!result.success) throw new Error('获取历史仓位失败')
return result.data!
},
}