KarlQuant commited on
Commit
44a372a
·
verified ·
1 Parent(s): 73a05a6

Upload Quasar_axrvi_ranker.py

Browse files
Files changed (1) hide show
  1. Quasar_axrvi_ranker.py +24 -24
Quasar_axrvi_ranker.py CHANGED
@@ -4024,32 +4024,32 @@ class QuasarAXRVIBridge:
4024
  asyncio.get_event_loop().create_task(self._safe_rank_and_gate())
4025
 
4026
 
4027
- def _reward_from_broker(self, trade: "Trade") -> float:
4028
- """
4029
- Compute replay reward from broker-authoritative profit.
4030
-
4031
- For multiplier contracts, trade.profit is the actual P&L in USD.
4032
- With $1 stake, profit of 0.03 = 3% return = reward of 0.03.
4033
- """
4034
- stake = self.trade_config.amount # should be 1.0
4035
-
4036
- if trade.profit is not None:
4037
- # Profit is already absolute P&L in account currency
4038
- # Normalize to stake for reward consistency
4039
- reward = trade.profit / stake if stake > 0 else 0.0
4040
 
4041
- # Sanity check: realistic rewards are between -1.0 and 5.0
4042
- if reward < -1.0 or reward > 10.0:
4043
- logger.warning(
4044
- f"[_reward_from_broker] Unusual reward {reward:.4f} for {trade.asset} | "
4045
- f"profit={trade.profit:.4f} stake={stake}"
4046
- )
4047
 
4048
- return reward
4049
-
4050
- # Fallback (should never happen with correct poc handling)
4051
- logger.warning(f"[_reward_from_broker] No profit for {trade.asset}, returning 0")
4052
- return 0.0
 
 
 
 
 
 
 
 
 
 
 
 
4053
  async def _safe_rank_and_gate(self) -> None:
4054
  """Wrapper that silently catches errors from refill-triggered rank_and_gate()."""
4055
  try:
 
4024
  asyncio.get_event_loop().create_task(self._safe_rank_and_gate())
4025
 
4026
 
4027
+ def _reward_from_broker(self, trade: "Trade") -> float:
4028
+ """
4029
+ Compute replay reward from broker-authoritative profit.
 
 
 
 
 
 
 
 
 
 
4030
 
4031
+ For multiplier contracts, trade.profit is the actual P&L in USD.
4032
+ With $1 stake, profit of 0.03 = 3% return = reward of 0.03.
4033
+ """
4034
+ stake = self.trade_config.amount # should be 1.0
 
 
4035
 
4036
+ if trade.profit is not None:
4037
+ # Profit is already absolute P&L in account currency
4038
+ # Normalize to stake for reward consistency
4039
+ reward = trade.profit / stake if stake > 0 else 0.0
4040
+
4041
+ # Sanity check: realistic rewards are between -1.0 and 5.0
4042
+ if reward < -1.0 or reward > 10.0:
4043
+ logger.warning(
4044
+ f"[_reward_from_broker] Unusual reward {reward:.4f} for {trade.asset} | "
4045
+ f"profit={trade.profit:.4f} stake={stake}"
4046
+ )
4047
+
4048
+ return reward
4049
+
4050
+ # Fallback (should never happen with correct poc handling)
4051
+ logger.warning(f"[_reward_from_broker] No profit for {trade.asset}, returning 0")
4052
+ return 0.0
4053
  async def _safe_rank_and_gate(self) -> None:
4054
  """Wrapper that silently catches errors from refill-triggered rank_and_gate()."""
4055
  try: