-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
43 lines (31 loc) · 1.04 KB
/
api.py
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
from abc import ABC, abstractmethod
from collections import namedtuple
from decimal import Decimal
from order import Order
SymbolInfo = namedtuple('SymbolInfo', 'quantity_precision, price_precision, min_notional')
class Api(ABC):
_STOP_PRICE_CORRECTION = Decimal(0.5) / 100 # 0.5%
@abstractmethod
def getSymbolInfo(self) -> SymbolInfo:
pass
@abstractmethod
def market_buy(self, symbol: str, amount: Decimal) -> Order:
pass
@abstractmethod
def isEndOfMockData(self) -> int:
pass
@abstractmethod
def get_price(self, symbol: str) -> float:
pass
# @abstractmethod
# def limit_buy(self, symbol: str, price: Decimal, amount: Decimal) -> Order:
# pass
# @abstractmethod
# def limit_sell(self, symbol: str, price: Decimal, amount: Decimal) -> Order:
# pass
@abstractmethod
def market_sell(self, symbol: str, total_quantity: Decimal) -> Order:
pass
@abstractmethod
def get_symbol_info(self, symbol: str) -> SymbolInfo:
pass