saving for japan

This commit is contained in:
2026-04-25 23:47:07 +00:00
parent dac490ca5b
commit 73c4eb1bf8
6 changed files with 240 additions and 159 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "6c70a8c3",
"metadata": {},
"outputs": [],
@@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "ff971ca9",
"metadata": {},
"outputs": [],
@@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "fc2c6d2b",
"metadata": {},
"outputs": [],
@@ -97,78 +97,207 @@
},
{
"cell_type": "code",
"execution_count": 59,
"id": "1e0cc529",
"execution_count": null,
"id": "03913674",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8dd8aa73",
"metadata": {},
"outputs": [],
"source": [
"d = dict(placed_order)\n",
"d = d['data']"
"d = await trading_client.account.get_positions_history()"
]
},
{
"cell_type": "code",
"execution_count": 61,
"id": "c6e2570b",
"execution_count": 12,
"id": "5f74f7cc",
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>9</th>\n",
" <th>10</th>\n",
" <th>11</th>\n",
" <th>12</th>\n",
" <th>13</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>(id, 2047947640758337536)</td>\n",
" <td>(account_id, 270571)</td>\n",
" <td>(market, ETH-USD)</td>\n",
" <td>(side, SHORT)</td>\n",
" <td>(size, 0.2160000000000000)</td>\n",
" <td>(max_position_size, 0.2160000000000000)</td>\n",
" <td>(leverage, 50.0000000000000000)</td>\n",
" <td>(open_price, 2315.5000000000000000)</td>\n",
" <td>(exit_price, 2308.6000000000000000)</td>\n",
" <td>(realised_pnl, 1.4249250000000000)</td>\n",
" <td>(realised_pnl_breakdown, trade_pnl=Decimal('1....</td>\n",
" <td>(created_time, 1777103741241)</td>\n",
" <td>(exit_type, TRADE)</td>\n",
" <td>(closed_time, 1777133049026)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>(id, 2047512381621272576)</td>\n",
" <td>(account_id, 270571)</td>\n",
" <td>(market, ETH-USD)</td>\n",
" <td>(side, LONG)</td>\n",
" <td>(size, 0.2150000000000000)</td>\n",
" <td>(max_position_size, 0.2150000000000000)</td>\n",
" <td>(leverage, 50.0000000000000000)</td>\n",
" <td>(open_price, 2316.6000000000000000)</td>\n",
" <td>(exit_price, 2315.5000000000000000)</td>\n",
" <td>(realised_pnl, 0.0720660000000000)</td>\n",
" <td>(realised_pnl_breakdown, trade_pnl=Decimal('-0...</td>\n",
" <td>(created_time, 1776999967376)</td>\n",
" <td>(exit_type, TRADE)</td>\n",
" <td>(closed_time, 1777103741241)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>(id, 2047419314696355840)</td>\n",
" <td>(account_id, 270571)</td>\n",
" <td>(market, ETH-USD)</td>\n",
" <td>(side, LONG)</td>\n",
" <td>(size, 0.2150000000000000)</td>\n",
" <td>(max_position_size, 0.2150000000000000)</td>\n",
" <td>(leverage, 50.0000000000000000)</td>\n",
" <td>(open_price, 2321.7000000000000000)</td>\n",
" <td>(exit_price, 2327.3000000000000000)</td>\n",
" <td>(realised_pnl, 1.3196460000000000)</td>\n",
" <td>(realised_pnl_breakdown, trade_pnl=Decimal('1....</td>\n",
" <td>(created_time, 1776977778492)</td>\n",
" <td>(exit_type, TRADE)</td>\n",
" <td>(closed_time, 1776996621824)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"{'id': 2047411567531950080,\n",
" 'external_id': '970778360519119766032805910949664642915982435081116578514332451865869879614'}"
" 0 1 2 \\\n",
"0 (id, 2047947640758337536) (account_id, 270571) (market, ETH-USD) \n",
"1 (id, 2047512381621272576) (account_id, 270571) (market, ETH-USD) \n",
"2 (id, 2047419314696355840) (account_id, 270571) (market, ETH-USD) \n",
"\n",
" 3 4 \\\n",
"0 (side, SHORT) (size, 0.2160000000000000) \n",
"1 (side, LONG) (size, 0.2150000000000000) \n",
"2 (side, LONG) (size, 0.2150000000000000) \n",
"\n",
" 5 6 \\\n",
"0 (max_position_size, 0.2160000000000000) (leverage, 50.0000000000000000) \n",
"1 (max_position_size, 0.2150000000000000) (leverage, 50.0000000000000000) \n",
"2 (max_position_size, 0.2150000000000000) (leverage, 50.0000000000000000) \n",
"\n",
" 7 8 \\\n",
"0 (open_price, 2315.5000000000000000) (exit_price, 2308.6000000000000000) \n",
"1 (open_price, 2316.6000000000000000) (exit_price, 2315.5000000000000000) \n",
"2 (open_price, 2321.7000000000000000) (exit_price, 2327.3000000000000000) \n",
"\n",
" 9 \\\n",
"0 (realised_pnl, 1.4249250000000000) \n",
"1 (realised_pnl, 0.0720660000000000) \n",
"2 (realised_pnl, 1.3196460000000000) \n",
"\n",
" 10 \\\n",
"0 (realised_pnl_breakdown, trade_pnl=Decimal('1.... \n",
"1 (realised_pnl_breakdown, trade_pnl=Decimal('-0... \n",
"2 (realised_pnl_breakdown, trade_pnl=Decimal('1.... \n",
"\n",
" 11 12 \\\n",
"0 (created_time, 1777103741241) (exit_type, TRADE) \n",
"1 (created_time, 1776999967376) (exit_type, TRADE) \n",
"2 (created_time, 1776977778492) (exit_type, TRADE) \n",
"\n",
" 13 \n",
"0 (closed_time, 1777133049026) \n",
"1 (closed_time, 1777103741241) \n",
"2 (closed_time, 1776996621824) "
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dict(d)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e4cedd1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'OK'"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dict(placed_order).get('status' \\\n",
"'')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-04-23 23:55:13.704000')"
]
},
"execution_count": 4,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"pd.to_datetime(1776988513704, unit='ms')"
"pd.DataFrame(list(dict(d)['data']))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "e119aaac",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-04-25 16:04:09.026000')"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"pd.to_datetime(1777133049026, unit='ms')"
]
},
{