diff --git a/README.md b/README.md index 4f1ebef..170a732 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,17 @@ This is a library-like application, which operates with orders and positions on your account. -*Current version:* **0.3** +*Current version:* **0.4** #### Features: * Creating an cancelling orders on your account. Stop-loss, Limit, passive, reduce-only, close-only, hidden orders supported. * Preventing these orders for being lost, cancelled or rejected: Supervisor will place them anew. * Supervisor closes all orders, which are not supervised. * When the supervised order has been filled, Supervisor will not try to place it. * Put callbacks on supervised orders, which are called when order has been filled, partially executed or cancelled. +* Set and maintain the position size. #### In develop: -* Manage positions on your account. - * Maintaining position size. - * Various market-price or limit entries in position. - * Enter position with rebate by tracking last market price and moving limit order up. +* Various market-price or limit entries in position. +* Enter position with rebate by tracking last market price and moving limit order up. ## Getting Started @@ -112,6 +111,12 @@ from supervisor import Supervisor supervisor = Supervisor(interface=exchange) ``` +Set necessary position size, Supervisor will fix it: + +```python +supervisor.position = 150 +``` + Create order: ```python diff --git a/example.py b/example.py index 3a91869..b48e75b 100644 --- a/example.py +++ b/example.py @@ -8,14 +8,20 @@ TEST_API_SECRET = 'your-api-secret' if __name__ == '__main__': + # Exchange is a interface-like class to call api methods exchange = Exchange(api_key=TEST_API_KEY, api_secret=TEST_API_SECRET, test=True, symbol='XBTUSD') supervisor = Supervisor(interface=exchange) + # create Order objects stop_loss = Order(order_type='Stop', stop_px=Decimal(2000), qty=10, side='Sell') tp1 = Order(order_type='Limit', price=Decimal(15000), qty=6, side='Sell', passive=True, reduce_only=True) tp2 = Order(order_type='Limit', price=Decimal(20000), qty=4, side='Sell', hidden=True) + # set needed position price + supervisor.position_size = 10 + + # attach some callbacks to stop-loss, note that events starts with "_" stop_loss._on_reject = lambda: print('Rejected') stop_loss._on_fill = lambda: print('We lost position(') stop_loss._on_cancel = lambda: print('Trading without stops is risking ;)') diff --git a/supervisor/__init__.py b/supervisor/__init__.py index 5058611..72a6251 100644 --- a/supervisor/__init__.py +++ b/supervisor/__init__.py @@ -1,3 +1,3 @@ from supervisor._supervisor import * -__version__ = '0.3' +__version__ = '0.4'