-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbroker.py
More file actions
22 lines (18 loc) · 687 Bytes
/
Copy pathbroker.py
File metadata and controls
22 lines (18 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class BrokerMeta(type):
"""A broker metaclass"""
def __instancecheck__(cls, instance):
return cls.__subclasscheck__(type(instance))
def __subclasscheck__(cls, subclass):
return (hasattr(subclass, 'get_position') and
callable(subclass.get_position) and
hasattr(subclass, 'place_order') and
callable(subclass.place_order))
class BrokerSuper:
"""A broker superclass"""
def get_position(self) -> str:
print("parent broker position")
def place_order(self) -> int:
pass
class FuturesBroker(metaclass=BrokerMeta):
"""broker interface built from brokerMeta metaclass."""
pass