In [1]:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

In [2]:
filename =  "901101-910131-SOD" 
resultsFilename = "results/"+filename+".csv" 
results = pd.read_csv(resultsFilename)

results['Optimal market size'] = (results['Optimal buyers']+results['Optimal sellers']) / 2
results['Normalized market size'] = results['Optimal units'] / (results['stddev']*np.sqrt(np.log(4*results['stddev'])))
print(len(results), " auctions")
results = results[results['Optimal gain']>0]
print(len(results), " auctions with positive optimal gain")
#results = results[results['Normalized market size']<200]

results['Asymptotic guarantee 3'] = 1 - 9 / results['Normalized market size']
results.loc[results['Asymptotic guarantee 3']<0, 'Asymptotic guarantee 3'] = 0


7914  auctions
2043  auctions with positive optimal gain

In [46]:
ax = plt.subplot(1, 1, 1)
results.plot(kind='scatter', x='Normalized market size',y='Asymptotic guarantee 3', color='b',  ax=ax)
results.plot(kind='scatter', x='Normalized market size',y='Competitive ratio', color='r', ax=ax)
#plt.show()


Out[46]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fbbf73dcf60>

In [52]:
results_bins = results.groupby(pd.cut(results['Normalized market size'],150)).mean()
ax = plt.subplot(1, 1, 1)
results_bins.plot(kind='line', x='Normalized market size',y='Asymptotic guarantee 3', color='b', ax=ax)
results_bins.plot(kind='scatter', x='Normalized market size',y='Competitive ratio', color='r', ax=ax)
ax.legend().set_visible(False)
#plt.show()



In [59]:
from statistics import *
import numpy as np
t1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 103, 113, 122, 129, 136, 145, 150, 150, 150, 150, 150, 151, 168, 181, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 213, 229, 250, 250, 250, 252, 298, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 310, 337, 350, 361, 400, 400, 400, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 516, 519, 700, 900, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1012, 1012, 1100, 1100, 1169, 1176, 1200, 1300, 1300, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1525, 1600, 1600, 1800, 1975, 1975, 1975, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2300, 2300, 2300, 2300, 2300, 2490, 2900, 2900, 2900, 3000, 3000, 3000, 3000, 3000, 3300, 3430, 3430, 3500, 5000, 5000, 5000, 5000, 5000, 10000, 10000]
print (mean(t1))
print(pstdev(t1))
t2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 145, 150, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 229, 250, 300, 300, 300, 300, 300, 300, 300, 350, 350, 400, 500, 500, 560, 603, 652, 800, 1000, 1087, 1100, 1222, 1300, 1355, 1500, 1800, 1925, 2000, 2200, 2200, 2590, 3000, 3400, 6000, 10444, 13213, 78500, 98678]
print (mean(t2))
print(pstdev(t2))
a=4
a**2


824.7591973244147
1231.1233805490306
3288.04
14362.477986234364
Out[59]:
16

In [22]:
filename =  "901101-910131-IBM-SOD"
datasetFilename = "datasets/"+filename+".CSV"
pricesFilename = "datasets/"+filename+"-PRICES.CSV"
dataset = pd.read_csv(datasetFilename)
dataset


Out[22]:
Unnamed: 0 Symbol Date Side Price Quantity Order date
0 111380 IBM 901101 BUY 96.000 1000 901016
1 111381 IBM 901101 SEL 168.000 100 900802
2 111382 IBM 901101 SEL 106.500 100 901031
3 111383 IBM 901101 SEL 112.500 100 901022
4 111384 IBM 901101 BUY 95.000 100 901012
5 111385 IBM 901101 SEL 113.500 100 901022
6 111386 IBM 901101 SEL 121.000 100 900720
7 111387 IBM 901101 BUY 100.000 100 901018
8 111388 IBM 901101 SEL 110.000 100 901022
9 111389 IBM 901101 BUY 101.000 1960 901023
10 111390 IBM 901101 BUY 97.000 400 901030
11 111391 IBM 901101 BUY 96.000 100 901012
12 111392 IBM 901101 SEL 112.500 100 901001
13 111393 IBM 901101 SEL 109.000 1000 901029
14 111394 IBM 901101 SEL 107.750 500 901031
15 111395 IBM 901101 BUY 95.000 100 901001
16 111396 IBM 901101 BUY 90.000 100 901016
17 111397 IBM 901101 BUY 96.000 1000 901016
18 111398 IBM 901101 SEL 111.500 100 901022
19 111399 IBM 901101 SEL 110.000 1940 901026
20 111400 IBM 901101 SEL 110.000 300 901019
21 111401 IBM 901101 BUY 92.000 100 901005
22 111402 IBM 901101 SEL 130.000 260 900913
23 111403 IBM 901101 SEL 106.000 450 901031
24 111404 IBM 901101 BUY 93.000 100 901026
25 111405 IBM 901101 SEL 108.000 100 901029
26 111406 IBM 901101 BUY 96.000 100 901009
27 111407 IBM 901101 SEL 109.500 100 901022
28 111408 IBM 901101 SEL 107.000 5000 901030
29 111409 IBM 901101 SEL 107.000 5000 901030
... ... ... ... ... ... ... ...
13368 124748 IBM 910131 BUY 126.875 20000 910131
13369 124749 IBM 910131 BUY 126.875 20000 910131
13370 124750 IBM 910131 BUY 126.875 20000 910131
13371 124751 IBM 910131 BUY 126.875 20000 910131
13372 124752 IBM 910131 BUY 126.875 20000 910131
13373 124753 IBM 910131 BUY 126.875 20000 910131
13374 124754 IBM 910131 BUY 126.875 20000 910131
13375 124755 IBM 910131 BUY 126.875 20000 910131
13376 124756 IBM 910131 BUY 126.875 20000 910131
13377 124757 IBM 910131 BUY 126.875 20000 910131
13378 124758 IBM 910131 BUY 126.875 20000 910131
13379 124759 IBM 910131 SEL 126.875 1000 910131
13380 124760 IBM 910131 SEL 127.000 2000 910131
13381 124761 IBM 910131 SEL 127.000 10000 910131
13382 124762 IBM 910131 SEL 127.000 10000 910131
13383 124763 IBM 910131 SEL 127.000 10000 910131
13384 124764 IBM 910131 SEL 127.000 10000 910131
13385 124765 IBM 910131 SEL 127.000 10000 910131
13386 124766 IBM 910131 SEL 126.875 8700 910131
13387 124767 IBM 910131 SEL 126.875 8700 910131
13388 124768 IBM 910131 SEL 127.000 812 910131
13389 124769 IBM 910131 SEL 126.750 400 910131
13390 124770 IBM 910131 SEL 126.875 4000 910131
13391 124771 IBM 910131 SEL 126.875 1000 910131
13392 124772 IBM 910131 BUY 127.000 2000 910131
13393 124773 IBM 910131 BUY 127.000 2000 910131
13394 124774 IBM 910131 BUY 127.000 2000 910131
13395 124775 IBM 910131 BUY 126.750 1000 910131
13396 124776 IBM 910131 BUY 126.750 500 910131
13397 124777 IBM 910131 SEL 126.875 1500 910131

13398 rows × 7 columns


In [19]:
prices[prices['Date']==901102]


Out[19]:
Unnamed: 0 Symbol Date Walrasian Price
8 8 IBM 901102.0 108.0

In [36]:
results = pd.merge(dataset, prices, on=['Symbol','Date'], how='outer')
results


Out[36]:
Unnamed: 0_x Symbol Date Side Price Quantity Order date Unnamed: 0_y Walrasian Price
0 111380 IBM 901101 BUY 96.000 1000 901016 50 106.375
1 111381 IBM 901101 SEL 168.000 100 900802 50 106.375
2 111382 IBM 901101 SEL 106.500 100 901031 50 106.375
3 111383 IBM 901101 SEL 112.500 100 901022 50 106.375
4 111384 IBM 901101 BUY 95.000 100 901012 50 106.375
5 111385 IBM 901101 SEL 113.500 100 901022 50 106.375
6 111386 IBM 901101 SEL 121.000 100 900720 50 106.375
7 111387 IBM 901101 BUY 100.000 100 901018 50 106.375
8 111388 IBM 901101 SEL 110.000 100 901022 50 106.375
9 111389 IBM 901101 BUY 101.000 1960 901023 50 106.375
10 111390 IBM 901101 BUY 97.000 400 901030 50 106.375
11 111391 IBM 901101 BUY 96.000 100 901012 50 106.375
12 111392 IBM 901101 SEL 112.500 100 901001 50 106.375
13 111393 IBM 901101 SEL 109.000 1000 901029 50 106.375
14 111394 IBM 901101 SEL 107.750 500 901031 50 106.375
15 111395 IBM 901101 BUY 95.000 100 901001 50 106.375
16 111396 IBM 901101 BUY 90.000 100 901016 50 106.375
17 111397 IBM 901101 BUY 96.000 1000 901016 50 106.375
18 111398 IBM 901101 SEL 111.500 100 901022 50 106.375
19 111399 IBM 901101 SEL 110.000 1940 901026 50 106.375
20 111400 IBM 901101 SEL 110.000 300 901019 50 106.375
21 111401 IBM 901101 BUY 92.000 100 901005 50 106.375
22 111402 IBM 901101 SEL 130.000 260 900913 50 106.375
23 111403 IBM 901101 SEL 106.000 450 901031 50 106.375
24 111404 IBM 901101 BUY 93.000 100 901026 50 106.375
25 111405 IBM 901101 SEL 108.000 100 901029 50 106.375
26 111406 IBM 901101 BUY 96.000 100 901009 50 106.375
27 111407 IBM 901101 SEL 109.500 100 901022 50 106.375
28 111408 IBM 901101 SEL 107.000 5000 901030 50 106.375
29 111409 IBM 901101 SEL 107.000 5000 901030 50 106.375
... ... ... ... ... ... ... ... ... ...
13368 124748 IBM 910131 BUY 126.875 20000 910131 22 126.875
13369 124749 IBM 910131 BUY 126.875 20000 910131 22 126.875
13370 124750 IBM 910131 BUY 126.875 20000 910131 22 126.875
13371 124751 IBM 910131 BUY 126.875 20000 910131 22 126.875
13372 124752 IBM 910131 BUY 126.875 20000 910131 22 126.875
13373 124753 IBM 910131 BUY 126.875 20000 910131 22 126.875
13374 124754 IBM 910131 BUY 126.875 20000 910131 22 126.875
13375 124755 IBM 910131 BUY 126.875 20000 910131 22 126.875
13376 124756 IBM 910131 BUY 126.875 20000 910131 22 126.875
13377 124757 IBM 910131 BUY 126.875 20000 910131 22 126.875
13378 124758 IBM 910131 BUY 126.875 20000 910131 22 126.875
13379 124759 IBM 910131 SEL 126.875 1000 910131 22 126.875
13380 124760 IBM 910131 SEL 127.000 2000 910131 22 126.875
13381 124761 IBM 910131 SEL 127.000 10000 910131 22 126.875
13382 124762 IBM 910131 SEL 127.000 10000 910131 22 126.875
13383 124763 IBM 910131 SEL 127.000 10000 910131 22 126.875
13384 124764 IBM 910131 SEL 127.000 10000 910131 22 126.875
13385 124765 IBM 910131 SEL 127.000 10000 910131 22 126.875
13386 124766 IBM 910131 SEL 126.875 8700 910131 22 126.875
13387 124767 IBM 910131 SEL 126.875 8700 910131 22 126.875
13388 124768 IBM 910131 SEL 127.000 812 910131 22 126.875
13389 124769 IBM 910131 SEL 126.750 400 910131 22 126.875
13390 124770 IBM 910131 SEL 126.875 4000 910131 22 126.875
13391 124771 IBM 910131 SEL 126.875 1000 910131 22 126.875
13392 124772 IBM 910131 BUY 127.000 2000 910131 22 126.875
13393 124773 IBM 910131 BUY 127.000 2000 910131 22 126.875
13394 124774 IBM 910131 BUY 127.000 2000 910131 22 126.875
13395 124775 IBM 910131 BUY 126.750 1000 910131 22 126.875
13396 124776 IBM 910131 BUY 126.750 500 910131 22 126.875
13397 124777 IBM 910131 SEL 126.875 1500 910131 22 126.875

13398 rows × 9 columns


In [37]:
results.drop(["Walrasian Price","Unnamed: 0_x","Unnamed: 0_y"], axis=1, inplace=True)
results


Out[37]:
Symbol Date Side Price Quantity Order date
0 IBM 901101 BUY 96.000 1000 901016
1 IBM 901101 SEL 168.000 100 900802
2 IBM 901101 SEL 106.500 100 901031
3 IBM 901101 SEL 112.500 100 901022
4 IBM 901101 BUY 95.000 100 901012
5 IBM 901101 SEL 113.500 100 901022
6 IBM 901101 SEL 121.000 100 900720
7 IBM 901101 BUY 100.000 100 901018
8 IBM 901101 SEL 110.000 100 901022
9 IBM 901101 BUY 101.000 1960 901023
10 IBM 901101 BUY 97.000 400 901030
11 IBM 901101 BUY 96.000 100 901012
12 IBM 901101 SEL 112.500 100 901001
13 IBM 901101 SEL 109.000 1000 901029
14 IBM 901101 SEL 107.750 500 901031
15 IBM 901101 BUY 95.000 100 901001
16 IBM 901101 BUY 90.000 100 901016
17 IBM 901101 BUY 96.000 1000 901016
18 IBM 901101 SEL 111.500 100 901022
19 IBM 901101 SEL 110.000 1940 901026
20 IBM 901101 SEL 110.000 300 901019
21 IBM 901101 BUY 92.000 100 901005
22 IBM 901101 SEL 130.000 260 900913
23 IBM 901101 SEL 106.000 450 901031
24 IBM 901101 BUY 93.000 100 901026
25 IBM 901101 SEL 108.000 100 901029
26 IBM 901101 BUY 96.000 100 901009
27 IBM 901101 SEL 109.500 100 901022
28 IBM 901101 SEL 107.000 5000 901030
29 IBM 901101 SEL 107.000 5000 901030
... ... ... ... ... ... ...
13368 IBM 910131 BUY 126.875 20000 910131
13369 IBM 910131 BUY 126.875 20000 910131
13370 IBM 910131 BUY 126.875 20000 910131
13371 IBM 910131 BUY 126.875 20000 910131
13372 IBM 910131 BUY 126.875 20000 910131
13373 IBM 910131 BUY 126.875 20000 910131
13374 IBM 910131 BUY 126.875 20000 910131
13375 IBM 910131 BUY 126.875 20000 910131
13376 IBM 910131 BUY 126.875 20000 910131
13377 IBM 910131 BUY 126.875 20000 910131
13378 IBM 910131 BUY 126.875 20000 910131
13379 IBM 910131 SEL 126.875 1000 910131
13380 IBM 910131 SEL 127.000 2000 910131
13381 IBM 910131 SEL 127.000 10000 910131
13382 IBM 910131 SEL 127.000 10000 910131
13383 IBM 910131 SEL 127.000 10000 910131
13384 IBM 910131 SEL 127.000 10000 910131
13385 IBM 910131 SEL 127.000 10000 910131
13386 IBM 910131 SEL 126.875 8700 910131
13387 IBM 910131 SEL 126.875 8700 910131
13388 IBM 910131 SEL 127.000 812 910131
13389 IBM 910131 SEL 126.750 400 910131
13390 IBM 910131 SEL 126.875 4000 910131
13391 IBM 910131 SEL 126.875 1000 910131
13392 IBM 910131 BUY 127.000 2000 910131
13393 IBM 910131 BUY 127.000 2000 910131
13394 IBM 910131 BUY 127.000 2000 910131
13395 IBM 910131 BUY 126.750 1000 910131
13396 IBM 910131 BUY 126.750 500 910131
13397 IBM 910131 SEL 126.875 1500 910131

13398 rows × 6 columns


In [ ]: