<html>
<p> <strong>SETTINGS</strong></p>
<p>In order to create a PM, we will need to set a particular parameter when creating the asset. This parameter can not be changed after creation of the asset. </p>
<p> Further, A PM-asset should have the following <strong>flags</strong> (not permissions): </p>
<pre><code>{<br>
"disable_force_settle" : <strong>true</strong>,<br>
"global_settle" : <strong>false</strong>,<br>
"witness_fed_asset" : <strong>false</strong>,<br>
"committee_fed_asset" : <strong>false</strong><br>
}</code></pre>
<p> and these MPA-options: </p>
<pre><code>{<br>
"feed_lifetime_sec" : 60 * 60 * 24 * 356,<br>
"minimum_feeds" : 1,<br>
"force_settlement_delay_sec" : 60<br>
"force_settlement_offset_percent" : 0<br>
"maximum_force_settlement_volume" : 100 * GRAPHENE_1_PERCENT,<br>
"short_backing_asset" : "1.3.0",<br>
}</code></pre>
<p> <strong>Note</strong></p>
<p>Unfortunatelly, <code>create_asset</code> cannot create prediction markets. Thus, we need to construct our <code>asser_create_operation</code>manually (see below).</p>
<p> <strong>Note</strong></p>
<p>The precision of the prediction market asset has to be identical with the short backing asset’s precision.</p>
<p><br></p>
<p> <strong>SETTLEMENT AUTHORITIES</strong></p>
<p>The issue can choose between three parties that are allowed to settle the prediction market:</p>
<ul>
<li>Committee</li>
<li>Witnesses</li>
<li>Other accounts</li>
</ul>
<p> <strong>Committee</strong></p>
<p>If only the committee is supposed to be able to settle the market, you need to set the options to :</p>
<pre><code>{<br>
"witness_fed_asset" : false,<br>
"committee_fed_asset" : true<br>
}</code></pre>
<p> <strong>Witnesses</strong></p>
<p>If only the witnesses are supposed to be able to settle the market, you need to set the options to :</p>
<pre><code>{<br>
"witness_fed_asset" : true,<br>
"committee_fed_asset" : false<br>
} </code></pre>
<p> <strong>Note</strong></p>
<p>The idea here is that the median of all price feeds published by the witnesses indicates a positive or negative resolution of the prediction market. </p>
<p> </p>
<h3><strong>Other Accounts</strong></h3>
<p>Similar to <a href="http://docs.bitshares.org/bitshares/user/privbta.html">Privatized BitAssets</a>, the feed can be also published by a arbitrary set of accounts. It is important to understand that in order to settle a prediction market, only <strong>one price feed</strong> is requried. Hence, anyone in the list of allowed settlers can settle the market and no consensus needs to be reached. Alternatively, if you want to settle a market only if several accounts can reach a consensus, a new resulution account can be created that uses <a href="http://docs.bitshares.org/bitshares/user/account-permissions.html">hierarchical multi-signature</a> similar to the committee-account.The list of settlement price producers can be defined with: </p>
<pre><code><strong>>>> </strong>update_asset_feed_producers <symbol> ["account-a", "account-b"] true</code></pre>
<p> <strong>PYTHON EXAMPLE</strong></p>
<pre><code><strong>from</strong> <strong>grapheneapi</strong> <strong>import</strong> GrapheneClient<br>
<strong>import</strong> <strong>json</strong><br>
<br>
perm = {}<br>
perm["charge_market_fee"] = 0x01<br>
perm["white_list"] = 0x02<br>
perm["override_authority"] = 0x04<br>
perm["transfer_restricted"] = 0x08<br>
perm["disable_force_settle"] = 0x10<br>
perm["global_settle"] = 0x20<br>
perm["disable_confidential"] = 0x40<br>
perm["witness_fed_asset"] = 0x80<br>
perm["committee_fed_asset"] = 0x100<br>
GRAPHENE_100_PERCENT = 10000<br>
GRAPHENE_1_PERCENT = GRAPHENE_100_PERCENT / 100<br>
<br>
<br>
<strong>class</strong> <strong>Config</strong>():<br>
wallet_host = "localhost"<br>
wallet_port = 8092<br>
wallet_user = ""<br>
wallet_password = ""<br>
<br>
<strong>if</strong> __name__ == '__main__':<br>
graphene = GrapheneClient(Config)<br>
<br>
issuer = "nathan"<br>
symbol = "PMMP"<br>
backing = "1.3.0"<br>
<br>
account = graphene.rpc.get_account(issuer)<br>
asset = graphene.rpc.get_asset(backing)<br>
<br>
permissions = {"charge_market_fee" : True,<br>
"white_list" : True,<br>
"override_authority" : True,<br>
"transfer_restricted" : True,<br>
"disable_force_settle" : True,<br>
"global_settle" : True,<br>
"disable_confidential" : True,<br>
"witness_fed_asset" : True,<br>
"committee_fed_asset" : True,<br>
}<br>
flags = {"charge_market_fee" : False,<br>
"white_list" : False,<br>
"override_authority" : False,<br>
"transfer_restricted" : False,<br>
"disable_force_settle" : True,<br>
"global_settle" : False,<br>
"disable_confidential" : False,<br>
"witness_fed_asset" : False,<br>
"committee_fed_asset" : False,<br>
}<br>
permissions_int = 0<br>
<strong>for</strong> p <strong>in</strong> permissions :<br>
<strong>if</strong> permissions[p]:<br>
permissions_int += perm[p]<br>
flags_int = 0<br>
<strong>for</strong> p <strong>in</strong> permissions :<br>
<strong>if</strong> flags[p]:<br>
flags_int += perm[p]<br>
options = {"max_supply" : 10000000000,<br>
"market_fee_percent" : 0,<br>
"max_market_fee" : 0,<br>
"issuer_permissions" : permissions_int,<br>
"flags" : flags_int,<br>
"core_exchange_rate" : {<br>
"base": {<br>
"amount": 10,<br>
"asset_id": asset["id"]},<br>
"quote": {<br>
"amount": 10,<br>
"asset_id": "1.3.1"}},<br>
"whitelist_authorities" : [],<br>
"blacklist_authorities" : [],<br>
"whitelist_markets" : [],<br>
"blacklist_markets" : [],<br>
"description" : "Prediction Market"<br>
}<br>
mpaoptions = {"feed_lifetime_sec" : 60 * 60 * 24 * 14,<br>
"minimum_feeds" : 1,<br>
"force_settlement_delay_sec" : 10,<br>
"force_settlement_offset_percent" : 0 * GRAPHENE_1_PERCENT,<br>
"maximum_force_settlement_volume" : 100 * GRAPHENE_1_PERCENT,<br>
"short_backing_asset" : asset["id"],<br>
}<br>
<br>
op = graphene.rpc.get_prototype_operation("asset_create_operation")<br>
op[1]["issuer"] = account["id"]<br>
op[1]["symbol"] = symbol<br>
op[1]["precision"] = asset["precision"]<br>
op[1]["common_options"] = options<br>
op[1]["bitasset_opts"] = mpaoptions<br>
<br>
<em>""" This flag will declare the asset as a prediction market</em><br>
<em> asset!</em><br>
<em> """</em><br>
op[1]["is_prediction_market"] = True<br>
<br>
handle = graphene.rpc.begin_builder_transaction()<br>
graphene.rpc.add_operation_to_builder_transaction(handle, op)<br>
graphene.rpc.set_fees_on_builder_transaction(handle, "1.3.0")<br>
tx = graphene.rpc.sign_builder_transaction(handle, True)<br>
<strong>print</strong>(json.dumps(tx, indent=4))</code></pre>
<p> </p>
<p>source : http://docs.bitshares.org/bitshares/tutorials/pm-create-manual.html</p>
<p>#bitshares #steemit</p>
</html>