feat(app): responsive asset detail layout, full width chart, reactive hero header, shimmer loaders and enriched fundamentals
This commit is contained in:
@@ -27,6 +27,7 @@ class TradeModel extends Equatable {
|
||||
final double winRate;
|
||||
final String timeframe;
|
||||
final String instrumentType;
|
||||
final String derivativeIsin;
|
||||
final DateTime? createdAt;
|
||||
|
||||
final String riskTolerance;
|
||||
@@ -67,6 +68,7 @@ class TradeModel extends Equatable {
|
||||
this.winRate = 50.0,
|
||||
this.timeframe = '1D',
|
||||
this.instrumentType = 'Stock',
|
||||
this.derivativeIsin = '',
|
||||
this.createdAt,
|
||||
this.riskTolerance = 'Moderate',
|
||||
this.vixValue = 0.0,
|
||||
@@ -92,21 +94,45 @@ class TradeModel extends Equatable {
|
||||
}
|
||||
|
||||
double get calculatedPnlAbs {
|
||||
if (pnlAbsolute != 0) return pnlAbsolute;
|
||||
if (isClosed && pnlAbsolute != 0) return pnlAbsolute;
|
||||
final curr = currentPrice;
|
||||
if (curr <= 0) return pnlAbsolute;
|
||||
final entry = actualEntryPrice > 0 ? actualEntryPrice : entryPrice;
|
||||
final curr = effectiveCurrentPrice;
|
||||
if (entry <= 0) return 0.0;
|
||||
final isShort = signalType == 'SELL' || signalType == 'SHORT';
|
||||
final rawMove = isShort ? ((entry - curr) / entry) : ((curr - entry) / entry);
|
||||
final posSize = positionSize > 0 ? positionSize : entry;
|
||||
final posSize = positionSize > 0 ? positionSize : (quantity > 0 ? quantity * entry : entry);
|
||||
final lev = leverageUsed > 0 ? leverageUsed : 1.0;
|
||||
return (rawMove * posSize * lev);
|
||||
final fees = entryFee + exitFee;
|
||||
return (rawMove * posSize * lev) - fees;
|
||||
}
|
||||
|
||||
double get calculatedPnlPct {
|
||||
if (pnlPercent != 0) return pnlPercent;
|
||||
if (isClosed && pnlPercent != 0) return pnlPercent;
|
||||
final pnlAbs = calculatedPnlAbs;
|
||||
final posSize = positionSize > 0 ? positionSize : (actualEntryPrice > 0 ? actualEntryPrice : entryPrice);
|
||||
final posSize = positionSize > 0 ? positionSize : (actualEntryPrice > 0 ? actualEntryPrice : (entryPrice > 0 ? entryPrice : 1.0));
|
||||
if (posSize <= 0) return 0.0;
|
||||
return (pnlAbs / posSize) * 100.0;
|
||||
}
|
||||
|
||||
double calculateLivePnlAbs(double livePrice) {
|
||||
if (isClosed && pnlAbsolute != 0) return pnlAbsolute;
|
||||
final curr = livePrice > 0 ? livePrice : currentPrice;
|
||||
if (curr <= 0) return pnlAbsolute;
|
||||
final entry = actualEntryPrice > 0 ? actualEntryPrice : entryPrice;
|
||||
if (entry <= 0) return 0.0;
|
||||
final isShort = signalType == 'SELL' || signalType == 'SHORT';
|
||||
final rawMove = isShort ? ((entry - curr) / entry) : ((curr - entry) / entry);
|
||||
final posSize = positionSize > 0 ? positionSize : (quantity > 0 ? quantity * entry : entry);
|
||||
final lev = leverageUsed > 0 ? leverageUsed : 1.0;
|
||||
final fees = entryFee + exitFee;
|
||||
return (rawMove * posSize * lev) - fees;
|
||||
}
|
||||
|
||||
double calculateLivePnlPct(double livePrice) {
|
||||
if (isClosed && pnlPercent != 0) return pnlPercent;
|
||||
final pnlAbs = calculateLivePnlAbs(livePrice);
|
||||
final posSize = positionSize > 0 ? positionSize : (actualEntryPrice > 0 ? actualEntryPrice : (entryPrice > 0 ? entryPrice : 1.0));
|
||||
if (posSize <= 0) return 0.0;
|
||||
return (pnlAbs / posSize) * 100.0;
|
||||
}
|
||||
@@ -161,6 +187,7 @@ class TradeModel extends Equatable {
|
||||
winRate: parseDbl(json['winRate'] ?? json['WinRate']),
|
||||
timeframe: (json['timeframe'] ?? json['Timeframe'])?.toString() ?? '1D',
|
||||
instrumentType: (json['instrumentType'] ?? json['InstrumentType'])?.toString() ?? 'Stock',
|
||||
derivativeIsin: (json['derivativeIsin'] ?? json['DerivativeIsin'] ?? json['knockoutIsin'] ?? json['KnockoutIsin'])?.toString() ?? '',
|
||||
createdAt: dt,
|
||||
riskTolerance: (json['riskTolerance'] ?? json['RiskTolerance'])?.toString() ?? 'Moderate',
|
||||
vixValue: parseDbl(json['vixValue'] ?? json['VixValue']),
|
||||
@@ -205,6 +232,7 @@ class TradeModel extends Equatable {
|
||||
'winRate': winRate,
|
||||
'timeframe': timeframe,
|
||||
'instrumentType': instrumentType,
|
||||
'derivativeIsin': derivativeIsin,
|
||||
'createdAt': createdAt?.toIso8601String(),
|
||||
'riskTolerance': riskTolerance,
|
||||
'vixValue': vixValue,
|
||||
|
||||
Reference in New Issue
Block a user