Last active
October 20, 2025 03:24
-
-
Save donghee/29672aca9b0b91cbbb0f07f27d1af8d5 to your computer and use it in GitHub Desktop.
Show percentage of ETRI EBID expected price for best beading using monte carlo simulation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://ebid.etri.re.kr/ebid/ | |
| # 6. 예비가격 및 예정가격 | |
| # ① 복수예비가격은 전자입찰 시작 직전에 전자입찰시스템의 난수발생기를 통하여 기초금액(예비가격 | |
| # 기초금액)의 ±2% 범위 내에서 15개의 예비가격으로 생성됩니다. | |
| # ② 예정가격은 전자입찰자가 응찰조서작성시 추첨한 예비가격번호 중 가장 많이 추첨된 번호순으로 4개를 | |
| # 선정하여 각 번호에 해당하는 예비가격을 산술평균하여 결정됩니다 | |
| # | |
| # 나라장터 복수예비가격 선정 방법 (더 자세히) | |
| # http://www.g2b.go.kr/pt/e-support/fwdEsupportMain.do?supportUrl=/pt/notice/listNotice.do 에서 예비가격 검색 | |
| # | |
| # 예시: 100000번 시뮬레이션, 2명의 입찰자, 예비가격: 51,100,000원 | |
| # 결과 화면: https://i.imgur.com/rnhURZr.png | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| import random | |
| import sys | |
| from collections import Counter | |
| def generate_price_list(price, percent, count): | |
| # generate reserved price list between 98% ~ 102% | |
| # p = [random.uniform(price*(1.0 - percent), price*(1.0 + percent)) for i in range(count)] | |
| # generate reserved price list base on table from g2b.go.kr (나라장터) | |
| # 복수 예가 작성 기준 (reserved price list table) https://i.imgur.com/KbWM0T5.png | |
| p = [random.uniform(price*((1.0 - percent) + (percent*2/count*i)), price*((1.0 - percent) + (percent*2/count*(i+1)))) for i in range(count)] | |
| return p | |
| def ebid_sim(num_simulation, bid_participants, reserved_price): | |
| final = [] | |
| for j in range(num_simulation): | |
| price_list = generate_price_list(reserved_price, 0.02, 15) # ±2%, 15 reserved prices | |
| prices = [] | |
| for i in range(bid_participants): | |
| for p in random.sample(price_list, 2): # choose two from price_list | |
| prices.append(p) | |
| prices_dict = dict(Counter(prices)) | |
| sorted_prices = [v for (v, c) in sorted(prices_dict.items(), reverse=True, key=lambda item: item[1])[:4]] # best 4 in most order | |
| average_price = sum(sorted_prices)/len(sorted_prices) # average of four prices. | |
| final.append(average_price) | |
| return final | |
| if __name__ == "__main__": | |
| reserved_price = 51100000.0 | |
| if len(sys.argv) > 1: | |
| reserved_price = float(sys.argv[1]) | |
| else: | |
| print("사용법: python3 etri_ebid_expected_price.py [예비가격]") | |
| print("예시: python3 etri_ebid_expected_price.py 51100000") | |
| print(f"현재 기본 예비가격: {reserved_price:,.0f}원으로 시뮬레이션을 실행합니다.\n") | |
| plt.style.use('ggplot') | |
| final = ebid_sim(100000, 2, reserved_price) # 100000 loop, 2 bid participants, 51,100,000 reserved price | |
| output = pd.DataFrame(final) | |
| ax = output.plot(kind='hist', bins=30) | |
| ax.set_xlabel("Price") | |
| ax.set_ylabel("Frequency") | |
| print(output.describe(percentiles=[p/20 for p in range(1, 20)])) | |
| plt.show() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
count 1.000000e+05
mean 5.109848e+07
std 2.769738e+05
min 5.015367e+07
5% 5.063944e+07
10% 5.073822e+07
15% 5.080506e+07
20% 5.085927e+07
25% 5.090678e+07
30% 5.094902e+07
35% 5.098880e+07
40% 5.102591e+07
45% 5.106299e+07
50% 5.109903e+07
55% 5.113449e+07
60% 5.117102e+07
65% 5.120848e+07
70% 5.124765e+07
75% 5.129035e+07
80% 5.133759e+07
85% 5.139175e+07
90% 5.145852e+07
95% 5.155631e+07
max 5.200070e+07