mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 23:06:58 +08:00
trade
This commit is contained in:
38
examples/trade/reward/base.py
Normal file
38
examples/trade/reward/base.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Abs_Reward(object):
|
||||
"""The abstract class for Reward."""
|
||||
|
||||
def __init__(self, config):
|
||||
return
|
||||
|
||||
def get_reward(self):
|
||||
""":return: reward"""
|
||||
reward = 0
|
||||
return reward
|
||||
|
||||
def __call__(self, *args, **kargs):
|
||||
return self.get_reward(*args, **kargs)
|
||||
|
||||
def isinstant(self):
|
||||
""":return: Whether the reward should be given at every timestep or only at the end of this episode."""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Instant_Reward(Abs_Reward):
|
||||
def __init__(self, config):
|
||||
self.ffr_ratio = config["ffr_ratio"]
|
||||
self.vvr_ratio = config["vvr_ratio"]
|
||||
|
||||
def isinstant(self):
|
||||
return True
|
||||
|
||||
|
||||
class EndEpisode_Reward(Abs_Reward):
|
||||
def __init__(self, config):
|
||||
self.ffr_ratio = config["ffr_ratio"]
|
||||
self.vvr_ratio = config["vvr_ratio"]
|
||||
|
||||
def isinstant(self):
|
||||
return False
|
||||
Reference in New Issue
Block a user