<?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 Ivanlisi on Medium]]></title>
        <description><![CDATA[Stories by Ivanlisi on Medium]]></description>
        <link>https://medium.com/@ivanlisi88?source=rss-850aef8b783c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*06DI1eSvqspaROi4</url>
            <title>Stories by Ivanlisi on Medium</title>
            <link>https://medium.com/@ivanlisi88?source=rss-850aef8b783c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:12:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ivanlisi88/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[Volatility Prediction]]></title>
            <link>https://medium.com/@ivanlisi88/volatility-prediction-46815515b365?source=rss-850aef8b783c------2</link>
            <guid isPermaLink="false">https://medium.com/p/46815515b365</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Ivanlisi]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 10:07:57 GMT</pubDate>
            <atom:updated>2023-01-18T08:06:31.283Z</atom:updated>
            <content:encoded><![CDATA[<p>Using the Flask framework and LSTM model</p><h3>Summary</h3><p>This project aims to provide a starting point for incorporating volatility into trading algorithms. It includes a user-friendly interface, a database, and a predictive model that uses long-term memory (LSTM) networks to forecast future volatility levels. By predicting volatility, traders can better manage the risks associated with sudden and unpredictable market changes and make more informed decisions about their trades. The user interface is built with the Flask framework and allows users to easily record and predict market data. The database is hosted on Google Cloud and uses pickle files to store data. LSTM networks are well-suited for this task because they can capture short-term dependencies in the data, handle noisy and incomplete data, and make accurate predictions about future volatility levels.</p><h3>Risks of volatility</h3><p>While volatility can provide opportunities for traders, it also carries risks. High volatility can lead to sudden and unpredictable changes in the market, which can result in significant losses for traders. By predicting volatility, traders can better manage these risks and make more informed decisions about their trades.</p><h3>A use case for volatility in Algo trading</h3><p>One potential use case for volatility prediction in algorithmic trading is to adjust the position size based on the volatility level. For example, a trader could use a volatility prediction model to identify periods of high volatility and reduce the size of their positions to reduce the risk of significant losses.</p><h3>User interface</h3><p>The user interface is designed to be intuitive and easy to use, even for people who do not need experience with coding. The record and predict tabs allow users to easily record market data and make predictions without writing any code. The user interface also provides a visual representation of the data, making it easier to understand and interpret the results of the predictions.<br>I used the Flask framework to create the user interface, which consists of two tabs: record and predict. The record tab allows users to record market data from the Binance exchange by candle kind and date range. We can see the markets in the database in the table of existing markets. I need to update the existing market table to show the data&#39;s candle type and the date range. The predict tab allows users to select a market, the number of candles to predict in the future, and the prediction model configuration.</p><h3>The database</h3><p>I used Google Cloud to store the data for this project. Since it is a small project, I used a bucket with pickle files instead of a SQL database. One limitation of the system is that it downloads the data to the local machine or server before starting the calculations.</p><h3>The prediction model</h3><p>I used long-term memory (LSTM) to predict volatility. LSTM is a type of recurrent neural network (RNN) that is well-suited for time series data and has been used successfully in various applications, including natural language processing, speech recognition, and time series forecasting. LSTM networks can capture long-term dependencies in the data, which helps predict future events.</p><p>In the case of volatility prediction, LSTM networks can be trained on historical market data to learn the patterns and trends in the data. The patterns and trends enable the network to make accurate predictions about future volatility levels based on the input data. LSTM networks are particularly well-suited for volatility prediction because they can capture the short-term dependencies in the data, which are essential for predicting future volatility levels. Additionally, LSTM networks can handle noisy and incomplete data, which is common in financial markets.</p><p>Overall, LSTM networks are a powerful tool for predicting volatility and have been shown to be effective in various applications.</p><p>One of the metrics used to evaluate the prediction model&#39;s performance is the mean absolute error (MAE). The MAE measures the average magnitude of the errors in the predictions without considering their direction. It is calculated as the sum of the absolute differences between the predicted values and the actual values, divided by the number of predictions.</p><p>In addition to the MAE, the standard deviation of the error (MAE std) can also be used to evaluate the prediction model&#39;s performance. The MAE std measures the dispersion of the errors in the predictions. It is calculated as the square root of the sum of the squared differences between the predicted values and the actual values, divided by the number of predictions.</p><p>The MAE and the MAE std can provide valuable insights into the prediction model&#39;s performance. A low MAE and MAE std indicate that the predictions are accurate and consistent, whereas a high MAE and MAE std indicate that the projections are less accurate and less consistent. By monitoring these metrics, traders can make more informed decisions about the reliability of the predictions and adjust their trading strategies accordingly.</p><h3>Conclusions</h3><p>Overall, I am satisfied with the prediction model performance, as the MAE and MAE std is low. The user interface is also easy to use and understand. In the future, I plan to improve the system by implementing a streaming data pipeline and a more efficient database. Thanks for watching!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46815515b365" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kelly criterion natural strategy in Crypto environment]]></title>
            <link>https://medium.com/@ivanlisi88/kelly-criterion-natural-strategy-in-crypto-environment-441f96fdb0a?source=rss-850aef8b783c------2</link>
            <guid isPermaLink="false">https://medium.com/p/441f96fdb0a</guid>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[kelly]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Ivanlisi]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 08:09:01 GMT</pubDate>
            <atom:updated>2022-08-15T08:09:01.250Z</atom:updated>
            <content:encoded><![CDATA[<p>I want to start with a super simple strategy — Buy at the start of the day and sell at the end. The exciting part is allocating the trade amount based on the current balance and past return.</p><p><a href="https://raposa.trade/blog/how-to-improve-your-trading-system-with-the-kelly-criterion/">I took the base code from the following article </a>— In the paper, he applies the strategy on SPY. He has excellent results and lots of information. But will the plan will work for <strong>crypto </strong>assets?</p><h4>The basic strategy:</h4><p>I will calculate the Kelly criterion for each period and place a trade according to the result. Example: If I have $1000 and Kelly is 0.8, I will put a transaction of $800.<br>In case Kelly is negative, I will not place short trades.</p><p>Enjoy the code: <a href="https://gist.github.com/Ivanchukk/9517332cd4525e088ead28bd572c4f2f">LINK</a></p><p>Let&#39;s start with MATIC:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*je0GMccz2pm99oRJeOpFiQ.png" /><figcaption>MATIC — Market return VS Kelly return</figcaption></figure><p>Market returns are much higher most of the time.<br>Notice that at some point (during the bullish run of 2021 Kelly made a very high return in a short period. We can learn from it that during the bullish market, Kelly performed better than the market.</p><h4>Improvements</h4><p>First of all, we can play with the fraction of Kelly. We can take 1/3 of Kelly (lower risk) or increase the risk to 1.5 of Kelly(higher risk). <br>Example: If Kelly tells me to place a proportion of 80% out of my balance as one trade, I&#39;ll lower my risk and put 80% * 0.3 = 24% as one transaction.</p><p>I will run a loop between 10% Kelly to 140%, Kelly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Zz9YHn003kSoGiOwexLXig.png" /><figcaption>MATIC — With different Kelly fractions</figcaption></figure><p>From this chart, we can learn that the Kelly fraction is essential. With some configuration, Kelly outperformed the market.</p><p>The best performer was 1.3 Kelly. Let&#39;s take a closer look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*LtIhFvJgiH9TT_b-WQl8fQ.png" /></figure><p><strong>Take a look at this astronomical return during the 2021 peak.</strong></p><h4>Same strategy for BTC</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*Qq1BxDBsK8D7IpoqWw2K-w.png" /><figcaption>BTC</figcaption></figure><p>None of the Kellys outperformed the market. <strong>It looks like the downside of this strategy is a bearish market.</strong> (We can improve it by placing short trades.)</p><h4>Play with the mean return period</h4><p>Kelly&#39;s criterion formula is very similar to Sharp ration calculation — The difference is that in the denominator, Kelly uses variance, while Sharp uses Sigma. The numerator is the mean of the return (It is possible to subtract the risk-free rate).</p><p>I&#39;d change the rolling of mean return and variance by for loop and plot the results <strong>only </strong>if the strategy beat the market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*p64ZLAwbCbLrX4l_V1ViKw.png" /><figcaption>Strategy positive returns</figcaption></figure><p>In the chart — The X-axes are the number of periods I used to calculate the mean return. The Y-axes are the log return for the period and the Kelly proportion.</p><p>The good news is that there is lots of configuration that outperformed the market.</p><p>One of the best periods is 120 days, with 17 out of 19 positive results.</p><p>From the chart above, we can think that the return of Kelly X 2 is an excellent 600%. But, In the following chart, we will see a bit different picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*1qVkcCD9aUMaI9DbhWEh_A.png" /></figure><p>As you can see, there was a return of 600% (Blue line). But, it happened only once with a period of 120 days. <br>We can see that a smaller proportion is much safer but have a lower return.</p><h4>Summary</h4><p>I think Kelly is usable in the crypto market and can be an excellent addition to ML strategy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8831a8c80d2d311904dc00ce671e3778/href">https://medium.com/media/8831a8c80d2d311904dc00ce671e3778/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=441f96fdb0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Momentum strategy — ML in the Crypto environment — Part 2]]></title>
            <link>https://medium.com/trading-data-analysis/momentum-strategy-ml-in-the-crypto-environment-part-2-91a5ce472ad2?source=rss-850aef8b783c------2</link>
            <guid isPermaLink="false">https://medium.com/p/91a5ce472ad2</guid>
            <category><![CDATA[crytocurrency]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[strategy]]></category>
            <dc:creator><![CDATA[Ivanlisi]]></dc:creator>
            <pubDate>Mon, 08 Aug 2022 06:47:36 GMT</pubDate>
            <atom:updated>2022-11-07T07:34:16.974Z</atom:updated>
            <content:encoded><![CDATA[<h3>Momentum strategy — ML in the Crypto environment — Part 2</h3><p>Explore the data</p><p><a href="https://medium.com/@ivanlisi88/momentum-strategy-ml-in-the-crypto-environment-c65c9d657ee9">In the first part, </a>I showed just one example of the model. It looked like the model was successful and may generate lots of profit.In this article, I will apply the same model to many different tokens and try to understand why some are successful, and some are not. Also, this time I will give you full access to the code.</p><p>I run the model on ten tokens with the same configuration as in the model from part one.<br><strong>predictors_list</strong> = [‘Volume’, ‘mfi’]<br><strong>tree_depth</strong> = 4<br><strong>leafs </strong>= 8</p><p>Lets check the results:</p><p><a href="https://medium.com/u/ea91a1cf958">Polygon</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*bW3ziOVuhuEKTj81xEBGUA.png" /><figcaption>the strategy made return of 1.955, and the market -0.491</figcaption></figure><p><a href="https://medium.com/u/698d3446046">Atomic</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*CebwzBe5Jo-XJSqgdr-z2A.png" /><figcaption>the strategy made return of -0.456, and the market -0.293</figcaption></figure><p>BTC:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*Unm6mv5GfttDNV5DexrDaQ.png" /><figcaption>the strategy made return of 0.434, and the market -0.749</figcaption></figure><p>ZRX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*TkTcWbNQcrjxADOn3vBudg.png" /><figcaption>the strategy made return of -0.584, and the market -0.68</figcaption></figure><p><a href="https://medium.com/u/13bfa9f22920">Aavesome</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*H81R4C6-NA95AJaCUl9eyg.png" /><figcaption>the strategy made return of -1.186, and the market -0.85</figcaption></figure><p><a href="https://medium.com/u/bb4a269b69c3">Algorand</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*rbQnhj5CFIzBH9hTh6aYBw.png" /><figcaption>the strategy made return of -1.503, and the market -0.751</figcaption></figure><p><a href="https://medium.com/u/87d28920d977">ChainLink</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*j3GXoIid0HSkFEbDj6jLSA.png" /><figcaption>the strategy made return of 0.32, and the market -1.095</figcaption></figure><p>SXP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*iqZeQfqmuHXKfZyZyuiACw.png" /><figcaption>the strategy made return of 0.327, and the market -0.92</figcaption></figure><p>SNX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*Bazdw7922ko62ccUVuJtgg.png" /><figcaption>the strategy made return of 0.429, and the market -0.137</figcaption></figure><p>XRP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*6wISfMZM00Ec6kSGAhV1Ow.png" /><figcaption>the strategy made return of -0.557, and the market -1.088</figcaption></figure><p>ATOM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*VEusi8hZoQITO1OVOYuVKg.png" /><figcaption>the strategy made return of -0.456, and the market -0.293</figcaption></figure><p>You must have noticed the polygon was almost the only one that made a good return.<br>What is interesting is that if I change the configuration a bit, have a tremendously positive effect on some of the tokens.</p><p>For example, with the configurations:<br><strong>predictors_list </strong>= [‘Close’, ‘Volume’, ‘MA’, ‘rsi’, ‘%K’, ‘%D’, ‘psl’, ‘rvi’, ‘true_range’, ‘pvt’, ‘pvr’, ‘mfi’]<br><strong>tree_depth</strong> = 6<br><strong>leafs</strong> = 3</p><p>ZRX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*qk0_IikWZuOomAPBUZvhcw.png" /><figcaption>the strategy made return of 1.3975515267401628, and the market -0.681</figcaption></figure><p>SXP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*BtKfza0CWTYZKs6pml8SfQ.png" /><figcaption>the strategy made return of 1.2941410245942637, and the market -0.9</figcaption></figure><p>As you can see, small changes significantly affect the result. What brings the question WHY?</p><p>To understand the model, I had a look at the model tree. I started with successful MATIC (Polygon)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9cTKGLOsCqSyNXpZFt1SA.png" /><figcaption>MATIC decision tree</figcaption></figure><p>As you can see, the model base its decision on MFI and volume. It is very strange to base the decision on volume because the mean volume 2 years ago may be completely different from the current mean volume. Each time the model tries to predict the direction using volume, it will be out of context.</p><p>Now let’s try an unsuccessful token like ATOM:<br>The result of the atom was “the strategy made a return of -0.456, and the market -0.293.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzCROJA2dROcE1UeBbLqQw.png" /><figcaption>ATOM decision tree</figcaption></figure><p>As you see, ATOM also starts with MFI, but in the second depth, he uses volume.</p><p>These results are the same for the rest of the tokens. You are welcome to check the code. There are more charts and exploration of the data. You are also welcome to play with it. It is straightforward, change the configuration, and you are ready to go.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb61b463dca055c0c34360232226172e/href">https://medium.com/media/cb61b463dca055c0c34360232226172e/href</a></iframe><p><strong>To conclude</strong> this part, I have to say that the positive results on Matic have been just lucky. I will not use this model for trading because it feels very random.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91a5ce472ad2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trading-data-analysis/momentum-strategy-ml-in-the-crypto-environment-part-2-91a5ce472ad2">Momentum strategy — ML in the Crypto environment — Part 2</a> was originally published in <a href="https://medium.com/trading-data-analysis">Trading Data Analysis</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passive income in FTX exchange]]></title>
            <link>https://medium.com/@ivanlisi88/passive-income-in-ftx-exchange-36de991b9630?source=rss-850aef8b783c------2</link>
            <guid isPermaLink="false">https://medium.com/p/36de991b9630</guid>
            <category><![CDATA[pasive-income]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[funding]]></category>
            <category><![CDATA[ftx]]></category>
            <category><![CDATA[investing]]></category>
            <dc:creator><![CDATA[Ivanlisi]]></dc:creator>
            <pubDate>Tue, 02 Aug 2022 12:35:16 GMT</pubDate>
            <atom:updated>2022-08-02T12:59:48.813Z</atom:updated>
            <content:encoded><![CDATA[<p>Let&#39;s see how much yield we can make using FTX funding program</p><h4>A quick explanation about funding</h4><p>Platform that offers future trading need to keep the future price as close to the spot price. In case there is big LONG (or SHORT) position the price of the future will drift away from the spot price. In order to balance ratio between LONG and SHORT position the exchange will pay you to hold the side with the lower position. You can find more information in <a href="https://dataguide.cryptoquant.com/market-data-indicators/funding-rates">cryptoQuant</a> or check a YouTube video of <a href="https://www.youtube.com/c/TheCalculatorGuy">The Calculator Guy</a> (He will explain about the program and revile very nice strategy around it). If you want to check the exact calculation of the funding program check <a href="https://help.ftx.com/hc/en-us/articles/360027946571-Fundin">FTX site.</a></p><h4>The problem I’m about to tackle</h4><p>I entered the FTX platform and didn’t find any charts of the funding rates. In the following link, <a href="https://ftxpremiums.com/">https://ftxpremiums.com/</a>, you can see that FTX provides only an <strong>average annualized funding rate. </strong>The problem is that they are showing current rate, sometime it could be more than 100%, but I don’t know what was the rate an hour ago, or a day ago. In my opinion it is hard to make smart decisions like this. So I will plot the annualized funding rate, and create demo investment of $10,000 to see how much profit I could make.</p><p><strong><em>In this article, I will plot the rates for the top 3 highest yield tokens. And will try to answer the question, “Is it worth a while to invest in funding rates?”</em></strong></p><h4>Research plan</h4><ol><li>Connect to FTX API and get 5000 hours off historical rates.</li><li>Calculate annualize rates for each one of the 5000 hours.</li><li>Make a demo investment of $10,000</li><li>Compound the yield in the initial investment. <br>Example: If I invested 500 tokens and after an hour received one token. I will immediately invest 501 tokens. This way, I will compound my return.</li><li>Calculate annualized yield and actual yield for each of the tokens FTX provides yield farming.</li><li>Plot the top 3 yield providers</li><li>Calculate the token price depreciation</li><li>Ask additional question</li><li>Conclusions</li></ol><h4>In the first step, I’ll calculate the data only for WBCT yield.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hq4f6y-51LCnBMuU_N9irw.png" /></figure><p>The yield is inferior… only 1.4% in 208 days.<br>In the line plot of WBTC rate there are sharper slopes. I wonder what happened in the market during this time.</p><p><em>Summary of the transaction:<br>You bought 0.198294665873488 BTC for the price of 50430.0. After 208 days, you got an extra 0.0028179941801329267 BTC, placing you with a total of 0.2011128583482868 BTC. The price of BTC after the investment period was 23758.0. You total PNL is: (0.198294665873488* (23758.0–50430.0)) +(0.0028179941801329267 * 23758.0) -$</em>5221.96542245</p><p>The total PNL is negative. Actually, for this specific period, the investment lost about 50%. This is not a result of the yield farming but the downside move of the crypto market. <br>A solution for this loss is hedging. There is some hedging strategy that you may apply to cancel your exposure on the position and profit only from the yield of the funding.</p><h4>Let&#39;s do the same for all the tokens and plot the top 10 tokens&#39; <strong>average annualized funding rate.</strong></h4><p>Top 10 tokens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*ibAvRkIczqKe91g-MMqCqw.png" /><figcaption>Top 10 tokens out of all FTX tokens</figcaption></figure><p>Sadly I got the following frightening chart. The high yield data points are very high yield just for one hour. Why is it happening? From time to time, the proportion between borrowers and lenders inclined to the lender&#39;s side. Don’t get very excited; the proportion reverts to the average quickly. But, you are welcome to try and exploit this vast rate (Let me know if you are successful).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mG1j2wG5uYcCLSZJ0a8jyA.png" /></figure><p>To make the chart readable, I cut the rate higher than 200%. Also, instead of showing the actual yield, I am showing 24H MA of the annualized funding rate. It will make the chart a bit smoother. (Note: There are days with 0%-1% they will be less seen because of the mean)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwOydUaJj_0KuSyFnvs2PA.png" /></figure><p>There are lots of days with low yields. There are exciting picks. I want to know the reason for the ups and downs and the powers that move the yield. <br>Even though AXS has many data points with a yield above 100%, the average result for the period is 48.077%.</p><h4>Calculate the token price depreciation</h4><p>So even if we are doing crazy high yield. Let’s face it is 134.7% yield in 208 days, one of the best yields you can get for passive income. So, where is the risk? Well, you need to buy the token, an altcoin. We never know what will happen to this tokens tomorrow, they may go up by 100% or down by 99%.<br>As this is very simple strategy (without hedging) the risk is very high.</p><p><em>Summary:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O60L7jSnvu2GrHoYqFeTkQ.png" /></figure><p><em>You bought 2597.402597402597 CEL for the price of 3.85. After 208.0 days, you got an extra 3499.4710013007652 CEL, placing you with a total of 6096.873598703362 CEL. The cost of CEL after the investment period was 1.081. PNL from yield farming is 3782.928152406127 PNL from inventory -7192.2077922077915. Your total PNL is -3409.2796398016644.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaE4UCAXcJ07ZYcDeuh0hw.png" /></figure><p><em>You bought 137.1742112482853 AXS for the price of 72.9. After 190.0 days, you got an extra 65.94991654455376 AXS, placing you with 203.12412779283906 AXS. The price of AXS after the investment period was 18.682. PNL from yield farming is 1232.0763408853531 PNL from inventory -7437.311385459533. Your total PNL is -6205.2350445741795.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tTwGndi9SuElJlwZ0r5bQ.png" /></figure><p><em>You bought 2817.298211015636 BNT for the price of 3.5495. After 208.0 days, you got an extra 668.1610860926027 BNT, placing you with a total of 3485.4592971082384 BNT. The price of BNT after the investment period was 0.586. PNL from yield farming is 391.54239645026513 PNL from inventory -8349.063248344837. Your total PNL is: -7957.520851894572</em></p><h4>Follow-up Questions</h4><ol><li>Why CEL yield increase so much in June 2022?</li><li>What are the forces influencing the rates of the tokens?</li><li>Is there a correlation between the price/volatility of the token and the rates?</li><li>Why is the slope of the yield getting sharper?</li><li>What happens in the market or in the pools during a very high yield? The yield I had to cut.</li></ol><h4>Final words</h4><p>It looks like there is lots of potential in this area. But, the strategy I showed here is not good enough. There is a lot of information about funding strategies on the internet. I will continue to explore more complex strategies and will publish them here.</p><p><a href="https://medium.com/u/b1877db1b771">CryptoQuant Team</a> , <a href="https://medium.com/u/6f53ad934548">FTX — Cryptocurrency Derivatives Exchange</a></p><h4>The code</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d56e7831dceb153e73b64efc92fcda1a/href">https://medium.com/media/d56e7831dceb153e73b64efc92fcda1a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36de991b9630" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Momentum strategy — ML in the Crypto environment]]></title>
            <link>https://medium.com/trading-data-analysis/momentum-strategy-ml-in-the-crypto-environment-c65c9d657ee9?source=rss-850aef8b783c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c65c9d657ee9</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[cryptocurrency-investment]]></category>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Ivanlisi]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 04:49:06 GMT</pubDate>
            <atom:updated>2022-11-07T07:34:39.840Z</atom:updated>
            <content:encoded><![CDATA[<h3>Momentum strategy — ML in the Crypto environment</h3><h4>Random forest model that beating the market by 122%</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*Y_u75zdhapKuunZyjMIAaw.png" /></figure><p>In this article, I’ll use KNN, decision tree, and random forest to predict the next day return in Crypto assets, <a href="https://medium.com/u/ea91a1cf958">Polygon</a> (MATIC). The Algo will trade once an interval.<br>My best prediction has 53% precision for positive days and 51% for gloomy days. The test dataset ran from 2021–09 to 2022–07 and made a return of 73%, while the market made a return of -49%. <br><em>Note: The prediction of bearish days might be more importer than positive days. I’ll write additional articles with an analysis of the results and try to improve the model based on the research.</em></p><h4>walk-through</h4><ol><li><strong>Binance API</strong><br>Get 1-day candles from Binance API.</li><li><strong>Indicators calculation </strong><br>Feature creation. We will calculate technical indicators: RVI, MFI, %K, RSI, %D, true_range, PVT, MA, PSI, and PVR using pandas-ta (ta)(a handy library for finance analysis).</li><li><strong>Feature selection<br></strong> We will use feature selection to check which indicators are the best predictors for our goal.<br><em>Note: this step is optional. The best way to find the best feature combination is to play with them and see the results of each variety.</em></li><li><strong>Run predictions<br></strong>We will start with KNN to get some baseline. KNN is not the best model, and usually, we will get better results using forest or DNN models. Then we will jump to the decision tree and random forest.</li><li><strong>Plot and analysis<br></strong>I’ll plot it but the analysis will be in the following article</li></ol><h4>The Trading Strategy</h4><p>I must create some entry and exit from position logic to compare my prediction results to the market results.<br>To make it as easy as possible, I’ll make only long trades. If the prediction says that the return will be positive, I’ll buy at the day&#39;s close price and close the position at the end of the following day. <br><em>Note: As the model predicts both positive and negative returns, it is possible to place also short trades.</em></p><h4>Configurations</h4><p><strong>Candle kind —</strong>The model works only with 1-day candles.</p><p><strong>Features — </strong>RVI, MFI, Volume, %k, rsi, %D, true_range, PVT, MA, Open, Low, Psi, Close, High, PVR</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*qm05uJtqlE2uwlVzSq9INw.png" /><figcaption>feature_importances</figcaption></figure><p><em>Note: eventually, I used only MFI and volume as my features as they gave the best results.</em></p><p><strong>Indicators rolling period</strong> — Part of the indicators have a rolling calculation. I used 30 days in my initial model, but then I noticed that 60 days gave better results. The exciting part is that 61 days or 59 days provides the worst consequences.</p><h3>Results</h3><h4>KNN</h4><p>Train_data Accuracy: 0.59<br>Test_data Accuracy: 0.55</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*cbuMKoQzYgf_7i-15BlHcA.png" /></figure><p><em>Notes: the strategy hadn&#39;t made any trades from 2021–12 to 2022–05, meaning the model predicted only negative days.<br>The accuracy looks good but the actual result not so much</em></p><h4>Decision Tree</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*yIwLVP5aDSpQsiKqz_2Cyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*KZz3CM2lF8hgRmuVdmqzeg.png" /></figure><p>We can see that the model returns prevail over the market returns.<br><em>Note: I used 60 days for rolling indicators, tree depths are 3, and leaves are 6. There is much to optimize and analyze by changing this parameter.</em></p><h4>Random forest</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*0ilUY2J1M9uE5-O59iPB7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*Y_u75zdhapKuunZyjMIAaw.png" /></figure><p>Once again, the strategy comes out ahead. This model is the best one because it has a better f1 score.</p><h4>Conclusions</h4><p>The best accuracy score I got is 53%; notice that the return of the decision tree was better, using random forest. These are amazing and very surprising results. <br>I have to say that the f1 score is not the best, and it is essential to understand what is going on in the predictions.</p><h4>Future research</h4><p>In the following article, I’ll dive into the random forest model. I will try to understand why the model outperformed the market. <br>Also, I’ll create functions to optimize the configuration.<br>I’ll try to run the model on different assets. In this article, I used as an example <a href="https://medium.com/u/ea91a1cf958">Polygon</a>. <br>Later, I will build a real trading strategy using the Kelly formula and Sharp optimization.</p><h4>Code</h4><p>As this model is actually useful I will not publish the code for the public. With that said I will happy to share it upon request.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c65c9d657ee9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trading-data-analysis/momentum-strategy-ml-in-the-crypto-environment-c65c9d657ee9">Momentum strategy — ML in the Crypto environment</a> was originally published in <a href="https://medium.com/trading-data-analysis">Trading Data Analysis</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>