initial
This commit is contained in:
commit
03e46c8254
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
**/.history
|
||||
**/results
|
||||
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal 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": [
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
46
coinbase/get_futures_list.py
Normal file
46
coinbase/get_futures_list.py
Normal 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
16
prod_utils.code-workspace
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../cvttpy_trading"
|
||||
},
|
||||
{
|
||||
"path": "../cvttpy_tools"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"workbench.colorTheme": "Solarized Dark"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user