You are basically leaving fees to yourself. But they should go to the exchange provider.
Line self.balance -= self.crypto_bought * current_price should be self.balance = 0 as is written in comment "buy with 100% of current balance" - this means balance should become zero after that (in your code you basically subtract from balance your balance reduced by fee so after this your balance contains fee which should be instead given to the exchange provider):
|
# Buy with 100% of current balance |
|
self.crypto_bought = self.balance / current_price |
|
self.crypto_bought *= (1-self.fees) # substract fees |
|
self.balance -= self.crypto_bought * current_price |
Line self.crypto_held -= self.crypto_sold should be self.crypto_held = 0 as you are selling here all your coins (instead you are just subtracting amount of coins reduced by fee so in your purse is left this "fee" amount of coins which should go to the exchange provider).
|
# Sell 100% of current crypto held |
|
self.crypto_sold = self.crypto_held |
|
self.crypto_sold *= (1-self.fees) # substract fees |
|
self.balance += self.crypto_sold * current_price |
|
self.crypto_held -= self.crypto_sold |
You are basically leaving fees to yourself. But they should go to the exchange provider.
Line
should beself.balance -= self.crypto_bought * current_priceself.balance = 0as is written in comment "buy with 100% of current balance" - this means balance should become zero after that (in your code you basically subtract from balance your balance reduced by fee so after this your balance contains fee which should be instead given to the exchange provider):RL-Bitcoin-trading-bot/RL-Bitcoin-trading-bot_7/RL-Bitcoin-trading-bot_7.py
Lines 265 to 268 in a01c8c8
Line
should beself.crypto_held -= self.crypto_soldself.crypto_held = 0as you are selling here all your coins (instead you are just subtracting amount of coins reduced by fee so in your purse is left this "fee" amount of coins which should go to the exchange provider).RL-Bitcoin-trading-bot/RL-Bitcoin-trading-bot_7/RL-Bitcoin-trading-bot_7.py
Lines 274 to 278 in a01c8c8