import numpy as np
import pandas as pd

class Reward_Helper(object):

    def set_reward(self, rewards, trader):
        """
        reward per t step
        reward = nav@t+1 - nav@t
        """

        NAV_chg = float(trader.acc.nav - trader.acc.prev_nav)

        # maximize NAV
        #rewards[trader.ID] = NAV_chg

        # maximize NAV, minimize num of trades (more trades gets penalized).
        if NAV_chg >= 0:
            rewards[trader.ID] = NAV_chg / (trader.acc.num_trades + 1)
        else:
            rewards[trader.ID] = NAV_chg * (trader.acc.num_trades + 1)

        trader.acc.reward = rewards[trader.ID]

        return rewards

36f6e559ff087d90a5c8a732ae3d57402e640dd0
<mask token>

<mask token>


class Reward_Helper(object):
    <mask token>

<mask token>


class Reward_Helper(object):

    def set_reward(self, rewards, trader):
        """
        reward per t step
        reward = nav@t+1 - nav@t
        """
        NAV_chg = float(trader.acc.nav - trader.acc.prev_nav)
        if NAV_chg >= 0:
            rewards[trader.ID] = NAV_chg / (trader.acc.num_trades + 1)
        else:
            rewards[trader.ID] = NAV_chg * (trader.acc.num_trades + 1)
        trader.acc.reward = rewards[trader.ID]
        return rewards

import numpy as np
import pandas as pd


class Reward_Helper(object):

    def set_reward(self, rewards, trader):
        """
        reward per t step
        reward = nav@t+1 - nav@t
        """
        NAV_chg = float(trader.acc.nav - trader.acc.prev_nav)
        if NAV_chg >= 0:
            rewards[trader.ID] = NAV_chg / (trader.acc.num_trades + 1)
        else:
            rewards[trader.ID] = NAV_chg * (trader.acc.num_trades + 1)
        trader.acc.reward = rewards[trader.ID]
        return rewards

import numpy as np
import pandas as pd

class Reward_Helper(object):

    def set_reward(self, rewards, trader):
        """
        reward per t step
        reward = nav@t+1 - nav@t
        """

        NAV_chg = float(trader.acc.nav - trader.acc.prev_nav)

        # maximize NAV
        #rewards[trader.ID] = NAV_chg

        # maximize NAV, minimize num of trades (more trades gets penalized).
        if NAV_chg >= 0:
            rewards[trader.ID] = NAV_chg / (trader.acc.num_trades + 1)
        else:
            rewards[trader.ID] = NAV_chg * (trader.acc.num_trades + 1)

        trader.acc.reward = rewards[trader.ID]

        return rewards
