-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexchange_interface.py
More file actions
77 lines (60 loc) · 2.89 KB
/
exchange_interface.py
File metadata and controls
77 lines (60 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import abc
from typing import List
from model.savings import InterestData
from model.transaction import TradingPair, TradeData
from model.withdrawal_deposit import WithdrawalData, DepositData
class ExchangeException(Exception):
pass
class ExchangeUnderMaintenanceException(ExchangeException):
pass
class AbstractCryptoExchangeClient(metaclass=abc.ABCMeta):
@classmethod
def __subclasshook__(cls, subclass):
return (callable(subclass.get_trading_pairs) and
hasattr(subclass, 'get_trading_pairs') and
callable(subclass.get_trades) and
hasattr(subclass, 'get_trades') and
callable(subclass.get_savings_interests) and
hasattr(subclass, 'get_savings_interests') and
callable(subclass.get_withdrawals) and
hasattr(subclass, 'get_withdrawals') and
callable(subclass.get_deposits) and
hasattr(subclass, 'get_deposits') or
NotImplemented)
@abc.abstractmethod
def get_trading_pairs(self, list_of_symbols_and_codes: List[str]) -> List[TradingPair]:
raise NotImplementedError
@abc.abstractmethod
def get_trades(self, from_timestamp: int, to_timestamp: int, list_of_trading_pairs: List[TradingPair]) -> List[TradeData]:
raise NotImplementedError
@abc.abstractmethod
def get_savings_interests(self, from_timestamp: int, to_timestamp: int, list_of_assets: List[str]) -> List[InterestData]:
raise NotImplementedError
@abc.abstractmethod
def get_withdrawals(self, from_timestamp: int, to_timestamp: int, list_of_assets: List[str]) -> List[WithdrawalData]:
raise NotImplementedError
@abc.abstractmethod
def get_deposits(self, from_timestamp: int, to_timestamp: int, list_of_assets: List[str]) -> List[DepositData]:
raise NotImplementedError
class AbstractCryptoExchangeClientModule(metaclass=abc.ABCMeta):
@classmethod
def __subclasshook__(cls, subclass):
return (callable(subclass.get_exchange_client) and
hasattr(subclass, 'get_exchange_client') and
callable(subclass.get_exchange_name) and
hasattr(subclass, 'get_exchange_name') and
callable(subclass.is_enabled) and
hasattr(subclass, 'is_enabled') or
NotImplemented)
@abc.abstractmethod
def get_exchange_client(self) -> AbstractCryptoExchangeClient:
raise NotImplementedError
# return here the instance of your client implementation
@abc.abstractmethod
def get_exchange_name(self) -> str:
raise NotImplementedError
# return here the exchange name which will be used for logging and user-interaction purposes
@abc.abstractmethod
def is_enabled(self) -> bool:
raise NotImplementedError
# return here if the plugin is enabled and all needed configuration is set