<rss version="2.0">
  <channel>
    <title>CafeIO</title>
    <link>https://akarsh.micro.blog/</link>
    <description></description>
    
    <language>en</language>
    
    <lastBuildDate>Sun, 09 Apr 2023 09:00:00 +0530</lastBuildDate>
    <item>
      <title>Deep Dive into Architecture Patterns, Part 2</title>
      <link>https://akarsh.micro.blog/2023/04/09/deep-dive-into.html</link>
      <pubDate>Sun, 09 Apr 2023 09:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/04/09/deep-dive-into.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Deep Dive into Architecture Patterns. This Post is focused on understanding different technology stacks and their usage.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This might very well be tangential to the idea of patterns, but I feel it is significant to be aware of the different technology stacks and from the core idea of patterns.&lt;/p&gt;
&lt;p&gt;A technology stack refers to a set of technologies that are used together to create a software application or system. Different technology stacks are typically named after the key technologies that they include, such as the operating system, programming language, web server, and database.&lt;/p&gt;
&lt;h2 id=&#34;tech-stack-management&#34;&gt;Tech Stack Management&lt;/h2&gt;
&lt;h3 id=&#34;some-popular-technology-stacks&#34;&gt;Some Popular Technology Stacks&lt;/h3&gt;
&lt;p&gt;Here’s a high-level view on some popular technology choices that we are currently presented with.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;LAMP Stack :&lt;/strong&gt; &lt;em&gt;Linux&lt;/em&gt;: LAMP stack is based on the Linux operating system, which is an open-source operating system that is widely used for servers and desktops. &lt;em&gt;Apache&lt;/em&gt;: Apache is a free, open-source web server software that is used to deliver web content over the internet. &lt;em&gt;MySQL&lt;/em&gt;: MySQL is a popular open-source relational database management system (RDBMS) that is used to store and retrieve data. &lt;em&gt;PHP&lt;/em&gt;: PHP is a popular open-source server-side scripting language that is used to create dynamic web pages and web applications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MEAN Stack :&lt;/strong&gt; &lt;em&gt;MongoDB&lt;/em&gt;: MongoDB is a NoSQL document-oriented database that is used to store data in a flexible, JSON-like format. &lt;em&gt;Express.js&lt;/em&gt;: Express.js is a lightweight web application framework that is used to build web applications and APIs in Node.js. &lt;em&gt;AngularJS&lt;/em&gt;: AngularJS is a JavaScript-based front-end web application framework that is used to build dynamic and responsive user interfaces. &lt;em&gt;Node.js&lt;/em&gt;: Node.js is a server-side JavaScript runtime environment that is used to run JavaScript on the server-side.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MERN Stack :&lt;/strong&gt; &lt;em&gt;MongoDB&lt;/em&gt;: Same as MEAN stack, MongoDB is used as the database in MERN stack.&lt;em&gt;Express.js:&lt;/em&gt; Same as MEAN stack, Express.js is used as the server-side framework.&lt;em&gt;React.js&lt;/em&gt;: React.js is a popular front-end JavaScript library that is used to build user interfaces.&lt;em&gt;Node.js&lt;/em&gt;: Same as MEAN stack, Node.js is used as the server-side runtime environment.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MERN with Next.js Stack :&lt;/strong&gt; &lt;em&gt;MongoDB&lt;/em&gt;: Same as MERN stack, MongoDB is used as the database in this stack.&lt;em&gt;Express.js&lt;/em&gt;: Same as MERN stack, Express.js is used as the server-side framework.&lt;em&gt;React.js&lt;/em&gt;: Same as MERN stack, React.js is used as the front-end JavaScript library. &lt;em&gt;Node.js&lt;/em&gt;: Same as the MERN stack, Node.js is used as the server-side runtime environment.&lt;em&gt;Next.js:&lt;/em&gt; Next.js is a popular React-based framework that is used to build server-side rendered web applications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;.NET Stack :&lt;/strong&gt; &lt;em&gt;.NET Framework or .NET Core:&lt;/em&gt; .NET Framework is a free, open-source development platform for building Windows-based desktop and web applications. .NET Core is a newer version of the framework that is designed to be cross-platform.&lt;em&gt;C#:&lt;/em&gt; C# is a modern, object-oriented programming language that is used to develop applications on the .NET platform. &lt;em&gt;Visual Studio IDE:&lt;/em&gt; Visual Studio is an integrated development environment (IDE) that is used to develop, test, and deploy .NET applications.&lt;em&gt;SQL Server:&lt;/em&gt; SQL Server is a popular relational database management system (RDBMS) developed by Microsoft.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python Flask Stack :&lt;/strong&gt; Python: &lt;em&gt;Python&lt;/em&gt; is a high-level programming language that is used for web development, data analysis, and artificial intelligence. &lt;em&gt;Flask&lt;/em&gt;: Flask is a lightweight web application framework that is used to build web applications and APIs in Python. &lt;em&gt;PostgreSQL&lt;/em&gt;: PostgreSQL is a popular open-source relational database management system (RDBMS) that is used to store and retrieve data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Django Stack :&lt;/strong&gt; &lt;em&gt;Django&lt;/em&gt;: Django is a high-level Python web framework that is used to build web applications and APIs quickly and efficiently. &lt;em&gt;PostgreSQL&lt;/em&gt;: PostgreSQL is a popular open-source relational database management system (RDBMS) that is used to store and retrieve data. &lt;em&gt;Nginx&lt;/em&gt;: Nginx is a high-performance web server that is used to deliver web content over the internet.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Java Stack :&lt;/strong&gt; &lt;em&gt;Java&lt;/em&gt;: Java is a widely used programming language that is used to develop a wide range of applications, from desktop and mobile apps to web and enterprise applications.&lt;em&gt;Spring Framework&lt;/em&gt;: Spring is a popular open-source framework that is used to build web applications and enterprise-level software systems. &lt;em&gt;Hibernate&lt;/em&gt;: Hibernate is an object-relational mapping (ORM) framework that is used to manage database operations in Java-based applications. &lt;em&gt;Apache Tomcat&lt;/em&gt;: Apache Tomcat is a popular open-source web server and servlet container that is used to deploy and run Java-based web applications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serverless Stack :&lt;/strong&gt; &lt;em&gt;AWS Lambda or Azure Functions&lt;/em&gt;: Serverless stack is a technology stack that doesn&amp;rsquo;t require any server management or infrastructure. AWS Lambda and Azure Functions are popular serverless computing services offered by Amazon Web Services and Microsoft Azure, respectively._ Amazon S3 or Azure Blob Storage_: Amazon S3 and Azure Blob Storage are popular object storage services that can be used to store and retrieve data in a serverless environment._ Amazon API Gateway or Azure API Management:_ Amazon API Gateway and Azure API Management are popular API gateway services that can be used to manage and secure APIs in a serverless environment.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;factors-to-keep-in-mind-before-selecting-tech-stack&#34;&gt;Factors to keep in mind before selecting Tech Stack&lt;/h3&gt;
&lt;p&gt;When selecting a technology stack, there are several factors that need to be considered. Here are some key factors that should be kept in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Project requirements&lt;/strong&gt;&lt;/em&gt;: Consider the requirements of the project, including the type of application, the features it needs to support, and the expected usage. The technology stack should be able to support these requirements and provide the necessary functionality.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;/em&gt;: Consider the scalability requirements of the project, including the expected growth of the application over time. The technology stack should be able to scale to meet the demands of the application without sacrificing performance.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/em&gt;: Consider the budget for the project and the cost of the technology stack. Some technology stacks may require more expensive hardware or licensing fees, while others may be more cost-effective.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Development resources&lt;/strong&gt;&lt;/em&gt;: Consider the skillset and experience of the development team. The technology stack should align with the team&amp;rsquo;s expertise to ensure efficient development and maintenance.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Community support&lt;/strong&gt;&lt;/em&gt;: Consider the level of community support for the technology stack. A strong community can provide valuable resources, tools, and support for developers, as well as ensure the longevity and sustainability of the technology.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Integration&lt;/strong&gt;&lt;/em&gt;: Consider the integration requirements of the project. The technology stack should be able to integrate with other systems and tools as needed.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Security&lt;/strong&gt;&lt;/em&gt;: Consider the security requirements of the project, including data privacy, regulatory compliance, and potential vulnerabilities. The technology stack should provide robust security features and be regularly updated to address new security threats.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Overall, it is important to carefully evaluate the specific requirements and constraints of the project to select the most appropriate technology stack.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Some popular technology stacks mentioned are LAMP, MEAN, MERN, MERN with Next.js, .NET, Python Flask, Django, Java, and Serverless stack. Factors to consider when choosing a technology stack include project requirements, scalability, cost, and development resources.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;deployment-patterns&#34;&gt;Deployment Patterns&lt;/h2&gt;
&lt;h3 id=&#34;deployment-approaches&#34;&gt;Deployment Approaches&lt;/h3&gt;
&lt;p&gt;The deployment options available for a technology stack depend on the specific components of the stack and the requirements of the project. However, here are some common deployment options that are available for most technology stacks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;On-premises deployment:&lt;/strong&gt; This is a traditional deployment method where the application is deployed on hardware that is located on-site or within the organization&amp;rsquo;s premises. This deployment method requires the organization to manage the hardware, software, and security of the application.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Virtual machines (VM) deployment:&lt;/strong&gt; In this deployment method, the application is deployed on a virtual machine that is hosted on a public cloud or private infrastructure. This method provides greater flexibility than on-premises deployment and allows the organization to scale resources up or down as needed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Container deployment:&lt;/strong&gt; Container deployment involves deploying the application in a container, such as Docker, which encapsulates the application and its dependencies. This method provides greater portability, as the container can be deployed on any infrastructure that supports the container runtime.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serverless deployment:&lt;/strong&gt; In a serverless deployment, the application is deployed as a set of functions that run in a serverless computing environment, such as AWS Lambda or Azure Functions. This deployment method eliminates the need to manage the underlying infrastructure and provides greater scalability.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Platform as a Service (PaaS) deployment:&lt;/strong&gt; PaaS deployment involves deploying the application on a cloud-based platform, such as Google App Engine, Heroku, or Microsoft Azure App Service. The platform manages the underlying infrastructure and provides developers with a pre-configured environment for deploying and running their applications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Infrastructure as a Service (IaaS) deployment:&lt;/strong&gt; IaaS deployment involves deploying the application on a cloud-based infrastructure, such as Amazon Web Services (AWS) or Microsoft Azure. This deployment method provides organizations with greater control over the underlying infrastructure and allows them to customize the environment to meet their specific requirements.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;factors-influencing-deployment-strategies&#34;&gt;Factors Influencing Deployment Strategies&lt;/h3&gt;
&lt;p&gt;When selecting a deployment method for a technology stack, there are several factors that should be considered. Here are some key choices that should be made:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;/em&gt;: Consider the expected traffic and usage of the application. If the application is expected to experience high levels of traffic or usage, a scalable deployment method such as serverless or container deployment may be more appropriate.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/em&gt;: Consider the budget for the project and the cost of the deployment method. For example, on-premises deployment may be more cost-effective for small projects, while cloud-based deployment may be more cost-effective for larger projects.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;&lt;/em&gt;: Consider the level of flexibility required for the project. For example, if the application needs to be deployed in different environments, a container or serverless deployment may be more appropriate.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Maintenance&lt;/strong&gt;&lt;/em&gt;: Consider the level of maintenance required for the deployment method. For example, on-premises deployment may require more maintenance than cloud-based deployment, which is managed by the cloud provider.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Security&lt;/strong&gt;&lt;/em&gt;: Consider the security requirements for the project. For example, if the application handles sensitive data, a cloud-based deployment method may require additional security measures to ensure the data is protected.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Integration&lt;/strong&gt;&lt;/em&gt;: Consider the integration requirements for the project. For example, if the application needs to integrate with other systems, a platform as a service (PaaS) deployment method may be more appropriate, as it provides pre-configured environments for deploying and running applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Overall, it is important to carefully evaluate the specific requirements and constraints of the project to select the most appropriate deployment method for the technology stack.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The section discusses different deployment approaches available for technology stacks, including on-premises, virtual machines, container, serverless, PaaS, and IaaS deployment. It also highlights the factors that should be considered when selecting a deployment method, such as scalability, cost, flexibility, maintenance, security, and integration requirements. The selection of the deployment method should depend on the specific requirements and constraints of the project.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;In summary, we discussed the popular technology stacks such as LAMP, MEAN, MERN, MERN with Next.js, .NET, Python Flask, Django, Java, and Serverless stack. When choosing a technology stack, it is important to consider project requirements, scalability, cost, and development resources.&lt;/p&gt;
&lt;p&gt;Deployment approaches are also important when it comes to technology stacks. There are several deployment methods available, including on-premises, virtual machines, container, serverless, PaaS, and IaaS deployment. Each deployment method has its own advantages and disadvantages. For example, serverless deployment eliminates the need to manage underlying infrastructure and provides greater scalability. The selection of the deployment method should depend on the specific requirements and constraints of the project. When selecting a deployment method, scalability, cost, flexibility, maintenance, security, and integration requirements should be considered.&lt;/p&gt;
&lt;p&gt;In summary, the selection of the technology stack and deployment method should depend on the specific requirements and constraints of the project. It is important to carefully evaluate the project&amp;rsquo;s needs and select the appropriate technology stack and deployment method. By doing so, you can ensure that the project is successful and meets its goals&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Unlocking The Secrets of Algo Trading: Learn How to Use Python for Getting Data and Strategies…!!</title>
      <link>https://akarsh.micro.blog/2023/04/04/unlocking-the-secrets.html</link>
      <pubDate>Tue, 04 Apr 2023 09:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/04/04/unlocking-the-secrets.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;With Python&amp;rsquo;s limitless libraries and tools, we can build a robust foundation to predict market trends, analyse financial data, and create advanced financial models.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Hey there! In this post, I&amp;rsquo;m going to talk about setting things up for algo trading. &lt;a href=&#34;https://www.youtube.com/watch?v=uvby-fWe8Ts&#34;&gt;In my previous video&lt;/a&gt;, I covered many aspects of algo trading, including technology, tools, markets, and data. I will build on top of that in this blog post. I would like to point out that this post is accompanied by a video which I shared before.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can watch the supplementary video and &lt;a href=&#34;https://www.youtube.com/watch?v=vBBM_2fu15U&#34;&gt;Follow Along the Video&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;hardware--software-setup&#34;&gt;Hardware &amp;amp; Software Setup&lt;/h2&gt;
