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

23 lines
510 B
Python

import numpy as np
from .base import Abs_Reward
class PPO_Reward(Abs_Reward):
"""The reward function defined in IJCAI 2020"""
def __init__(self, *args):
pass
def isinstant(self):
return False
def get_reward(self, performace_raise, ffr, this_tt_ratio, is_buy):
if is_buy:
this_tt_ratio = 1 / this_tt_ratio
if this_tt_ratio < 1:
return -1.0
elif this_tt_ratio < 1.1:
return 0.0
else:
return 1.0