Skip to content

Commit fc25c0b

Browse files
committed
Add new API Client.get_orders
1 parent ed4ec60 commit fc25c0b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

shipane_sdk/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def get_positions(self, client=None, timeout=None):
7777
positions = pd.DataFrame(json['dataTable']['rows'], columns=json['dataTable']['columns'])
7878
return {'sub_accounts': sub_accounts, 'positions': positions}
7979

80+
def get_orders(self, client=None, status="", timeout=None):
81+
request = Request('GET', self.__create_url(client, 'orders', status=status))
82+
response = self.__send_request(request, timeout)
83+
json = response.json()
84+
df = pd.DataFrame(json['dataTable']['rows'], columns=json['dataTable']['columns'])
85+
return df
86+
8087
def buy(self, client=None, timeout=None, **kwargs):
8188
kwargs['action'] = 'BUY'
8289
return self.__execute(client, timeout, **kwargs)

tests/shipane_sdk/test_client.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ def test_get_positions(self):
4343
except HTTPError as e:
4444
self.fail()
4545

46+
def test_get_orders(self):
47+
try:
48+
df = self.client.get_orders(self.client_param)
49+
self.assertIsNotNone(df['委托编号'][0])
50+
except HTTPError as e:
51+
self.fail()
52+
53+
def test_get_open_orders(self):
54+
try:
55+
df = self.client.get_orders(self.client_param, 'open')
56+
self.assertIsNotNone(df['委托编号'][0])
57+
except HTTPError as e:
58+
self.fail()
59+
60+
def test_get_filled_orders(self):
61+
try:
62+
df = self.client.get_orders(self.client_param, 'filled')
63+
self.assertIsNotNone(df['委托编号'][0])
64+
except HTTPError as e:
65+
self.fail()
66+
4667
def test_buy_stock(self):
4768
try:
4869
order = self.client.buy(self.client_param, symbol='000001', price=8.11, amount=100)

0 commit comments

Comments
 (0)