commit 03e46c82543c0b9abc8d61ca1c0b7abeb9a1b9c9 Author: Oleg Sheynin Date: Fri Aug 15 20:33:36 2025 -0400 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b10be5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/.history +**/results diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2194e59 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Get Coinbase Token", + "type": "debugpy", + "request": "launch", + "console": "integratedTerminal", + "python": "/home/oleg/.pyenv/python3.12-venv/bin/python3.12", + "env": { + "PYTHONPATH": "${workspaceFolder}/.." + }, + "program": "${workspaceFolder}/coinbase/get_futures_list.py", + "args": [ + ] + } + ] +} \ No newline at end of file diff --git a/coinbase/get_futures_list.py b/coinbase/get_futures_list.py new file mode 100644 index 0000000..ba69db8 --- /dev/null +++ b/coinbase/get_futures_list.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from cvttpy_tools.secrets import Secrets +from cvttpy_tools.app import App + +from cvttpy_tools.logger import Log +from cvttpy_trading.exchanges.coinbase.auth import create_rest_jwt + + +async def get_token(infscl_path: str) -> str: + secrets = Secrets.instance() + await secrets.load() + secret = secrets.get(key=infscl_path) + + token = create_rest_jwt( + secret=secret, + method="GET", + url="https://api.coinbase.com/api/v3/brokerage/products" + ) + return token + + +async def main(): + token = await get_token(infscl_path="COINBASE_ADV_RO") + cmd = ( + "curl" + " --request GET" + " --url" + " 'https://api.coinbase.com/api/v3/brokerage/products?" + "product_type=FUTURE" + "&expiring_contract_status=STATUS_UNEXPIRED" + "&contract_expiry_type=EXPIRING" + "'" + f" --header \"Authorization: Bearer {token}\"" + ) + + import subprocess,json,pprint + resp = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True).stdout + # pprint.pprint(json.loads(resp)) + print(resp) + +if __name__ == "__main__": + Log(log_level="WARNING") + App() + App.instance().add_call(stage=App.Stage.Run, func=main()) + App.instance().run() diff --git a/prod_utils.code-workspace b/prod_utils.code-workspace new file mode 100644 index 0000000..e30d405 --- /dev/null +++ b/prod_utils.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "../cvttpy_trading" + }, + { + "path": "../cvttpy_tools" + } + ], + "settings": { + "workbench.colorTheme": "Solarized Dark" + } +} \ No newline at end of file