&lt;p&gt;You don&amp;rsquo;t need a fancy computer for this, anything online or a simple computer will work.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;8 GB of RAM with an i5 Processor. Something lower might work too.&lt;/li&gt;
&lt;li&gt;Apple Silicon (m1/m2) is great too if you can install the required dependencies. There are few libraries which do not work on it.&lt;/li&gt;
&lt;li&gt;Anaconda Environment with Python 3.7. Though higher version of python can be taken, however I have found this to be the common denominator which most libraries support.&lt;/li&gt;
&lt;li&gt;List of Libraries to Install
&lt;ul&gt;
&lt;li&gt;Pandas&lt;/li&gt;
&lt;li&gt;Numpy&lt;/li&gt;
&lt;li&gt;Matplotlib, Seaborn, Plotly&lt;/li&gt;
&lt;li&gt;yfinance&lt;/li&gt;
&lt;li&gt;Cufflinks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bonus&lt;/strong&gt; : Just use Google Colab and install yfinance, Cufflinks in there and get started&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;heres-what-we-will-focus-on&#34;&gt;Here’s what we will focus on&lt;/h2&gt;
&lt;p&gt;We will be setting up a python environment, getting market data using Yahoo Finance, and doing some basic statistical analysis. We will then create a simple strategy and compare returns.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get market data from Yahoo Finance.&lt;/li&gt;
&lt;li&gt;Play with the data, get data from NSE, and do stats on it.&lt;/li&gt;
&lt;li&gt;Calculate moving averages and do plotting.&lt;/li&gt;
&lt;li&gt;Try to do something known as Bollinger bands, which is a technical indicator.&lt;/li&gt;
&lt;li&gt;Make a simple moving average-based strategy.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;more-details&#34;&gt;More Details&lt;/h2&gt;
&lt;p&gt;After installing the libraries, we will use Yahoo Finance to get market data. We will define a variable ticker and set start and end dates. Then, we will download the data and create a data frame. We will also reduce the number of days to make it easier to plot.&lt;/p&gt;
&lt;p&gt;Next, we will plot the high, lows, and search for patterns. We will also calculate some basic formulas like simple moving average, exponential moving averages, and Bollinger bands. Bollinger bands is a plus-minus two standard deviations up and down from a simple moving average.&lt;/p&gt;
&lt;p&gt;Finally, we will make a simple moving average-based strategy. The strategy will be to sell if a condition is met and hold if it is not.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Complete Code is shared below&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Install necessary libraries.&lt;/li&gt;
&lt;li&gt;Define variable ticker and set start and end dates.&lt;/li&gt;
&lt;li&gt;Download data and create a data frame.&lt;/li&gt;
&lt;li&gt;Reduce the number of days to make it easier to plot.&lt;/li&gt;
&lt;li&gt;Plot high lows and search for patterns.&lt;/li&gt;
&lt;li&gt;Calculate basic formulas like simple moving average, exponential moving averages, and Bollinger bands.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;working-with-a-strategy&#34;&gt;Working with a Strategy&lt;/h2&gt;
&lt;p&gt;In the world of algorithmic trading, having a well-defined strategy is crucial for success. A trading strategy is simply a set of rules that traders follow to generate signals that indicate when to buy, sell, or do nothing.&lt;/p&gt;
&lt;p&gt;One popular trading strategy is using the &lt;strong&gt;simple moving average (SMA)&lt;/strong&gt;. The SMA is a technical indicator that helps traders identify trends in the market. It calculates the average price of a security over a specific time period, such as 12 days, by adding up the closing prices of each day and dividing it by the number of days in the period.&lt;/p&gt;
&lt;p&gt;When using the SMA, traders typically buy a stock when its closing price is higher than its simple moving average and sell it when the closing price is lower. This approach can help traders identify potential uptrends or downtrends in the market and make informed decisions on when to enter or exit a trade.&lt;/p&gt;
&lt;p&gt;However, it&amp;rsquo;s important to note that no trading strategy is foolproof. &lt;em&gt;Market conditions can change rapidly, and unforeseen events can impact a stock&amp;rsquo;s performance.&lt;/em&gt; Therefore, it&amp;rsquo;s essential to continually monitor the market and adjust trading strategies as needed.&lt;/p&gt;
&lt;p&gt;In addition to the SMA, there are many other technical indicators and trading strategies that traders can use to make informed decisions in the market. Some popular ones include the &lt;strong&gt;relative strength index (RSI)&lt;/strong&gt;, the &lt;strong&gt;moving average convergence divergence (MACD)&lt;/strong&gt;, and &lt;strong&gt;the Bollinger Bands&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;When studying financial engineering and data science, it&amp;rsquo;s essential to clean up data to ensure that the calculations are accurate. This often involves dropping unnecessary columns and removing any errors or outliers that may skew the results.&lt;/p&gt;
&lt;p&gt;In summary, having a well-defined trading strategy is essential for success in algorithmic trading. The SMA is just one of many technical indicators and trading strategies that traders can use to make informed decisions in the market. However, it&amp;rsquo;s important to continually monitor the market and adjust strategies as needed to stay ahead of the game.&lt;/p&gt;
&lt;h2 id=&#34;complete-code&#34;&gt;Complete Code&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;#pip install yfinance plotly cufflinks

