Skip to content

Commit

Permalink
Add position-related features.
Browse files Browse the repository at this point in the history
Change __version__ to '0.4'. Update README.md. Update example.py.
  • Loading branch information
forkcs committed May 8, 2020
1 parent 0e76ea6 commit 4d8148b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;)')
Expand Down
2 changes: 1 addition & 1 deletion supervisor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from supervisor._supervisor import *

__version__ = '0.3'
__version__ = '0.4'

0 comments on commit 4d8148b

Please sign in to comment.