<?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 Xumit Capital on Medium]]></title>
        <description><![CDATA[Stories by Xumit Capital on Medium]]></description>
        <link>https://medium.com/@xumitcapital?source=rss-c3ba94f4021d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IaAR1HyjCs-rS09DLLZEcg.png</url>
            <title>Stories by Xumit Capital on Medium</title>
            <link>https://medium.com/@xumitcapital?source=rss-c3ba94f4021d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 06:50:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xumitcapital/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[An Introduction to EB-5 Program]]></title>
            <link>https://xumitcapital.medium.com/an-introduction-to-eb-5-program-a21565d8467e?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a21565d8467e</guid>
            <category><![CDATA[golden-visa]]></category>
            <category><![CDATA[investment-migration]]></category>
            <category><![CDATA[green-card]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 15:58:32 GMT</pubDate>
            <atom:updated>2026-11-03T15:58:32.711Z</atom:updated>
            <content:encoded><![CDATA[<h3>EB-5 Explained: What the Visa Numbers and Rules Mean Before You Invest</h3><p>Most people first hear about EB-5 as a route to a U.S. green card through investment. The route is real, but it comes with ongoing obligations, a capped supply of visas, and a process that runs through several government bodies.</p><h3>A green card comes with conditions</h3><p>A green card is not a document you collect and forget. Permanent residents are taxed on their worldwide income from the day they receive permanent residence, so families with income abroad need tax planning from the outset.</p><p>The U.S. also expects green card holders to make the country their primary home. You can show this through a home you own or rent, along with everyday ties such as bank accounts, investments, credit cards and a driver’s license. Stay abroad for more than six months and you may face questions at the border about whether you have given up your residence. The guide recommends a re-entry permit from USCIS, which lets a holder remain outside the U.S. for up to a year without losing that status.</p><p>Male green card holders also have a duty to register with Selective Service between the ages of 18 and 25. Registration does not mean serving in the military. It does mean a registrant could be called up if the government ever chose to draft men.</p><h3>Only 9,940 EB-5 visas a year</h3><p>Each fiscal year, which runs from October to September, 9,940 EB-5 visas are available. That figure counts investors, spouses and children individually. Within it, 20% are reserved for rural projects, 10% for high-unemployment areas and 2% for infrastructure.</p><p>Unused visas in a reserved category do not disappear. They roll over to the same category the following year, then join the general pool from the third year. The guide also notes that the true number can be somewhat higher in some years, because unused family-based green cards spill over into employment categories, and EB-5 can claim a share of that spillover.</p><p>The bigger point is demand. When you count each applicant’s spouse and children, demand has outstripped supply in many years. That creates queues, and the guide promises a full discussion of queuing and allocation later in Chapter 9.</p><h3>Petitions peaked in 2015 and have fallen since</h3><p>The number of Form I-526 petitions tells a clear story. Filings rose sharply through the mid-2010s, peaking at 17,691 in 2015. After that they declined, falling to 1,147 in 2022 and 2,792 in 2023. The guide attributes the post-2015 slide mainly to slower-than-expected processing and a growing backlog of applicants waiting their turn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*7NeCVJOQAKyzafcVQ97rmA.png" /><figcaption>$62 Billion of investments have been raised in EB-5 so far since 1990</figcaption></figure><h3>Who actually receives the visas</h3><p>Visa issuance shows a shift in nationality over time. In FY2014, China accounted for 9,128 of the 10,723 visas issued, with India at just 96. By FY2023, China’s count had dropped to 6,262, while India had risen to 815 after reaching 1,381 in FY2022. Vietnam and South Korea also grew over the same period. The visible dip in FY2020 and FY2021 reflects the COVID-19 slowdown.</p><p>These figures include principal investors, spouses and children. They also explain why country of origin matters. The guide notes that visa availability depends on the investor’s, or spouse’s, country of chargeability, which is usually the country of birth. Applicants from high-demand countries can wait longer, even when their paperwork is complete.</p><h3>The agencies behind every step</h3><p>Three bodies handle the process, and it helps to know who does what:</p><ul><li><strong>USCIS</strong> is part of the Department of Homeland Security. Its Investor Program Office adjudicates the initial petitions, Form I-526 or I-526E, and sends approved cases to the National Visa Center where required. USCIS also handles applications for adjustment of status (Form I-485) and removal of conditions (Form I-829).</li><li><strong>The National Visa Center (NVC)</strong> sits within the State Department. It receives approved petitions for investors living abroad, gathers personal documents, and forwards files to the relevant embassy or consulate.</li><li><strong>U.S. embassies and consulates</strong> conduct the visa interviews and issue the visas.</li></ul><p>— — Xumit Capital team (<a href="https://xumitcapital.com/investment-migration/usa/">xumitcapital.com</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a21565d8467e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Corporate Governance matters?]]></title>
            <link>https://xumitcapital.medium.com/why-corporate-governance-matters-61f6ec5740b3?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/61f6ec5740b3</guid>
            <category><![CDATA[corporate-governance]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 06:36:00 GMT</pubDate>
            <atom:updated>2023-06-09T06:36:00.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qusfAG_-2uPWYF5je5sMQ.png" /></figure><p>Written by <strong>Margret Syriac</strong> (<a href="/service/mailto:margret.tapmimpl2022@learner.manipal.edu">margret.tapmimpl2022@learner.manipal.edu</a>)</p><p>Corporate governance holds immense significance for businesses and society as a whole. The recognition of massive corporate collapses resulting from weak governance systems has underscored the need for international improvements and reforms in corporate governance. Instances such as Enron and Parmalat have prompted countries worldwide to take pre-emptive measures to address similar issues within their domestic frameworks.</p><p>The USA responded swiftly to these failures by enacting the Sarbanes-Oxley Act in July 2002. Similarly, the UK published the Higgs Report and the Smith Report in January 2003 in direct response to recent corporate governance failures. These events have elevated corporate governance to become one of the most frequently discussed topics in the global business arena.</p><p>The importance of a strong and functional corporate governance can be further explained using instances where its absence led to collapse of largest companies on the face of Earth.</p><p>The high-profile collapse of Enron in 2001, one of America’s largest companies, has drawn international attention to corporate failures and highlighted the role that strong governance plays in preventing such incidents. Corporate governance encompasses both formal and informal institutions, including private and public entities, that govern the relationship between corporate insiders (those managing corporations) and all other stakeholders who invest resources in various companies.</p><p>Essentially, corporate governance comprises a set of rule-based processes, laws, policies, and accountability mechanisms that regulate the interactions between investors (shareholders) and the management of investee companies. The significance of corporate governance gained prominence in the aftermath of the Asian financial crisis in 1997–1998 and the corporate scandals of the early 2000s, such as Enron and WorldCom.</p><p>The Enron case highlighted several corporate governance problems. Unrestrained power in the hands of the CEO was a key issue, as well as unethical activities that continued to be revealed after the company’s downfall. For example, Enron’s energy traders manipulated markets where California purchased electricity, which became evident through released documents. Overall, Enron’s corporate governance was weak in various aspects, with a board lacking moral character and engaging in fraudulent behaviour.</p><p>The collapse of Enron led to significant reactions in the USA and the UK, prompting a focus on corporate governance weaknesses. The long-term impact of Enron’s collapse should ideally result in a cleaner and more ethical corporate environment worldwide. Regular updates to corporate governance codes and systematic reviews of checks and balances are essential to prevent similar incidents in the future.</p><p>Corporate governance checks and balances can help detect unethical practices, but they cannot cure them entirely. The intangible nature of fraud and the subjective nature of human behaviour create complexities in addressing issues of fraud and ethical breakdown. Sheldon Zenner, an American white-collar criminal and civil lawyer, emphasised the challenges in defining right and wrong during the Enron trial.</p><p>Unfortunately, after the threat of global financial crises waned, corporate governance took a backseat in academic research. However, the enduring lessons from these incidents serve as a reminder of the ongoing importance of robust corporate governance practices to ensure the stability and integrity of businesses and financial systems.</p><p>Let’s dive into events where corporate governance changed the future of the companies for good.</p><p>In the early 2000s, Nestlé, a renowned multinational food and beverage company, found itself entangled in a controversy surrounding unethical marketing practices and a perceived lack of transparency. These allegations had the potential to significantly impact the company’s reputation and, subsequently, its stock performance. However, Nestlé swiftly responded to the situation by implementing robust corporate governance measures, ultimately turning the tide in its favour.</p><p>Recognising the importance of addressing the concerns raised, Nestlé took proactive steps to improve its corporate governance framework. One notable action was the adoption of the Nestlé Corporate Business Principles, a comprehensive set of guidelines outlining the company’s commitment to ethical behaviour, respect for human rights, and environmental sustainability. By establishing clear principles and values, Nestlé demonstrated its dedication to responsible corporate conduct.</p><p>Furthermore, Nestlé recognised the significance of transparency in rebuilding trust with its stakeholders. The company strengthened its sustainability reporting practices, providing comprehensive and detailed information about its environmental and social performance. This commitment to transparency allowed investors and the public to gain a deeper understanding of Nestlé’s efforts in areas such as water management, climate change mitigation, and responsible sourcing of raw materials.</p><p>The implementation of stronger corporate governance measures had a positive impact on Nestlé’s stock performance. Investors appreciated the company’s proactive approach in addressing the allegations and its commitment to ethical conduct and sustainability. The enhanced transparency reassured stakeholders that Nestlé was taking the necessary steps to align its practices with societal expectations.</p><p>Transparency of corporate practices plays a significant role in influencing the stock prices of a company. Transparent companies tend to attract more investors, enjoy higher market confidence, and benefit from a positive reputation. On the other hand, a lack of transparency can erode investor trust, increase perceived risk, and negatively impact stock prices. Investors value transparency as it enables them to make informed decisions and assess the long-term prospects and sustainability of a company.</p><p>Facing scrutiny over its weak governance practices in the late 2000s, Samsung undertook significant reforms. These included appointing independent directors, enhancing disclosure practices, and strengthening internal controls. These efforts contributed to increased investor trust and positively impacted Samsung’s stock performance.</p><p>In India, the structure responsible for overseeing corporate governance initiatives consists of two key entities: the Ministry of Corporate Affairs (MCA) and the Securities and Exchange Board of India (SEBI). The role of SEBI is to monitor and regulate the corporate governance practices of companies listed on stock exchanges in India. This regulatory oversight is carried out through the implementation of Clause 49, which is incorporated in the listing agreement between stock exchanges and companies. Compliance with the provisions of Clause 49 is mandatory for listed companies.</p><p>On the other hand, the Ministry of Corporate Affairs, in collaboration with various committees and forums, facilitates the exchange of knowledge and ideas related to corporate governance. One such forum is the National Foundation for Corporate Governance (NFCG), which operates as a non-profit trust. The NFCG serves as a platform for corporate leaders, policymakers, regulators, law enforcement agencies, and non-governmental organisations to share their experiences and perspectives on corporate governance.</p><p>The Desirable Corporate Governance Code introduced by the Confederation of Indian Industry (CII) in 1998 brought forth the concept of independent directors and their compensation in listed companies. The Kumar Mangalam Birla Committee, in 2000, recommended that if a company had an executive Chairman, at least half of the board should consist of independent directors, while in other cases, at least one-third should be independent directors.</p><p>The Clause 49, which was updated based on the report by the Narayana Murthy Committee, provides a more detailed definition of independent directors. It also mandates listed companies to have an optimal mix of executive and non-executive directors, with non-executive directors accounting for at least 50% of the board.</p><p>In 2013, the Companies Act introduced the requirement of appointing a resident director and a woman director. The Act also defined the term “Key Managerial Personnel” to include positions such as Chief Executive Officer, Managing Director, Company Secretary, and Chief Financial Officer, among others. The Act introduced new concepts like performance evaluation of the board, committees, and individual directors.</p><p>The revised Clause 49, implemented in 2013, states that the compensation paid to non-executive directors, including independent directors, must be determined by the Board and approved by shareholders in a General Meeting. There are also limits placed on stock options granted to non-executive directors, and these details must be disclosed in the company’s annual report. Independent directors are required to adhere to a Code of Conduct and affirm their compliance with it annually.</p><p>Countries like India, experiencing rapid growth, have attracted significant investments from international investors and large domestic financial institutions seeking global expansion. As a result, corporate governance standards in investee companies have made notable advancements. Numerous research reports have demonstrated that companies with robust governance systems have delivered favourable risk-adjusted returns to their shareholders. Therefore, if a company wishes to attract institutional investor participation, it must demonstrate a compelling commitment to enhancing the quality of its corporate governance practices.</p><p>Indian companies should adopt best practices, such as the OECD Corporate Governance Principles revised in 2004, which serve as a global benchmark. Given the prevalence of concentrated corporate ownership in countries like India, it becomes crucial to treat all shareholders, including domestic and foreign institutional investors, fairly and equitably.</p><p>Institutional investors are expected to actively engage in the voting process during Annual General Meetings (AGMs) for the shares they hold in their portfolio companies. Additionally, they should publicly disclose their voting records, including the reasons behind any non-disclosures. It is also essential for institutional investors to provide explanations for their support or opposition to any Board Resolution of their portfolio companies, which should be made available on their websites.</p><p>Under the 2013 Act, it is now compulsory for companies with over one thousand shareholders, debenture-holders, deposit-holders, and other security holders at any point in a financial year to establish a Stakeholders Relationship Committee. This committee will be composed of a non-executive director serving as the chairperson, along with other members as determined by the Board. The primary objective of this committee is to address and resolve any concerns or complaints raised by the company’s security holders.</p><p>Corporate governance is a critical driver of stock market trading. By fostering transparency, accountability, and ethical behaviour, it builds investor confidence, protects shareholder rights, and mitigates risks. Moreover, effective governance practices contribute to long-term value creation and sustainable growth. As investors, it is imperative to assess a company’s governance structure before making investment decisions. Likewise, companies must prioritise corporate governance to maintain a competitive edge and attract investment.</p><p>Remember, a well-governed company not only benefits its shareholders but also contributes to the overall stability and integrity of the stock market.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61f6ec5740b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Position Sizing: The Underdog Parameter in Trading]]></title>
            <link>https://xumitcapital.medium.com/position-sizing-the-underdog-parameter-in-trading-2cb91062d2fb?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cb91062d2fb</guid>
            <category><![CDATA[position-sizing]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[technical-analysis]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Fri, 12 May 2023 17:01:32 GMT</pubDate>
            <atom:updated>2023-05-13T05:17:52.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*lh2u78JysEL4FivwRTHeTg.png" /></figure><p>Written by <strong>Rohin Maliakkal</strong> (<a href="/service/mailto:rohin.tapmimpl2022@learner.manipal.edu">rohin.tapmimpl2022@learner.manipal.edu</a>)</p><p>Position sizing is the process of determining the appropriate size of each investment in a portfolio based on the investor’s risk tolerance, investment objectives, and the characteristics of the stock or asset under consideration. Position sizing allows investors to limit the exposure to a single stock or market sector and help in reducing risk.</p><p><strong>Why is position sizing important?</strong></p><p>Given below is an example of five different trades that happened in five different days. In the first example, without proper position sizing we could see a winning percentage of 60% but still it is a loss we end up losing our capital. Many of us may have experienced this. But look at the second example same winning percentage but different result. How did this happen?</p><p>There comes the reason why it is important to keep position size and the importance of risk to reward ratio. In the second case, we gave a certain percent of the capital to each trade thereby limiting exposure of the whole capital. And also, in each trade in a day, we decided a certain risk to reward ratio also. This helps in limiting the loss that can happen in a trade. Further moving on I’ll explain how can this be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*ZVZbgSgVYoDBELdRazE74g.png" /></figure><p>There are basically 3 types of position sizing techniques:</p><ol><li><strong>Unit per fixed amount</strong></li></ol><p>This strategy is used by most people. In this strategy, a trader or investor decides how much money they are willing to risk on each trade or investment.</p><p>The trader or investor then decides on the unit size for each trade or investment. The unit size is the amount of money assigned to each trade or investment. For example, if we have a capital of 4 lakh and have an opportunity of 4 trades, allocate 1 lakh to each of the trades as shown in the figure below. As a trader I will allocate the number of units based on this fixed amount (1 lakh) which I am willing to risk with this approach. The price was taken on 9th May 2023.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*ycmsisxmiDCeKou_Y9fXJw.png" /></figure><p>From this method, if we look at the maximum loss that may come from a particular trade in this portfolio is ₨ 447 (after brokerage). This helps in limiting the losses and saving the capital. By this method, for starters we can set a risk to reward ratio of 0.3:0.6 % by setting a target and stop loss for each trade.</p><p><strong>2. Percentage margin</strong></p><p>Another method used by traders and investors to determine the appropriate size of their positions is percentage margin in position sizing. Each trade or investment is assigned a percentage of the trading account.</p><p>To use this method, we must first decide how much money we are willing to risk on each trade as a percentage of their account size. Assuming we have a capital of 1 lakh, we decided to assign 5% of our capital to a trade that is 5000 rupees. Suppose we get an opportunity to trade HINDUNILVR (now trading at about 2500), we can buy 2 shares of HINDUNILVR as per our 5% capital. If we also get an opportunity to buy ULTRACEMCO (now trading at Rs.7735), we should let go off the opportunity as this is not included in our method.</p><p>It is important to note that using percentage margin for position sizing can result in larger position sizes as the trading account grows, increasing the risk of significant losses if a trade goes against the trader or investor. As a result, as the trading account grows, it is critical to constantly reassess and adjust the percentage margin.</p><p><strong>3. Percentage volatility method</strong></p><p>The volatility of the underlying asset is used to determine the appropriate position size for a trade. Suppose TCS on 4th May 2023 has O:3,180 H: 3,224 L: 3,178 C: 3,220, so the volatility is found by subtracting high and low price of that day.</p><p>Volatility = 3,224–3,178 = 46</p><p>We can find the volatility of TCS for the last n days and average it with the help of Average True Range (ATR) indicator. Here for example ATR of TCS for the last 14 days is around 50.</p><p>So now we have to find how many shares we have to buy assuming a capital of 10 lakh and if we decide on a volatility exposure of 0.5%. i.e., about 5K. So, I should buy shares such that the overall volatility exposure is less than 5K.</p><p>5000/50 = 100 shares. That means 100*3,220 = Rs. 3,22,000</p><p>So, if the position goes against us, we stand a chance to lose 5k on 10 lakh capital. This same can be done in a portfolio. Let’s look into a portfolio in which it’s done. From the same example given in units per fixed amount. Let the stocks be TATA STEEL, ONGC, HINDUNILVR, JSW STEEL. So a volatility of 1% is determined for 10 lakh capital which is distributed uniformly among the 4 stocks.</p><p>That is Rs. 2,500/- each</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UH8JGnhbVXzogaMDfsEIWg.png" /></figure><p>From a capital of 10 lakh, only Rs. 5,57,130 has to be employed in the portfolio. The remaining amount can be used to invest in other trade opportunities. Even if all positions of this portfolio go down also, we stand to lose 10k. The volatility percent is decided by a trader’s risk tolerance towards his investment. By these methods I hope for a trader or an investor you could book high profits by minimizing your losses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cb91062d2fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s on the Way to your Trading Desk?: Technology That Matters]]></title>
            <link>https://wire.insiderfinance.io/whats-on-the-way-to-your-trading-desk-technology-that-matters-9fad0a74b3a?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fad0a74b3a</guid>
            <category><![CDATA[technical-analysis]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[algotrading]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Wed, 10 May 2023 15:16:36 GMT</pubDate>
            <atom:updated>2023-05-11T15:38:51.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*rQsXIMZFiLLFtPquxLxxmg.png" /></figure><p>Written by Margret Syriac (<a href="/service/mailto:margret.tapmimpl2022@learner.manipal.edu">margret.tapmimpl2022@learner.manipal.edu</a>)</p><p><strong>Introduction</strong></p><p>The financial industry has greatly benefited from technological advancements over the past 20 years. Most capital markets professionals believe that technology has improved market efficiency, although some industry veterans have lost their jobs due to automation. Baby boomers were less positive about the impact of technology than Gen Xers and millennials, and regulators are still grappling with the occasional volatility caused by computer-based trading. However, the advantages of technological progress far outweigh the disadvantages, with technology helping both big companies and small startups to thrive in the market. Although more than half of the respondents believe that technology has helped established companies to solidify their position, a larger majority believe that it has also enabled new startups to challenge the market leaders, despite the inherent difficulties of breaking into an entrenched market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-TzsG6yU35WBclZogZpZDA.png" /></figure><p><strong><em>Capital markets professionals overwhelmingly see artificial intelligence as the most potentially disruptive technology in the coming 3–5 years.</em></strong></p><p><strong>WHAT’S NEW?</strong></p><p>Trading desks have become more efficient and have improved their execution quality with the use of algo wheels for equity trades and automated responses to bond market requests. Large data sets and complex analytics have also enabled asset managers to get the best price on trades and work with the best counterparties, ultimately saving investors millions. Banks are using machine learning to provide better service to clients based on their behavior and preferences. Although these advancements have had a significant impact, they only represent the beginning of what’s possible in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EELXZ7J4jyTjVwWL2FDkNA.png" /></figure><p><strong>1. Artificial Intelligence</strong></p><p>The use of artificial intelligence (AI) in the stock market is rapidly transforming the industry. By leveraging AI algorithms, traders can analyse vast amounts of data, detect patterns, and make better-informed decisions about purchasing and selling stocks. These algorithms are capable of learning from past decisions, allowing them to refine their strategies and become more effective over time. Additionally, AI can assist traders in monitoring market conditions and news updates in real-time, offering valuable insights into market sentiment and potential risks.</p><p><strong>2. Blockchain</strong></p><p>The stock market is experiencing a transformation through the use of blockchain technology. Blockchain leverages a distributed ledger that is decentralized, which can enhance transparency and efficiency in the stock market. By using blockchain-based systems, transactions can be processed with greater speed and security, reducing the likelihood of fraud and errors. Furthermore, intermediaries may become redundant because of blockchain technology.</p><p><strong>3. Robotic Process Automation</strong></p><p>RPA is a technology that automates repetitive tasks and processes using software robots. In the stock market, RPA can be used to automate tasks such as data entry, data analysis, and trade execution. By freeing up traders from these tasks, RPA can help them focus on higher-level tasks such as strategy development and risk management.</p><p><strong>4. Quantum computing</strong></p><p>Quantum Computing is a new technology that has the potential to revolutionize the working of stock market. With its ability to process large amounts of data and perform complex calculations at unprecedented speeds, quantum computing can help traders analyze market data more quickly and accurately. It can also help develop more sophisticated trading strategies that take into account a wider range of variables and factors.</p><p><strong>5. Internet of Things (IoT)</strong></p><p>IoT is a network of interconnected devices and sensors that collect and transmit data over the internet. In the stock market, IoT can be used to collect data from a variety of sources such as social media, news articles, and market data. This data can then be used to develop trading strategies that consider a wide range of variables and factors.</p><p><strong>TECHNOLOGY THAT MATTER</strong></p><p><strong><em>Performance analytics sit at the intersection of several bigger technology trends, including AI, cloud computing, alternative data, and big data.</em></strong></p><p>The current state of the market should be considered a new standard, and the industry will aim to exceed it each year. Automated trading, alternative data, and real-time analytics are now the norm, and the focus should shift to emerging technology tools that will have a greater impact in the next three to five years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rf5uWUaiDD7SoVRAJb5ECw.png" /></figure><p>Trading desks need to consider both tactical and strategic innovation. Although they have no effect on the desk’s P&amp;L today or next month, the former, which includes revolutionary technological advancements like artificial intelligence and cloud computing, is essential for long-term growth and profitability. Solutions focused on cybersecurity, real-time risk management and trade performance analytics will all be critical to the success of trading desks in the coming years.</p><p><strong>TRADING AND AI</strong></p><p>According to capital markets professionals, among the many incredible technologies that have impacted our lives, such as cloud computing, high-speed internet, and blockchain, AI is seen as the most potentially disruptive in the next three to five years. In contrast, institutional traders of all ages remain mostly uninterested in cryptocurrencies despite efforts to make these markets more accessible. Millennials are particularly optimistic about the potential for AI on trading desks, with two-thirds believing it will be highly disruptive in the coming years, compared to only half of Gen Xers. Having grown up with AI affecting various aspects of their lives, such as Netflix and Google, millennials are confident about the impact it can have on capital markets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DiEAYKROpy5UwWd_xf3A0g.png" /></figure><p><strong>AI TRADING:</strong></p><p>AI trading is the use of artificial intelligence algorithms to analyze and trade in the stock market. These algorithms use machine learning techniques to analyze vast amounts of market data, such as stock prices, news articles, and social media trends, to identify patterns and make informed trading decisions. AI algorithms can also learn from past decisions and adjust their strategies, accordingly, making them more effective over time.</p><p><strong>How does it work?</strong></p><p>AI trading works by using machine learning algorithms to analyze market data and make trading decisions. These algorithms use a variety of techniques, including natural language processing, sentiment analysis, and technical analysis, to identify patterns and trends in the market. Once a pattern or trend is identified, the algorithm can execute trades automatically based on predefined trading rules.</p><p>AI algorithms can learn from past decisions and adjust their strategies, accordingly, making them more effective over time. Finally, AI trading can help reduce the emotional biases that can often impact human traders, leading to more consistent and profitable trading strategies.</p><p><strong>Some AI tools to aid stock trading:</strong></p><ul><li>Sigmoidal: The program utilizes artificial intelligence to acquire knowledge on forecasting market trends and recognize connections among assets. Furthermore, machine learning automates the trading of securities. The firm’s artificial intelligence and robotic process automation services handle all aspects of the development process, from brainstorming to the finished product. This technology simplifies the examination of potential investments to help with decision-making.</li><li>Kavout is an AI-powered stock selection and analysis platform that uses machine learning algorithms to identify promising investment opportunities. The platform uses a proprietary scoring system to rate stocks based on a range of factors such as financial performance, growth potential, and market sentiment.</li><li>Trade Ideas is an AI-powered trading platform that uses machine learning algorithms to identify profitable trading opportunities. The platform scans the market for patterns and trends and provides traders with real-time alerts and recommendations based on their trading strategies.</li><li>Tickeron: One of the many useful features offered by Tickeron is AI Trend Prediction. Tickeron utilizes an AI-driven trend forecasting system that examines historical pricing data to anticipate future market trends. Additionally, it assigns a confidence score to each prediction to enable you to evaluate its probability.</li></ul><p><strong>What’s the Impact?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ESB28y6Q54S3Iuzm72zEIw.png" /></figure><p>The impact of artificial intelligence (AI) on financial services is still up for debate, but machine learning (ML) is seen as the most attention-grabbing type of AI. Despite challenges related to data normalization and privacy rules, capital markets firms are hiring specialists to effectively aggregate and normalize data for AI-driven solutions. Banks, exchanges, and fintech vendors are making the most progress with AI, with AI investment expected to be most impactful for execution algorithms and the analysis of structured and unstructured data. AI-driven execution algorithms have been used by a small number of early adopters in equity markets, and as they learn from market conditions and traders’ preferences, they can provide better services at a lower cost. Asset managers and hedge funds are not investing heavily in AI, with only 1 in 5 using it today. Given the challenges and costs associated with building cutting-edge AI solutions, it may be smarter for these firms to let their vendors and trading counterparties make the investment. This way, they can access fully vetted tools and reduce risk while still benefiting from AI on the trading desk.</p><p><strong>Development of AI?</strong></p><p>While financial services have invested billions of dollars in developing technology, the lack of sophistication in AI on trading desks is somewhat disappointing given the level of talent in the industry. However, the true potential of AI in trading has not yet been fully explored. Developing AI is expensive as it requires significant investment in R&amp;D and developer resources. Nonetheless, the benefits of AI are expected to outweigh the costs, with costs reducing after the initial implementation. This is particularly important given the current pressures on broker-dealers to increase return on equity for their low-margin trading businesses. The buy side is also facing pressure to reduce costs due to the continued downward pressure on management fees.</p><p><strong>Reference:</strong></p><p>Survey results by Refinitiv examining the technology trends, the data explosion and the skills required to be successful in capital markets in the future : The future of Trading Technology</p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fad0a74b3a" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/whats-on-the-way-to-your-trading-desk-technology-that-matters-9fad0a74b3a">What’s on the Way to your Trading Desk?: Technology That Matters</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Download Bank Nifty Options Data using Python?]]></title>
            <link>https://wire.insiderfinance.io/how-to-download-bank-nifty-options-data-using-python-ea9e53e1cd74?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea9e53e1cd74</guid>
            <category><![CDATA[nifty]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 06:36:08 GMT</pubDate>
            <atom:updated>2023-03-21T19:26:47.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*raNDdHgrCP0AMVNH.jpg" /></figure><p>Written by <strong>Kaushik Sanghani</strong> (<a href="/service/mailto:kaushik.sanghani@xumitcapital.com">kaushik.sanghani@xumitcapital.com</a>)</p><p>Backtesting strategies using spot market and futures market data has become easier with the availability of various libraries like backtrader, vectorbt, and backtesting.py. However, backtesting trading strategies on derivatives is not as simple. While equity data is freely available on Yahoo Finance, most derivatives data is paid, especially for intraday data. Nsepy and Nse Bhavcopy provide free EOD option data for weekly and monthly expiry, but accessing and managing this data can be complicated due to different strike prices, expiries, and holidays. This article offers a Python code that can download daily Bank Nifty options data from Nsepy and organise it in a structured way for further backtesting. While the article doesn’t delve too deeply into the logic behind the code, it includes comments where necessary for clarity.</p><p>The process used to develop this code involved several steps.</p><ol><li>Initially, the weekly expiry dates from 2017 to 2023 were identified.</li><li>These dates contain the expiry dates for all instruments, with BANK NIFTY and NIFTY expiring on Thursdays and FIN NIFTY expiring on Tuesdays, assuming no holidays. If the goal is to obtain weekly option data, then the expiry days that fall on Tuesdays should be excluded, and Mondays and Fridays should be removed after accounting for holidays.</li><li>The expiry date for the last week is determined, which corresponds to the FUTURE contract expiry date for that month.</li><li>The futures data for each expiry date is downloaded and saved to a dataframe.</li><li>Using nsepy, options data is downloaded for the given expiry and 10 strikes above and below the futures expiry prices are selected.</li><li>Finally, the data is organized, and the NIFTY cash price is added.</li></ol><pre>#importing libraries<br>import pandas as pd<br>from datetime import date<br>import nsepy<br>from copy import deepcopy<br>from datetime import datetime<br>import numpy as np<br>from nsepy import get_history<br><br>#-----------------------------------------------------------------------------------------------------<br><br>#creating dictionaries of expiry dates and then also to store weekday of that expiry to remove the <br>#tuesday expiry of finnifty<br>expiry_dict = {2017:{},2018:{},2019:{},2020:{},2021:{},2022:{}}<br>expiry_dict_weekday = {2017:{},2018:{},2019:{},2020:{},2021:{}, 2022:{}}<br><br>month_dict = {}<br>month_dict_for_weekday = {}<br><br>#adding 1-12 month in month_expiry as well as month_dict_for_weekday<br>for i in range(1,13):<br>    month_dict[i] = []<br>    month_dict_for_weekday[i] = []<br><br>#getting expiry dates from nsepy.get_expiry_date for each month and year and then storing into our<br>#dictionary<br>#also calculating weekday of that expiry<br>#if it&#39;s monday=0, thursday=3 etc.<br>for year in expiry_dict:<br>    for month in month_dict:<br>        expiry_dict[year][month] = list(nsepy.get_expiry_date(year = year, month = month))<br>        expiry_dict[year][month].sort()<br>        <br>        expiry_dict_weekday[year][month] = []<br>        for k in expiry_dict[year][month]:<br>            expiry_dict_weekday[year][month].append(k.weekday())<br><br><br><br>#adding values for 2023 because we are in the march right now and we are not having data for all 12 months<br>expiry_dict[2023] = {1:[],2:[]}<br>expiry_dict_weekday[2023] = {1:[],2:[]}<br>for month in range(1,3):<br>    expiry_dict[2023][month] = list(nsepy.get_expiry_date(year = 2023, month = month))<br>    expiry_dict[2023][month].sort()<br>    <br>    expiry_dict_weekday[2023][month] = []<br>    for k in expiry_dict[2023][month]:<br>        expiry_dict_weekday[2023][month].append(k.weekday())<br>        <br>#-----------------------------------------------------------------------------------------------------<br><br><br><br>#creating copy<br>expiry_dict_after_removing_fin_exp = deepcopy(expiry_dict)<br>expiry_dict_after_removing_fin_exp_weekday = deepcopy(expiry_dict_weekday)<br><br>#removing the monday, tuesday and friday expiry<br>for year in expiry_dict:<br>    for month in expiry_dict[year]:<br>        for day in range(len(expiry_dict_weekday[year][month])):<br>            if ((expiry_dict_weekday[year][month][day]) == 1 or (expiry_dict_weekday[year][month][day]) == 4 or (expiry_dict_weekday[year][month][day]) == 0): #and (year == 2021 or year == 2022):<br>                <br>                print(expiry_dict_weekday[year][month][day])<br>                expiry_dict_after_removing_fin_exp[year][month].remove(expiry_dict[year][month][day])<br>                expiry_dict_after_removing_fin_exp_weekday[year][month].remove(expiry_dict_weekday[year][month][day])<br>#-----------------------------------------------------------------------------------------------------<br><br><br><br>#getting last month expiry for future contract<br>last_exp_of_month = []<br><br><br>for year in expiry_dict_after_removing_fin_exp:<br>    for month in expiry_dict_after_removing_fin_exp[year]:<br>        last_exp_of_month.append(expiry_dict_after_removing_fin_exp[year][month][-1])<br>#-----------------------------------------------------------------------------------------------------<br><br><br>#creating sample format for banknifty futures data<br>sample_data = get_history(symbol = &#39;BANKNIFTY&#39;, index= True, futures= True, start =date(2019, 2, 28) , end = date(2019, 3, 28), expiry_date=date(2019, 3, 28))<br>sample_data.columns<br><br>sample_data<br><br>#column names of banknifty futures data<br>bank_nifty_fut_data = pd.DataFrame(columns=sample_data.columns)<br>bank_nifty_fut_data<br><br>#-----------------------------------------------------------------------------------------------------<br><br><br>#getting bank nifty futures data for each month expiry and appending future data into one dataframe<br>for i in range(len(last_exp_of_month)-1):<br>    df = get_history(symbol = &#39;BANKNIFTY&#39;, index=True, futures=True, start=last_exp_of_month[i] , end = last_exp_of_month[i+1], expiry_date=last_exp_of_month[i+1])<br>    <br>    bank_nifty_fut_data = pd.concat([bank_nifty_fut_data,df])<br><br>#-----------------------------------------------------------------------------------------------------<br><br><br><br>#all option expiries in the list format<br>all_option_expiries = []<br><br>for year in expiry_dict_after_removing_fin_exp:<br>    for month in expiry_dict_after_removing_fin_exp[year]:<br>        for exp_date in expiry_dict_after_removing_fin_exp[year][month]:<br>            all_option_expiries.append(exp_date)<br>all_option_expiries<br><br>#we want to work with weekly expiries and for bank nifty it has started from second month so removing<br>#expiry data of january 2017<br>all_option_expiries = all_option_expiries[4:]<br>all_option_expiries<br><br>#creating sample dataframe for the option data<br>sample_api_call = get_history(symbol = &#39;BANKNIFTY&#39;, index=True,start =date(2019, 1, 31),end =date(2019, 2, 14),option_type=&#39;PE&#39;,strike_price=10000,expiry_date=date(2019, 2, 14))<br><br>options_data = pd.DataFrame(columns=sample_api_call.columns)<br>options_data<br><br>#-----------------------------------------------------------------------------------------------------<br><br>#iterating over all the expiries<br>for n in range(len(all_option_expiries) - 1):<br>    print(all_option_expiries[n])<br>    #getting future price at current expiry<br>    bank_nifty_fut_price_at_given_date = bank_nifty_fut_data[&#39;Close&#39;].loc[all_option_expiries[n]]<br>    <br>    if (isinstance(bank_nifty_fut_price_at_given_date, pd.Series)):<br>        bank_nifty_fut_price_at_given_date = bank_nifty_fut_price_at_given_date[0]<br>        <br>    #we will be fatching data of +10 strike and -10 strike from the expiry price of bank nifty <br>    #future<br>    bank_nifty_fut_price_at_given_date_rounded = round(bank_nifty_fut_price_at_given_date/100)*100<br>    <br>    strike_low_range = bank_nifty_fut_price_at_given_date_rounded - 1000<br>    strike_upper_range = bank_nifty_fut_price_at_given_date_rounded + 1000<br>    #below 100 is a strike price difference. for bank nifty it&#39;s 100 now and for nifty it&#39;s 50 now<br>    for i in range(strike_low_range,strike_upper_range,100):<br>        <br>#         print(i)<br>        #getting pe and ce data for the given expiry, strike price and given underlying<br>        df_pe= get_history(symbol = &#39;BANKNIFTY&#39;,index = True,start = all_option_expiries[n], end = all_option_expiries[n+1],option_type=&#39;PE&#39;,strike_price=i,expiry_date=all_option_expiries[n+1])<br>        df_ce = get_history(symbol = &#39;BANKNIFTY&#39;,index = True,start = all_option_expiries[n], end = all_option_expiries[n+1],option_type=&#39;CE&#39;,strike_price=i,expiry_date=all_option_expiries[n+1])<br>        #storing it into options_data<br>        options_data = pd.concat([options_data,df_pe])<br>        options_data = pd.concat([options_data,df_ce])<br>        <br>#-----------------------------------------------------------------------------------------------------<br><br><br><br>#future data<br>bank_nifty_fut_data = bank_nifty_fut_data[[&#39;Close&#39;]]<br><br>#taking necessary columns from option data<br>options_data = options_data[[&#39;Symbol&#39;,&#39;Expiry&#39;,&#39;Option Type&#39;, &#39;Strike Price&#39;, &#39;Close&#39;]]<br>options_data<br><br>#adding values bank nifty cash and bank nifty future<br>options_data[&#39;BANKNIFTY FUT&#39;] = 0<br>options_data[&#39;BANKNIFTY CASH&#39;] = 0<br><br><br>#getting bank nifty cash data for the given interval<br>bank_nifty_cash = get_history(&#39;BANKNIFTY&#39;,index=True, start = date(2017,2,2), end = date(2023,2,28))<br>bank_nifty_cash = bank_nifty_cash[[&#39;Close&#39;]]<br><br><br>#attaching spot price of bank nifty for given each row of option price on given table<br>for i in range(len(options_data)):<br>    print(options_data.index[i])<br>    options_data[&#39;BANKNIFTY CASH&#39;].iloc[i] = bank_nifty_cash[&#39;Close&#39;].loc[options_data.index[i]]<br>    #options_data[&#39;NIFTY FUT&#39;].iloc[i] = nifty_cash_data[&#39;Close&#39;].loc[options_data.index[i]]<br>    <br>#-----------------------------------------------------------------------------------------------------<br><br><br>options_data_with_reset_index = options_data.reset_index()<br>options_data_with_reset_index<br><br>#creating the price pivot table for call and put <br>opttable = pd.pivot_table(options_data_with_reset_index, values=&#39;Close&#39;, index=[&#39;index&#39;,&#39;Option Type&#39;,&#39;Expiry&#39;,&#39;BANKNIFTY CASH&#39;], columns=[&#39;Strike Price&#39;], aggfunc=np.sum)<br><br><br>#grp based on option type<br>grouped_with_pe_ce = options_data.groupby(&#39;Option Type&#39;)<br>grouped_with_pe_ce_after_grouping = grouped_with_pe_ce.apply(lambda a: a[:])<br><br>#just pe data<br>options_data_pe = options_data[options_data[&#39;Option Type&#39;] == &#39;PE&#39;]<br><br>#just ce data<br>options_data_ce = options_data[options_data[&#39;Option Type&#39;] == &#39;CE&#39;]<br><br>#pe ce data in one data frame for given date<br>ce_pe_in_differnt_columns = pd.concat([options_data_ce,options_data_pe], axis = 1)<br><br>#-----------------------------------------------------------------------------------------------------</pre><p><strong>Notes:</strong></p><p>The code provided above is intended for use in a notebook environment. To fully comprehend the logic and nuances of the code, it is recommended that you run it in a notebook environment. The code in different notebook cells is separated by “# — — — — -”.</p><p>If you wish to download stock option data, a similar approach can be used. Simply download the data for month-end expiries and apply the same logic to FIN NIFTY by excluding Thursday expiries and using Wednesday for holidays.</p><p>In the final cell, you can export the data in various formats, including one dataframe containing all CE PE data, a pivottable format, and separate dataframes for CE PE data, as well as a row containing both CE PE data and the NIFTY cash price.</p><p>Examples of the exported data are provided below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*YJ4t93UbkgErh35v" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/0*4YhLYDaioYF_PtfQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*89DemQ_fOB9eRhgq" /></figure><p>The above downloaded data can be utilised for backtesting various option End of Day (EOD) trading strategies. We will investigate this further in the future. Thank you for taking the time to read this article.</p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea9e53e1cd74" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/how-to-download-bank-nifty-options-data-using-python-ea9e53e1cd74">How to Download Bank Nifty Options Data using Python?</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning (ML) Trading Strategy on NIFTY]]></title>
            <link>https://wire.insiderfinance.io/machine-learning-ml-trading-strategy-on-nifty-968aa3465ad4?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/968aa3465ad4</guid>
            <category><![CDATA[nifty]]></category>
            <category><![CDATA[trading-strategy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algotrading]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 07:16:10 GMT</pubDate>
            <atom:updated>2023-02-28T15:31:52.115Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3GvFvgApDnCE7N_uxc_KA.png" /></figure><p>Written by <strong>Kaushik Sanghani</strong> (<a href="/service/mailto:kaushik.sanghani@xumitcapital.com">kaushik.sanghani@xumitcapital.com</a>)</p><p>In my previous articles, I primarily utilized the moving average crossover strategy to explain quantitative concepts, despite the fact that it is not a widely used trading strategy. Most traders rely on tested technical indicator strategies to make trading decisions. However, there is another option available — AI and Machine Learning. AI and ML have become ubiquitous in many industries. As beginners, we are familiar with typical machine learning projects such as house price prediction models and recommendation systems. In this article, we will explore how to use machine learning algorithms on stock market data from scratch in a straightforward manner. Additionally, we will perform back-testing on our trading strategy. While reading this article, readers will have the opportunity to implement the code in their Python environment.</p><p>It’s worth noting that this article does not provide a guaranteed strategy for making money in the live market. Instead, it teaches readers how to approach machine learning when developing and back-testing strategies. It provides a framework through which any machine learning algorithm can be back-tested on OHLC data.</p><p>To tackle this problem of using machine learning in NIFTY OHLC data, we will follow a typical data science framework which is described below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/0*Gv2KPIeVjy9J_tzK" /></figure><ol><li>Defining Problem Statement</li></ol><p>2. Data Mining</p><p>3. Data Cleaning</p><p>4. Data Exploration</p><p>5. Feature Engineering</p><p>6. Predictive modelling</p><p>7. Evaluation of model</p><p>8. Visualization</p><p>9. Deployment</p><p>Now, let’s move on to the problem statement. The problem statement for any trading strategy is straightforward — “Should we buy an instrument at any given time?” If our algorithm predicts that the price of an instrument will rise in the future, we will buy it. On the other hand, if the algorithm predicts that the price will fall, we will take a short position on the instrument. In our strategy, we aim to predict whether we should buy NIFTY (assuming that we can replace it with NIFTYBEES) or not. This will be a long-only strategy.</p><p>This strategy uses supervised machine learning to evaluate the trading algorithm’s performance and back-test historical data. Therefore, we need to create a target variable. The target variable or signal will have two values — 1 and 0. A value of 1 means buying the instrument. In contrast, a value of 0 means not doing anything since it is a long-only strategy. We will create a target variable based on the near future return, one candle away.</p><pre>#Importing libraries<br>import pandas as pd  <br>import numpy as np <br>import quantstats as qs <br>import talib as ta <br>from copy import deepcopy<br>import seaborn as sns <br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.metrics import classification_report, confusion_matrix, ConfusionMatrixDisplay<br><br><br>import matplotlib.pyplot as plt <br>import matplotlib.colors as clrs<br><br>from statsmodels.tsa.stattools import adfuller<br>from sklearn.model_selection import train_test_split<br><br>#Reading 1m file<br>df = pd.read_pickle(&#39;nifty_1m_cleaned_data.pickle&#39;)<br>df = df.reset_index()<br>df[&#39;index&#39;] = df[&#39;index&#39;] - pd.Timedelta(minutes=1)<br><br># Assuming you have a dataframe named df with a DatetimeIndex<br>df = df.set_index(&#39;index&#39;)<br>df = df.resample(&#39;15min&#39;, offset=&#39;15min&#39;).agg({&#39;Open&#39;: &#39;first&#39;, &#39;High&#39;: &#39;max&#39;, &#39;Low&#39;: &#39;min&#39;, &#39;Close&#39;: &#39;last&#39;})<br>df = df.dropna()<br><br>df = df.tail(60000)<br><br>data = deepcopy(df) <br><br>data[&#39;Open&#39;] = np.float64(data[&#39;Open&#39;])<br>data[&#39;High&#39;] = np.float64(data[&#39;High&#39;])<br>data[&#39;Low&#39;] = np.float64(data[&#39;Low&#39;])<br>data[&#39;Close&#39;] = np.float64(data[&#39;Close&#39;])<br>data.index = pd.to_datetime(data.index)<br><br>data.Close.plot(figsize = (8,5), color = &#39;b&#39;)<br>plt.ylabel(&#39;Close price&#39;)<br>plt.xlabel(&#39;Date&#39;)<br>plt.show()<br><br>#create a column &#39;future_returns&#39; with the calculation of percentage change<br>data[&#39;future_returns&#39;] = data[&#39;Close&#39;].pct_change().shift(-1)<br><br>#create the signal column<br>data[&#39;signal&#39;] = np.where(data[&#39;future_returns&#39;] &gt; 0, 1, 0)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/0*eu6qH0l9vlRfiA9s" /></figure><p>To train our machine learning model, we require features that will aid in predicting future prices. As technical analysts, we know many indicators to help predict price trends and volatility. We can generate as many features as technical indicators. Our model will identify which combination of indicators and features works best with NIFTY data. We have used simple indicators such as previous candle returns, simple moving averages, correlation, volatility, and so on to create features to simplify matters. However, one can use other indicators to develop a better strategy. Here in the given code, the features and target variable are separated.</p><pre>#Creating a column &#39;pct_change&#39; with the 15-minute prior percentage change<br>data[&#39;pct_change&#39;] = data[&#39;Close&#39;].pct_change()<br><br>#Creating a column &#39;pct_change2&#39; with the 30-minute prior percentage change<br>data[&#39;pct_change2&#39;] = data[&#39;Close&#39;].pct_change(2)<br><br>#Creating a column &#39;pct_change5&#39; with 75-minute prior percentage change<br>data[&#39;pct_change5&#39;] = data[&#39;Close&#39;].pct_change(5)<br><br><br><br>#Creating a column by the name RSI, and assigning the RSI(14) value<br>data[&#39;rsi&#39;] = ta.RSI(data[&#39;Close&#39;].values, timeperiod=14)<br><br>#Creating a column by the name ADX, and assigning the ADX values to it<br>data[&#39;adx&#39;] = ta.ADX(high = data[&#39;High&#39;].values,<br>                    low = data[&#39;Low&#39;].values,<br>                    close = data[&#39;Close&#39;].values,<br>                    timeperiod = 14)<br><br>#Creating a column by the name sma and assigning SMA values to it<br>data[&#39;sma&#39;] = data[&#39;Close&#39;].rolling(window=14).mean()<br><br>#Creating a column by the name corr, and assigning the correlation values to it<br>data[&#39;corr&#39;] = data[&#39;Close&#39;].rolling(window=14).corr(data[&#39;sma&#39;]) <br><br># 1d 2d Volatility<br>data[&#39;volatility&#39;] = data.rolling(int(6.25*4), min_periods = int(6.25*4))[&#39;pct_change&#39;].std()*100 <br>data[&#39;volatility2&#39;] = data.rolling(int(6.25*8), min_periods = int(6.25*8))[&#39;pct_change&#39;].std()*100 <br><br>#Dropping missing values<br>data.dropna(inplace=True)<br><br>#Target<br>y = deepcopy(data[[&#39;signal&#39;]])<br><br>#Features<br>X = deepcopy(data[[&#39;Open&#39;,&#39;High&#39;,&#39;Low&#39;,&#39;Close&#39;, &#39;pct_change&#39;, &#39;pct_change2&#39;,<br>         &#39;pct_change5&#39;, &#39;rsi&#39;, &#39;adx&#39;, &#39;sma&#39;, &#39;corr&#39;, &#39;volatility&#39;, &#39;volatility2&#39;]])</pre><p>Let’s visualise all the features which we have created.</p><pre>i = 1<br>#Set number of rows in subplot<br>nrows = int(X.shape[1])<br>for feature in X.columns:<br>    plt.subplot(nrows,3,i)<br>    <br>    #Plot the feature<br>    X[feature].plot(figsize=(12,3*X.shape[1]),<br>                   color = np.random.rand(3,))<br>    plt.ylabel(feature)<br>    plt.xticks(rotation=&#39;vertical&#39;)<br>    plt.title(feature)<br>    i += 1<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/0*O5bVtfMbNb1a628H" /></figure><p>Since most ML algorithms require stationary features, we will exclude non-stationary features. We will use the adfuller test to test for stationarity, which I have explained in the pairs trading article. After conducting the test, we have determined that Open, High, Low, Close, and SMA are not stationary features. Consequently, we will drop these features.</p><pre>def stationary(series):<br>    result = adfuller(series)<br>    if(result[1] &lt; 0.05):<br>        return &#39;stationary&#39;<br>    else:<br>        return &#39;not stationary&#39;<br>    <br>#Checking for stationarity<br>for col in X.columns:<br>    if stationary(data[col]) == &#39;not stationary&#39;:<br>        print(f&#39;{col} -- not stationary&#39;)<br>        X.drop(columns=[col], axis=1, inplace=True)<br>    else:<br>        print(f&#39;{col} -- stationary&#39;)</pre><p>To enhance the model, we must eliminate multicollinearity from the feature space. Therefore, we will assess the correlation between all the features and exclude those with an absolute correlation greater than 0.75. One could set the threshold at 0.7. After conducting this test, we discovered that the volatility and volatility2 features correlate greater than 0.75. Hence, we will drop the volatility2 feature.</p><pre>#plotting correlation<br>plt.figure(figsize=(8,5))<br>sns.heatmap(X.corr(), annot=  True, cmap = &#39;coolwarm&#39;)<br>plt.show()<br><br>#Function to return the paris with correlation above threshold<br>def get_pair_above_threshold(X,threshold):<br>    #Calculate the correlation<br>    correl = X.corr()<br>    <br>    #Unstack the matrix<br>    correl = correl.abs().unstack()<br><br>    #Recurring and Redudant pair<br>    pairs_to_drop = set()<br>    cols = X.corr().columns<br>    <br>    for i in range(0, X.corr().shape[1]):<br>        for j in range(0, i+1):<br>            pairs_to_drop.add((cols[i], cols[j]))<br><br>    #Dropping the recurring and redudant pair<br>    correl = correl.drop(labels=pairs_to_drop).sort_values(ascending=False)<br>    <br>    return correl[correl &gt; threshold].index<br><br>print(get_pair_above_threshold(X,0.75))<br><br>X = X.drop(columns=[&#39;volatility2&#39;],axis=1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*_w8wPqtUH78RuOW3" /></figure><p>We will use the train_test_split method from the sklearn module to divide the data into 80% training and 20% testing data. Alternatively, one could choose a combination of (70, 30). Since we are working with time series data, we will not shuffle the data during the split. If we shuffle the data, we will encounter a problem of data leakage.</p><pre>#Obtaining the features and target for the &#39;train_data&#39; and &#39;test_data&#39; without<br>#shuffling<br><br>X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.80, shuffle=False)<br><br>plt.figure(figsize=(15,5))<br><br>plt.plot(X_train[&#39;pct_change&#39;], linestyle = &#39;None&#39;,<br>        marker = &#39;.&#39;, markersize = 3.0, label = &#39;X_train data&#39;,<br>        color = &#39;blue&#39;)<br>plt.plot(X_test[&#39;pct_change&#39;], linestyle = &#39;None&#39;,<br>        marker = &#39;.&#39;, markersize = 3.0, label = &#39;X_test data&#39;,<br>        color = &#39;green&#39;)<br><br>plt.title(&#39;Visulizing Train and Test Dataset&#39;)<br>plt.xlabel(&#39;Years&#39;)<br>plt.ylabel(&#39;% Change&#39;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*H6zVgKqnKbopV84D" /></figure><p>Continuing from the previous paragraph, to create a machine learning model, we need to deal with a classification task as per the problem statement: whether to take a long position on NIFTY or not. We can use various machine learning algorithms, such as logistic regression, decision trees, SVM classifier, Random Forest, XG booster, etc. However, we will use the Random Forest Classifier for this article. This algorithm combines multiple decision trees to make more accurate predictions.</p><p>Each decision tree is trained on a random subset of the data and features, which makes the trees less prone to overfitting and increases the overall accuracy of the model. The algorithm then combines the predictions of each tree to make a final classification decision. Several hyperparameters, such as max_depth, max_features, and n_estimators, can be chosen randomly. However, we can use hyperparameter tuning methods to improve the algorithm further. Once we have chosen the hyperparameters, we can train our model, test it on the out-of-sample dataset and evaluate the results.</p><pre>#Creating the machine learning model<br>rf_model = RandomForestClassifier(n_estimators=3, max_features=3,<br>                                 max_depth=2, random_state=4)<br><br>#Training the model<br>rf_model.fit(X_train, y_train[&#39;signal&#39;])<br>&quot;Training is done&quot;<br><br>y_pred = rf_model.predict(X_test)<br>y_pred<br><br>accuracy_data = (temp == y_test[&#39;signal&#39;])<br><br>accuracy_percentage = round(100* accuracy_data.sum()/len(accuracy_data),2)<br>accuracy_percentage<br><br>#plot accuracy data<br>plt.figure(figsize=(15,5))<br>#color mapping for the correct and incorrect predictions <br>cmap = clrs.ListedColormap([&#39;green&#39;, &#39;red&#39;])<br>plt.yticks([])<br>plt.scatter(x = y_test.index, y = [1]*len(y_test),<br>           c = (accuracy_data!=True).astype(float),<br>           marker = &#39;.&#39;, cmap = cmap)<br>plt.title(&#39;Accuracy (Correct is green and Incorrect is Red)&#39;)<br>plt.xlabel(&#39;Years&#39;)<br>plt.show()<br><br>#Define the confusion matrix<br>confusion_matrix_data = confusion_matrix(y_test.values,y_pred)<br><br>cm_display = ConfusionMatrixDisplay(confusion_matrix = confusion_matrix_data, display_labels = [&#39;No Position&#39;, &#39;Long Position&#39;])<br><br>cm_display.plot()<br>plt.show()<br><br>#Classification report <br>classification_report_data = classification_report(y_test.values, y_pred)<br>print(classification_report_data)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/0*MtLqcblRB2GlDO6Q" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/0*_F6xbLjWI5WN7k5y" /></figure><p>The accuracy obtained for our algorithm is 51.39%, which is decent, as it predicts the correct results for 51.39 out of 100 times. However, relying solely on accuracy is insufficient to evaluate the model’s effectiveness. We also need to analyse the accuracy label-wise or the actions taken by the ML model. This involves assessing the total number of True Positive, True Negative, False Positive, and False Negative cases, which can be seen in the confusion matrix. Additionally, we have calculated the f1 score, which ranges from 0 to 1, with zero being the worst and one being the best. Explaining the confusion matrix and f1 score would require an entire article.</p><p>So far, we have obtained an accuracy of around 51%, which does not provide any information about the trading system. Therefore, we need to perform the typical back-testing process to learn more about this trading strategy and evaluate various metrics such as the equity curve of the strategy, returns, risk, Sharpe ratio, maximum drawdown, winning amount per trade, and losing amount per trade. We will calculate all these metrics for our strategy from the beginning. In the end, we will also use the quantstats library to compute more detailed metrics and visualize them.</p><pre>#making strategy data for backtesting purpose<br>strategy_data = data[[&#39;Close&#39;]].merge(X_test[[]], left_index=True, right_index=True)<br><br>strategy_data[&#39;signal&#39;] = y_pred<br>strategy_data<br><br><br><br>#Calculating the percentage change<br>strategy_data[&#39;pct_change&#39;] = strategy_data[&#39;Close&#39;].pct_change()<br><br>#Calculating the strategy returns<br>strategy_data[&#39;strategy_returns&#39;] = strategy_data[&#39;signal&#39;].shift(1) * strategy_data[&#39;pct_change&#39;]<br><br>#Dropping missing value<br>strategy_data.dropna(inplace=True)<br><br>strategy_data<br><br>#Trade logs<br><br>def get_trades(data, close_column, signal_column):<br>    #Create a dataframe to store value of each trade<br>    trades = pd.DataFrame()<br>    <br>    #Set current position as 0,<br>    #and entry time as empty<br>    current_position = 0<br>    entry_time = &#39;&#39;<br>    <br>    #Loop through each trade in dataframe<br>    <br>    for i in data.index:<br>        #Each row in dataframe will be treated as a new position<br>        <br>        new_position = data.loc[i, signal_column]<br>        <br>        if new_position != current_position:<br>            if entry_time != &#39;&#39;:<br>                entry_price = data.loc[entry_time, close_column]<br>                exit_time = i <br>                exit_price = data.loc[exit_time, close_column]<br>                <br>                trade_details = pd.DataFrame([<br>                    (current_position, entry_time, entry_price, exit_time, exit_price)<br>                ])<br>                trades = trades.append(trade_details, ignore_index=True)<br>                <br>                entry_time = &#39;&#39;<br>            <br>            if new_position != 0:<br>                entry_time = i <br>                <br>            current_position = new_position<br>    <br>    #Adding the trade details to the &#39;trades&#39; dataframe<br>    <br>    trades.columns = [&#39;Position&#39;, &#39;Entry Time&#39;, &#39;Entry Price&#39;, &#39;Exit Time&#39;,<br>                     &#39;Exit Price&#39;]<br>    <br>    trades[&#39;PnL&#39;] = (trades[&#39;Exit Price&#39;] - trades[&#39;Entry Price&#39;]) * trades[&#39;Position&#39;]<br>    <br>    return trades <br><br>trade_log = get_trades(strategy_data, &#39;Close&#39;, &#39;signal&#39;)<br><br><br>trade_log<br><br>def get_analytics(trades):<br>    # Creating the dataframe to store the parameters<br>    analytics = pd.DataFrame(index=[&#39;Strategy&#39;])<br>    <br>    # Number of long trades<br>    analytics[&#39;num_of_long&#39;] = len(trades.loc[trades.Position == 1])<br>    <br>    # Number of short trades<br>    analytics[&#39;num_of_short&#39;] = len(trades.loc[trades.Position == -1])<br>    <br>    # Total number of trades<br>    analytics[&#39;total_trades&#39;] = analytics.num_of_long + analytics.num_of_short<br>    <br>    # Gross Profit<br>    analytics[&#39;gross_profit&#39;] = trades.loc[trades.PnL &gt; 0].PnL.sum()<br>    <br>    # Gross Loss<br>    analytics[&#39;gross_loss&#39;] = trades.loc[trades.PnL &lt; 0].PnL.sum()<br>    <br>    # Net Profit<br>    analytics[&#39;net_profit&#39;] = trades.PnL.sum()<br>    <br>    # Profitable trades<br>    analytics[&#39;winners&#39;] = len(trades.loc[trades.PnL &gt; 0])<br>    <br>    # Loss-making trades<br>    analytics[&#39;losers&#39;] = len(trades.loc[trades.PnL &lt;= 0])<br>    <br>    # Win percentage<br>    analytics[&#39;win_percentage&#39;] = 100 * analytics.winners /analytics.total_trades<br>    <br>    # Loss percentage<br>    analytics[&#39;loss_percentage&#39;] = 100 * analytics.losers /analytics.total_trades<br>    <br>    # Per trade profit/loss of winning trades<br>    analytics[&#39;per_trade_PnL_winners&#39;] = trades.loc[trades.PnL &gt; 0].PnL.mean()<br>    <br>    # Per trade profit/loss of losing trades<br>    analytics[&#39;per_trade_PnL_losers&#39;] = trades.loc[trades.PnL &lt;= 0].PnL.mean()<br>    <br>    analytics = round(analytics, 2)<br>    <br>    return analytics.T<br><br>analytics = get_analytics(trade_log)<br><br><br>print(analytics)<br><br>#Plotting equity curve<br><br>strategy_data[&#39;cumulative_returns&#39;] = (1 + strategy_data[&#39;strategy_returns&#39;]).cumprod()<br><br><br>#Plot cummulative strategy returns<br><br>strategy_data[&#39;cumulative_returns&#39;].plot(figsize = (8,5), color = &#39;green&#39;)<br>plt.title(&#39;Equity Curve&#39;, fontsize = 14)<br>plt.ylabel(&#39;Cummulative returns&#39;)<br>plt.tight_layout()<br>plt.show()<br><br>cummulative_returns = (strategy_data[&#39;cumulative_returns&#39;][-1] - 1) * 100<br>print(f&#39;The cummulative returns is {cummulative_returns}&#39;)<br><br>#Annualised returns<br>annulised_return = ((strategy_data[&#39;cumulative_returns&#39;][-1] ** (252*6.25*4/strategy_data.shape[0]) - 1))* 100<br>print(f&#39;Annulised return is {annulised_return}&#39;)<br><br>#Annulised volatility<br>annulised_volatility = strategy_data[&#39;strategy_returns&#39;].std()*np.sqrt(252*6.25*4)*100<br>print(f&#39;Annulised volatility is {annulised_volatility}&#39;)<br><br>#Calculating running maximum<br><br>running_max = np.maximum.accumulate(strategy_data[&#39;cumulative_returns&#39;].dropna())<br><br>#Ensure that the value nver drops below 1<br>running_max[running_max &lt; 1] = 1 <br><br>#Calculate the percentage drawdown<br>drawdown = ((strategy_data[&#39;cumulative_returns&#39;])/running_max - 1) * 100<br><br>#Calculate maximum drawdown<br>max_dd = drawdown.min()<br>print(f&#39;Maximum drawdown is {max_dd}&#39;)<br><br>#Plotting under water equity curve<br><br>fig = plt.figure(figsize=(10,5))<br>plt.plot(drawdown, color = &#39;red&#39;)<br>plt.fill_between(drawdown.index, drawdown.values, color = &#39;red&#39;)<br>plt.title(&#39;Underwater equity curve&#39;)<br>plt.ylabel(&#39;Drawdown(%)&#39;)<br>plt.xlabel(&#39;Year&#39;)<br><br>plt.tight_layout()<br>plt.show()<br><br>#Sharpe ratio <br>sharpe_ratio = round(strategy_data[&#39;strategy_returns&#39;].mean() / strategy_data[&#39;strategy_returns&#39;].std() * np.sqrt(252*6.25*4),2)<br>print(f&#39;Shapre ratio is {sharpe_ratio}&#39;)<br><br># Quantstats Report Making<br><br><br>strategy_data<br><br>strategy = {<br>    &#39;strategy_returns&#39;: 1<br>}<br><br>strategy_data = strategy_data.reset_index()<br>strategy_data[&#39;index&#39;] = pd.to_datetime(strategy_data[&#39;index&#39;])<br>strategy_data = strategy_data.set_index(strategy_data[&#39;index&#39;])<br><br>portfolio = qs.utils.make_index(strategy,rebalance=None,returns=strategy_data)<br><br><br>qs.reports.html(portfolio,title=&#39;Random Forest on NIFTY&#39;,download_filename=&#39;ml_in_market.html&#39;)<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*0XxQczP2A_rHt864" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*H7BH1wwwzMn--_SK" /></figure><p>According to our analysis, our strategy generates approximately 11% return per year with a volatility of approximately 14% and a maximum drawdown of 15%, resulting in a Sharpe ratio of 0.83. However, we have not yet considered slippage and brokerage charges. Therefore, this strategy may not perform well enough to trade in the live market. But there are numerous possibilities to create different optimised trading strategies, such as using complex indicators, different machine learning algorithms with tuned hyperparameters, and risk management systems to reduce drawdown.</p><p>I hope this article has given you a clear understanding of the framework and approach to using ML in the stock market.</p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=968aa3465ad4" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/machine-learning-ml-trading-strategy-on-nifty-968aa3465ad4">Machine Learning (ML) Trading Strategy on NIFTY</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HFT Concepts: Order book and Order types]]></title>
            <link>https://wire.insiderfinance.io/hft-concepts-order-book-and-order-types-ae0f30ea752b?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae0f30ea752b</guid>
            <category><![CDATA[hft]]></category>
            <category><![CDATA[hfthighfrequencytrading]]></category>
            <category><![CDATA[algotrading]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Mon, 20 Feb 2023 13:06:01 GMT</pubDate>
            <atom:updated>2023-02-20T15:05:52.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*a8LrD0m4YEcqUk-Z.png" /></figure><p>Written by <strong>Kaushik Sanghani</strong> (<a href="/service/mailto:kaushik.sanghani@xumitcapital.com">kaushik.sanghani@xumitcapital.com</a>)</p><p>I am currently investigating high-frequency trading, which involves executing thousands of orders within seconds. This type of trading is quite distinct from technical trading and investment strategies. Fewer resources are available to learn about it than typical algorithmic trading strategies. To comprehend high-frequency trading, we must understand order books and order types. This article will provide a brief overview of how order books operate and the various types of orders. In future articles, we will also delve into specific strategies, such as statistical arbitrage and order book strategies.</p><p>Firstly, let’s begin by exploring how the order book operates. Most of us have likely come across the order book while placing orders. For example, I have attached a screenshot of Zerodha’s order book for Infosys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*8DDtQiL9fxSYZNTd" /></figure><p>The order book displays all the bids on the left-hand side and all the asks on the right-hand side. To illustrate how an order book is created, let’s use the following dummy data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*ChOSXrzxdpdsP5P1" /></figure><p>Let’s understand the order flow first. When a trader places an order, it is first directed to the broker, who then sends it to the central exchange, such as NSE or BSE. A matching algorithm is used at the exchange to match the buy order with the sell order, and a trade occurs. Most exchanges use the “Price Time Priority algorithm” to match orders based on their price and the time they were placed. To visualise these orders, the order book is maintained using the price time priority algorithm.</p><p><strong>Price time priority algorithm:</strong></p><p>According to this algorithm, the exchange will prioritise orders with the best price, and if two orders have the same price, the earlier order will be executed first.</p><p>Using the example above with dummy data, the generated order book is presented below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/0*HoH1dYtqx1IHZ6lm" /></figure><p>In the current market, the price of a dummy asset is 995 rupees, and the order book is constantly updated as new orders are received and matched using the algorithm we discussed earlier. The changes in the order book depend on the type of orders placed by traders. Various types of orders, including limit orders and market orders, are well-known. However, to understand the market microstructure, we need to explore these order types further and discuss other order types.</p><p>To better understand different types of orders, it’s essential to understand the concept of a market maker. While many retail traders use directional strategies, some firms make profits by taking advantage of the spread, which is the difference between the best bid and best ask prices. In the example above, the spread is 5 rupees, which can vary depending on the security’s liquidity. Market makers profit by placing limit buy orders just below the best bid and limit sell orders just above the best ask, as in the case where the current market price is 990. By doing so, they can make money through the spread and are referred to as market makers.</p><p><strong>Market Order:</strong></p><p>A market order is an order type that is immediately executed at the best available price once it hits the exchange. If a trader places a market buy order, their order will be matched with the volume on the ask side, regardless of the price. These orders offer the advantage of execution certainty, but the trader pays the bid-ask spread, and when trading with a large volume, they may receive an inferior price. In the example given, with a current market price of 995 rupees, if a trader places a market buy order for 80 shares, their cost would be calculated as follows:</p><p>Cost = 1000*15 + 1005*50 + 1010*15 = 15000 + 50250 + 15150 = 80500</p><p><strong>Limit Order:</strong></p><p>In the context of the order book example given earlier, a limit order is an order type where the trader specifies the price and volume. If the specified price is better than the current market price, the order is immediately executed, otherwise, it is placed on the limit order book and will get executed when it matches with the opposite side trade. There is a fixed price when the order is executed, but there is no guarantee of getting filled, and the probability depends on the limit order price. For example, if a trader places a limit buy order at 994 when the current market price is 995, the order will be placed in the limit order book. If the trader places a limit buy order at the best ask (here 1000), it will get executed at that price. If the order is only partially filled, the remaining volume will be placed at price 1000 in the limit order book.</p><p><strong>Stop order:</strong></p><p>A stop-loss order is an instruction to sell (or buy) a security if it reaches a certain price level. It is a risk management tool traders, and investors use to limit their losses and protect their profits. Stop-loss orders can be set as a fixed price or percentage of the current market price. Once the stop-loss price is reached, the order becomes a market order and is executed at the next available price, which may be above or below the stop-loss level.</p><p><strong>Iceberg order:</strong></p><p>Iceberg orders refer to a type of order where a large volume of a trader is split into visible and hidden portions, much like how only a tiny part of an iceberg is visible above the water. The visible part is shown to other market participants, while the hidden part is kept private. This allows the trader to hide their true trading intentions and avoid revealing their entire trading volume at once. The hidden portion of the order is only released to the public domain after each execution of the order.</p><p><strong>Fill or Kill order (FOK):</strong></p><p>Fill or Kill (FOK) is an order where the trader instructs the broker to fill the entire order immediately or cancel. If the order cannot be filled completely, it gets cancelled, unlike other order types that can remain in the order book for some time. FOK orders are helpful for traders who need to execute a large order quickly or those who want to avoid partial fills. However, the disadvantage of FOK orders is that they may result in missed opportunities if the entire order cannot be filled.</p><p>In addition to the basic order types, there are more advanced orders, such as <strong>Gorilla orders, Pegged orders, and Discretionary orders</strong>. There are also other concepts in high-frequency trading, including <strong>dark pools</strong>. These topics will be covered in the following article.</p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae0f30ea752b" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/hft-concepts-order-book-and-order-types-ae0f30ea752b">HFT Concepts: Order book and Order types</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mean Reversion Strategy using Python]]></title>
            <link>https://wire.insiderfinance.io/mean-reversion-strategy-using-python-6dfed9ed988c?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dfed9ed988c</guid>
            <category><![CDATA[algotrading]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[trading-system]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 13:56:23 GMT</pubDate>
            <atom:updated>2023-02-09T15:51:33.973Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzLD7XZMlYK05ENB7efAWg.png" /></figure><p>Written by <strong>Shubham Soni</strong> (<a href="/service/mailto:associate.01@xumitcapital.com">associate.01@xumitcapital.com</a>)</p><h3>Introduction</h3><p>Mean reversion is a popular trading strategy used in the financial market to take advantage of the tendency of an asset’s price to move back to its mean or average price over time. This strategy uses statistical analysis and mathematical models to identify opportunities to buy low and sell high, thereby maximizing profits. Python, a powerful and versatile programming language, has become the go-to tool for data analysis and computational finance due to its simplicity, speed, and a rich library of modules and packages. In this article, we will explore how to implement a mean reversion trading strategy using Python, from data collection and analysis to backtesting and execution. Whether you’re a seasoned trader or just starting out, this guide will provide you with the knowledge and skills to build and refine your own mean reversion trading strategy in Python.</p><h3>What is Mean Reversion</h3><p>Mean reversion is a widely used trading strategy that is based on the assumption that the price of an asset will tend to move back towards its average price over time. This strategy involves buying an asset when its price is lower than its mean, and selling it when its price is higher. In this way, traders can take advantage of the market inefficiencies and generate profits. At its core, mean reversion traders look for strong price movements and then try to identify when those prices are likely to reverse. The way to apply this strategy in the market is to seek out extreme events and then bet that things will revert back to nearer the average.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AlKejKjYlIKyDbjO" /></figure><h3>Drawbacks of using Mean Reversion</h3><p>Main problems that traders face when using mean reversion strategy:</p><ol><li>If a stock is dropped for a major reason; such as a structural change or if there’s real game changing news, the chances of that stock snapping back quickly and giving you a profit is much smaller.</li><li>Momentum is the enemy of this strategy.</li><li>Strong price movements can go on for a very long time and a reversal may not occur for a long period</li><li>Instead of the price reversing and meeting the moving average again, often price just consolidates after a strong move and the moving catches up with the price</li></ol><h3>Designing the Strategy</h3><p>In order to design our trading strategy, we will consider 200 Days moving average as the guiding principle. If we take Bharti Airtel stock (NSE:BHARTIARTL) as a reference and look at its price action over the last 1 year, we see that whenever the stock price deviates from its long-term average value, sooner or later it reverts back to the long term mean value.</p><p>The graph below shows the mean reversion action. Here the blue line represents daily price action and orange line represents the 200 days moving average</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*KJQ6dDruHBmsUXB4" /></figure><p>Most retail traders/investors in India do not usually short a stock simply because they do not understand the complexities associated with short selling, hence our main focus while designing this trading strategy will be on buying low and selling high.</p><p>There are numerous other ways in which mean reversion theory could be applied in trading, either independently or in conjunction with other trading strategies however since the scope of this article is limited to the introduction of Mean reversion as a trading strategy, we will keep our strategy simple.</p><p>Let’s understand key terminologies that we will be using in the code before we start making our trading system:</p><ol><li>52 week low: lowest price a stock has traded at, in the past 52 weeks.</li><li>52 week high: The highest price a stock has traded at, in the past 52 weeks.</li><li>Diff: 52 week high — 52 week low</li><li>Distance: Closing Price — 200 MA value</li><li>200 Days Moving Average: A 200-day Moving Average (MA) is simply <strong>the average closing price of a stock over the last 200 days</strong>. They are used as trend indicators that reflect momentum in the price of the asset.</li></ol><p>Our system will generate a <strong>buy signal</strong> when all of the following conditions are satisfied:</p><ol><li>(52 week low + diff * 0.2) &lt; stock price &lt; (52 week low + diff * 0.8)</li></ol><p>When stocks trade closer to their 52w high/low price and their prices start going up or down closer to their extreme values, there is a possibility that some news is driving the change and the fluctuation in price is not random, hence we avoid any stock trading outside these ranges i.e. we only consider stocks whose current price action is inside of the purple lines.</p><p>2. Stock Price &lt; 200 days MA</p><p>This gives the stock a chance to correct itself, and revert to its mean value, which is higher than its current price.</p><p>3. Distance is in the top 5 percentile</p><p>This will make sure that the deviation from mean value is significant and the stock price is expected to rise significantly.</p><p>Whereas, a sell signal is generated if:</p><ol><li>Stoploss is hit: There is a possibility that after buying a stock, the prices of stock might fall, in order to take this into account, we set a stoploss (maximum loss we’re willing to take before selling).</li><li>Profit Cap is reached: If, as anticipated, the prices start to rise then we have to decide at what point we want to sell the asset to capture the profit before the prices fall again. (Helps us to keep greed levels in check).</li></ol><h3>Coding the Strategy</h3><h3>Data Sources</h3><ul><li>We get the NIFTY 50 universe data (tickers) from nifty’s own website.</li></ul><p>#NIFTY 50 Universe</p><pre>nifty_50_ticker_url = &#39;https://www1.nseindia.com/content/indices/ind_nifty50list.csv&#39;<br>nifty_50 = pd.read_csv(nifty_50_ticker_url)</pre><ul><li>Now that we have the tickers list available, we get the historical data for the tickers from a python library called <strong>yfinance.</strong></li></ul><pre>#Downloading historic data from yfinance<br>historic_price = yf.download((nifty_50.Symbol + &#39;.NS&#39;).to_list(), progress=True)[&#39;Adj Close&#39;]</pre><h3>Data Preparation</h3><ul><li>We have historical data of 50 stocks from NIFTY 50 available with us, using which we’ll calculate the moving average of all stocks.</li></ul><pre>#calculate 200 days moving average<br>moving_avg = historic_price.rolling(200).mean()</pre><ul><li>Now we create a python dictionary to store the updated datasets such them we can access them easily.</li></ul><pre>#Creating a dictionary of data with Ticker as the Key and merged df as value<br>final_data = {}<br>for ticker in nifty_50.Symbol:<br>    ticker = ticker + &#39;.NS&#39;<br>    merged_df = pd.merge(historic_price[ticker], moving_avg[ticker], left_index=True, right_index=True)<br>    merged_df.columns = [&#39;Adj Close&#39;, &#39;200MA&#39;]<br>    merged_df[&#39;distance&#39;] = merged_df[&#39;Adj Close&#39;] - merged_df[&#39;200MA&#39;]#((merged_df[&#39;Adj Close&#39;] - merged_df[&#39;200MA&#39;])*100)/merged_df[&#39;200MA&#39;]<br>    data_dict = {<br>        &#39;price_df&#39;: merged_df,<br>        &#39;52w_data&#39; : price_df.loc[ticker.split(&#39;.&#39;)[0]]<br>    }<br>    final_data[ticker] = data_dict</pre><h3>Main Algorithm</h3><p>Here we code the main algorithm using Python.</p><p>This piece of code</p><ul><li>creates additional columns in the data frame to store buy and sell data</li><li>Calculates max_price, and min_price of the past 52 weeks for each observation.</li><li>Generates buy signal when all the conditions are satisfied.</li><li>Generates sell signal when stop-loss is encountered.</li><li>Generates sell signal when Max profit cap is reached.</li></ul><pre>cum_pnl = 0<br>txns = []<br><br><br>#condition 1<br>#Adj Close value between 20-60%<br>for ticker in final_data:<br>    df = final_data[ticker][&#39;price_df&#39;]<br>    df = df.iloc[-1250:,:]<br>    df[&#39;52w_max&#39;] = np.nan<br>    df[&#39;52w_min&#39;] = np.nan<br>    df[&#39;diff&#39;] = np.nan<br>    df[&#39;top_5&#39;] = np.nan<br><br><br>    for i in range(len(df)):<br>        # slice the dataframe to get the last 250 rows<br>        sliced_df = df.iloc[max(0, i-250):i+1]<br>        # calculate the maximum and minimum price in the sliced dataframe<br>        max_price = sliced_df[&#39;Adj Close&#39;].max()<br>        min_price = sliced_df[&#39;Adj Close&#39;].min()<br>        diff = max_price - min_price<br>        # do something with the maximum and minimum price<br>        df.iloc[i,3] = max_price<br>        df.iloc[i,4] = min_price<br>        df.iloc[i,5] = diff<br>        df.iloc[i,6] = df.iloc[i,2] &lt; np.percentile(sliced_df.distance, 5)<br><br><br>    state = &#39;out&#39;  # state can be &#39;out&#39;, &#39;long&#39; or &#39;short&#39;<br>    profit = 0<br>    stop_loss = 0<br>   <br>    for index, row in df.iterrows():<br>    # check if the state is &#39;out&#39; and the current price goes below 200MA<br>        if state == &#39;out&#39; and ((row[&#39;Adj Close&#39;] &gt; (row[&#39;52w_min&#39;] + 0.2* row[&#39;diff&#39;])) &amp; (row[&#39;Adj Close&#39;] &lt; (row[&#39;52w_min&#39;] + 0.6*row[&#39;diff&#39;]))) &amp; (row[&#39;200MA&#39;] &gt; row[&#39;Adj Close&#39;]) &amp; (row[&#39;top_5&#39;]):<br>            state = &#39;long&#39;<br>            buy_price = row[&#39;Adj Close&#39;]<br>            stop_loss = buy_price * 0.9<br>            print(&#39;Bought {} on {} at {}&#39;.format(ticker, index, buy_price))<br>       <br>        # check if the state is &#39;long&#39; and the current price goes below stop loss<br>        if state == &#39;long&#39; and row[&#39;Adj Close&#39;] &lt; stop_loss:<br>            state = &#39;out&#39;<br>            sell_price = row[&#39;Adj Close&#39;]<br>            profit = sell_price - buy_price<br>            cum_pnl += profit<br>            txns.append([index, ticker, profit])<br>            print(&#39;Sold {} on {} at {} for a profit of {}&#39;.format(ticker, index, sell_price, profit))<br>       <br>        # check if the state is &#39;long&#39; and the profit is more than 20%<br>        if state == &#39;long&#39; and (row[&#39;Adj Close&#39;] - buy_price) / buy_price &gt; 0.2:<br>            state = &#39;out&#39;<br>            sell_price = row[&#39;Adj Close&#39;]<br>            profit = sell_price - buy_price<br>            cum_pnl += profit<br>            txns.append([index, ticker, profit])<br>            print(&#39;Sold {} on {} at {} for a profit of {}&#39;.format(ticker, index, sell_price, profit))<br>print(&#39;final profit/loss is rs: {}&#39;.format(cum_pnl))</pre><h3>Backtesting</h3><p>Now that we have designed and coded our strategy, we backtest it over the historical data. It is advised that you should test your strategy as back in time as possible because it exposes our strategy to various events which have happened in past decades, such as recessions, bear markets, bull markets, market crashes, etc. It makes your strategy more robust.</p><p>Since we have taken all the companies in present-day NIFTY 50 in our portfolio, it is not possible for us to back our data that deep therefore, we test our data on the last 5 years and take it as the benchmark to compare it with the past 1 year data.</p><p>It is important to note that how successful our strategy is also dependent upon the values of parameters that we set i.e. our risk-taking ability (stop-loss percentage) and how much we want the stock prices to rise before we sell them (profit target). Hence we take a combination of various stop-loss and profit-target values and backtest our data over those as well to find the most profitable combination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/0*BcjmPl78uO05TlJE" /></figure><p>Looking at the table above, we can see that the most profitable setup among all is where we take stop-loss to be 15% and profit-target to be 29%. It has generated a return of 18000 rs. in the time span of 5 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*7i_mu3bqiBqOpv5l" /></figure><p>It should also be noted that our strategy has not been very successful because it is a very simple strategy However when combined with other strategies, it might work well.</p><p>Presented below is the Cumulative Profit and Loss graph of our most successful strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/0*Y1XL5rE_U7_YTwcb" /></figure><p>When tested on 2022 data, our strategy performed poorly as it generated a return of rs 2128 which is not surprising considering what the state of the market was in the whole year 2022.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/0*hcueqqbwzjK0Hpl9" /></figure><h3>Conclusion</h3><p>One thing that has been observed about mean reversion is that a good mean reversion trade requires things to stay the same. When a stock drops 10 or 20 percent, there is usually a reason, and you can usually find out what it is. If it’s dropped for a major reason, such as a structural change, or if there’s real game-changing news, the chances of that stock snapping back quickly and giving you a profit are much smaller. When this happens, you get momentum, and this is obviously the enemy of a mean reversion strategy. But other times, a stock can drop sharply for less obvious reasons. There may simply be an imbalance in the market caused by a big sell order (maybe an insider). Or the stock may drop due to an overreaction to a short-term event (such as a terrorist threat, election result, or oil spill).</p><p>These are often the most opportune moments for mean reversion trades. We get a big move, but really, not an awful lot has changed. So mean reversion strategies require things to stay the same. You don’t want structural, intrinsic change when making a mean reversion trade, but you do want overreactions and illogical price movements. If you can find ways to quantify that, you will be on your way to developing a sound mean reversion trading strategy.</p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dfed9ed988c" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/mean-reversion-strategy-using-python-6dfed9ed988c">Mean Reversion Strategy using Python</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All about UK Innovator Visa]]></title>
            <link>https://xumitcapital.medium.com/all-about-uk-innovator-visa-b897baae6f84?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b897baae6f84</guid>
            <category><![CDATA[uk-innovator-visa]]></category>
            <category><![CDATA[golden-visa]]></category>
            <category><![CDATA[uk-visa]]></category>
            <category><![CDATA[investment-migration]]></category>
            <category><![CDATA[uk-visa-consultant]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 13:56:43 GMT</pubDate>
            <atom:updated>2023-01-31T13:56:43.827Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OT-rrahnYCHcNprZ7gBNFQ.jpeg" /></figure><p>Written by <strong>Dheer Ved</strong> (<a href="/service/mailto:dheer.ved@xumitcapital.com">dheer.ved@xumitcapital.com</a>)</p><p><strong>UK Innovator Visa</strong></p><p>In the last blog, we discussed<strong> </strong>an Active Investor Program and saw Canada Starta-Up Visa. So today, we are going to explore one more program of Investor Immigration Program under the Active Investor Program, the UK Innovator Visa.</p><p>The United Kingdom, also known as the UK, is a sovereign country in western Europe. It comprises four constituent countries: England, Scotland, Wales and Northern Ireland. The UK has a rich history and culture, with notable contributions to literature, art and science. The official language is English and the currency is the British Pound.</p><p>UK Innovator Visa is a type of visa available for those who wish to set up a business or invest in a business in the United Kingdom. The innovator visa is for people with experience who want to start their own business in the UK. The initial visa is granted for a period of 3 years which can be extended for more 3 years. The investor is applicable for permanent residency, Indefinite Leave to Remain (ILR) after 5 years of continuous residency and not being absent from the UK for more than 180 days in a 12-month period. Once the investor gets an ILR and holds it for 12 months, he/she can apply for citizenship.</p><p><strong>What is the UK Innovator Visa?</strong></p><p>On March 29 2019, the UK Home Office launched a new category known as “<strong>Innovator Visa” </strong>for experienced entrepreneurs seeking to establish a new business in the United Kingdom. This new category aims the businesses should be viable, scalable and innovative in order to drive economic growth in the UK. Your business or business idea must be approved by an Endorsing body in the UK and you meet other eligibility criteria.</p><p><strong>Eligibility Requirements</strong></p><p>In order to qualify for the Innovator Visa you must meet certain eligibility criteria such as</p><ul><li><strong>Have a business idea that is Innovative, Scalable and Viable:</strong> Your business idea must be:</li></ul><ol><li>Innovative: The applicants must have a business plan that is new and different from existing market</li><li>Scalable: A structured business plan that the business will grow in the future and create necessary jobs</li><li>Viable: The business idea must be realistic and the applicant has relevant skills and experience to run the business</li></ol><ul><li><strong>The business or business idea must be approved by an Endorsing Body:</strong></li></ul><p>Applicant must obtain an endorsement letter from an approved endorsement body. Endorsing bodies are responsible for assessing the eligibility of the start-ups. These bodies can be business incubators, investment funds, universities, colleges and other bodies authorised by UK Home Office. The endorsement letter must be issued not more than 90 days before you apply for UK Innovator Visa.</p><ul><li><strong>Investment Fund: </strong>You must have at least £50,000 in investment funds to apply for an innovator visa. You must prove where you got these funds and they must be legally sourced. You are allowed to make a joint investment with other Entrepreneurs but you cannot share the same investment. Each one of you is required to make a separate £50,000 investment. You do not need to invest any funds if:</li></ul><ol><li>Your business already exists in the UK and you are switching to an Innovator visa from another visa category</li><li>You have made innovations to the business and are already endorsed by the approved endorsing bodies</li></ol><ul><li><strong>Funds to support yourself: </strong>Fund of at least £1,270 is needed in your bank account for consecutive 28 days before you apply for an Innovator Visa.</li><li><strong>Knowledge of English: </strong>The applicant must usually prove their knowledge of English when they apply for UK Innovator Visa. The applicant’s must prove that they can write, speak, read and understand English to a level of B2 on the Common European Framework of Reference for Languages (CEFR) scale. This is considered an upper intermediate level which is equivalent to 5.5–6.5 on IELTS. They can prove this by the following:</li></ul><ol><li>Take a language test from an approved agency by passing SELT (Secure English Language Test)</li><li>Having a degree-level academic qualification that was taught in English at a University recognised in the UK</li><li>Having a GCSE, A Level, Scottish National Qualifications Level 4 or 5 or Scottish Higher or Advanced Higher in English</li><li>Having a degree level academic qualification which was taught in English</li></ol><p><strong>General Requirements for UK Innovator Visa</strong></p><ul><li>At least 18 years old</li><li>A valid business plan</li><li>An endorsement letter from the endorsing bodies</li><li>Being of good health</li><li>Clean criminal records</li></ul><p><strong>UK Innovator Visa Benefits</strong></p><ul><li>Path to Citizenship</li><li>Permits Dual Citizenship</li><li>Low/No Investment required</li><li>Short processing time</li><li>World-renowned schools and universities</li><li>Enhanced Education opportunities</li><li>Enhanced business access to large economies</li><li>Visa-free travel to 180+ countries</li><li>Live, work and study anywhere in the United Kingdom</li></ul><p><strong>Criteria for settlement of ILR</strong></p><p>To get a permanent residence or Indefinite Leave to Remain (ILR) after the 3rd year the applicant must fulfil <strong>2/7 </strong>requirements:</p><ul><li>Invested at least £50,000 in the business</li><li>Generated minimum annual revenue of £1 Million dollars</li><li>Generated minimum average revenue of £500,000 with at least £100,000 from overseas export</li><li>Has applied for Intellectual Property Rights (IPR) in the United Kingdom</li><li>Has created at least 10 full-time jobs for residents workers</li><li>Has created at least five jobs for UK citizens with a gross salary of £25,000 a year</li><li>You have at least doubled the numbers of customers in your business</li></ul><p>For the purpose of getting a Permanent Residency the applicant must:</p><ul><li>You have to spend at least 180 days in 12 month period in the UK</li><li>Demonstrate an active role in the day to day management of the business</li><li>Submit a report to the endorsing body to showcase the development of the business after 6, 12 and 24 months of the business being operational.</li></ul><p><strong>UK Innovator Visa Application Fees:</strong></p><p><strong>Application Fee: </strong>The main applicant processing fee is £1,036 and</p><p><strong>Include your Spouse/Children Fee: </strong>A processing fee of £1,036 per person</p><p><strong>Application Timeline</strong></p><ul><li><strong>Month 1: </strong>Apply for a visa and collect it. Enter the UK and initiate the business venture</li><li><strong>Year 1–3: </strong>No more than 180 absent from the UK in each calendar year to be eligible for PR</li><li><strong>Year 5: </strong>PR granted. No more than 90 days absent from the county</li><li><strong>Year 6: </strong>UK Citizenship is granted provided no more than 450 days absent from the UK and more than 90 days in the last year</li></ul><p><strong>What you can Do and Cannot Do on the Innovator Visa</strong></p><p>Can Do:</p><ul><li>Can set up several businesses</li><li>Work for your business</li><li>Bring your spouse and children as dependents</li><li>Travel abroad and return back to the UK</li><li>Can apply to settle permanently in the UK also known as ILR if you have been in the UK for 3 years</li><li>Extend your visa multiple times</li></ul><p>Cannot Do:</p><ul><li>You cannot work outside your business</li><li>Work as a professional sportsperson or a sports coach</li><li>Apply for public funds</li></ul><p><strong>Why choose the United Kingdom?</strong></p><ul><li>Economic heart of the world</li><li>Education: UK has one of the best educational institutions from pre-school to university</li><li>Ease of travel and mobility: UK is one of the best countries for travel and mobility in this time of increased globalisation</li><li>Healthcare: The UK is well known for its National Health Service, which provides excellent free health care. UK boasts some of the best medical facilities in the world</li><li>Direct International flights connections to major global cities</li><li>Attractive tax regime for High Net Worth Individuals</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b897baae6f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced backtesting on NIFTY using Walk-forward Analysis in Python]]></title>
            <link>https://wire.insiderfinance.io/advanced-backtesting-on-nifty-using-walk-forward-analysis-in-python-90da743fcf78?source=rss-c3ba94f4021d------2</link>
            <guid isPermaLink="false">https://medium.com/p/90da743fcf78</guid>
            <category><![CDATA[nifty]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[backtesting]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[vectorbt]]></category>
            <dc:creator><![CDATA[Xumit Capital]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 04:47:55 GMT</pubDate>
            <atom:updated>2023-01-25T14:01:53.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPM6Ev7G7eGRBZzpMEuTCg.png" /></figure><p>Written by <strong>Kaushik Sanghani</strong> (<a href="/service/mailto:kaushik.sanghani@xumitcapital.com">kaushik.sanghani@xumitcapital.com</a>)</p><p>In this article, we will delve deeper into the concept of walk-forward analysis and its practical implementation. We will take the example of an exponential moving crossover system applied to NIFTY hourly data. Using Python, we will perform backtesting, optimization, and walk-forward analysis to evaluate the performance of the strategy. We will also discuss how to interpret the results and make decisions based on the findings. This will help readers understand the importance and usefulness of walk-forward analysis in evaluating trading strategies and models.</p><p>Before delving into the concept of walk-forward analysis, it’s important to understand why optimization is crucial in trading. Optimization is the process of finding the best combination of parameters for a trading strategy to ensure maximum profitability and minimum risk. For example, we may know that a combination of (20,50) exponential moving average crossover system works well in the live market and we are making consistent money by trading this strategy. But, there are thousands of other possible combinations we could have chosen, like (21,43) for example. To find the best combination that has worked out in historical data, we optimize our strategy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/0*udSEzf8VgzV9RcVO" /></figure><p>However, using historical data to optimize a strategy has a pitfall called overfitting. It happens when a strategy is fine-tuned too much to the historical data, and it becomes too specific to that data. As a result, it may not work in the future, as we don’t have any evidence that this combination will work in the future or even if it works, we don’t have any test data to check this hypothesis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*iCx6-WRtRylNuk_-" /></figure><p>To overcome this problem, we use some data for testing our trading strategy as out-of-sample data. We optimize the strategy based on in-sample data and find the suitable parameters for the strategy and check the validity of our strategy on out-of-sample data. This method works better than the previous one, but financial markets, particularly equity markets, are so dynamic that it may not be suitable to use 10–20 years back data for optimization purposes. Therefore, we need a dynamic technique to optimize our trading strategy, and this is where walk-forward analysis comes into play.</p><h3>Walk-forward analysis:</h3><p>Walk-forward analysis is a technique used to evaluate the performance of a trading strategy or model by simulating the process of repeatedly rolling forward the in-sample data and using the out-of-sample data to test the strategy. The goal is to avoid overfitting and to better assess the strategy’s ability to generalize to new data.</p><p>The process of walk-forward analysis begins by dividing the data into two parts: in-sample data and out-of-sample data. The in-sample data is used to train and optimize the strategy, while the out-of-sample data is used to test the strategy’s performance. The in-sample and out-of-sample data are typically divided using a rolling window, which moves forward in time as the analysis progresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*VViShvdNXOXrnbt5" /></figure><p>Once the in-sample data has been used to train and optimize the strategy, the out-of-sample data is used to test the performance of the strategy. The process is then repeated by moving the rolling window forward in time and using the new out-of-sample data to test the strategy’s performance. This process is repeated multiple times, allowing the strategy to be tested on different periods of data.</p><p>The key advantage of walk-forward analysis is that it allows for a more realistic evaluation of the strategy’s performance. By simulating the process of repeatedly rolling forward the data and testing the strategy on new out-of-sample data, walk-forward analysis helps to avoid overfitting and to better assess the strategy’s ability to generalize to new data.</p><h3>Backtesting in python</h3><p>Now let’s understand walk-forward analysis with the use of python. We have taken hourly data from <strong>2018–04–11 11:15:00 to 2022–11–29 15:30:00. </strong>Which are 8000 hourly data points. We will understand this analysis with the use of EMA crossover strategy. We will use <a href="https://vectorbt.dev/"><strong>vectorbt</strong></a><strong> </strong>library for all the background calculations. See the chart to gain some context around the NIFTY 50 price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*sLRhAzMgFx890qcF" /></figure><p>We will begin by demonstrating how to use vectorbt, a powerful backtesting library, to perform backtesting on a random parameter of exponential moving averages (EMAs) with values (10, 20) and check the results. The code provided here can perform this task, and below it, the results of this strategy are compared against a buy and hold strategy as a benchmark. Vectorbt is particularly useful in this context because of its speed and its ability to provide a detailed report of trades and other parameters. It’s recommended to refer to the vectorbt documentation for more information on its capabilities and how to use it effectively.</p><pre>#importing libraries<br>import pandas as pd  <br>import numpy as np <br>import pickle<br>from datetime import datetime <br>import vectorbt as vbt<br><br>#reading the datafile<br>df = pd.read_pickle(r&#39;D://XumitCapital//Trading Strategy Backtesting Framework For Blog//nifty_1m_cleaned_data.pickle&#39;)<br><br>#Data pre-prcocessing<br>df = df.reset_index()<br>df[&#39;index&#39;] = df[&#39;index&#39;] - pd.Timedelta(minutes=1)<br># Assuming you have a dataframe named df with a DatetimeIndex<br>df = df.set_index(&#39;index&#39;)<br>df = df.resample(&#39;60min&#39;, offset=&#39;15min&#39;).agg({&#39;Open&#39;: &#39;first&#39;, &#39;High&#39;: &#39;max&#39;, &#39;Low&#39;: &#39;min&#39;, &#39;Close&#39;: &#39;last&#39;})<br>df = df.dropna()<br>df = df.tail(8000)<br><br>#Here we are taking the recent last 8000 hours data <br>df[&#39;Close&#39;] = np.float64(df[&#39;Close&#39;])<br>test_df = df.tail(1000) #1000 points for test purpose<br>train_df = df.head(7000) #7000 points for train purpose<br><br>import plotly.express as px<br><br>fig = px.line(df, x=df.index, y=&#39;Close&#39;, title=&#39;NIFTY hourly chart&#39;)<br>fig.show()<br><br>## Simple Just strategy making with random parameters<br><br>#calculating fast ema and slow ema<br>fast_ema = vbt.MA.run(close=train_df[&#39;Close&#39;], window=10, ewm=True)<br>slow_ema = vbt.MA.run(close=train_df[&#39;Close&#39;], window=20, ewm=True)<br><br># Generate crossover signals<br>ema_entries = fast_ema.ma_crossed_above(slow_ema)<br>ema_exits = fast_ema.ma_crossed_below(slow_ema)<br><br>#creating portfolio<br>ema_pf = vbt.Portfolio.from_signals(train_df[&#39;Close&#39;], ema_entries, ema_exits,freq=&#39;60m&#39;)<br><br>print(pd.DataFrame(ema_pf.stats(), columns=  [&#39;Results&#39;]))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/0*MOYflSudS_dnttmg" /></figure><p>Now, we will optimize our strategy by adjusting the parameters of the fast EMA and slow EMA on the first 7000 data points. By doing this, we will find the best parameters and test them on 1000 out-of-sample data points. It is important to note that the process of selecting parameters and analyzing the results is a detailed topic that could require an entire article on its own. For now, let’s focus on the practical implementation of this process using Python. The code for this task can be found in the provided notebook, and it’s recommended to explore the code to understand the background calculations. Additionally, a heatmap of the results of different parameter combinations is provided below the code for further analysis.</p><pre>## Optimization with min Window 10 and Max Window as 50<br><br>min_window = 10<br>max_window = 50<br><br>perf_metrics = [&#39;total_return&#39;, &#39;positions.win_rate&#39;, &#39;positions.expectancy&#39;, &#39;max_drawdown&#39;]<br>perf_metric_names = [&#39;Total return&#39;, &#39;Win rate&#39;, &#39;Expectancy&#39;, &#39;Max drawdown&#39;]<br><br># Pre-calculate running windows on data with time buffer<br>fast_ma, slow_ma = vbt.MA.run_combs(<br>    train_df[&#39;Close&#39;], np.arange(min_window, max_window+1), <br>    r=2, short_names=[&#39;fast_ma&#39;, &#39;slow_ma&#39;],ewm = True)<br><br>dmac_entries = fast_ma.ma_crossed_above(slow_ma)<br>dmac_exits = fast_ma.ma_crossed_below(slow_ma)<br><br># Build portfolio<br>dmac_pf = vbt.Portfolio.from_signals(train_df[&#39;Close&#39;], dmac_entries, dmac_exits,freq=&#39;60m&#39;)<br><br><br># Calculate performance of each window combination<br>metric = &#39;total_return&#39;<br><br>dmac_perf = dmac_pf.deep_getattr(metric)<br><br>print(dmac_perf.shape)<br><br>print(dmac_perf.idxmax())<br><br>print(dmac_perf.max())<br><br>##For plotting<br><br># Convert this array into a matrix of shape (99, 99): 99 fast windows x 99 slow windows<br>dmac_perf_matrix = dmac_perf.vbt.unstack_to_df(symmetric=True, <br>    index_levels=&#39;fast_ma_window&#39;, column_levels=&#39;slow_ma_window&#39;)<br><br><br>dmac_perf_matrix.vbt.heatmap(<br>    xaxis_title=&#39;Slow window&#39;, <br>    yaxis_title=&#39;Fast window&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*-7eL2OUHll6rsAf9" /></figure><p>After the optimization process, we found that the combination of (10, 15) gave the best results on in-sample backtesting. Now, we will use this parameter combination to test it on the out-of-sample data points. The code and results for this are provided below. It’s important to note that results on out-of-sample data will give us a more accurate idea of how the strategy will perform in the future market conditions.</p><pre>#calculating fast ema and slow ema<br>fast_ema = vbt.MA.run(close=test_df[&#39;Close&#39;], window=10, ewm=True)<br>slow_ema = vbt.MA.run(close=test_df[&#39;Close&#39;], window=15, ewm=True)<br><br># Generate crossover signals<br>ema_entries = fast_ema.ma_crossed_above(slow_ema)<br>ema_exits = fast_ema.ma_crossed_below(slow_ema)<br><br>#creating portfolio<br>ema_pf = vbt.Portfolio.from_signals(test_df[&#39;Close&#39;], ema_entries, ema_exits,freq=&#39;60m&#39;)<br><br>#printing the stats<br>print(ema_pf.stats())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/0*ov13twMMxzIevvmP" /></figure><p>Now, we will move on to the implementation of walk-forward analysis. In this process, we are using 8000 data points and creating 32 different windows, each containing 250 data points. From these windows, we take 200 as the in-sample data to run optimization on and test the best parameters on the out-of-sample data. It’s important to note that the best parameter combination is not only the one that gives the best returns but also the one that is most suitable for the market conditions. Below, you will find some visualizations and code to better understand this process.</p><pre># Creating the custom fixation for the  code<br>split_kwargs = dict(n=32,<br>                   window_len = 250,<br>                   set_lens = (50,),<br>                   left_to_right = False)<br><br>pf_kwargs = dict(direction = &#39;both&#39;,<br>                freq = &#39;60m&#39;)<br><br># Here n = 32 means we are dividing our total datapoints into 32 different windows, with each window lenght 250 from which<br># 200 are insample data and 50 are out of the sample data<br><br><br>#we are considering windows from (10,50)<br>windows = np.arange(10,50)<br><br>#creating rolling split for each window<br>def roll_in_and_out_samples(price, **kwargs):<br>    return price.vbt.rolling_split(**kwargs)<br><br>#plotting each rolling split with in-sample and out-sample<br>roll_in_and_out_samples(df[&#39;Close&#39;], **split_kwargs, plot=True, trace_names=[&#39;in-sample&#39;, &#39;out-sample&#39;])<br><br>#saperating in-sample and out-sample and also indices in different dataframe<br>(in_price, in_indexes), (out_price, out_indexes) = roll_in_and_out_samples(df[&#39;Close&#39;], **split_kwargs)<br><br>print(in_price.shape, len(in_indexes))  # in-sample<br>print(out_price.shape, len(out_indexes))  # out-sample<br><br><br>#creating the bench-mark or say holding from the start of the window till end of the in-sample datapoints<br>#0-200<br>in_hold_sharpe = simulate_holding(in_price, **pf_kwargs)<br>print(in_hold_sharpe)<br><br><br>#creating portfolio and also returning the total returns<br>#here we are considering the exponential moving averages<br>def simulate_all_params(price, windows, **kwargs):<br>    #to create dataframe for different combinations from our window (10,50)<br>    fast_ma, slow_ma = vbt.MA.run_combs(price, windows, r=2, short_names=[&#39;fast&#39;, &#39;slow&#39;],ewm=True)<br>    #creating entries and exits while also creating portfolio and returning the total returns for comparision<br>    entries = fast_ma.ma_crossed_above(slow_ma)<br>    exits = fast_ma.ma_crossed_below(slow_ma)<br>    pf = vbt.Portfolio.from_signals(price, entries, exits, **kwargs)<br>    return pf.total_return()<br><br># Simulate all params for in-sample ranges<br>in_sharpe = simulate_all_params(in_price, windows, **pf_kwargs)<br><br>print(in_sharpe)<br><br>#getting the best index from each period<br>def get_best_index(performance, higher_better=True):<br>    if higher_better:<br>        return performance[performance.groupby(&#39;split_idx&#39;).idxmax()].index<br>    return performance[performance.groupby(&#39;split_idx&#39;).idxmin()].index<br><br>in_best_index = get_best_index(in_sharpe)<br>print(in_best_index)<br><br>#getting the best params function for in-sample<br>def get_best_params(best_index, level_name):<br>    return best_index.get_level_values(level_name).to_numpy()<br><br><br>in_best_fast_windows = get_best_params(in_best_index, &#39;fast_window&#39;)<br>in_best_slow_windows = get_best_params(in_best_index, &#39;slow_window&#39;)<br>in_best_window_pairs = np.array(list(zip(in_best_fast_windows, in_best_slow_windows)))<br><br>print(in_best_window_pairs)<br><br><br>#plotting the best-params<br>pd.DataFrame(in_best_window_pairs, columns=[&#39;fast_window&#39;, &#39;slow_window&#39;]).vbt.plot()<br><br><br><br>#holding returns out of the sample data<br>out_hold_sharpe = simulate_holding(out_price, **pf_kwargs)<br>print(out_hold_sharpe)<br><br># Simulate all params for out-sample ranges<br>out_sharpe = simulate_all_params(out_price, windows, **pf_kwargs)<br><br>print(out_sharpe)<br><br>#same we have done in in-sample<br>def simulate_best_params(price, best_fast_windows, best_slow_windows, **kwargs):<br>    fast_ma = vbt.MA.run(price, window=best_fast_windows, per_column=True)<br>    slow_ma = vbt.MA.run(price, window=best_slow_windows, per_column=True)<br>    entries = fast_ma.ma_crossed_above(slow_ma)<br>    exits = fast_ma.ma_crossed_below(slow_ma)<br>    pf = vbt.Portfolio.from_signals(price, entries, exits, **kwargs)<br>    return pf.total_return()<br><br><br># Use best params from in-sample ranges and simulate them for out-sample ranges<br>out_test_sharpe = simulate_best_params(out_price, in_best_fast_windows, in_best_slow_windows, **pf_kwargs)<br><br>print(out_test_sharpe)<br>#Plotting <br>cv_results_df = pd.DataFrame({<br>    &#39;in_sample_hold&#39;: in_hold_sharpe.values,<br>    &#39;in_sample_median&#39;: in_sharpe.groupby(&#39;split_idx&#39;).median().values,<br>    &#39;in_sample_best&#39;: in_sharpe[in_best_index].values,<br>    &#39;out_sample_hold&#39;: out_hold_sharpe.values,<br>    &#39;out_sample_median&#39;: out_sharpe.groupby(&#39;split_idx&#39;).median().values,<br>    &#39;out_sample_test&#39;: out_test_sharpe.values<br>})<br><br><br>color_schema = vbt.settings[&#39;plotting&#39;][&#39;color_schema&#39;]<br><br>cv_results_df.vbt.plot(<br>    trace_kwargs=[<br>        dict(line_color=color_schema[&#39;blue&#39;]),<br>        dict(line_color=color_schema[&#39;blue&#39;], line_dash=&#39;dash&#39;),<br>        dict(line_color=color_schema[&#39;blue&#39;], line_dash=&#39;dot&#39;),<br>        dict(line_color=color_schema[&#39;orange&#39;]),<br>        dict(line_color=color_schema[&#39;orange&#39;], line_dash=&#39;dash&#39;),<br>        dict(line_color=color_schema[&#39;orange&#39;], line_dash=&#39;dot&#39;)<br>    ]<br>)</pre><p>Different windows and their in-sample and out-sample visulization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jk7mUyyokd-y77re" /></figure><p>Optimization results on on each window from in-sample data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*gkVm-AARApZ55Zrk" /></figure><p>Results from out-sample backtesting on each window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/0*bY-NqKtDozPnvDu7" /></figure><p>Visualization of mean and median parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/0*4Zztw2RiczEvKf-X" /></figure><p>Visit our website at: <a href="https://xumitcapital.com/">xumitcapital.com</a></p><h4>A Message from InsiderFinance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*X3mrYDdx2klkVa7Rv5AmWg.png" /></figure><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a></li><li>📚 Take our <a href="https://learn.insiderfinance.io/p/mastering-the-flow">FREE Masterclass</a></li><li><strong>📈 Discover </strong><a href="https://insiderfinance.io/?utm_source=wire&amp;utm_medium=message"><strong>Powerful Trading Tools</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90da743fcf78" width="1" height="1" alt=""><hr><p><a href="https://wire.insiderfinance.io/advanced-backtesting-on-nifty-using-walk-forward-analysis-in-python-90da743fcf78">Advanced backtesting on NIFTY using Walk-forward Analysis in Python</a> was originally published in <a href="https://wire.insiderfinance.io/">InsiderFinance Wire</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>