# Core Imports
import pandas as pd
import numpy as np
import datetime
import yfinance as yf
import matplotlib.pyplot as plt

#Ticker is the stock that we want to get
Ticker = &amp;quot;^NSEI&amp;quot;


# Get Sample data based on a Ticker
end1 = datetime.date.today()
start1 = end1 - pd.Timedelta(days=5)

df = yf.download(Ticker, start=start1, end=end1, interval=&amp;quot;5m&amp;quot; )
print(df.head())
df.info()

# Plotting the Data

df1a = df.copy()
df1a.loc[&#39;2023-02-13&#39;, [&#39;Open&#39;, &#39;High&#39;, &#39;Low&#39;, &#39;Close&#39;]].plot(grid=True, linewidth=1, figsize=(14, 9))

# Just the Closing Price
df1a[&#39;Close&#39;].plot(grid=True, linewidth=1, figsize=(14, 9))

# Core Calculation Functions 
# SMA
def get_sma(prices, rate):
  return prices.rolling(rate).mean()

# EMA
def get_ema(prices, rate):
  return prices.ewm(span=ema, adjust=False).mean()

# Bollinger Bands

# Bollinger bands are a technical analysis tool used by traders to identify potential entry and exit points in the market. They are created by plotting a moving average of the price along with two standard deviation lines above and below it. By doing so, Bollinger bands can provide an indication of whether a stock is overbought or oversold. They also help traders identify potential breakouts or reversals in the market. With this knowledge, traders can make more informed decisions when entering or exiting a position in the market.

def get_bollinger_bands(prices,rate):
    sma = get_sma(prices, rate)
    std = prices.rolling(rate).std()
    bollinger_up = sma + std * 2 # Calculate top band
    bollinger_down = sma - std * 2 # Calculate bottom band
    return bollinger_up, bollinger_down


# Other Functions

def download_daily_data(ticker, start, end):
    &amp;quot;&amp;quot;&amp;quot; 
    The function downloads daily market data to a pandas DataFrame 
    using the &#39;yfinance&#39; API between the dates specified.
    &amp;quot;&amp;quot;&amp;quot;
    data = yf.download(ticker, start, end)
    
    return data

def compute_daily_returns(data):
    &amp;quot;&amp;quot;&amp;quot; 
    The function computes daily log returns based on the Close prices in the pandas DataFrame
    and stores it in a column  called &#39;cc_returns&#39;.
    &amp;quot;&amp;quot;&amp;quot;
    data[&#39;cc_returns&#39;] = np.log(data[&#39;Close&#39;] / data[&#39;Close&#39;].shift(1))
    return data

# Generate Bollinger bands for the above

bollinger_up, bollinger_down = get_bollinger_bands(df1a[&#39;Close&#39;],20)


# Plot the Results

symbol = &#39;NSE&#39;
closing_prices = df1a[&#39;Close&#39;]

plt.title(symbol + &#39; Bollinger Bands&#39;)
plt.xlabel(&#39;Days&#39;)
plt.ylabel(&#39;Closing Prices&#39;)
plt.plot(closing_prices, label=&#39;Closing Prices&#39;)
plt.plot(bollinger_up, label=&#39;Bollinger Up&#39;, c=&#39;g&#39;)
plt.plot(bollinger_down, label=&#39;Bollinger Down&#39;, c=&#39;r&#39;)
plt.legend()
plt.show()


# Strategy Perform Calculations

# Remove the Un-necessary Columns
df1a.drop(columns=[&#39;High&#39;, &#39;Low&#39;, &#39;Volume&#39;], inplace=True)

# Create a new colum which captures the percentage cahnge from previous day
df1a[&#39;cc_returns&#39;] = df1a[&#39;Close&#39;].pct_change()

# Define a short 12 day sma 
sma = 12
df1a[&#39;sma&#39;] = df1a[&#39;Close&#39;].rolling(window=sma).mean()

print(df1a.head())
print(df1a.tail())

# If the closging price is higher that sma buy else do nothing
df1a[&#39;position&#39;] = np.where((df1a[&#39;Close&#39;] &amp;gt; df1a[&#39;sma&#39;]), 1, 0)
df1a[&#39;position&#39;] = df1a[&#39;position&#39;].shift(1)
df1a[&#39;position&#39;].value_counts()

# Plotting the above strategy returns

df1a[&#39;strategy_returns&#39;] = df1a[&#39;cc_returns&#39;] * df1a[&#39;position&#39;]


df1a[&#39;strategy_returns&#39;] = 1 + df1a[&#39;strategy_returns&#39;]
df1a[&#39;cc_returns&#39;] = 1 + df1a[&#39;cc_returns&#39;]

print(df1a.head())
print(df1a.tail())

df1a[[&#39;cc_returns&#39;, &#39;strategy_returns&#39;]].cumprod().plot(grid=True, figsize=(9, 5))

print(&#39;Buy and hold returns: &#39;, np.round(df1a[&#39;cc_returns&#39;].cumprod()[-1], 2))
print(&#39;Strategy returns: &#39;, np.round(df1a[&#39;strategy_returns&#39;].cumprod()[-1], 2))
HyperWrite Logo
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Deep Dive into Architecture Patterns, Part 1</title>
      <link>https://akarsh.micro.blog/2023/04/02/deep-dive-into.html</link>
      <pubDate>Sun, 02 Apr 2023 09:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/04/02/deep-dive-into.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Deep Dive into Architecture Patterns. This Post is focused on understanding requirements (Functional and Non-Functional)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Architecture patterns are general, reusable solutions to recurring design problems at the system level. They provide a blueprint for organising and structuring software systems and their components, such as modules, layers, and services. Architecture patterns provide guidance on how to design and implement software systems with specific characteristics and qualities, such as scalability, performance, security, and maintainability.&lt;/p&gt;
&lt;p&gt;In the previous post &lt;a href=&#34;https://www.cafeio.xyz/architecture-patterns/&#34;&gt;Architecture Patterns,&lt;/a&gt; we looked at patterns from a bird&amp;rsquo;s-eye view. Patterns, however, are the heart and soul of Architecture and warrant a much deeper conversation. In the upcoming parts (still discovering how many to write) I intend to talk about patterns in more depth.&lt;/p&gt;
&lt;p&gt;In this post, I will talk about System requirement that lead to the right pattern selection.&lt;/p&gt;
&lt;h2 id=&#34;factors-influencing-architectural-pattern-choice&#34;&gt;Factors Influencing Architectural Pattern Choice&lt;/h2&gt;
&lt;p&gt;There could be a variety of factors influencing the choice of patterns. Some of the more obvious ones are listed below.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Functional Requirements :&lt;/strong&gt; Functional requirements describe what the system should do, such as the features it must provide and the tasks it must perform. The functional requirements of a system can help determine the appropriate architecture pattern. For example, if the system needs to support multiple user interfaces, a layered architecture pattern may be appropriate, as it provides a clear separation between the presentation layer and the business logic layer. On the other hand, if the system needs to support complex business workflows and data processing, a workflow-driven architecture pattern may be more suitable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Technology Stack:&lt;/strong&gt; The technology stack used in the system can influence the choice of architecture pattern. For example, if the system is built using a specific programming language or framework, there may be architecture patterns that are better suited to that technology stack.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Domain Complexity:&lt;/strong&gt; The complexity of the domain that the system is intended to model can help determine the appropriate architecture pattern. For example, if the domain is complex and involves many interacting components, a domain-driven design (DDD) architecture pattern may be appropriate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Non-functional Requirements:&lt;/strong&gt; Non-functional requirements such as performance, security, and maintainability can also influence the choice of architecture pattern. For example, if the system needs to be highly secure, a layered architecture pattern may be appropriate.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Beyond this, I have found the following to be also a contributing factor :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Team’s Capability (One of the Underdog in the selection)&lt;/li&gt;
&lt;li&gt;COTS products and Vendor-driven environments (Influence Security and compliance heavily)&lt;/li&gt;
&lt;li&gt;Existing IT Landscape (Data Center Setups can potentially challenge some modern patterns which are better suited to cloud)&lt;/li&gt;
&lt;li&gt;Pricing and Time To Market&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;functional-requirements&#34;&gt;Functional Requirements&lt;/h2&gt;
&lt;p&gt;Functional requirements are a crucial element in the development of software systems. They define what a system should do, including its features and functionality. When it comes to designing the software architecture, functional requirements have a significant impact on the selection of appropriate architecture patterns.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://i.stack.imgur.com/NXzMw.gif&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Functional requirements can determine the appropriate architecture pattern by providing insights into the system&amp;rsquo;s features and capabilities.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For example, if the system needs to handle complex business workflows and data processing, a workflow-driven architecture pattern may be more suitable. This pattern provides a visual representation of the workflow and ensures that the business logic is decoupled from the presentation layer.&lt;/li&gt;
&lt;li&gt;Similarly, if the system needs to support multiple user interfaces, a layered architecture pattern may be appropriate. This pattern separates the system into different layers, each with a specific responsibility, making it easier to maintain and scale the system.&lt;/li&gt;
&lt;li&gt;Another example of how functional requirements can impact architecture patterns is in the case of real-time systems. Real-time systems have stringent timing requirements and require an architecture pattern that can provide predictable and reliable performance. In this case, a microservices architecture pattern may be more suitable, as it enables the system to be broken down into smaller, independent services that can be scaled and deployed separately.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In conclusion, functional requirements have a significant impact on the selection of appropriate architecture patterns. The selection of an architecture pattern must meet the functional requirements of the system and ensure that it is scalable, maintainable, and extensible. Therefore, it is crucial to carefully analyse the system&amp;rsquo;s functional requirements before selecting an appropriate architecture pattern.&lt;/p&gt;
&lt;h2 id=&#34;non--functional-requirements&#34;&gt;Non – Functional requirements&lt;/h2&gt;
&lt;p&gt;Non-functional requirements define the performance, security, reliability, and other quality attributes that a software system must meet. Non-functional requirements are important because they determine how well the system performs its tasks and how easy it is to use and maintain.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://akfpartners.com//uploads/blog/NFR_PNG.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One example of how non-functional requirements impact architecture patterns is in the case of performance. If a system has high-performance requirements, such as low latency or high throughput, then an appropriate architecture pattern must be selected. In this case, a distributed architecture pattern, such as a microservices architecture or a service-oriented architecture, may be more suitable, as it provides scalability and fault tolerance.&lt;/li&gt;
&lt;li&gt;Similarly, if a system needs to be highly secure, a layered architecture pattern with a clear separation of concerns may be more appropriate. This pattern separates the system into different layers, each with a specific responsibility, making it easier to secure and maintain.&lt;/li&gt;
&lt;li&gt;Another example of how non-functional requirements can influence architecture patterns is in the case of scalability. If a system needs to handle a large volume of data or traffic, then an appropriate architecture pattern must be selected. In this case, a distributed architecture pattern such as a microservices&#39; architecture may be more suitable, as it enables the system to be broken down into smaller, independent services that can be scaled and deployed separately.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;types-of-nfrs&#34;&gt;Types of NFRs&lt;/h3&gt;
&lt;p&gt;In general, NFRs are quality attributes of the system and are usually the “ity” requirements. Some of them are mentioned before.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;: This refers to how the system responds to a specific workload or user load. Performance requirements can include response time, throughput, and resource utilization.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to handle an increasing amount of work or users without affecting its performance. Scalability requirements can include horizontal scalability, vertical scalability, and load balancing.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reliability&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to function correctly and without failure over time. Reliability requirements can include fault tolerance, disaster recovery, and backup and recovery.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to protect against unauthorised access, data theft, and other security threats. Security requirements can include authentication, access control, encryption, and compliance with industry standards.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Usability&lt;/strong&gt;: This refers to how easy the system is to use and how well it meets user needs. Usability requirements can include accessibility, responsiveness, and user interface design.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: This refers to how easy it is to maintain and update the system over time. Maintainability requirements can include modularity, documentation, and code quality.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interoperability&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to interact with other systems and applications. Interoperability requirements can include support for industry standards and protocols, data exchange formats, and integration with third-party systems.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compatibility&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to work with different hardware, software, and network environments. Compatibility requirements can include support for different operating systems, browsers, databases, and other software components.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Availability&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to be accessible and operational when required. Availability requirements can include uptime, downtime, and recovery time objectives.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Capacity&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to handle a specific volume of data or transactions. Capacity requirements can include data storage, processing power, and network bandwidth.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compliance&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to meet legal, regulatory, and industry standards. Compliance requirements can include data privacy, security regulations, accessibility standards, and industry-specific regulations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance efficiency&lt;/strong&gt;: This refers to the system&amp;rsquo;s ability to achieve performance objectives with minimal resource consumption. Performance efficiency requirements can include energy efficiency, resource utilization, and optimization of memory and processing power.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testability&lt;/strong&gt;: This refers to how easy it is to test the system and validate its functionality. Testability requirements can include support for automated testing, test data management, and traceability of test results.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The list can be further extended, but this is a good starting point for evaluation of NFRs.&lt;/p&gt;
&lt;h3 id=&#34;how-to-prioritise-nfrs&#34;&gt;How to Prioritise NFRs?&lt;/h3&gt;
&lt;p&gt;Prioritising non-functional requirements (NFRs) is critical to the success of software development projects. Here are some common prioritisation techniques for NFRs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;MoSCoW method&lt;/strong&gt;: This technique involves dividing NFRs into four categories: Must have, Should have, Could have, and Won&amp;rsquo;t have. The must-have requirements are the most critical, while the won&amp;rsquo;t-have requirements are the least important.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cost-benefit analysis&lt;/strong&gt;: This technique involves assessing the cost of implementing an NFR against its benefits. NFRs with the highest benefits and lowest costs are given a higher priority.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Risk-based prioritisation&lt;/strong&gt;: This technique involves identifying the potential risks associated with each NFR and prioritizing them based on their impact on the system&amp;rsquo;s performance, reliability, and security.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User-based prioritisation&lt;/strong&gt;: This technique involves prioritizing NFRs based on user needs and preferences. User feedback and surveys can help identify the most critical NFRs from a user&amp;rsquo;s perspective.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Impact mapping&lt;/strong&gt;: This technique involves mapping NFRs to the system&amp;rsquo;s goals and objectives. NFRs that have a more significant impact on achieving the system&amp;rsquo;s goals are given a higher priority.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kano model&lt;/strong&gt;: This technique involves categorising NFRs into three categories: must-haves, performance, and delighters. Must-haves are essential requirements, performance requirements are expected by users, and delighters are features that exceed user expectations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Planning poker&lt;/strong&gt;: This technique involves a collaborative effort where development team members discuss and estimate the priority of each NFR. This technique can help achieve consensus and ensure that.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In conclusion, prioritisation of NFRs is a critical activity in software development. By using techniques such as MoSCoW, AHP, Cost-Benefit Analysis, Risk-Based Prioritisation, Agile Prioritisation, and Kano Model, software developers can ensure that the most critical requirements are met, and resources are allocated effectively to achieve the desired system performance, reliability, and user satisfaction.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;&amp;ldquo;Deep Dive into Architecture Patterns, Part 1&amp;rdquo; is a comprehensive guide that delves into the world of architecture patterns. Architecture patterns provide reusable solutions to common design problems, serving as a blueprint for structuring and organising software systems and their components. The post emphasises understanding the functional and non-functional requirements when selecting the appropriate architecture pattern for a system.&lt;/p&gt;
&lt;p&gt;Functional requirements define what the system should do, such as the features it must provide and the tasks it must perform. These requirements can help determine the appropriate architecture pattern. For example, a workflow-driven architecture pattern is more suitable for systems that handle complex business workflows and data processing. On the other hand, a layered architecture pattern may be more appropriate for systems that support multiple user interfaces.&lt;/p&gt;
&lt;p&gt;Non-functional requirements, such as performance, security, reliability, and scalability, determine how well the system performs its tasks and how easy it is to use and maintain. A distributed architecture pattern, such as a microservices&#39; architecture, may be more suitable for systems that require high-performance and scalability. A layered architecture pattern with a clear separation of concerns may be more appropriate for highly secure systems. The post also discusses the types of NFRs, such as performance, security, and maintainability.&lt;/p&gt;
&lt;p&gt;The post concludes that selecting the appropriate architecture pattern requires careful analysis of the system&amp;rsquo;s functional and non-functional requirements to ensure that it is scalable, maintainable, and extensible. Other factors such as technology stack, domain complexity, and team capability can also influence the pattern selection. This informative guide is a must-read for developers, architects, and software engineers who are keen to learn more about architecture patterns and their impact on software design.&lt;/p&gt;
&lt;h2 id=&#34;references&#34;&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://akfpartners.com/growth-blog/the-problem-with-non-functional-requirements&#34;&gt;https://akfpartners.com/growth-blog/the-problem-with-non-functional-requirements&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Why is it Important to understand TimeSeries in Algo Trading?</title>
      <link>https://akarsh.micro.blog/2023/03/28/why-is-it.html</link>
      <pubDate>Tue, 28 Mar 2023 09:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/28/why-is-it.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Time series analysis plays an important role in understanding and forecasting stock market behaviour&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&#34;what-is-algorithmic-trading&#34;&gt;What is Algorithmic Trading?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Algorithmic trading&lt;/strong&gt;, also known as algo trading, is a method of executing trades in financial markets using pre-programmed instructions that automatically execute trades based on certain criteria or market conditions.&lt;/p&gt;
&lt;p&gt;Algo trading is commonly used by institutional investors such as hedge funds, banks, and pension funds, as well as by individual traders. The use of algorithms can lead to increased efficiency and speed of trading, as well as reduced transaction costs. However, algo trading can also come with risks, such as the potential for errors in the programming or unexpected market movements that could trigger unintended trades.&lt;/p&gt;
&lt;h3 id=&#34;what-is-time-series&#34;&gt;What is Time Series?&lt;/h3&gt;
&lt;p&gt;In the context of the stock market, a &lt;strong&gt;time series&lt;/strong&gt; is a set of historical stock market data that is collected and organised over a period of time. This data typically includes the prices of a particular stock, index, or other financial instrument at different points in time, and can also include other metrics such as trading volume or market capitalisation.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;If you&amp;rsquo;re interested in trading, then you&amp;rsquo;ve likely heard of algorithmic trading, or algo trading for short. This approach uses sophisticated mathematical models and algorithms to analyze market data and identify buying and selling opportunities automatically. By doing so, algo trading eliminates the need for human intervention in executing trades.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When it comes to analyzing stock market data, one popular method is time series analysis. This technique involves studying historical data to identify patterns, trends, and relationships between different variables.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Technical analysts often use time series data to develop trading strategies and make predictions about future market movements. By using tools such as moving averages, chart patterns, and technical indicators, traders can identify patterns and trends in the data and make informed decisions about buying, selling, or holding stocks or other financial instruments.&lt;/p&gt;
&lt;p&gt;By leveraging the power of algo trading and time series analysis, traders can gain a more profound understanding of the stock market and make more informed investment decisions.&lt;/p&gt;
&lt;h2 id=&#34;components-of-stock-market-data&#34;&gt;Components of Stock Market Data&lt;/h2&gt;
&lt;p&gt;Stock market data typically includes a variety of components that can provide insights into the performance of individual stocks, as well as broader market trends. Some of the most common components of stock market data include:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Stock prices:&lt;/strong&gt; The prices of individual stocks at different points in time are a key component of stock market data. This includes the opening and closing prices, as well as intra-day highs and lows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Volume:&lt;/strong&gt; The total number of shares traded for a particular stock over a given time period is known as volume. Volume can be an important indicator of market sentiment and can help investors understand the level of interest in a particular stock.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Market capitalisation:&lt;/strong&gt; Market capitalisation is the total value of a company&amp;rsquo;s outstanding shares. It is calculated by multiplying the total number of shares by the current market price per share.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dividends:&lt;/strong&gt; Dividends are payments made by companies to their shareholders as a share of profits. Dividend data can provide insights into a company&amp;rsquo;s financial health and growth potential.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Earnings:&lt;/strong&gt; Earnings reports provide information on a company&amp;rsquo;s financial performance, including revenues, expenses, and net income. This information can be used to evaluate the financial health and growth potential of a company.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;News and events:&lt;/strong&gt; News and events that impact the stock market, such as company announcements, economic reports, and geopolitical events, can also be an important component of stock market data.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By analyzing these components and searching for patterns and trends, investors and traders can gain a more profound understanding of the stock market and make more informed investment decisions.&lt;/p&gt;
&lt;p&gt;If you play close attention, most of these components are time—varying. Typically, Period and Interval are two aspects of time which are factored in. For example,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stock Closing Price for a year with the interval being 1 day&lt;/li&gt;
&lt;li&gt;Daily Volume for # of traded days&lt;/li&gt;
&lt;li&gt;Ticker data (almost real-time or Second internal&lt;/li&gt;
&lt;li&gt;Annual Earning Reports&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://marketsmith.investors.com/stock-market/Image.axd?name=smIndicator.png&#34; alt=&#34;&#34;&gt;
&lt;img src=&#34;https://digitalpress.fra1.cdn.digitaloceanspaces.com/bbrg6nv/2023/03/Image.axd-1-1.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;components-of-time-series&#34;&gt;Components of Time Series&lt;/h2&gt;
&lt;p&gt;By identifying these components in a time series, analysts can gain a more in-depth understanding of the underlying patterns and trends in the data.&lt;/p&gt;
&lt;p&gt;This information can be used to make predictions, develop forecasting models, and inform decision-making for Quantitative finance.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Trend:&lt;/strong&gt; A trend is a long-term increase or decrease in the data over time. It can be upward, downward, or stable.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Seasonality:&lt;/strong&gt; Seasonality refers to the regular and periodic fluctuations in the data that occur within a year or other fixed time period. For example, sales of winter clothing may be higher during the winter months, while sales of summer clothing may be higher in the summer months.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cyclical components:&lt;/strong&gt; Cyclical components are fluctuations in the data that occur over a period longer than a year. They can be influenced by factors such as economic cycles or business cycles.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Irregular components:&lt;/strong&gt; Irregular components are unexpected fluctuations in the data that are not accounted for by trend, seasonality, or cyclical components. They may be due to random events, measurement error, or other factors.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;http://ebooks.ibsindia.org/quantitative-methods/wp-content/uploads/sites/16/2021/03/3-120.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;putting-theory-to-practise&#34;&gt;Putting Theory to Practise&lt;/h2&gt;
&lt;p&gt;We will look at two simple strategies that are purely time series based and are extremely popular in the trading world. &lt;em&gt;I would like to point out that this is not a trading advice and the examples just illustrate the concept.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&#34;golden-crossover-strategy&#34;&gt;Golden Crossover strategy&lt;/h3&gt;
&lt;p&gt;The Golden Crossover Strategy is a popular technical analysis trading strategy used in the stock market. It involves using two moving averages of different lengths to identify buying and selling signals.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The two moving averages used in the Golden Crossover Strategy are the 50-day moving average and the 200-day moving average.&lt;/li&gt;
&lt;li&gt;The 50-day moving average is calculated by taking the average price of a stock over the last 50 days, while the 200-day moving average is calculated by taking the average price of a stock over the last 200 days.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;The Golden Crossover occurs when the 50-day moving average crosses above the 200-day moving average, indicating a bullish signal. This is interpreted as a buy signal, as it suggests that the stock is trending upwards and has the potential to increase in value.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code&gt;import yfinance as yf
import numpy as np

# Download historical stock data for a given ticker symbol
stock_data = yf.download(&#39;AAPL&#39;, start=&#39;2020-01-01&#39;, end=&#39;2022-01-01&#39;)

# Calculate the 50-day and 200-day moving averages
stock_data[&#39;50_day_ma&#39;] = stock_data[&#39;Adj Close&#39;].rolling(window=50).mean()
stock_data[&#39;200_day_ma&#39;] = stock_data[&#39;Adj Close&#39;].rolling(window=200).mean()

# Generate signals based on the Golden Crossover strategy
stock_data[&#39;signal&#39;] = 0.0
stock_data[&#39;signal&#39;][50:] = np.where(stock_data[&#39;50_day_ma&#39;][50:] 
                                      &amp;gt; stock_data[&#39;200_day_ma&#39;][50:], 1.0, 0.0)

# Calculate the positions based on the signals
stock_data[&#39;position&#39;] = stock_data[&#39;signal&#39;].diff()

# Plot the stock prices, moving averages, and trading signals
import matplotlib.pyplot as plt

plt.figure(figsize=(10,5))
plt.plot(stock_data[&#39;Adj Close&#39;], label=&#39;AAPL&#39;)
plt.plot(stock_data[&#39;50_day_ma&#39;], label=&#39;50-day MA&#39;)
plt.plot(stock_data[&#39;200_day_ma&#39;], label=&#39;200-day MA&#39;)

# Plot the buy and sell signals
plt.plot(stock_data[stock_data[&#39;position&#39;] == 1].index, 
         stock_data[&#39;50_day_ma&#39;][stock_data[&#39;position&#39;] == 1], 
         &#39;^&#39;, markersize=10, color=&#39;green&#39;, label=&#39;buy&#39;)
plt.plot(stock_data[stock_data[&#39;position&#39;] == -1].index, 
         stock_data[&#39;50_day_ma&#39;][stock_data[&#39;position&#39;] == -1], 
         &#39;v&#39;, markersize=10, color=&#39;red&#39;, label=&#39;sell&#39;)
plt.xlabel(&#39;Date&#39;)
plt.ylabel(&#39;Price&#39;)
plt.title(&#39;Golden Crossover Strategy for AAPL&#39;)
plt.legend()
plt.show()
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;arima-model-autoregressive-integrated-moving-average&#34;&gt;ARIMA Model (Autoregressive Integrated Moving Average)&lt;/h3&gt;
&lt;p&gt;The ARIMA model consists of three components: autoregression, integration, and moving average. Autoregression refers to the use of past values of the time series as predictors for future values. Integration involves transforming the data to make it stationary, meaning that the mean and variance are constant over time. Moving average involves using past errors as predictors for future values.&lt;/p&gt;
&lt;p&gt;To use ARIMA for algo trading, historical stock price data is first analyzed to identify the trend, seasonality, and other components of the time series. The data is then transformed to make it stationary, and an ARIMA model is fit to the transformed data. &lt;strong&gt;The model can be used to forecast future stock prices, and these forecasts can be used to make trading decisions automatically.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;Algorithmic trading is the use of pre-programmed instructions to automatically execute trades in financial markets based on certain criteria or market conditions. It is popular among institutional investors and individual traders for its speed and efficiency, although it also comes with risks. Time series, on the other hand, refers to a set of historical stock market data collected and organised over a period of time, typically including stock prices and trading volumes. Technical analysts use time series analysis to identify patterns and trends and develop trading strategies.&lt;/p&gt;
&lt;p&gt;Components of stock market data include stock prices, volume, market capitalisation, dividends, earnings, and news and events, all of which can provide insights into the performance of individual stocks and broader market trends. In analyzing these components and searching for patterns and trends, investors and traders can gain a more profound understanding of the stock market and make more informed investment decisions. Time series analysis helps analysts identify the components of a time series, such as trend, seasonality, cyclical components, and irregular components, which can inform decision-making in quantitative finance.&lt;/p&gt;
&lt;p&gt;The article also includes examples of two simple trading strategies based on time series analysis: the Golden Crossover Strategy and the Momentum Strategy. These strategies are not intended as trading advice but are used to illustrate the concept of time series analysis in trading.&lt;/p&gt;
&lt;h2 id=&#34;references&#34;&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://marketsmith.investors.com/stock-market/&#34;&gt;https://marketsmith.investors.com/stock-market/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ebooks.ibsindia.org/quantitative-methods/chapter/session-23-time-series-analysis-introduction-components-of-time-series/&#34;&gt;https://ebooks.ibsindia.org/quantitative-methods/chapter/session-23-time-series-analysis-introduction-components-of-time-series/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Architecture Patterns?</title>
      <link>https://akarsh.micro.blog/2023/03/26/architecture-patterns.html</link>
      <pubDate>Sun, 26 Mar 2023 09:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/26/architecture-patterns.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Do software products follow patterns? Why is it important to think about them?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Human beings have a knack for finding patterns. Given clouds we tend to find shapes and faces in them, we connect the stars with imaginary lines to define autonomic shapes etc. Seeing patterns is a natural function of the human brain intended to help us learn.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Software products are no different.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;**Design problems **arise during the software development process when there is a need to make decisions about the software architecture, design, and implementation.&lt;/p&gt;
&lt;p&gt;Examples of design problems may include&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Choosing the appropriate software components and technologies,&lt;/li&gt;
&lt;li&gt;Selecting the most suitable algorithms and data structures,&lt;/li&gt;
&lt;li&gt;Optimising performance&lt;/li&gt;
&lt;li&gt;Ensuring maintainability and scalability&lt;/li&gt;
&lt;li&gt;Balancing competing requirements.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Unfortunately, these discussions are extremely common and difficult to address given that software systems are in a constant state of evolution. The subsequent decisions have to be made by balancing trade-offs between different factors, such as performance, scalability, security, maintainability, and usability.&lt;/p&gt;
&lt;h2 id=&#34;patterns-to-the-rescue&#34;&gt;Patterns to the Rescue&lt;/h2&gt;
&lt;p&gt;Fortunately, for us, these design concerns have become repetitive over time and there are well established constructs that either solve them or provide a conversation ground for. These are called Architecture Patterns.&lt;/p&gt;
&lt;p&gt;In a nutshell, An &lt;strong&gt;architecture patters&lt;/strong&gt; is a general, reusable solution to a recurring design concern in software architecture. It provides a standard template for solving a particular architectural concern, and it can be applied across different systems and contexts.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Architecture patterns&lt;/strong&gt; are usually higher-level than &lt;strong&gt;Design patterns&lt;/strong&gt; (Future Post, most likely), which focus on individual software components and their interactions. They help to ensure that software systems are designed with consistency, maintainability, and scalability in mind.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By using architecture patterns, software architects can avoid reinventing the wheel for common design challenges and instead rely on proven solutions.&lt;/p&gt;
&lt;p&gt;Some examples of architecture patterns include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Layered architecture&lt;/li&gt;
&lt;li&gt;Client-server architecture&lt;/li&gt;
&lt;li&gt;Microservices architecture&lt;/li&gt;
&lt;li&gt;Model-View-Controller (MVC) architecture&lt;/li&gt;
&lt;li&gt;Event-driven architecture&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;layered-architecture&#34;&gt;Layered Architecture&lt;/h3&gt;
&lt;p&gt;also known as n-tier architecture, is a widely used architecture pattern in software engineering. It divides a software system into multiple layers, where each layer represents a different level of abstraction or functionality. The layers are stacked on top of each other, and each layer only communicates with the adjacent layers, making it easy to modify or replace individual layers without affecting the entire system. This architecture pattern provides a clear separation of concerns and facilitates the implementation of complex systems. The most common layers are the presentation layer, business logic layer, and data storage layer.&lt;/p&gt;
&lt;h3 id=&#34;client-server-architecture&#34;&gt;Client-Server Architecture:&lt;/h3&gt;
&lt;p&gt;is a distributed architecture pattern where a client (user interface) interacts with a server to perform a specific function. The client sends requests to the server, and the server processes the requests and sends the results back to the client. This architecture pattern is commonly used in web applications and other network-based systems, where the client can be a web browser or a mobile app, and the server can be a web server or a database server. The main advantage of client-server architecture is its scalability and flexibility, as it allows multiple clients to access the same server concurrently.&lt;/p&gt;
&lt;h3 id=&#34;microservices-architecture&#34;&gt;Microservices Architecture&lt;/h3&gt;
&lt;p&gt;is a modern architecture pattern that structures a software system as a collection of small, independent services, each with its own functionality and data storage. Each service communicates with other services using APIs and protocols, making it easy to modify or replace individual services without affecting the entire system. Microservices architecture promotes flexibility, scalability, and resilience in software systems, making it ideal for large, complex applications with changing requirements.&lt;/p&gt;
&lt;h3 id=&#34;model-view-controller-mvc-architecture&#34;&gt;Model-View-Controller (MVC) Architecture&lt;/h3&gt;
&lt;p&gt;pattern for building user interfaces, web applications, and other interactive systems. It divides the application into three components: the model, the view, and the controller. The model represents the application&amp;rsquo;s data and business logic, the view represents the user interface, and the controller manages the communication between the model and the view. This architecture pattern promotes separation of concerns and modularity, making it easy to modify or replace individual components without affecting the entire system.&lt;/p&gt;
&lt;h3 id=&#34;event-driven-architecture&#34;&gt;Event-Driven Architecture&lt;/h3&gt;
&lt;p&gt;is a distributed architecture pattern where software components communicate with each other through events, such as messages, signals, or notifications. The components are decoupled and only communicate with each other through events, which are generated and consumed asynchronously. This architecture pattern promotes scalability, flexibility, and responsiveness in software systems, making it ideal for complex, event-driven systems such as real-time applications, streaming services, and messaging systems.&lt;/p&gt;
&lt;h2 id=&#34;how-to-decide-&#34;&gt;How to Decide ?&lt;/h2&gt;
&lt;p&gt;Selecting the appropriate architecture pattern for a software system depends on a variety of factors, including the system&amp;rsquo;s requirements, constraints, and expected behaviours. Here are some steps you can follow to help you choose the best architecture pattern for your project:&lt;/p&gt;
&lt;h3 id=&#34;requirements-and-constraints&#34;&gt;Requirements and constraints&lt;/h3&gt;
&lt;p&gt;Understanding the system&amp;rsquo;s requirements is essential in selecting an appropriate architecture pattern. Identify the system&amp;rsquo;s functional requirements, such as the features, use cases, and workflows, as well as non-functional requirements such as performance, scalability, security, and maintainability.&lt;/p&gt;
&lt;h3 id=&#34;domain-andproblem-complexity&#34;&gt;Domain and problem complexity&lt;/h3&gt;
&lt;p&gt;Consider the complexity of the problem domain and the overall architecture. For example, a microservices architecture may be suitable for a large, complex, and distributed system, while a simpler monolithic architecture might be more suitable for a small project.&lt;/p&gt;
&lt;h3 id=&#34;team-expertise&#34;&gt;Team expertise &lt;/h3&gt;
&lt;p&gt;Evaluate your team&amp;rsquo;s experience and familiarity with the potential architecture patterns. A pattern that your team is already comfortable with may lead to faster development and fewer mistakes.&lt;/p&gt;
&lt;h3 id=&#34;integration-with-existing-systems&#34;&gt;Integration with existing systems&lt;/h3&gt;
&lt;p&gt;Consider how the new system will integrate with other systems and components, and select a pattern that will facilitate smooth integration&lt;/p&gt;
&lt;h3 id=&#34;scalabilityand-performance&#34;&gt;Scalability and performance&lt;/h3&gt;
&lt;p&gt;Evaluate how well the architecture pattern will support the expected load, growth, and performance requirements of the system.&lt;/p&gt;
&lt;h3 id=&#34;testability&#34;&gt;Testability&lt;/h3&gt;
&lt;p&gt;Ensure the selected pattern allows for easy and thorough testing of the system&amp;rsquo;s components.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;Architecture patterns are general, reusable solutions to recurring design problems at the system level. They provide a blueprint for organising and structuring software systems and their components, such as modules, layers, and services. Architecture patterns provide guidance on how to design and implement software systems with specific characteristics and qualities, such as scalability, performance, security, and maintainability.&lt;/p&gt;
&lt;h2 id=&#34;references&#34;&gt;References&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://martinfowler.com/eaaCatalog/&#34; title=&#34;Catalog of Patterns of Enterprise Application Architecture&#34;&gt;https://martinfowler.com/eaaCatalog/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://martinfowler.com/architecture/&#34; title=&#34;Software Architecture Guide&#34;&gt;https://martinfowler.com/architecture/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>Setting things Up</title>
      <link>https://akarsh.micro.blog/2023/03/19/setting-things-up.html</link>
      <pubDate>Sun, 19 Mar 2023 15:00:00 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/19/setting-things-up.html</guid>
      <description>&lt;p&gt;Algorithmic trading, also known as algo trading, is the use of computer programs to follow a defined set of instructions for placing trades. It is a form of automated trading that allows traders to execute orders with speed and precision. Algo trading helps traders to identify and react to market opportunities faster, reduces emotions, and increases discipline. It also allows traders to track multiple accounts and multiple markets simultaneously.&lt;/p&gt;
&lt;p&gt;In this post/video we will get started with foundational code in python and cover the following introductory material.&lt;/p&gt;
&lt;p&gt;• Setting up yfinance library&lt;/p&gt;
&lt;p&gt;• Basic Operations and Plotting&lt;/p&gt;
&lt;p&gt;• SMA, EMA, Bollinger Bands&lt;/p&gt;
&lt;p&gt;• Simple Strategy based on SMA&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; is a popular language for algorithmic trading. It has a wide range of libraries and tools for performing data analysis, backtesting and paper trading. It is also used for developing trading strategies and optimising them for different markets. Python has a wide range of libraries for performing data analysis, backtesting and paper trading. The most popular libraries include &lt;em&gt;Pandas, Numpy, Scipy, Matplotlib, Scikit-learn, and Statsmodels.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://gist.github.com/vermaakarsh/c28cba65c27c42b2ec358b5de4daac01&#34;&gt;Code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://youtu.be/uvby-fWe8Ts&#34;&gt;youtu.be/uvby-fWe8&amp;hellip;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;definitions&#34;&gt;Definitions&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Simple Moving Average :&lt;/strong&gt; A simple moving average (SMA) calculates the average of a selected range of prices, usually closing prices, by the number of periods in that range.&lt;/p&gt;
&lt;p&gt;• &lt;a href=&#34;https://www.investopedia.com/terms/s/sma.asp&#34;&gt;www.investopedia.com/terms/s/s&amp;hellip;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Exponential Moving Average :&lt;/strong&gt; An exponential moving average (EMA) is a type of moving average (MA) that places a greater weight and significance on the most recent data points. The exponential moving average is also referred to as the exponentially weighted moving average. An exponentially weighted moving average reacts more significantly to recent price changes than a simple moving average simple moving average (SMA), which applies an equal weight to all observations in the period.&lt;/p&gt;
&lt;p&gt;• &lt;a href=&#34;https://www.investopedia.com/terms/e/ema.asp&#34;&gt;www.investopedia.com/terms/e/e&amp;hellip;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bollinger Band :&lt;/strong&gt; A Bollinger Band® is a technical analysis tool defined by a set of trendlines. They are plotted as two standard deviations, both positively and negatively, away from a simple moving average (SMA) of a security&amp;rsquo;s price and can be adjusted to user preferences.&lt;/p&gt;
&lt;p&gt;• &lt;a href=&#34;https://www.investopedia.com/terms/b/bollingerbands.asp&#34;&gt;www.investopedia.com/terms/b/b&amp;hellip;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To get started with algorithmic trading, one needs to understand the different strategies and how to implement them. Strategies include mean reversion, momentum, arbitrage, market making, pair trading, and volatility trading. Mean reversion is the theory that suggests that prices tend to revert to their mean or average. Momentum is the theory that suggests that prices move in the same direction for a period of time. Arbitrage is the strategy of taking advantage of differences in prices of the same security in different markets. Market making is a strategy of providing liquidity to the market by buying and selling the same security. Pair trading is the strategy of buying and selling two correlated securities. Volatility trading is the strategy of trading on the volatility of the market.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why should you draw Software Architectures ?</title>
      <link>https://akarsh.micro.blog/2023/03/18/why-should-you.html</link>
      <pubDate>Sat, 18 Mar 2023 09:27:30 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/18/why-should-you.html</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Thoughts &amp;amp; Experiences for Drawing Software Architecture&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Most Architects represent their thoughts in the form of diagrams. These are of varied types and formats.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some like to represent in the form of mixed formats representing Data flow, Applications, and Infrastructure all in a single view while others are often selective about what is captured&lt;/li&gt;
&lt;li&gt;Some will focus on the direction of arrows, strength(thickness) of lines, and color of lines while others might doodle away&lt;/li&gt;
&lt;li&gt;Choosing the amount of detail presented is a choice that is individual too unless stronger standards exist&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of them are correct and there’s always more than a single diagram that can communicate. But why are diagrams so effective in describing architectures? The answer lies in a definition or more so understanding of the Term.&lt;/p&gt;
&lt;p&gt;While there are many I love the definition by Mr. Martin Fowler, “&lt;strong&gt;the shared understanding that the expert developers have of the system design&lt;/strong&gt;” ..! In a complex system with multiple services and a varied tech stack, this definition helps intuitively understand why there is a need to draw.&lt;/p&gt;
&lt;p&gt;Softwares evolve and are constantly under change. With this, there is a natural need to understand the impact of a change on the overall system. This is critical to maintaining the stability and continuity of the system. How many times has it happened that we find ourselves changing a piece scared to death about it causing a cascading impact in production, or blowing off a downstream system due to a lack of awareness of the overall picture? This awareness is what the Architecture diagram brings in.&lt;/p&gt;
&lt;p&gt;So next time you have a change ensure that the first activity within your sprint is to assess the architecture impact. &lt;em&gt;Even if there is none it is important to capture a simple &lt;strong&gt;ADR (Architecture decision record)&lt;/strong&gt; describing the requirement and capturing the conversation.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&#34;best-practises-out-of-the-personal-experience&#34;&gt;Best Practises out of the personal experience&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Use colors to represent changing states&lt;/li&gt;
&lt;li&gt;Ensure that arrows follow a single convention (Data flow, Call Flow, etc)&lt;/li&gt;
&lt;li&gt;Group multiple interfaces and move them to a different diagram basis the interoperability method (All external REST APIs are grouped under a single group)&lt;/li&gt;
&lt;li&gt;Different environments can have different diagrams with a graduation process guiding them&lt;/li&gt;
&lt;li&gt;Limit the details (Focus on requirements and eliminate the noise)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the next post, I will try to take a sample app and draw it as I think might be good. Stay tuned.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Introduction to Algo Trading</title>
      <link>https://akarsh.micro.blog/2023/03/17/introduction-to-algo.html</link>
      <pubDate>Fri, 17 Mar 2023 13:52:27 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/17/introduction-to-algo.html</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Algorithmic trading, also known as algo trading, is the use of computer programs to follow a defined set of instructions for placing trades. It is a form of automated trading that allows traders to execute orders with speed and precision. Algo trading helps traders to identify and react to market opportunities faster, reduces emotions, and increases discipline. It also allows traders to track multiple accounts and multiple markets simultaneously.&lt;/p&gt;
&lt;p&gt;In this blog post, we will explore the basics of algo trading and its components. We’ll look at what a ticker is and the difference between quants and technical and fundamental analysis. We’ll also look at the basics of Python, strategies, libraries, backtesting, and paper trades.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=uvby-fWe8Ts&#34;&gt;https://www.youtube.com/watch?v=uvby-fWe8Ts&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;ticker-liquidity--order-book&#34;&gt;Ticker, Liquidity &amp;amp; Order Book&lt;/h2&gt;
&lt;p&gt;Let’s start by looking at what a &lt;strong&gt;ticker&lt;/strong&gt; is. A ticker is the state of an order book in any given instance. The tick includes the trades executed in the given instance with the bid/ask information. For each trading interval, four price points are available: open, high, low, and close. There are two kinds of participants: buyers and sellers. Participants place orders as bid and ask.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Liquidity&lt;/strong&gt; can be defined as the flow of bid and ask orders in a given time interval. If the liquidity is high, it means it is easy to trade in the instrument and the slippage cost will be lower for the participants. The details of the bid and ask and trades at any given time are considered as an order book. The rule of the order book is, that the highest bid price in the market is the best bid and the lowest ask is the best ask. Most of the exchanges follow the price-time priority rule, where the bigger bid and smaller ask will be given precedence in trade execution. If the price is the same for the two orders then the time will factor will be used. The order that arrived earlier will be given priority in trade execution.&lt;/p&gt;
&lt;h2 id=&#34;order-types&#34;&gt;Order Types&lt;/h2&gt;
&lt;p&gt;There are different types of orders available, such as market orders, limit orders, stop orders, iceberg orders, fill or kill orders, and immediate or cancel orders.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Market orders&lt;/strong&gt; execute at the current best price available, while limit orders are placed to buy or sell a security at a specific price.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stop orders&lt;/strong&gt; are also alternatively called stop-loss orders, which is an order to buy or sell an instrument once the price of the instrument reaches a specified price, known as the stop price.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Iceberg orders&lt;/strong&gt; are an order type that slices orders of larger quantity (or value) into smaller orders, where each small order, or leg, is sent to the exchange only after the previous order is filled.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fill or kill (FOK)&lt;/strong&gt; orders are an order to buy or sell a security that must be filled in its entirety or else canceled.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Immediate or cancel orders (IOC)&lt;/strong&gt; are an order to buy or sell a security that attempts to execute all or part immediately and then cancels any unfilled portion of the order.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;quants-technical--fundamental-analysis&#34;&gt;Quants, Technical &amp;amp; Fundamental Analysis&lt;/h2&gt;
&lt;p&gt;Now let’s look at the difference between quants and technical and fundamental analysis.&lt;/p&gt;
&lt;p&gt;• &lt;strong&gt;Quants&lt;/strong&gt; use mathematical and statistical models to analyze financial data and make predictions.&lt;/p&gt;
&lt;p&gt;• &lt;strong&gt;Technical analysi&lt;/strong&gt;s is the study of past price movements and trading volumes to identify patterns and make predictions about future price movements.&lt;/p&gt;
&lt;p&gt;• &lt;strong&gt;Fundamental analysi&lt;/strong&gt;s is the study of economic and financial factors that can affect the price of a security.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; is a programming language used by quants and traders to develop algo trading systems. It has libraries for data analysis, machine learning, and quantitative analysis.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Strategies&lt;/strong&gt; are the core of algo trading.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They are the set of rules and conditions that define when and how to enter and exit a trade.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Backtesting&lt;/strong&gt; is the process of testing a strategy on historical data to evaluate its performance. Paper trading is the practice of simulating the trading of securities without using actual money.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;In conclusion, algo trading is a form of automated trading that allows traders to execute orders with speed and precision. It helps traders to identify and react to market opportunities faster, reduces emotions, and increases discipline.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Git states</title>
      <link>https://akarsh.micro.blog/2023/03/14/git-states.html</link>
      <pubDate>Tue, 14 Mar 2023 16:58:31 +0530</pubDate>
      
      <guid>http://akarsh.micro.blog/2023/03/14/git-states.html</guid>
      <description>&lt;p&gt;Broadly speaking, there are three states in which your files can be: modified, staged and committed. It is crucial to understand these terms, which will help in familiarizing yourself with the git environment&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Modified:&lt;/strong&gt; This refers to the state when you have made changes to the file but you have not committed the changes yet.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Staged:&lt;/strong&gt; It means that you are ready to commit the changes you have made in your file, marked as modified.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Committed&lt;/strong&gt;: It indicates that the data is stored in your local database.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/m2vlW7sdylYJb54Um0Dzpe2E.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;starting-a-new-project-with-git&#34;&gt;Starting a new project with git&lt;/h2&gt;
&lt;p&gt;Let’s Begin by Creating a Local Repository (Execute the command in a Cell) and simultaneously see how to “commit”, which is creating a snapshot of the entire state of the project at a moment. Github helps you create a remote repository.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Random trivia:&lt;/strong&gt; Github has recently changed the name of “master” branch to “main” due to cultural sensitivity around slavery.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git init
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;output&#34;&gt;output&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;Initialised empty Git repository in D:/git_training/.git/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Exclamation Mark ensures that the command is executed as a Terminal Command. The output shows that we have created a local Empty git repository.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git status
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We should be able to evaluate the status of the created repository using the &lt;strong&gt;Status&lt;/strong&gt; command&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git status
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This would allow us to check the current status of our Repository at any point in time.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/m_yETelptRTYsjSrYzsNR2jr.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Let’s add a New File to the Folder called &lt;strong&gt;hello.txt&lt;/strong&gt; which has a sample text inside it.&lt;/p&gt;
&lt;p&gt;Execute the following to see if Git has started tracking changes.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git Status
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Output should be something similar to this.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/WgYc38v96YF1HhaemC1BNXC5.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;This is very informative. Let us evaluate each of the messages before proceeding further.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;On branch master:&lt;/strong&gt; It means that we are currently working on the master branch&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No commits yet:&lt;/strong&gt; We have not made any commits to the repository so far&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Untracked files:&lt;/strong&gt; This shows that git was able to find some files which are part of the folder that git is trying to track&lt;/p&gt;
&lt;p&gt;Git Branch&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A &lt;strong&gt;branch in Git&lt;/strong&gt; is simply a lightweight movable pointer to one of these commits. The default &lt;strong&gt;branch&lt;/strong&gt; name in &lt;strong&gt;Git&lt;/strong&gt; is &lt;strong&gt;master (now main)&lt;/strong&gt;. As you initially make commits, you’re given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git Commit
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Git Commit&lt;/strong&gt; - Commits are created with the &lt;em&gt;git commit&lt;/em&gt; command to capture the state of a project at that point in time. The most recent state of the project is called &lt;strong&gt;HEAD.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Effectively we are trying to achieve the following workflow:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/R20t2Lby2eFbXhXMd1KiLzbP.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;We will now add the files that are currently untracked.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git add .  Git status
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will be adding the un-tracked listed above in our repository. Notice the &lt;strong&gt;.&lt;/strong&gt;; at the end. This is to select all the files. Alternatively, file names can be specified.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/kLzzzS3OHNb0pWT8kUDGVI9n.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;The status has not changed to &lt;strong&gt;No Commits&lt;/strong&gt; which specifies that changes are yet to be committed to the branch master.&lt;/p&gt;
&lt;p&gt;Before we start committing Git needs to know who we are in order to maintain a name and email ID along with the commits. Execute the following before making a commit. &lt;strong&gt;This is a One Time Activity&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git config --global user.email &amp;quot;you@example.com&amp;quot;
git config --global user.name &amp;quot;Your Name&amp;quot;```
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, let&#39;s &lt;strong&gt;Commit&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git commit -m &amp;quot;Initial Commit&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;hyphen m&lt;/em&gt; specifies the comment that should be added to commit. Consider it like a changelog that a user can maintain.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/czZ7uqvdeCxjexWv0YNyOyuC.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;The following message confirms that 1 file was changed with 2 lines added into the Git version system. Furthermore, we can track &lt;strong&gt;Git Status&lt;/strong&gt; which we have already learnt.&lt;/p&gt;
&lt;h2 id=&#34;working-with-remote-repositories&#34;&gt;Working with remote repositories&lt;/h2&gt;
&lt;p&gt;Github allows you to create remote repositories which can move the project from local to a remote repository.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Git push
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://slabstatic.com/prod/uploads/ig8k00bf/posts/images/OnpluRmksssfVrCEzYvkR-J7.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;After you are done committing your code, it is time to populate your remote repository on Github. This can be done with the &lt;strong&gt;Push&lt;/strong&gt; command on git. If you are working on the master branch and pushing code to the origin repository, then:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git push origin master
Git pull
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An easy way to copy an entire repository on a remote repository is to use &lt;strong&gt;git clone&lt;/strong&gt; with the link to the repository on Github. If you would like to download content from a remote repository and match your remote repository to it, you can use &lt;strong&gt;git pull&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git pull origin master
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You would be accustomed to &lt;strong&gt;pulling requests&lt;/strong&gt; while working in teams. This helps to ensure that contribution by a member is done without affecting the entire workflow and it also acts as a system of the check so that the original repository is not negatively impacted.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
