Files
Funding_Rate/mexc.ipynb

307 lines
7.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"id": "7a3f41bd",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import requests\n",
"from datetime import datetime"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "3b48e1ce",
"metadata": {},
"outputs": [],
"source": [
"mexc_all_tickers = 'https://api.mexc.com/api/v1/contract/ticker'\n",
"edgex_all_tickers = 'https://pro.edgex.exchange/api/v1/public/quote/getTicker/?contractId=10000001'"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "ab38d984",
"metadata": {},
"outputs": [],
"source": [
"r = requests.get(mexc_all_tickers)\n",
"data = r.json()['data']"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "2976b377",
"metadata": {},
"outputs": [],
"source": [
"r = requests.get(edgex_all_tickers)\n",
"data = r.json()['data']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1139b1a3",
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(data)\n",
"df['fundingRate_pct'] = df['fundingRate']*100"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b00512dc",
"metadata": {},
"outputs": [],
"source": [
"df_trim = df[['symbol','fundingRate_pct','volume24']].copy()\n",
"df_trim = df_trim.loc[df_trim['volume24'] > 10_000]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f7b44068",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>symbol</th>\n",
" <th>fundingRate_pct</th>\n",
" <th>volume24</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>55</th>\n",
" <td>DRIFT_USDT</td>\n",
" <td>-1.1360</td>\n",
" <td>3308466</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>RED_USDT</td>\n",
" <td>-1.1138</td>\n",
" <td>105826673</td>\n",
" </tr>\n",
" <tr>\n",
" <th>157</th>\n",
" <td>PIXEL_USDT</td>\n",
" <td>-0.4059</td>\n",
" <td>12415472</td>\n",
" </tr>\n",
" <tr>\n",
" <th>105</th>\n",
" <td>NIL_USDT</td>\n",
" <td>-0.3846</td>\n",
" <td>31438005</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>SUPER_USDT</td>\n",
" <td>-0.3718</td>\n",
" <td>2469502</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>PLAY_USDT</td>\n",
" <td>0.0838</td>\n",
" <td>22168649</td>\n",
" </tr>\n",
" <tr>\n",
" <th>414</th>\n",
" <td>PUMPBTC_USDT</td>\n",
" <td>0.0913</td>\n",
" <td>745129</td>\n",
" </tr>\n",
" <tr>\n",
" <th>398</th>\n",
" <td>QQQSTOCK_USDT</td>\n",
" <td>0.0969</td>\n",
" <td>59485</td>\n",
" </tr>\n",
" <tr>\n",
" <th>222</th>\n",
" <td>GUA_USDT</td>\n",
" <td>0.0996</td>\n",
" <td>45623</td>\n",
" </tr>\n",
" <tr>\n",
" <th>265</th>\n",
" <td>BROCCOLIF3B_USDT</td>\n",
" <td>0.1647</td>\n",
" <td>3936939</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>837 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" symbol fundingRate_pct volume24\n",
"55 DRIFT_USDT -1.1360 3308466\n",
"10 RED_USDT -1.1138 105826673\n",
"157 PIXEL_USDT -0.4059 12415472\n",
"105 NIL_USDT -0.3846 31438005\n",
"33 SUPER_USDT -0.3718 2469502\n",
".. ... ... ...\n",
"12 PLAY_USDT 0.0838 22168649\n",
"414 PUMPBTC_USDT 0.0913 745129\n",
"398 QQQSTOCK_USDT 0.0969 59485\n",
"222 GUA_USDT 0.0996 45623\n",
"265 BROCCOLIF3B_USDT 0.1647 3936939\n",
"\n",
"[837 rows x 3 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_trim.sort_values('fundingRate_pct', ascending=True)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6775a03f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1775583908"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"round(datetime.now().timestamp())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "edca3b9f",
"metadata": {},
"outputs": [],
"source": [
"### PRIVATE API ###\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51e50e0d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "21aabf30",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "f91b1c04",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "71e551f4",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "py_313",
"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.13.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}