Skip to content

Instantly share code, notes, and snippets.

@muyexi
Created January 14, 2023 06:32
Show Gist options
  • Save muyexi/73d7204aaef86fc0b258ec9f6dd97284 to your computer and use it in GitHub Desktop.
Save muyexi/73d7204aaef86fc0b258ec9f6dd97284 to your computer and use it in GitHub Desktop.
okx-watchlist.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/muyexi/73d7204aaef86fc0b258ec9f6dd97284/okx-watchlist.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"Export OKX Spot USDT markets as TradingView Watchlist."
],
"metadata": {
"id": "RHf8NWhT9Z3P"
}
},
{
"cell_type": "code",
"source": [
"!pip install ccxt"
],
"metadata": {
"collapsed": true,
"id": "O6_4jXY_9V32"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "AeSP9bKNcr8w"
},
"outputs": [],
"source": [
"import ccxt\n",
"import json\n",
"\n",
"okex = ccxt.okex()\n",
"okex.load_markets()\n",
"\n",
"market_ids = \"\"\n",
"for k,v in okex.markets.items():\n",
" if \"-USDT\" in v['id'] and \"-USDT-\" not in v['id']:\n",
" market_ids += \"OKEX:\" + v['id'].replace(\"-\", \"\") + \"\\n\"\n",
" print(\"OKEX:\" + v['id'].replace(\"-\", \"\"))\n",
"\n",
"with open(\"okex_usdt_markets.txt\", \"w\") as text_file:\n",
" text_file.write(market_ids)"
]
},
{
"cell_type": "code",
"source": [
"from google.colab import files\n",
"files.download('okex_usdt_markets.txt') "
],
"metadata": {
"id": "I1xlNIz5dYNk"
},
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
},
"colab": {
"provenance": [],
"include_colab_link": true
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment