Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 1x 1x 2x 1x 3x | import { BaseClient } from './baseClient';
export interface StrategyResponse {
id: number;
offer_id: string;
title: string;
master_length: number;
risk_level: string;
splitting: string;
provider: string;
max_loss: number;
max_gain: number;
}
export interface StrategyTradesRequestOptions {
startDate?: number;
endDate?: number;
}
export interface StrategyTrade {
id: number;
offer_id: string;
symbol: string;
asset: string;
direction: string;
price: number;
original_price: number | undefined;
underlying_price: number;
timestamp: number;
quantity: number;
status: string;
tag: string;
created_at: string;
updated_at: string;
}
export type StrategyTradesResponse = StrategyTrade[];
export interface StrategyStateResponse {
id: number;
offer_id: string;
apy_all: string;
apy_2y: string;
apy_1y: string;
apy_6m: string;
apy_3m: string;
apy_1m: string;
max_drawdown_percentage: string;
max_drawdown_duration: string;
longest_gap_duration: string;
timestamp: string;
strategy_data: string;
strategy_trade_data?: string;
tvl: string;
max_capacity: string;
created_at: string;
updated_at: string;
}
/**
* Strategy service client
*/
export class StrategyClient extends BaseClient {
/**
* Retrieves the high-level information for the given strategy
*
* @param strategyName The name of the strategy
* @returns {Promise<StrategyResponse>}
*/
public getStrategy(strategyName: string): Promise<StrategyResponse> {
return this.get(`/${strategyName}`);
}
/**
* Retrieves the current state for the given strategy
*
* @param strategyName The name of the strategy
* @returns {Promise<StrategyStateResponse>}
*/
public getStrategyState(
strategyName: string,
): Promise<StrategyStateResponse> {
return this.get(`/${strategyName}/state`);
}
/**
* Retrieves the trades for the given strategy, with optional filters for start/end date
*
* @param strategyName The name of the strategy
* @param options Optional filters for start/end date
* @returns {Promise<StrategyTradesResponse>}
*/
public getStrategyTrades(
strategyName: string,
{ startDate, endDate }: StrategyTradesRequestOptions = {},
): Promise<StrategyTradesResponse> {
return this.get(`/${strategyName}/trades`, {
start_date: startDate,
end_date: endDate,
});
}
}
|