Update bot market type
This commit is contained in:
@@ -5,7 +5,7 @@ import {useExpanded, useFilters, usePagination, useSortBy, useTable,} from 'reac
|
||||
import useApiUrlStore from '../../../app/store/apiStore'
|
||||
import useBacktestStore from '../../../app/store/backtestStore'
|
||||
import type {Backtest, LightBacktestResponse} from '../../../generated/ManagingApi'
|
||||
import {BacktestClient, BacktestSortableColumn, IndicatorType} from '../../../generated/ManagingApi'
|
||||
import {BacktestClient, BacktestSortableColumn, IndicatorType, TradingType} from '../../../generated/ManagingApi'
|
||||
import {ConfigDisplayModal, IndicatorsDisplay, SelectColumnFilter} from '../../mollecules'
|
||||
import {UnifiedTradingModal} from '../index'
|
||||
import Toast from '../../mollecules/Toast/Toast'
|
||||
@@ -148,6 +148,7 @@ interface BacktestTableProps {
|
||||
indicators?: string[] | null
|
||||
durationMinDays?: number | null
|
||||
durationMaxDays?: number | null
|
||||
tradingType?: TradingType | null
|
||||
}) => void
|
||||
filters?: {
|
||||
nameContains?: string | null
|
||||
@@ -160,6 +161,7 @@ interface BacktestTableProps {
|
||||
indicators?: string[] | null
|
||||
durationMinDays?: number | null
|
||||
durationMaxDays?: number | null
|
||||
tradingType?: TradingType | null
|
||||
}
|
||||
openFiltersTrigger?: number // When this changes, open the filter sidebar
|
||||
}
|
||||
@@ -196,6 +198,7 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
const [selectedIndicators, setSelectedIndicators] = useState<string[]>([])
|
||||
const [durationMinDays, setDurationMinDays] = useState<number | null>(null)
|
||||
const [durationMaxDays, setDurationMaxDays] = useState<number | null>(null)
|
||||
const [selectedTradingType, setSelectedTradingType] = useState<TradingType | null>(null)
|
||||
|
||||
// Delete confirmation state
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
||||
@@ -227,6 +230,7 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
setSelectedIndicators([])
|
||||
setDurationMinDays(null)
|
||||
setDurationMaxDays(null)
|
||||
setSelectedTradingType(null)
|
||||
}
|
||||
|
||||
// Refresh data function
|
||||
@@ -249,6 +253,7 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
indicators: selectedIndicators.length ? selectedIndicators : null,
|
||||
durationMinDays,
|
||||
durationMaxDays,
|
||||
tradingType: selectedTradingType,
|
||||
})
|
||||
setIsFilterOpen(false)
|
||||
}
|
||||
@@ -270,7 +275,8 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
filters.indicators?.join(',') || undefined,
|
||||
filters.durationMinDays || undefined,
|
||||
filters.durationMaxDays || undefined,
|
||||
filters.nameContains || undefined
|
||||
filters.nameContains || undefined,
|
||||
filters.tradingType || undefined
|
||||
)
|
||||
|
||||
// Parse the response to get the deleted count
|
||||
@@ -305,7 +311,8 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
filters.tickers?.length ||
|
||||
filters.indicators?.length ||
|
||||
filters.durationMinDays !== null ||
|
||||
filters.durationMaxDays !== null
|
||||
filters.durationMaxDays !== null ||
|
||||
filters.tradingType !== null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -335,6 +342,7 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
setSelectedIndicators(filters.indicators ? [...filters.indicators] : [])
|
||||
setDurationMinDays(filters.durationMinDays ?? null)
|
||||
setDurationMaxDays(filters.durationMaxDays ?? null)
|
||||
setSelectedTradingType(filters.tradingType ?? null)
|
||||
}, [filters])
|
||||
|
||||
// Handle external trigger to open filters
|
||||
@@ -507,6 +515,16 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
accessor: 'config.timeframe',
|
||||
disableSortBy: true,
|
||||
},
|
||||
{
|
||||
Filter: SelectColumnFilter,
|
||||
Header: 'Trading Type',
|
||||
accessor: 'tradingType',
|
||||
Cell: ({cell}: any) => {
|
||||
const tradingType = cell.value as TradingType;
|
||||
return <span className="badge badge-outline">{tradingType}</span>;
|
||||
},
|
||||
disableSortBy: true,
|
||||
},
|
||||
{
|
||||
Header: 'Indicators',
|
||||
accessor: 'config.scenario.indicators',
|
||||
@@ -798,6 +816,25 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Trading Type */}
|
||||
<div className="mb-6">
|
||||
<div className="mb-2 font-medium">Trading Type</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{Object.values(TradingType).map((type) => (
|
||||
<button
|
||||
key={type}
|
||||
className={`btn btn-xs ${selectedTradingType === type ? 'btn-primary' : 'btn-outline'}`}
|
||||
onClick={() => setSelectedTradingType(selectedTradingType === type ? null : type)}
|
||||
>
|
||||
{type}
|
||||
</button>
|
||||
))}
|
||||
{selectedTradingType && (
|
||||
<button className="btn btn-xs btn-ghost" onClick={() => setSelectedTradingType(null)}>Clear</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 justify-end">
|
||||
<button className="btn btn-ghost btn-sm" onClick={() => setIsFilterOpen(false)}>Cancel</button>
|
||||
<button className="btn btn-primary btn-sm" onClick={applyFilters}>Apply</button>
|
||||
|
||||
@@ -797,7 +797,7 @@ export class BacktestClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<FileResponse>(null as any);
|
||||
}
|
||||
|
||||
backtest_DeleteBacktestsByFilters(scoreMin: number | null | undefined, scoreMax: number | null | undefined, winrateMin: number | null | undefined, winrateMax: number | null | undefined, maxDrawdownMax: number | null | undefined, tickers: string | null | undefined, indicators: string | null | undefined, durationMinDays: number | null | undefined, durationMaxDays: number | null | undefined, name: string | null | undefined): Promise<FileResponse> {
|
||||
backtest_DeleteBacktestsByFilters(scoreMin: number | null | undefined, scoreMax: number | null | undefined, winrateMin: number | null | undefined, winrateMax: number | null | undefined, maxDrawdownMax: number | null | undefined, tickers: string | null | undefined, indicators: string | null | undefined, durationMinDays: number | null | undefined, durationMaxDays: number | null | undefined, name: string | null | undefined, tradingType: TradingType | null | undefined): Promise<FileResponse> {
|
||||
let url_ = this.baseUrl + "/Backtest/ByFilters?";
|
||||
if (scoreMin !== undefined && scoreMin !== null)
|
||||
url_ += "scoreMin=" + encodeURIComponent("" + scoreMin) + "&";
|
||||
@@ -819,6 +819,8 @@ export class BacktestClient extends AuthorizedApiBase {
|
||||
url_ += "durationMaxDays=" + encodeURIComponent("" + durationMaxDays) + "&";
|
||||
if (name !== undefined && name !== null)
|
||||
url_ += "name=" + encodeURIComponent("" + name) + "&";
|
||||
if (tradingType !== undefined && tradingType !== null)
|
||||
url_ += "tradingType=" + encodeURIComponent("" + tradingType) + "&";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: RequestInit = {
|
||||
@@ -945,7 +947,7 @@ export class BacktestClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<PaginatedBacktestsResponse>(null as any);
|
||||
}
|
||||
|
||||
backtest_GetBacktestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: BacktestSortableColumn | undefined, sortOrder: string | null | undefined, scoreMin: number | null | undefined, scoreMax: number | null | undefined, winrateMin: number | null | undefined, winrateMax: number | null | undefined, maxDrawdownMax: number | null | undefined, tickers: string | null | undefined, indicators: string | null | undefined, durationMinDays: number | null | undefined, durationMaxDays: number | null | undefined, name: string | null | undefined): Promise<PaginatedBacktestsResponse> {
|
||||
backtest_GetBacktestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: BacktestSortableColumn | undefined, sortOrder: string | null | undefined, scoreMin: number | null | undefined, scoreMax: number | null | undefined, winrateMin: number | null | undefined, winrateMax: number | null | undefined, maxDrawdownMax: number | null | undefined, tickers: string | null | undefined, indicators: string | null | undefined, durationMinDays: number | null | undefined, durationMaxDays: number | null | undefined, name: string | null | undefined, tradingType: TradingType | null | undefined): Promise<PaginatedBacktestsResponse> {
|
||||
let url_ = this.baseUrl + "/Backtest/Paginated?";
|
||||
if (page === null)
|
||||
throw new Error("The parameter 'page' cannot be null.");
|
||||
@@ -981,6 +983,8 @@ export class BacktestClient extends AuthorizedApiBase {
|
||||
url_ += "durationMaxDays=" + encodeURIComponent("" + durationMaxDays) + "&";
|
||||
if (name !== undefined && name !== null)
|
||||
url_ += "name=" + encodeURIComponent("" + name) + "&";
|
||||
if (tradingType !== undefined && tradingType !== null)
|
||||
url_ += "tradingType=" + encodeURIComponent("" + tradingType) + "&";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: RequestInit = {
|
||||
@@ -5482,6 +5486,7 @@ export interface TradingBotResponse {
|
||||
startupTime: Date;
|
||||
name: string;
|
||||
ticker: Ticker;
|
||||
tradingType: TradingType;
|
||||
masterAgentName?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -987,6 +987,7 @@ export interface TradingBotResponse {
|
||||
startupTime: Date;
|
||||
name: string;
|
||||
ticker: Ticker;
|
||||
tradingType: TradingType;
|
||||
masterAgentName?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {Loader, Slider} from '../../components/atoms'
|
||||
import {BottomMenuBar, Modal, Toast} from '../../components/mollecules'
|
||||
import {BacktestTable, UnifiedTradingModal} from '../../components/organism'
|
||||
import type {LightBacktestResponse} from '../../generated/ManagingApi'
|
||||
import {BacktestClient, BacktestSortableColumn} from '../../generated/ManagingApi'
|
||||
import {BacktestClient, BacktestSortableColumn, TradingType} from '../../generated/ManagingApi'
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
|
||||
@@ -38,6 +38,7 @@ const BacktestScanner: React.FC = () => {
|
||||
indicators?: string[] | null
|
||||
durationMinDays?: number | null
|
||||
durationMaxDays?: number | null
|
||||
tradingType?: TradingType | null
|
||||
}>({})
|
||||
|
||||
const { apiUrl } = useApiUrlStore()
|
||||
@@ -69,6 +70,7 @@ const BacktestScanner: React.FC = () => {
|
||||
filters.durationMinDays ?? null,
|
||||
filters.durationMaxDays ?? null,
|
||||
filters.nameContains ?? null,
|
||||
filters.tradingType ?? null,
|
||||
)
|
||||
return {
|
||||
backtests: (response.backtests as LightBacktestResponse[]) || [],
|
||||
@@ -217,6 +219,7 @@ const BacktestScanner: React.FC = () => {
|
||||
indicators?: string[] | null
|
||||
durationMinDays?: number | null
|
||||
durationMaxDays?: number | null
|
||||
tradingType?: TradingType | null
|
||||
}) => {
|
||||
setFilters(newFilters)
|
||||
setCurrentPage(1)
|
||||
@@ -246,7 +249,8 @@ const BacktestScanner: React.FC = () => {
|
||||
(filters.tickers && filters.tickers.length) ||
|
||||
(filters.indicators && filters.indicators.length) ||
|
||||
(filters.durationMinDays !== undefined && filters.durationMinDays !== null) ||
|
||||
(filters.durationMaxDays !== undefined && filters.durationMaxDays !== null)
|
||||
(filters.durationMaxDays !== undefined && filters.durationMaxDays !== null) ||
|
||||
(filters.tradingType !== undefined && filters.tradingType !== null)
|
||||
) ? (
|
||||
<div className="flex flex-wrap gap-2 items-center">
|
||||
<span className="text-sm opacity-70 mr-1">Active filters:</span>
|
||||
@@ -274,6 +278,9 @@ const BacktestScanner: React.FC = () => {
|
||||
{(filters.durationMinDays !== undefined && filters.durationMinDays !== null) || (filters.durationMaxDays !== undefined && filters.durationMaxDays !== null) ? (
|
||||
<div className="badge badge-outline">Duration: {filters.durationMinDays ?? 0}–{filters.durationMaxDays ?? '∞'} days</div>
|
||||
) : null}
|
||||
{filters.tradingType !== undefined && filters.tradingType !== null && (
|
||||
<div className="badge badge-outline">Trading Type: {filters.tradingType}</div>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user