saving
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 134,
|
||||
"execution_count": 1,
|
||||
"id": "c0bfb3b5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -15,13 +15,13 @@
|
||||
"import json\n",
|
||||
"from dataclasses import dataclass\n",
|
||||
"\n",
|
||||
"from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs, PartialCreateOrderOptions, BalanceAllowanceParams\n",
|
||||
"from py_clob_client.clob_types import OrderArgs, OrderType, PostOrdersArgs, PartialCreateOrderOptions, BalanceAllowanceParams, OpenOrderParams\n",
|
||||
"from py_clob_client.order_builder.constants import BUY, SELL\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 135,
|
||||
"execution_count": 2,
|
||||
"id": "7d7dc787",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -49,17 +49,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 136,
|
||||
"execution_count": 3,
|
||||
"id": "c3e07e21",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Timestamp('2026-03-31 05:45:00')"
|
||||
"Timestamp('2026-04-04 05:15:00')"
|
||||
]
|
||||
},
|
||||
"execution_count": 136,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -74,74 +74,74 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 137,
|
||||
"execution_count": 4,
|
||||
"id": "10671da4",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'id': '1787714',\n",
|
||||
" 'question': 'Bitcoin Up or Down - March 31, 1:45AM-1:50AM ET',\n",
|
||||
" 'conditionId': '0xd1773b412dacad884c202a7b14f0197918b1e22028ce2b5737fbd659bbe150f0',\n",
|
||||
" 'slug': 'btc-updown-5m-1774935900',\n",
|
||||
"{'id': '1840714',\n",
|
||||
" 'question': 'Bitcoin Up or Down - April 4, 1:15AM-1:20AM ET',\n",
|
||||
" 'conditionId': '0xa71ed436d160cc45bf182b9004e0c10b16322ea1b41375182b747c2629223ecc',\n",
|
||||
" 'slug': 'btc-updown-5m-1775279700',\n",
|
||||
" 'resolutionSource': 'https://data.chain.link/streams/btc-usd',\n",
|
||||
" 'endDate': '2026-03-31T05:50:00Z',\n",
|
||||
" 'liquidity': '12631.9812',\n",
|
||||
" 'startDate': '2026-03-30T05:53:51.811773Z',\n",
|
||||
" 'endDate': '2026-04-04T05:20:00Z',\n",
|
||||
" 'liquidity': '19009.3694',\n",
|
||||
" 'startDate': '2026-04-03T05:23:41.149918Z',\n",
|
||||
" 'image': 'https://polymarket-upload.s3.us-east-2.amazonaws.com/BTC+fullsize.png',\n",
|
||||
" 'icon': 'https://polymarket-upload.s3.us-east-2.amazonaws.com/BTC+fullsize.png',\n",
|
||||
" 'description': 'This market will resolve to \"Up\" if the Bitcoin price at the end of the time range specified in the title is greater than or equal to the price at the beginning of that range. Otherwise, it will resolve to \"Down\".\\nThe resolution source for this market is information from Chainlink, specifically the BTC/USD data stream available at https://data.chain.link/streams/btc-usd.\\nPlease note that this market is about the price according to Chainlink data stream BTC/USD, not according to other sources or spot markets.',\n",
|
||||
" 'outcomes': '[\"Up\", \"Down\"]',\n",
|
||||
" 'outcomePrices': '[\"0.875\", \"0.125\"]',\n",
|
||||
" 'volume': '94249.88157999996',\n",
|
||||
" 'outcomePrices': '[\"0.505\", \"0.495\"]',\n",
|
||||
" 'volume': '1149.1770909999996',\n",
|
||||
" 'active': True,\n",
|
||||
" 'closed': False,\n",
|
||||
" 'marketMakerAddress': '',\n",
|
||||
" 'createdAt': '2026-03-30T05:52:34.18484Z',\n",
|
||||
" 'updatedAt': '2026-03-31T05:48:51.799961Z',\n",
|
||||
" 'createdAt': '2026-04-03T05:22:26.236646Z',\n",
|
||||
" 'updatedAt': '2026-04-04T05:14:58.886334Z',\n",
|
||||
" 'new': False,\n",
|
||||
" 'featured': False,\n",
|
||||
" 'archived': False,\n",
|
||||
" 'restricted': True,\n",
|
||||
" 'groupItemThreshold': '0',\n",
|
||||
" 'questionID': '0x33d208062bed0d8fcf68d2f3899e528f103ad7e7763efc763f71c065ea6c842c',\n",
|
||||
" 'questionID': '0x1f7b9fd2711422d90794895b99edcb93a81246afd56b08ee4736c9b57565f8f7',\n",
|
||||
" 'enableOrderBook': True,\n",
|
||||
" 'orderPriceMinTickSize': 0.01,\n",
|
||||
" 'orderMinSize': 5,\n",
|
||||
" 'volumeNum': 94249.88157999996,\n",
|
||||
" 'liquidityNum': 12631.9812,\n",
|
||||
" 'endDateIso': '2026-03-31',\n",
|
||||
" 'startDateIso': '2026-03-30',\n",
|
||||
" 'volumeNum': 1149.1770909999996,\n",
|
||||
" 'liquidityNum': 19009.3694,\n",
|
||||
" 'endDateIso': '2026-04-04',\n",
|
||||
" 'startDateIso': '2026-04-03',\n",
|
||||
" 'hasReviewedDates': True,\n",
|
||||
" 'volume24hr': 93644.03624199987,\n",
|
||||
" 'volume1wk': 93644.03624199987,\n",
|
||||
" 'volume1mo': 93644.03624199987,\n",
|
||||
" 'volume1yr': 93644.03624199987,\n",
|
||||
" 'clobTokenIds': '[\"13157292356296687506747919717798752029699544499054519087985411865141996614822\", \"70507961363566124468475538524172170043725846352735387705515911177933084557518\"]',\n",
|
||||
" 'volume24hrClob': 93644.03624199987,\n",
|
||||
" 'volume1wkClob': 93644.03624199987,\n",
|
||||
" 'volume1moClob': 93644.03624199987,\n",
|
||||
" 'volume1yrClob': 93644.03624199987,\n",
|
||||
" 'volumeClob': 94249.88157999996,\n",
|
||||
" 'liquidityClob': 12631.9812,\n",
|
||||
" 'volume24hr': 1149.1770909999998,\n",
|
||||
" 'volume1wk': 1149.1770909999998,\n",
|
||||
" 'volume1mo': 1149.1770909999998,\n",
|
||||
" 'volume1yr': 1149.1770909999998,\n",
|
||||
" 'clobTokenIds': '[\"111612048087962925846397645788043113901565915142888535086349545305985085081594\", \"12874695654084258339187997850118078073676562138805309130550135898707856234061\"]',\n",
|
||||
" 'volume24hrClob': 1149.1770909999998,\n",
|
||||
" 'volume1wkClob': 1149.1770909999998,\n",
|
||||
" 'volume1moClob': 1149.1770909999998,\n",
|
||||
" 'volume1yrClob': 1149.1770909999998,\n",
|
||||
" 'volumeClob': 1149.1770909999996,\n",
|
||||
" 'liquidityClob': 19009.3694,\n",
|
||||
" 'makerBaseFee': 1000,\n",
|
||||
" 'takerBaseFee': 1000,\n",
|
||||
" 'acceptingOrders': True,\n",
|
||||
" 'negRisk': False,\n",
|
||||
" 'ready': False,\n",
|
||||
" 'funded': False,\n",
|
||||
" 'acceptingOrdersTimestamp': '2026-03-30T05:52:46Z',\n",
|
||||
" 'acceptingOrdersTimestamp': '2026-04-03T05:22:35Z',\n",
|
||||
" 'cyom': False,\n",
|
||||
" 'competitive': 0.8767123287671234,\n",
|
||||
" 'competitive': 0.9999750006249843,\n",
|
||||
" 'pagerDutyNotificationEnabled': False,\n",
|
||||
" 'approved': True,\n",
|
||||
" 'rewardsMinSize': 50,\n",
|
||||
" 'rewardsMaxSpread': 4.5,\n",
|
||||
" 'spread': 0.01,\n",
|
||||
" 'lastTradePrice': 0.89,\n",
|
||||
" 'bestBid': 0.87,\n",
|
||||
" 'bestAsk': 0.88,\n",
|
||||
" 'lastTradePrice': 0.51,\n",
|
||||
" 'bestBid': 0.5,\n",
|
||||
" 'bestAsk': 0.51,\n",
|
||||
" 'automaticallyActive': True,\n",
|
||||
" 'clearBookOnStart': False,\n",
|
||||
" 'showGmpSeries': False,\n",
|
||||
@@ -152,7 +152,7 @@
|
||||
" 'pendingDeployment': False,\n",
|
||||
" 'deploying': False,\n",
|
||||
" 'rfqEnabled': False,\n",
|
||||
" 'eventStartTime': '2026-03-31T05:45:00Z',\n",
|
||||
" 'eventStartTime': '2026-04-04T05:15:00Z',\n",
|
||||
" 'holdingRewardsEnabled': False,\n",
|
||||
" 'feesEnabled': True,\n",
|
||||
" 'requiresTranslation': False,\n",
|
||||
@@ -164,7 +164,7 @@
|
||||
" 'rebateRate': 0.2}}"
|
||||
]
|
||||
},
|
||||
"execution_count": 137,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -175,22 +175,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 132,
|
||||
"execution_count": 5,
|
||||
"id": "5ba43ffc",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'Up': '29663568421665501825278796284809925893978140634751674792176179244450686939029',\n",
|
||||
" 'Down': '17234806616394620691850452772328817031586809400835664344689152810552758258009',\n",
|
||||
"{'Up': '111612048087962925846397645788043113901565915142888535086349545305985085081594',\n",
|
||||
" 'Down': '12874695654084258339187997850118078073676562138805309130550135898707856234061',\n",
|
||||
" 'isActive': False,\n",
|
||||
" 'MinTickSize': 0.01,\n",
|
||||
" 'isNegRisk': False,\n",
|
||||
" 'ConditionId': '0x1778b4a38f2ce99260f9d3d0d78729d37fbd24439e06e6c92aad429439e0f7b2'}"
|
||||
" 'ConditionId': '0xa71ed436d160cc45bf182b9004e0c10b16322ea1b41375182b747c2629223ecc'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 132,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -201,7 +201,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 124,
|
||||
"execution_count": 6,
|
||||
"id": "5d356d3b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -210,7 +210,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"creating client...\n",
|
||||
"You've made 55 trades\n",
|
||||
"You've made 297 trades\n",
|
||||
"client created successfully!\n"
|
||||
]
|
||||
}
|
||||
@@ -221,17 +221,51 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 128,
|
||||
"execution_count": null,
|
||||
"id": "22eb81de",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Filtered by market\n",
|
||||
"order_status = client.get_orders(\n",
|
||||
" OpenOrderParams(id=\"0x9249ce4a8bc67de355b487b00eaa6ce25c1b451867f9350672b25eaa1de08494\")\n",
|
||||
")[0]['status']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "fb3b8151",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'CANCELED'"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"order"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "de5ccc3a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"7.6829"
|
||||
"0.0"
|
||||
]
|
||||
},
|
||||
"execution_count": 128,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -366,11 +400,12 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[{'errorMsg': '', 'orderID': '0x575c43f35b1f5e3e01779df5293d987dc81a347a4e09423a856ecb45555e30cb', 'takingAmount': '', 'makingAmount': '', 'status': 'live', 'success': True}]\n"
|
||||
"[{'errorMsg': '', 'orderID': '0x0c701329ddd7881505648c5ebdd03cd6f86ae3a70b0cf150bcb53946e043e6bf', 'takingAmount': '', 'makingAmount': '', 'status': 'live', 'success': True}]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%time\n",
|
||||
"### POST \n",
|
||||
"response = client.post_orders([\n",
|
||||
" PostOrdersArgs(\n",
|
||||
@@ -1465,25 +1500,100 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "56b8e1cc",
|
||||
"execution_count": 35,
|
||||
"id": "4d524867",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"o = {'type': 'TRADE', 'id': '1de1c277-d281-4be5-a388-305beb95e713', 'taker_order_id': '0xc77331796ad40133a2b4d9a387c10d326c180ad1195306240416150e337f0376', 'market': '0x1cdd4f44f73da702120f02962bf02a2599a7573a39b05ac8ca12a24301542e3e', 'asset_id': '108194336731497303295771496985972597853032131719077291707737599874190461476381', 'side': 'BUY', 'size': '5', 'fee_rate_bps': '1000', 'price': '0.7', 'status': 'CONFIRMED', 'match_time': '1775025187', 'last_update': '1775025253', 'outcome': 'Up', 'owner': '00e5d36c-6c46-77e1-a436-0f0a4bfbfdd8', 'trade_owner': '00e5d36c-6c46-77e1-a436-0f0a4bfbfdd8', 'maker_address': '0xb2967A7e578E700E27611238B7F762BdADC72CcB', 'transaction_hash': '0x3654fac56e1548bcc14d01ce4888ea0c3cec29d553009e054fc67088ece5f5b3', 'bucket_index': 0, 'maker_orders': [{'order_id': '0xb9a39a5e8082846bfdd92d33fba5112466b939ad7f33b76905982549767acf0a', 'owner': '70dd335a-6089-6022-6726-565c7480b291', 'maker_address': '0x010138da36CF100c00a5A59C8643E4A4A55DF19C', 'matched_amount': '5', 'price': '0.3', 'fee_rate_bps': '1000', 'asset_id': '26175835004768067043908573558643253609047604517388456461023977022509795794691', 'outcome': 'Down', 'outcome_index': 0, 'side': 'BUY'}], 'trader_side': 'TAKER', 'timestamp': '1775025253290', 'event_type': 'trade'}"
|
||||
"o = {'orderID': '0xaebd4053bd167eb7a7fc48ae29036829582787a73d8cc7b8b1afa7294c474972',\n",
|
||||
" 'owner': '00e5d36c-6c46-77e1-a436-0f0a4bfbfdd8',\n",
|
||||
" 'market': '0xf856ff89eb9ed2ab393a1bbc496b5db539b4d7f9cec91202b13c97379e9e58d6',\n",
|
||||
" 'asset_id': '39378292107289994981363071337831788209917841322683175778910172170676449806535',\n",
|
||||
" 'side': 'BUY',\n",
|
||||
" 'order_owner': '00e5d36c-6c46-77e1-a436-0f0a4bfbfdd8',\n",
|
||||
" 'original_size': '10',\n",
|
||||
" 'size_matched': '0',\n",
|
||||
" 'price': '0.2',\n",
|
||||
" 'associate_trades': [],\n",
|
||||
" 'outcome': 'Up',\n",
|
||||
" 'type': 'CANCELLATION',\n",
|
||||
" 'created_at': '1774818626',\n",
|
||||
" 'expiration': '0',\n",
|
||||
" 'order_type': 'GTC',\n",
|
||||
" 'status': 'CANCELED',\n",
|
||||
" 'maker_address': '0xb2967A7e578E700E27611238B7F762BdADC72CcB',\n",
|
||||
" 'timestamp': '1774818630291',\n",
|
||||
" 'event_type': 'order'}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 47,
|
||||
"id": "43a68ee8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ut = {'trade_side':'MAKER', 'taker_order_id': None, 'maker_orders': [{\"side\": \"BUY\", \"owner\": \"f44394d9-7782-e5e5-af99-dd515edd7fd9\", \"price\": \"0.44\", \"outcome\": \"Up\", \"asset_id\": \"55598909213399021321632159985071802901933471635502091907595118948537230110477\", \"order_id\": \"0x7eed6fa75cd49680b738e1563fc9e5dc0f7095c8a7dd3ee1a496c01f4ad2f610\", \"fee_rate_bps\": \"1000\", \"maker_address\": \"0xE29042f5D913DCC4015aaB3455C13C58514CA33F\", \"outcome_index\": 0, \"matched_amount\": \"15.25\"}, {\"side\": \"BUY\", \"owner\": \"520cb8f0-a71b-1c49-8dd6-751e682ee7f8\", \"price\": \"0.44\", \"outcome\": \"Up\", \"asset_id\": \"55598909213399021321632159985071802901933471635502091907595118948537230110477\", \"order_id\": \"0xf7c0a9e322fbf232dce6290f36bbe5e484ccec7fda599ddeb98867f241df6e37\", \"fee_rate_bps\": \"1000\", \"maker_address\": \"0x74a6364297292774c7f9a16B925207E77eEE262D\", \"outcome_index\": 0, \"matched_amount\": \"5\"}, {\"side\": \"BUY\", \"owner\": \"ae0f07ea-bcbe-3d54-6841-f220e89794ae\", \"price\": \"0.44\", \"outcome\": \"Up\", \"asset_id\": \"55598909213399021321632159985071802901933471635502091907595118948537230110477\", \"order_id\": \"0xe321494520de4737980a15160bfae94cb48791a2dc978aa843e7a8504e815771\", \"fee_rate_bps\": \"1000\", \"maker_address\": \"0xDba9C86F8d20ac73BcBf4dedaA6ADbd26A0a1303\", \"outcome_index\": 0, \"matched_amount\": \"5\"}, {\"side\": \"BUY\", \"owner\": \"00e5d36c-6c46-77e1-a436-0f0a4bfbfdd8\", \"price\": \"0.44\", \"outcome\": \"Up\", \"asset_id\": \"55598909213399021321632159985071802901933471635502091907595118948537230110477\", \"order_id\": \"0xaebd4053bd167eb7a7fc48ae29036829582787a73d8cc7b8b1afa7294c474972\", \"fee_rate_bps\": \"1000\", \"maker_address\": \"0xb2967A7e578E700E27611238B7F762BdADC72CcB\", \"outcome_index\": 0, \"matched_amount\": \"4.75\"}]}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"id": "ae50f082",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"USER_TRADES = [ut]\n",
|
||||
"user_trade = next( ( item for item in USER_TRADES if ( o['orderID'] == item['taker_order_id'] ) or ( o[\"orderID\"] == item['maker_orders'][0]['order_id'] ) ), None )"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ae50f082",
|
||||
"id": "11c111eb",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"USER_TRADES = [o]\n",
|
||||
"user_trade = next( ( item for item in USER_TRADES if ( o['orderID'] == item['taker_order_id'] ) or ( o[\"orderID\"] == item['maker_orders'][0]['order_id'] ) ), None )"
|
||||
"for t in USER_TRADES:\n",
|
||||
" if t['trade_side']=='MAKER':\n",
|
||||
" pass\n",
|
||||
" elif t['taker_order_id'] == o[\"orderID\"]:\n",
|
||||
" pass\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 46,
|
||||
"id": "de38feda",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"user_trade"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "67b7b730",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d15d92d3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in New Issue
Block a user