1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-11 14:56:55 +08:00
Files
qlib/examples/trade/reward/pa_penalty.py
Yuchen Fang 98086e4fdc trade
2021-01-28 00:34:32 +08:00

15 lines
439 B
Python

import numpy as np
from .base import Instant_Reward
class PA_Penalty(Instant_Reward):
"""Reward: (Abs(tt_ratio_t - 1) * 10000 * v_t / target - v_t^2 * penalty) / 100"""
def __init__(self, config):
self.penalty = config["penalty"]
def get_reward(self, performance_raise, v_t, target, PA_t, *args):
reward = PA_t * v_t / target
reward -= self.penalty * (v_t / target) ** 2
return reward / 100