├── .gitignore ├── LICENSE ├── README.md ├── kabusapi ├── __init__.py ├── board.py ├── cancelorder.py ├── orders.py ├── positions.py ├── ranking.py ├── register.py ├── sendorder.py ├── symbol.py ├── symbolname.py ├── unregister.py ├── wallet.py └── websocket.py └── sample ├── push_sample.py ├── sample.py └── sample_1_5.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aoi Shirasu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-kabusapi 2 | 3 | kabuステーション®API用Pythonライブラリ 4 | 5 | 公式:https://kabucom.github.io/kabusapi/ptal/index.html 6 | 7 | 使い方など: 8 | - [python-kabusapiの使い方](https://qiita.com/shirasublue/items/bbd8b5860612904deea0) 9 | - [PUSH API用にPythonラッパーをアップデートした](https://qiita.com/shirasublue/items/f51986f39dd8a3bf8310) 10 | 11 | 基本的には sample 内コードを参照のこと。 12 | 13 | requests, websockets をインストールのこと。 14 | 15 | ``` 16 | pip install requests websockets 17 | ``` 18 | -------------------------------------------------------------------------------- /kabusapi/__init__.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | from kabusapi import sendorder 5 | from kabusapi import cancelorder 6 | from kabusapi import wallet 7 | from kabusapi import board 8 | from kabusapi import symbol 9 | from kabusapi import orders 10 | from kabusapi import positions 11 | from kabusapi import symbolname 12 | from kabusapi import ranking 13 | from kabusapi import register 14 | from kabusapi import unregister 15 | from kabusapi import websocket 16 | 17 | 18 | class Context(object): 19 | def __init__( 20 | self, 21 | hostname='localhost', 22 | port=18080, 23 | password=None, 24 | token=None, 25 | ): 26 | self._hostname = hostname 27 | self._port = port 28 | self._base_url = "http://{}:{}".format( 29 | hostname, port, 30 | ) 31 | self._headers = {'Content-Type': 'application/json', } 32 | 33 | self.token = token 34 | if token: 35 | self._set_header('X-API-KEY', token) 36 | elif password: 37 | self._set_token(password) 38 | 39 | self.sendorder = sendorder.EntitySpec(self) 40 | self.cancelorder = cancelorder.EntitySpec(self) 41 | self.wallet = wallet.EntitySpec(self) 42 | self.board = board.EntitySpec(self) 43 | self.symbol = symbol.EntitySpec(self) 44 | self.orders = orders.EntitySpec(self) 45 | self.positions = positions.EntitySpec(self) 46 | self.symbolname = symbolname.EntitySpec(self) 47 | self.ranking = ranking.EntitySpec(self) 48 | self.register = register.EntitySpec(self) 49 | self.unregister = unregister.EntitySpec(self) 50 | self.websocket = websocket.EntitySpec(self) 51 | 52 | def _set_header(self, key, value): 53 | self._headers[key] = (value) 54 | 55 | def _set_token(self, password): 56 | payload = json.dumps( 57 | {'APIPassword': password, } 58 | ).encode('utf8') 59 | 60 | response = requests.post( 61 | self._base_url + '/kabusapi/token', 62 | data=payload, 63 | headers=self._headers 64 | ) 65 | 66 | try: 67 | self.token = json.loads(response.text)['Token'] 68 | except BaseException: 69 | raise Exception(response.text) 70 | 71 | self._set_header('X-API-KEY', self.token,) 72 | -------------------------------------------------------------------------------- /kabusapi/board.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | symbol = kwargs.get("symbol") 11 | exchange = kwargs.get("exchange") 12 | 13 | response = requests.get( 14 | self.ctx._base_url + '/kabusapi/board' 15 | + '/' + str(symbol) + '@' + str(exchange), 16 | headers=self.ctx._headers) 17 | 18 | return json.loads(response.text) 19 | -------------------------------------------------------------------------------- /kabusapi/cancelorder.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | payload = json.dumps(kwargs).encode('utf8') 11 | 12 | response = requests.put( 13 | self.ctx._base_url + '/kabusapi/cancelorder', 14 | payload, 15 | headers=self.ctx._headers) 16 | 17 | return json.loads(response.text) 18 | -------------------------------------------------------------------------------- /kabusapi/orders.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | payload = kwargs 11 | 12 | response = requests.get( 13 | self.ctx._base_url + '/kabusapi/orders', 14 | params=payload, 15 | headers=self.ctx._headers) 16 | 17 | return json.loads(response.text) 18 | -------------------------------------------------------------------------------- /kabusapi/positions.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | payload = kwargs 11 | 12 | response = requests.get( 13 | self.ctx._base_url + '/kabusapi/positions', 14 | params=payload, 15 | headers=self.ctx._headers) 16 | 17 | return json.loads(response.text) 18 | -------------------------------------------------------------------------------- /kabusapi/ranking.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | payload = kwargs 11 | 12 | response = requests.get( 13 | self.ctx._base_url + '/kabusapi/ranking', 14 | params=payload, 15 | headers=self.ctx._headers) 16 | 17 | return json.loads(response.text) 18 | -------------------------------------------------------------------------------- /kabusapi/register.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | symbols = kwargs.get('Symbols') 11 | payload = json.dumps( 12 | {"Symbols": symbols}).encode('utf8') 13 | 14 | response = requests.put( 15 | self.ctx._base_url + '/kabusapi/register', 16 | payload, 17 | headers=self.ctx._headers) 18 | 19 | return json.loads(response.text) 20 | -------------------------------------------------------------------------------- /kabusapi/sendorder.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | payload = json.dumps(kwargs).encode('utf8') 11 | 12 | response = requests.post( 13 | self.ctx._base_url + '/kabusapi/sendorder', 14 | payload, 15 | headers=self.ctx._headers) 16 | 17 | return json.loads(response.text) 18 | 19 | def future(self, **kwargs): 20 | payload = json.dumps(kwargs).encode('utf8') 21 | 22 | response = requests.post( 23 | self.ctx._base_url + '/kabusapi/sendorder/future', 24 | payload, 25 | headers=self.ctx._headers) 26 | 27 | return json.loads(response.text) 28 | 29 | def option(self, **kwargs): 30 | payload = json.dumps(kwargs).encode('utf8') 31 | 32 | response = requests.post( 33 | self.ctx._base_url + '/kabusapi/sendorder/option', 34 | payload, 35 | headers=self.ctx._headers) 36 | 37 | return json.loads(response.text) 38 | -------------------------------------------------------------------------------- /kabusapi/symbol.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | symbol = kwargs.get("symbol") 11 | exchange = kwargs.get("exchange") 12 | 13 | response = requests.get( 14 | self.ctx._base_url + '/kabusapi/symbol' 15 | + '/' + str(symbol) + '@' + str(exchange), 16 | headers=self.ctx._headers) 17 | 18 | return json.loads(response.text) 19 | -------------------------------------------------------------------------------- /kabusapi/symbolname.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def future(self, **kwargs): 10 | future_code = kwargs.get("FutureCode") 11 | deriv_month = kwargs.get("DerivMonth") 12 | 13 | payload = { 14 | "FutureCode": future_code, 15 | "DerivMonth": deriv_month, 16 | } 17 | 18 | response = requests.get( 19 | self.ctx._base_url + '/kabusapi/symbolname/future', 20 | params=payload, 21 | headers=self.ctx._headers) 22 | 23 | return json.loads(response.text) 24 | 25 | def option(self, **kwargs): 26 | deriv_month = kwargs.get("DerivMonth") 27 | put_or_call = kwargs.get("PutOrCall") 28 | strike_price = kwargs.get("StrikePrice") 29 | 30 | payload = { 31 | "DerivMonth": deriv_month, 32 | "PutOrCall": put_or_call, 33 | "StrikePrice": strike_price, 34 | } 35 | 36 | response = requests.get( 37 | self.ctx._base_url + '/kabusapi/symbolname/option', 38 | params=payload, 39 | headers=self.ctx._headers) 40 | 41 | return json.loads(response.text) 42 | -------------------------------------------------------------------------------- /kabusapi/unregister.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def __call__(self, **kwargs): 10 | symbols = kwargs.get('Symbols') 11 | payload = json.dumps( 12 | {"Symbols": symbols}).encode('utf8') 13 | 14 | response = requests.put( 15 | self.ctx._base_url + '/kabusapi/unregister', 16 | payload, 17 | headers=self.ctx._headers) 18 | 19 | return json.loads(response.text) 20 | 21 | def all(self): 22 | response = requests.put( 23 | self.ctx._base_url + '/kabusapi/unregister/all', 24 | headers=self.ctx._headers) 25 | 26 | return json.loads(response.text) 27 | -------------------------------------------------------------------------------- /kabusapi/wallet.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | 5 | class EntitySpec(object): 6 | def __init__(self, ctx): 7 | self.ctx = ctx 8 | 9 | def cash(self, **kwargs): 10 | symbol = kwargs.get("symbol") 11 | exchange = kwargs.get("exchange") 12 | 13 | if symbol and exchange: 14 | response = requests.get( 15 | self.ctx._base_url + '/kabusapi/wallet/cash' 16 | + '/' + str(symbol) + '@' + str(exchange), 17 | headers=self.ctx._headers) 18 | else: 19 | response = requests.get( 20 | self.ctx._base_url + '/kabusapi/wallet/cash', 21 | headers=self.ctx._headers) 22 | 23 | return json.loads(response.text) 24 | 25 | def margin(self, **kwargs): 26 | symbol = kwargs.get("symbol") 27 | exchange = kwargs.get("exchange") 28 | 29 | if symbol and exchange: 30 | response = requests.get( 31 | self.ctx._base_url + '/kabusapi/wallet/margin' 32 | + '/' + str(symbol) + '@' + str(exchange), 33 | headers=self.ctx._headers) 34 | else: 35 | response = requests.get( 36 | self.ctx._base_url + '/kabusapi/wallet/margin', 37 | headers=self.ctx._headers) 38 | 39 | return json.loads(response.text) 40 | 41 | def future(self, **kwargs): 42 | symbol = kwargs.get("symbol") 43 | exchange = kwargs.get("exchange") 44 | 45 | if symbol and exchange: 46 | response = requests.get( 47 | self.ctx._base_url + '/kabusapi/wallet/future' 48 | + '/' + str(symbol) + '@' + str(exchange), 49 | headers=self.ctx._headers) 50 | else: 51 | response = requests.get( 52 | self.ctx._base_url + '/kabusapi/wallet/future', 53 | headers=self.ctx._headers) 54 | 55 | return json.loads(response.text) 56 | 57 | def option(self, **kwargs): 58 | symbol = kwargs.get("symbol") 59 | exchange = kwargs.get("exchange") 60 | 61 | if symbol and exchange: 62 | response = requests.get( 63 | self.ctx._base_url + '/kabusapi/wallet/option' 64 | + '/' + str(symbol) + '@' + str(exchange), 65 | headers=self.ctx._headers) 66 | else: 67 | response = requests.get( 68 | self.ctx._base_url + '/kabusapi/wallet/option', 69 | headers=self.ctx._headers) 70 | 71 | return json.loads(response.text) 72 | -------------------------------------------------------------------------------- /kabusapi/websocket.py: -------------------------------------------------------------------------------- 1 | import websockets 2 | import asyncio 3 | import json 4 | import traceback 5 | 6 | 7 | class EntitySpec(object): 8 | def __init__(self, ctx): 9 | self.ctx = ctx 10 | self.uri = "ws://{}:{}/kabusapi/websocket".format( 11 | ctx._hostname, ctx._port, 12 | ) 13 | 14 | def __call__(self, func): 15 | async def stream(func): 16 | async with websockets.connect(self.uri, 17 | ping_timeout=None) as ws: 18 | while not ws.closed: 19 | response = await ws.recv() 20 | try: 21 | func(json.loads(response)) 22 | except BaseException: 23 | traceback.print_exc() 24 | self.loop.stop() 25 | self.loop = asyncio.get_event_loop() 26 | self.loop.create_task(stream(func)) 27 | return stream 28 | 29 | def run(self): 30 | self.loop.run_forever() 31 | -------------------------------------------------------------------------------- /sample/push_sample.py: -------------------------------------------------------------------------------- 1 | import kabusapi 2 | 3 | url = "localhost" 4 | port = "18081" # 検証用, 本番用は18080 5 | 6 | # 初期設定 PUSH配信にトークン・パスワードは不要 7 | api = kabusapi.Context(url, port, ) 8 | 9 | # 受信用関数 情報が受信される度にここが呼ばれる 10 | 11 | 12 | @api.websocket 13 | def recieve(msg): 14 | print(msg) 15 | # ここで処理を行う 16 | 17 | 18 | # 受信開始 19 | api.websocket.run() 20 | -------------------------------------------------------------------------------- /sample/sample.py: -------------------------------------------------------------------------------- 1 | import kabusapi 2 | 3 | url = "localhost" 4 | port = "18081" # 検証用, 本番用は18080 5 | password = "hogehoge" 6 | 7 | # 初期設定・トークン取得 8 | api = kabusapi.Context(url, port, password) 9 | 10 | # 取得トークンの表示 11 | print(api.token) 12 | 13 | # トークンを指定した初期設定 パスワードが不要 14 | api = kabusapi.Context(url, port, token='fugafuga') 15 | 16 | 17 | # 注文発注 (現物買い) 18 | data = { 19 | "Password": "hoge", 20 | "Symbol": 8306, # MUFG 21 | "Exchange": 1, 22 | "SecurityType": 1, 23 | "Side": 2, 24 | "CashMargin": 1, 25 | "MarginTradeType": None, 26 | "DelivType": 1, 27 | "FundType": "02", 28 | "AccountType": 4, 29 | "Qty": 100, 30 | "ClosePositionOrder": None, 31 | "Price": 0, 32 | "ExpireDay": 0, 33 | "FrontOrderType": 10, 34 | } 35 | response = api.sendorder(**data) 36 | 37 | 38 | # 注文取消 39 | data = { 40 | "OrderId": "hoge", 41 | "Password": "fuga", 42 | } 43 | response = api.cancelorder(**data) 44 | 45 | 46 | # 取引余力(現物) 47 | response = api.wallet.cash() 48 | 49 | 50 | # 取引余力(現物)(銘柄指定) 51 | data = { 52 | "symbol": 8306, 53 | "exchange": 1, 54 | } 55 | response = api.wallet.cash(**data) 56 | 57 | 58 | # 取引余力(信用) 59 | response = api.wallet.margin() 60 | 61 | 62 | # 取引余力(信用)(銘柄指定) 63 | data = { 64 | "symbol": 8306, 65 | "exchange": 1, 66 | } 67 | response = api.wallet.margin(**data) 68 | 69 | 70 | # 時価情報・板情報 71 | data = { 72 | "symbol": 8306, 73 | "exchange": 1, 74 | } 75 | response = api.board(**data) 76 | 77 | 78 | # 銘柄情報 79 | data = { 80 | "symbol": 8306, 81 | "exchange": 1, 82 | } 83 | response = api.symbol(**data) 84 | 85 | 86 | # 注文約定照会 87 | response = api.orders() 88 | 89 | 90 | # 残高照会 91 | response = api.positions() 92 | 93 | 94 | # 銘柄登録 95 | data = { 96 | "Symbols": [ 97 | {"Symbol": 8306, "Exchange": 1, }, 98 | {"Symbol": 9433, "Exchange": 1, }, 99 | ] 100 | } 101 | response = api.register(**data) 102 | 103 | 104 | # 銘柄登録解除 105 | data = { 106 | "Symbols": [ 107 | {"Symbol": 8306, "Exchange": 1, }, 108 | {"Symbol": 9433, "Exchange": 1, }, 109 | ] 110 | } 111 | response = api.unregister(**data) 112 | 113 | 114 | # 銘柄登録全解除 115 | response = api.unregister.all() 116 | -------------------------------------------------------------------------------- /sample/sample_1_5.py: -------------------------------------------------------------------------------- 1 | import kabusapi 2 | 3 | url = "localhost" 4 | port = "18081" 5 | password = "hogehoge" 6 | 7 | api = kabusapi.Context(url, port, password) 8 | 9 | 10 | # 注文発注 (先物買い) 11 | data = { 12 | "Password": "hoge", 13 | "Symbol": 165120018, # 日経平均先物 20/12 14 | "Exchange": 23, 15 | "TradeType": 1, 16 | "TimeInForce": 2, 17 | "Side": 2, 18 | "Qty": 1, 19 | "ClosePositionOrder": None, 20 | "FrontOrderType": 120, # 成行 21 | "Price": 0, 22 | "ExpireDay": 0, 23 | } 24 | response = api.sendorder.future(**data) 25 | print(response) 26 | 27 | 28 | # 注文発注(オプション買い) 29 | { 30 | "Password": "hoge", 31 | "Symbol": 135126818, # 日経平均オプション 20/12 プット 26875 32 | "Exchange": 23, 33 | "TradeType": 1, 34 | "TimeInForce": 2, 35 | "Side": 2, 36 | "Qty": 10, 37 | "ClosePositionOrder": None, 38 | "FrontOrderType": 120, # 成行 39 | "Price": 0, 40 | "ExpireDay": 0, 41 | } 42 | response = api.sendorder.option(**data) 43 | print(response) 44 | 45 | 46 | # 取引余力(先物) 47 | response = api.wallet.future() 48 | print(response) 49 | 50 | 51 | # 取引余力(先物)(銘柄指定) 52 | data = { 53 | "symbol": 165120018, 54 | "exchange": 23, 55 | } 56 | response = api.wallet.option(**data) 57 | print(response) 58 | 59 | 60 | # 取引余力(オプション) 61 | response = api.wallet.option() 62 | print(response) 63 | 64 | 65 | # 取引余力(オプション)(銘柄指定) 66 | data = { 67 | "symbol": 135126818, 68 | "exchange": 23, 69 | } 70 | response = api.wallet.option(**data) 71 | print(response) 72 | 73 | 74 | # 注文約定照会(取得商品選択) 75 | data = { 76 | "product": 3, # 先物 77 | } 78 | response = api.orders(**data) 79 | print(response) 80 | 81 | 82 | # 残高照会(取得商品選択) 83 | data = { 84 | "product": 4, # OP 85 | } 86 | response = api.positions(**data) 87 | print(response) 88 | 89 | 90 | # 先物銘柄コード取得 91 | data = { 92 | "FutureCode": "NK225", 93 | "DerivMonth": 0, 94 | } 95 | response = api.symbolname.future(**data) 96 | print(response) 97 | 98 | 99 | # オプション銘柄コード取得 100 | data = { 101 | "DerivMonth": 0, 102 | "PutOrCall": 'P', 103 | "StrikePrice": 0, 104 | } 105 | response = api.symbolname.option(**data) 106 | print(response) 107 | 108 | 109 | # ランキング取得 110 | data = { 111 | "Type": 1, 112 | "ExchangeDivision": 'ALL', 113 | } 114 | response = api.ranking(**data) 115 | --------------------------------------------------------------------------------