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

Abstracting the exchange #104

Open
mwbrulhardt opened this issue Jul 8, 2019 · 0 comments
Open

Abstracting the exchange #104

mwbrulhardt opened this issue Jul 8, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@mwbrulhardt
Copy link
Contributor

I'm looking through the code for the environment and I notice that it is holding onto a lot of information that the exchange would be holding onto, such as:

  • balance
  • account_history
  • price (at the time of trade), etc.

It might be good to make an Exchange abstract class. This class will hold all information that has to do with your account, and in addition can be set to have a paper mode or a live trading mode. We can make a DummyExchange class to handle the cases where the algorithm is either training, testing, or in paper mode, then for live trading it would just be a matter of switching the mode to live. I think it would also make the exchanges more pluggable. So the abstract class would look something similar to this:

import abc

class Exchange(object, abc.ABCMeta):

    def ___init___(self, exchange_id, init_balance, **kwargs):
        self.exchange_id
        self.init_balance = init_balance
        self.credentials = kwargs.get('credentials', {})

    @abc.abstractmethod
    def buy(self, amount):
        raise NotImplemented

    @abc.abstractmethod
    def sell(self, amount):
        raise NotImplemented

When live trading the class would just need to be injected with the credentials so that live trading could take place. Let me know if this is at all helpful!

@notadamking notadamking added the enhancement New feature or request label Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants