<jupyter_start><jupyter_text>Huang<jupyter_code>%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import networkx as nx
import pymarket as pm<jupyter_output><empty_output><jupyter_text>Creates new market<jupyter_code>mar = pm.Market()
    
mar.accept_bid(1, 6.7, 0, True, 0)
mar.accept_bid(1, 6.6, 1, True, 0)
mar.accept_bid(1, 6.5, 2, True, 0)
mar.accept_bid(1, 6.4, 3, True, 0)
mar.accept_bid(1, 6.3, 4, True, 0)
mar.accept_bid(1, 6, 5, True, 0)

mar.accept_bid(1, 1, 6, False, 0)
mar.accept_bid(1, 2, 7, False, 0)
mar.accept_bid(2, 3, 8, False, 0)
mar.accept_bid(2, 4, 9, False, 0)
mar.accept_bid(1, 6.1, 10, False, 0)

bids = mar.bm.get_df()
transactions, extras = mar.run('huang')
stats = mar.statistics()<jupyter_output><empty_output><jupyter_text>Orignal supply and demand curves<jupyter_code>mar.plot()<jupyter_output><empty_output><jupyter_text>Supply and demand curves after market is splitted<jupyter_code>fig, ax = plt.subplots(figsize=(8, 6))
ax = mar.plot_method('huang', ax=ax)<jupyter_output><empty_output><jupyter_text>Analysis of the trade Trading price* Selling Price: 4, defined by bid 9, consequently, 9 does not trade* Buying Price:  6, defined by bid 5, consequently, 5 does not trade Actually trading* Buying: 0, 1, 2, 3* Selling: 6, 7, 8 Results* Supply and demand have the same size.* The profit of the market maker coincides with the blue shaded area  Statistics<jupyter_code>print('Percentage of the maximum possible traded quantity')
stats['percentage_traded']
print('Percentage of the maximum possible total welfare')
stats['percentage_welfare']
print('Profits per user')
for u in bids.user.unique():
    print(f'User {u:2} obtained a profit of {stats["profits"]["player_bid"][u]:0.2f}')
print(f'Profit to Market Maker was {stats["profits"]["market"]:0.2f}')<jupyter_output>Profit to Market Maker was 8.00
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.039466666666666664, 'mean_word_length': 6.328125, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '18805', 'license': 'MIT', 'n_tokens_mistral': 762, 'n_tokens_neox': 703, 'n_words': 205, 'path': 'docs/Huang.ipynb', 'repo_name': 'taqtiqa-mark/pymarket', 'size': '1875'}