<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Xavier Lyu on Medium]]></title>
        <description><![CDATA[Stories by Xavier Lyu on Medium]]></description>
        <link>https://medium.com/@xavier_lyu?source=rss-e72b150a57ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*50djEHbvjDoGFwQwc0TY8A.jpeg</url>
            <title>Stories by Xavier Lyu on Medium</title>
            <link>https://medium.com/@xavier_lyu?source=rss-e72b150a57ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:31:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xavier_lyu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Maximizing Your Impact in Bittensor: What You Should Know Before Running a Node]]></title>
            <link>https://medium.com/@xavier_lyu/maximizing-your-impact-in-bittensor-what-you-should-know-before-running-a-node-a1773d5fb088?source=rss-e72b150a57ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1773d5fb088</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[bittensor]]></category>
            <dc:creator><![CDATA[Xavier Lyu]]></dc:creator>
            <pubDate>Tue, 20 Feb 2024 16:20:23 GMT</pubDate>
            <atom:updated>2024-05-04T20:47:40.579Z</atom:updated>
            <content:encoded><![CDATA[<p>Participating in Bittensor as a miner or validator offers a differentiated way to impact the evolving field of decentralized AI. This write-up aims to demystify the process, rewards, and considerations involved in becoming an integral part of this protocol.</p><p>The first step to becoming a validator or miner is securing your position within a subnet. This involves registering your keys by purchasing a UID slot in your chosen subnet. The cost of registration varies across subnets and can be easily checked on <a href="https://taostats.io/">taostats.io</a> or via the command line using $ btcli subnet register. The registration cost is dependent on demand to enter the subnet, and not just the subnet itself, as the subnet owner doesn’t have power over the registration cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LeIWuJKFXMKHCvO6a7Y4g.png" /><figcaption>taostats.io</figcaption></figure><p>Once registered, you can set up your validator or miner. It’s important to follow the specific requirements and setup processes unique to each subnet, which are detailed in the README files found on their respective GitHub repositories. Only the top 64 validators by stake across all subnets are granted a validator permit, marking them as active participants. The <a href="https://docs.bittensor.com/subnets/register-and-participate#validator-permit">docs</a> here provide sample Python code to calculate the TAO needed to acquire a validator permit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VOj6FCI5G2hWWemShVr5Eg.png" /><figcaption>Subnet 8’s metagraph</figcaption></figure><p>Active participation is rewarded differently as a miner or validator. Miners earn through an INCENTIVE score, while validators benefit from a DIVIDENDS score. These scores can be viewed on each subnet’s metagraph (Example: <a href="https://taostats.io/subnets/netuid-8/">Subnet 8</a> or through CLI $ btcli subnets metagraph --netuid &lt;ID&gt;). Your daily TAO earnings can be determined using the formula: INCENTIVE * (EMISSION * 0.41) + DIVIDENDS * (EMISSION * 0.41), where EMISSION represents the subnet’s share of minted TAO and DIVIDENDS represents the percentage weight by stake of all validators in your subnet. Of the total daily allocation, 82% is shared equally between validators and miners, with each group receiving 41%, and the remaining 18% goes to the subnet owner. Detailed information on emissions and their calculation is accessible on <a href="https://x.taostats.io/#subnets">taostats</a> and through these <a href="https://docs.bittensor.com/emissions">docs</a>, which also provide Python code for calculation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YYlHNydEQ12XG6d6HmgRLg.png" /></figure><p>Each subnet has its own way of rewarding miners, based on their performance as assessed by validators. Here’s a simplified breakdown of the process:</p><ul><li>Validators evaluate miners’ performance and assign them weights, which are essentially scores indicating how well each miner is doing. The validators represent the weights as a vector.</li><li>Validators independently send their vectors to the blockchain, which might happen at different times.</li><li>Every 360 blocks — known as a “tempo” — the blockchain gathers these weight vectors into a matrix.</li><li>Using this matrix and the stakes associated with each miner’s UID, the Yuma Consensus (YC) algorithm calculates the rewards for miners and validators.</li><li>Note that if a validator’s vector is submitted late, it is considered in the next tempo, and that each subnet’s YC timing can start differently even though this 360-block tempo applies to all subnets.</li></ul><p>In the context of Subnet 8 (Time-Series Prediction), validators calculate the RMSE between the miners’ predicted BTC prices and the actual BTC price. They then adjust the scores based on each miner’s past performance, combine them into a weight vector, and normalize it using the Yeo-Johnson transformation and MinMaxScaler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABzs9HeasEREHNghvaFPIg.png" /><figcaption><a href="https://docs.bittensor.com/learn/anatomy-of-incentive-mechanism#subnet-reward-model">https://docs.bittensor.com/learn/anatomy-of-incentive-mechanism#subnet-reward-model</a></figcaption></figure><p>To avoid bad validators lying about the weights to manipulate incentives, YC rewards miner-value evaluations that agree with the subjective evaluations produced by other validators, weighted by stake.</p><p>For most subnets, the validator’s script is readily available in each subnet’s GitHub repository, abstracting away the process. However, achieving a positive DIVIDENDS score as a validator is not as simple as it may seem, even with a permit and after being operational for a few days. This is largely because miners, driven by their own bandwidth considerations and strategic preferences, tend to prioritize requests from validators holding stakes over 20,000 TAO (or 5,000 in some subnets) because stakes below this threshold negligibly impact the network’s weight system. Consequently, miners deem it inefficient to allocate their resources to validators with lesser stakes, as doing so could compromise their availability for more influential validators. It’s important to note that this behavior is not mandated by Bittensor’s code but rather emerges from the miners’ self-interest and their discretion in code deployment, illustrating a market-driven dynamic within the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHZqiUsG2qB5YTcBEF7gog.png" /><figcaption>Top 30 Bittensor Validators by Stake (02/20/2024)</figcaption></figure><p>For a clearer picture of validator performance, you can refer to a subnet’s metagraph, like the one for Subnet 8 at <a href="https://taostats.io/subnets/netuid-8">https://taostats.io/subnets/netuid-8</a>. Here, you’ll notice some nodes show a 0 DIVIDENDS score even with a validator checkmark. This shows that a node’s positive daily rewards could be due to either a positive INCENTIVE score as a miner or a DIVIDENDS score as a validator (or both!)</p><p>A single coldkey can register for multiple subnets–a smart move for validators looking to maximize their earnings. By doing so, you optimize your total staked TAO, as it isn’t split among subnets, effectively reducing overhead costs with each additional subnet you join. Therefore, validating could be more lucrative by expanding across multiple subnets instead of just one or two. The registration fee is non-refundable, so monitoring your performance is crucial to avoid the risk of deregistration once the immunity period ends.</p><p>You can learn more about the anatomy of the incentive mechanism from this <a href="https://docs.bittensor.com/learn/anatomy-of-incentive-mechanism#subnet-reward-model">page</a> of the documentation. This <a href="https://docs.bittensor.com/learn/anatomy-of-incentive-mechanism#subnet-reward-model">flow chart</a> is a good illustration of rewards distribution. TAO emissions are only distributed after every tempo (72 minutes assuming 12 seconds per block). You can check a subnet’s tempo and immunity period with btcli s hyperparameteres --netuid &lt;&gt;.</p><p>While the rewards can be significant, success requires careful planning, strategic investment, and an understanding of the network’s dynamics. By securing your position, understanding the roles and rewards, and navigating the challenges, you can become a valuable part of Bittensor’s revolution.</p><p>Twitter: <a href="https://twitter.com/xavi3rlu">@xavi3rlu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1773d5fb088" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Capturing Liquidation Levels on GMX Part 1/2]]></title>
            <link>https://medium.com/@xavier_lyu/capturing-liquidation-levels-on-gmx-part-1-2-97d8794a56e6?source=rss-e72b150a57ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/97d8794a56e6</guid>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[decentralized-exchange]]></category>
            <category><![CDATA[margin-trading]]></category>
            <category><![CDATA[on-chain-data]]></category>
            <dc:creator><![CDATA[Xavier Lyu]]></dc:creator>
            <pubDate>Tue, 30 May 2023 14:56:50 GMT</pubDate>
            <atom:updated>2023-06-07T14:45:39.935Z</atom:updated>
            <content:encoded><![CDATA[<h4>Unveiling other traders’ liquidation levels could be a crucial advantage in trading</h4><h3>Background</h3><p>Many exchanges offer leverage to traders, enabling them to borrow funds and enter larger positions than their own funds allow, in order to amplify P&amp;L. However, leverage trading (or margin trading) carries the risk of liquidation, where traders may lose all or most of their initial margin. Initial margin is the trader’s own money, while borrowed funds make up the rest. Exchanges close positions when losses reach the initial margin to protect borrowed funds. The liquidation level, provided by exchanges, indicates the price at which a trade would be liquidated. Knowing other traders’ liquidation levels can provide an advantage, similar to knowing their stop losses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jokHK74ChAYEfCvY" /><figcaption>liquidation level tool on Hyblock</figcaption></figure><p>Vendors such as <a href="https://hyblockcapital.com/">Hyblock</a> provide such data and insight on centralized exchanges such as Binance. In contrast, decentralized exchanges like GMX stores data publicly on-chain and offer leverage up to 50x. In this two-part series, we will delve into the how to capture and parse event log on Arbitrum and visualize it like the chart above.</p><p>In part 1, we will cover the thought process and math, and part 2 we will go over the full-fledged python code from filtering events with web3.py and charting it with plotly.</p><h3>GMX Vault Arbitrum Events</h3><p>When you open a position on GMX, there are two emitted events from GMX Vault contract (0x489e…C4A) that look interesting: IncreasePosition and UpdatePosition :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vSPvhKWVT6zU1edorCP27A.png" /><figcaption>IncreasePosition and UpdatePosition event logs</figcaption></figure><p>Every position has a unique key. sizeDelta and size are your notional size. All the numbers are in USD and everything else is self-explanatory. The contract also emits DecreasePosition and ClosePosition events:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nac-vB1amdEEQ8ZvZyp_ow.png" /><figcaption>DecreasePosition and ClosePosition event logs</figcaption></figure><p>It is crucial to capture all these components: IncreasePosition/DecreasePosition, UpdatePosition, and ClosePosition, as each of these events plays a vital role in completing the puzzle. IncreasePosition/DecreasePosition provides the position’s key and user address, UpdatePosition allows for leverage and liquidation price calculations, while ClosePosition ensures any closed trades are accounted for. At the end, we will construct 3 DataFrames with the corresponding data, and combine them to obtain a holistic view.</p><h3>Estimating Liquidation Levels</h3><p>The metadata above does not include leverage and liquidation level (aka liquidation price). However, we can calculate these values based on available information. GMX’s documentation does not provide the specific formula, nor does it immediately state the existence of a minimum liquidation penalty of $5 or 1% of notional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*UcaA_rhMshbLaVwWVe_y6w.png" /><figcaption>GMX Docs: <a href="https://gmxio.gitbook.io/gmx/trading#partial-liquidations">https://gmxio.gitbook.io/gmx/trading#partial-liquidations</a></figcaption></figure><p>Let’s derive it ourselves! What above is saying is that your collateral value after P&amp;L needs to be at least 1% notional (or $5), or you will be liquidated. Neglecting borrow fee for simplicity:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*vkUUIAW-v28YE3qW" /></figure><p>where C is collateral in USD, L is leverage (eg. 3x is 3). For example, if you put down $100 collateral for a 5x long position PNL% can be rewritten as a fraction of price difference between entry (p_i) and exit (p_j) price:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*_BbqlxflWhMdjYqi" /></figure><p>For example, if I put down $100 (C) as collateral to open a 6.9x (L) long position when ETH is $1500 (p_i), but then ETH drops to $1400 (p_j) so my PNL% is -0.067 times 6.9, or -46.23% (oof). Your margin is now $100 * (100% - 46.23%), or $53.77. You are not liquidated at this moment because your margin is bigger than $5 and 0.01 * $100 * 6.9 = $6.9. Same thing for short leveraged position but it goes the opposite way.</p><p>Essentially, this equation needs to hold in order to not get liquidated, so we need to solve for the lower bound of p_j. After some algebraic manipulation, this is what p_j comes out to be for long/short leverage and that’s our liquidation level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/0*QWKnA1U52U8rotHs" /><figcaption>long liquidation price level</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*3af13ozK_zlpfSj4" /><figcaption>short liquidation price level</figcaption></figure><p>Leverage L is easy to calculate. It is just notional (size) divided by collateral (collateral), which are both given in the metadata.</p><h3>Scraping Event Logs</h3><p>I recommend skimming through <a href="https://medium.com/mycrypto/understanding-event-logs-on-the-ethereum-blockchain-f4ae7ba50378">this Medium post</a> on how topics and data in Ethereum log work if you are not familiar with it.</p><blockquote>“The first part of a log record consists of an array of topics. These topics are used to describe the event. The first topic usually consists of the signature (a keccak256 hash) of the name of the event that occurred, including the types…” — @Luit_H <a href="https://link.medium.com/YjDyojww4zb">https://link.medium.com/YjDyojww4zb</a></blockquote><p>Since we already have the interested events and their topics (the keccak256 hash), we can scrape all logs on that contract using web3.py’s filter. Here’s how the code would look like</p><pre>GMX_VAULT_ADDRESS = &#39;0x489ee077994B6658eAfA855C308275EAd8097C4A&#39;<br>INCREASEPOSITION_TOPIC = &#39;0x2fe68525253654c21998f35787a8d0f361905ef647c854092430ab65f2f15022&#39;<br>DECREASEPOSITION_TOPIC = &#39;0x93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30&#39;<br><br>log_filter = w3.eth.filter({<br>    &quot;fromBlock&quot;: start_block,<br>    &quot;toBlock&quot;: end_block,<br>    &quot;address&quot;: GMX_VAULT_ADDRESS,<br>    &quot;topics&quot;: [[INCREASEPOSITION_TOPIC, DECREASEPOSITION_TOPIC]],<br>})<br><br>logs = log_filter.get_all_entries()</pre><p>This filter gets all logs, an array, from GMX vault where the first topic is either INCREASEPOSITION_TOPIC or DECREASEPOSITION_TOPIC between the 2 specified block numbers. The topics parameter in w3.eth.filter is very interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*HCVJdjnzRs83KnlNWb6nYQ.png" /><figcaption>Ethereum JSON-RPC docs: <a href="https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter">https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter</a></figcaption></figure><p>Here’s what a log in logs would look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*N685BZGLHBZj8IJxbV5KsA.png" /></figure><p>The real meat is in data field, which we need to parse to get JSON-like object like in the image at the top. Thankfully, web3.py has a convenient function that parses it for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J89G22ZWx3Wu5Hr2E9l-fA.png" /></figure><p>Now we have a way of retrieving event logs and parse their data to a nice JSON format. In the next and last part, we will construct DataFrames with these data, merge them together to get the whole picture, and then visualize them with plotly. Savvy quants can also plug these data into their models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8qQ5BoBSthLAKz73cMG5wQ.png" /></figure><p>Twitter: <a href="https://twitter.com/xavi3rlu">@xavi3rlu</a></p><h3>Appendix</h3><p>I found that get_event_data(w3.codec, contract.events.UpdatePosition().abi, log) might not work for all web3.py versions, so what should we do if that’s the case? Take thedata above as an example:</p><pre>0x8f3a77f1fbbb764fd42370c51cdd660a69a7b923816015fb8ffff90c774d30ba00000000000000000000000001d4636330e24225f78a7571a5682debfe5c7f2a000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c28e04087deedca09276889d9800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000588bc91bf5e4b9e08e0ad800000000000000000000000000000000000000000000031ce570c69f78441aeb5e588a</pre><p>This is supposed to be this</p><pre>{<br>  &#39;key&#39;: &#39;8F3A77F1FBBB764FD42370C51CDD660A69A7B923816015FB8FFFF90C774D30BA&#39;,<br>  &#39;account&#39;: &#39;0x01d4636330e24225f78a7571a5682debfe5c7f2a&#39;,<br>  &#39;collateralToken&#39;: &#39;0xff970a61a04b1ca14834a43f5de4533ebddb5cc8&#39;,<br>  &#39;indexToken&#39;: &#39;0x82af49447d8a07e3bd95bd0d56f35241523fbab1&#39;,<br>  &#39;collateralDelta&#39;: 0,<br>  &#39;sizeDelta&#39;: 246627444399474842112333076617600,<br>  &#39;isLong&#39;: False,<br>  &#39;price&#39;: 1795927000000000000000000000000000,<br>  &#39;fee&#39;: 246627444399474842112333076618,<br>}</pre><p>Thankfully, the solution is easy. Each field in the JSON object is encoded sequentially in a 64 bytes hex value. Therefore, you can continually take 64 characters of that string, and if it needs to be an integer, convert it by</p><pre>int(&#39;00000000000000000000000000000000000000000000031ce570c69f78441aeb5e588a&#39;, 16)<br># 246627444399474842112333076618</pre><p>This is very different from the EVM transaction calldata where you have to reverse engineer the argument encoding. You can read more about it <a href="https://docs.soliditylang.org/en/v0.8.19/abi-spec.html">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97d8794a56e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deriving Black-Scholes from Geometric Brownian Probability Density Function]]></title>
            <link>https://medium.com/@xavier_lyu/deriving-black-scholes-from-geometric-brownian-probability-density-function-5d6ab084a78b?source=rss-e72b150a57ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d6ab084a78b</guid>
            <category><![CDATA[options]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[black-scholes-model]]></category>
            <dc:creator><![CDATA[Xavier Lyu]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 20:39:53 GMT</pubDate>
            <atom:updated>2023-01-09T21:37:29.896Z</atom:updated>
            <content:encoded><![CDATA[<h4>Nothing revolutionary, maybe it can help with your stochastic calculus problem set :)</h4><p>In <a href="https://lambert-guillaume.medium.com/pricing-uniswap-v3-lp-positions-towards-a-new-options-paradigm-dce3e3b50125">this article</a> <strong>Pricing Uniswap v3 LP Positions: Towards a New Options Paradigm?</strong>, Prof. Guillaume Lambert left the following exercise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*468XHrgSA9amxONU.png" /><figcaption>from Lambert’s Medium post</figcaption></figure><p>I will show my solution here.</p><p>First of all, let’s calculate the probability of S_t &gt; K, aka the condition{S_t &gt; K}.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*YMeDDcKKcjSPpfdT1qqdoQ.png" /></figure><p>Recall that S_t follows a <a href="https://en.wikipedia.org/wiki/Geometric_Brownian_motion">Geometric Brownian Motion</a> (GBM). The <a href="https://en.wikipedia.org/wiki/Wiener_process">Wiener process</a> W_t is normally distributed, aka W_t ~ N(0,t) , therefore it can be rewritten as Z*sqrt(t) where Z ~ N(0,1) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/0*PnPzBjxY3ynwETD-" /></figure><p>Substituting this back to {S_t &gt; K} and rearranging the equation we get the following condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*lmP4Q8xuz4W7VfAo" /></figure><h3>1. Equation</h3><p>Now let’s start with the actual equation, we first abbreviate the GBM probability density function (pdf) as lower case phi since φ is commonly used to represent pdf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*i5z8N01m_nuzOkkN" /></figure><p>We can take e^{-\mu t} out, manipulate the equation, and tackle each integral. We can’t take out φ because φ depends on x(see the very first screenshot at the top of this post).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*8BxaPeKfL7XnX9Nn" /></figure><p>This looks a lot like the Black-Scholes already.</p><h3>1.1 Solving the first part</h3><p>Recall that φ is a pdf, and the definition of expected value is the integral of x times its pdf. If you squint your eyes and look at the integral carefully, it is the same as below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*H2AuM9TDMJHLx7d9" /></figure><p>where “1” is an indicator function. This is essentially saying that the integral equals to the expected value of S_t on the condition that S_t &gt; K.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*dRZyJ01Dz_jaW1Zy" /></figure><p>We can now substitute S_t, the integral, and {S_t &gt; K} into the equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*lyxvaNVyA8oIcnUx" /></figure><p>Since Z is a random variable with a normal distribution of mean 0 and standard deviation 1, we can rewrite the expected value back to an integral with the pdf of a normal distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*6Nv_kqeuzc-D1RG-" /></figure><p>where Φ* is the cumulative distribution function (CDF) of N(σ\sqrt(t), 1) and d1 is the lower bound of the integral. To make Φ the CDF of N(0,1), we just need to make d1 to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*trHq6LcOwyVk5mLU" /></figure><h3>1.2 Solving the second part</h3><p>This part is shorter. Following the same intuition as above, we can rewrite</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*w5EyHiw3H1l94whP" /></figure><p>Notice how the expected value does not have x in it. That’s because the integrand only has the pdf.</p><h3>2. Piecing them together</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*4OyAoYbbCVrRB2E4" /></figure><blockquote>Twitter: @xavi3rlu Telegram: javierlu</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d6ab084a78b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>