Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is having a high reward and low profit a normal case? #8

Closed
toksis opened this issue Apr 13, 2020 · 13 comments
Closed

[Question] Is having a high reward and low profit a normal case? #8

toksis opened this issue Apr 13, 2020 · 13 comments

Comments

@toksis
Copy link

toksis commented Apr 13, 2020

Hello,

Is reward calculation ok? I have a high reward but on a loss profit.
Reward

I am using stable baselines.

I am using this signal features.

def my_process_data(env):
    start = env.frame_bound[0] - env.window_size
    end = env.frame_bound[1]
    prices = env.df.loc[:, 'Close'].to_numpy()[start:end]
    # print(env.df)
    indi = Indicators(env.df)
    signal_features = env.df.loc[:, ['Close', 'Open', 'High', 'Low','Volume']].to_numpy()[start+1:end]
    #signal_features = env.df.loc[:, ['Close','Volume']].to_numpy()[start+1:end]
    
   
    rsi = indi.rsi(5,1)
    rsicolumn = rsi.to_numpy()[start:end].reshape(-1,1)
    print("rsi shape: ",rsicolumn.shape)
    signal_features = np.append(signal_features, rsicolumn, axis=1)
    
    # print(signal_features)
    return prices, signal_features      
@AminHP
Copy link
Owner

AminHP commented Apr 13, 2020

Did you change the unit_side?

@toksis
Copy link
Author

toksis commented Apr 13, 2020

Hello, I did not change the unit side. Only the signal features.

@AminHP
Copy link
Owner

AminHP commented Apr 13, 2020

Try to change its value to right and show me the result.

@toksis
Copy link
Author

toksis commented Apr 13, 2020

I am running it now. I will update you later.

@toksis
Copy link
Author

toksis commented Apr 13, 2020

Training Done
rsi shape:  (6224, 1)
C:\anaconda\envs\StableBaselines\lib\site-packages\gym\logger.py:30: UserWarning: WARN: Box bound precision lowered by casting to float32
m
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
info: {'total_reward': 3.8000000000004697, 'total_profit': 0.9996196706347698, 'position': 0}
ploting renderall

env_maker = lambda: MyForexEnv(df=FOREX_EURUSD_1H_ASK,unit_side = 'right', window_size=5, frame_bound=(5, len(FOREX_EURUSD_1H_ASK)))

@AminHP
Copy link
Owner

AminHP commented Apr 14, 2020

There is a fact you may notice. Maximizing the reward does not necessarily increase the profit. Because parameters like trade_fee, etc are not considered in calculating the reward. It is very difficult to find a proper reward calculation method.

Once I tried to use profit as reward, but it didn't get better. Maybe I missed something. But you should look for a good reward function, and that's an essential part of solving such a problem.

@toksis
Copy link
Author

toksis commented Apr 21, 2020

Hello, in your code, how will the machine know if the one you buy is the one you sell and when there is a trade? thank you

@AminHP
Copy link
Owner

AminHP commented Apr 21, 2020

Hi!

What do you mean by "the one you buy is the one you sell"? Can you explain it a bit more?

Here you can find if there is a trade.

@toksis
Copy link
Author

toksis commented Apr 21, 2020

I mean your Trade. You buy forex NZD/USD and at .65 then you sell it at .69 to close your position.

@AminHP
Copy link
Owner

AminHP commented Apr 21, 2020

I'm not sure that I understand what you mean correctly. But if you are asking how the machine knows which buy action is a trade, the answer is:

If you check out the source code here, you will see that the actual trade only happens when the position changes. So, having like 100 buy actions in a row doesn't make 100 trades.

@toksis
Copy link
Author

toksis commented Apr 22, 2020

Thank you. So the multi buy action is a hold. Then when there is a Sell, it will close a trade.
So there is only one buy and sell trade per session? Is that it? thanks

@AminHP
Copy link
Owner

AminHP commented Apr 22, 2020

Yes, it is like you said.

@toksis
Copy link
Author

toksis commented Apr 22, 2020

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants