Skip to content

Commit

Permalink
增加了华泰证券客户端的国债正回购/逆回购的接口。 (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixleon18 authored May 27, 2020
1 parent c775a49 commit d98f38a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions easytrader/clienttrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ def cancel_entrust(self, entrust_no):
return self._handle_pop_dialogs()
return {"message": "委托单状态错误不能撤单, 该委托单可能已经成交或者已撤"}

@perf_clock
def repo(self, security, price, amount, **kwargs):
self._switch_left_menus(["债券回购", "融资回购(正回购)"])

return self.trade(security, price, amount)

@perf_clock
def reverse_repo(self, security, price, amount, **kwargs):
self._switch_left_menus(["债券回购", "融劵回购(逆回购)"])

return self.trade(security, price, amount)


@perf_clock
def buy(self, security, price, amount, **kwargs):
self._switch_left_menus(["买入[F1]"])
Expand Down
4 changes: 4 additions & 0 deletions easytrader/pop_dialog_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def handle(self, title) -> Optional[dict]:
self._submit_by_shortcut()
return None

if "正回购" in content:
self._submit_by_shortcut()
return None

return None

if title == "提示":
Expand Down
12 changes: 12 additions & 0 deletions tests/test_easytrader.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ def test_invalid_sell(self):
def test_auto_ipo(self):
self._user.auto_ipo()

def test_invalid_repo(self):
import easytrader

with self.assertRaises(easytrader.exceptions.TradeError):
result = self._user.repo("204001", 100, 1)

def test_invalid_reverse_repo(self):
import easytrader

with self.assertRaises(easytrader.exceptions.TradeError):
result = self._user.reverse_repo("204001", 1, 100)


@unittest.skipUnless("htzq" in TEST_CLIENTS and IS_WIN_PLATFORM, "skip htzq test")
class TestHTZQClientTrader(unittest.TestCase):
Expand Down

0 comments on commit d98f38a

Please sign in to comment.