Introduce closedTrade type

This commit is contained in:
Matthias 2020-08-25 19:52:07 +02:00
parent b0c69f6d77
commit 79886014ab
4 changed files with 36 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import 'echarts/lib/component/dataZoom';
import 'echarts/lib/component/visualMap'; import 'echarts/lib/component/visualMap';
import 'echarts/lib/component/visualMapPiecewise'; import 'echarts/lib/component/visualMapPiecewise';
import { Trade } from '@/store/types'; import { ClosedTrade } from '@/store/types';
// Define Column labels here to avoid typos // Define Column labels here to avoid typos
const CHART_PROFIT = 'Profit'; const CHART_PROFIT = 'Profit';
@ -28,7 +28,7 @@ const CHART_TRADE_COUNT = 'Trade Count';
}, },
}) })
export default class CumProfitChart extends Vue { export default class CumProfitChart extends Vue {
@Prop({ required: true }) trades!: Array<Trade>; @Prop({ required: true }) trades!: ClosedTrade[];
get cumulativeData() { get cumulativeData() {
const res: Record<string, any>[] = []; const res: Record<string, any>[] = [];

View File

@ -74,7 +74,7 @@ export default class TradeList extends Vue {
perPage = this.activeTrades ? 200 : 15; perPage = this.activeTrades ? 200 : 15;
tableFields: Array<Record<string, string>> = [ tableFields: Array<Record<string, string | Function>> = [
{ key: 'trade_id', label: 'ID' }, { key: 'trade_id', label: 'ID' },
{ key: 'pair', label: 'Pair' }, { key: 'pair', label: 'Pair' },
{ key: 'amount', label: 'Amount' }, { key: 'amount', label: 'Amount' },

View File

@ -1,7 +1,7 @@
import * as moment from 'moment'; import * as moment from 'moment';
export function formatPercent(value: number): string { export function formatPercent(value: number, decimals = 3): string {
return value ? `${(value * 100).toFixed(3)}%` : ''; return value ? `${(value * 100).toFixed(decimals)}%` : '';
} }
export function formatPrice(value: number): string { export function formatPrice(value: number): string {

View File

@ -138,3 +138,34 @@ export interface Trade {
initial_stop_loss_pct?: number; initial_stop_loss_pct?: number;
open_order_id?: string; open_order_id?: string;
} }
export interface ClosedTrade extends Trade {
fee_open_cost: number;
fee_open_currency: string;
/** Close date in the format Y-M-d HH:mm:ss */
close_date: string;
close_timestamp: number;
close_rate: number;
close_profit: number;
close_profit_abs: number;
fee_close: number;
fee_close_cost?: number;
fee_close_currency?: string;
current_rate?: number;
sell_reason?: string;
min_rate?: number;
max_rate?: number;
stop_loss_abs: number;
stop_loss_ratio: number;
stop_loss_pct: number;
stoploss_order_id?: string;
stoploss_last_update?: string;
stoploss_last_update_timestamp?: number;
initial_stop_loss_abs?: number;
initial_stop_loss_ratio?: number;
initial_stop_loss_pct?: number;
open_order_id?: string;
}