Skip to content

Errors in deduction of fees - fees are actually not applied at all #24

@mikosat

Description

@mikosat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions