This commit is contained in:
Oleg Sheynin 2025-08-15 20:33:36 -04:00
commit 03e46c8254
4 changed files with 85 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
**/.history
**/results

21
.vscode/launch.json vendored Normal file
View File

@ -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": [
]
}
]
}

View File

@ -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()

16
prod_utils.code-workspace Normal file
View File

@ -0,0 +1,16 @@
{
"folders": [
{
"path": "."
},
{
"path": "../cvttpy_trading"
},
{
"path": "../cvttpy_tools"
}
],
"settings": {
"workbench.colorTheme": "Solarized Dark"
}
}