Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modify_order #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions degiroapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DeGiro:
__GET_REQUEST = 0
__POST_REQUEST = 1
__DELETE_REQUEST = 2
__PUT_REQUEST = 3

client_token = any
session_id = any
Expand Down Expand Up @@ -83,6 +84,8 @@ def __request(url, cookie=None, payload=None, headers=None, data=None, post_para
response = requests.post(url, params=post_params, json=payload)
elif request_type == DeGiro.__POST_REQUEST:
response = requests.post(url, json=payload)
elif request_type == DeGiro.__PUT_REQUEST:
response = requests.put(url, params=post_params, json=payload)
else:
raise Exception(f'Unknown request type: {request_type}')

Expand Down Expand Up @@ -158,6 +161,34 @@ def delete_order(self, orderId):
request_type=DeGiro.__DELETE_REQUEST,
error_message='Could not delete order' + " " + orderId)

def modify_order(self, orderType, orderId, productId, buySell, timeType, size, limit=None):
modify_order_params = {
'intAccount': self.client_info.account_id,
'sessionId': self.session_id,
}
if orderType == Order.Type.LIMIT:
order_payload = {
'buySell': buySell,
'orderType': Order.Type.LIMIT,
'productId': productId,
'timeType': timeType,
'size': size,
'price': limit
}
elif orderType == Order.Type.STOPLOSS:
order_payload = {
'buySell': buySell,
'orderType': Order.Type.STOPLOSS,
'productId': productId,
'timeType': timeType,
'size': size,
'stopPrice': limit
}

return self.__request(DeGiro.__ORDER_URL + orderId + ';jsessionid=' + self.session_id, None,
order_payload, request_type=DeGiro.__PUT_REQUEST,
error_message='Could not modify order' + " " + orderId)

@staticmethod
def filtercashfunds(cashfunds):
data = []
Expand Down