<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' 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">
  <channel>
    <title>Josep</title>
    <description></description>
    <link>https://dbadailystuff.silvrback.com/feed</link>
    <atom:link href="https://dbadailystuff.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="dbadailystuff.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Thu, 25 Oct 2018 15:07:23 +0200</pubDate>
    <managingEditor>josepmv@gmail.com (Josep)</managingEditor>
      <item>
        <guid>http://dbadailystuff.com/parse-zipped-postgresql-s-logs-and-save-them-in-a-parquet-file#44760</guid>
          <pubDate>Thu, 25 Oct 2018 15:07:23 +0200</pubDate>
        <link>http://dbadailystuff.com/parse-zipped-postgresql-s-logs-and-save-them-in-a-parquet-file</link>
        <title>Parse zipped PostgreSQL&#39;s logs and save them in a parquet file</title>
        <description></description>
        <content:encoded><![CDATA[<p>I&#39;m administrating a large number of PostgreSQL&#39;s servers and I get their logs zipped. To analyze them I&#39;ve done a Spark task for:</p>

<ol>
<li>Unzip the files</li>
<li>Parse then logs of PostgreSQL</li>
<li>Save (append) the data into a parquet file</li>
</ol>

<p>In a following post I will show how to query them to get usefull information.</p>

<h1 id="postgresqls-logs-format">PostgreSQL&#39;s logs format</h1>

<p>The log format specified in the PostgreSQL&#39;s config file is the following:</p>

<p><code>log_line_prefix = &#39;%t %a %u %d %c &#39;</code></p>

<p>Special values:</p>

<ul>
<li>%a = application name</li>
<li>%u = user name</li>
<li>%d = database name</li>
<li>%t = timestamp without milliseconds</li>
<li>%c = session ID</li>
</ul>

<h1 id="code">Code</h1>

<p>The code can be found in a Jupyter Notebook in <a href="https://github.com/josepmv/dbadailystuff/blob/master/Parse%20zipped%20PostgreSQL&#x27;s%20logs%20and%20save%20them%20in%20a%20parquet%20file.ipynb">my GitHub</a>.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://dbadailystuff.com/percentage-of-time-series-over-its-sma-simple-moving-average-compared-against-a-weighted-index#44535</guid>
          <pubDate>Tue, 09 Oct 2018 10:33:29 +0200</pubDate>
        <link>http://dbadailystuff.com/percentage-of-time-series-over-its-sma-simple-moving-average-compared-against-a-weighted-index</link>
        <title>Percentage of time series over its SMA (Simple Moving Average) compared against a weighted index</title>
        <description></description>
        <content:encoded><![CDATA[<h1 id="problem-with-weighted-indexes">Problem with weighted indexes</h1>

<p>One problem with weighted indexes is that few components of the index can move its value when the value of few components is much bigger than the others. That could give misleading conclusions. For example, when small weighted components are not following the trend of the big ones. Some scenarios where we can see that are:</p>

<ul>
<li>Stocks.</li>
<li>House prices.</li>
</ul>

<h3 id="stocks">Stocks</h3>

<p>When a market value-weighted index like SP&amp;500 is going up, one could think that all the stocks are going up. But sometimes few stock weight a big percentage of the index. Currently few tech companies have a high percentage on SP&amp;500.</p>

<h3 id="house-prices">House prices</h3>

<p>House market valuations often are made taking into consideration the number of sales of the zone / country (that would be like an index) and that would have the same effect as a weight index where each city would be like a stock and the country like an index. But big cities usually are more expensive than small cities and villages and they might even behave different. Currently in Spain, cities like Barcelona and Madrid prices are all times high while in some rural zones the prices haven&#39;t raised after the 2008 real state crisis. These differences can also happen in neighborhoods in big cities.</p>

<h1 id="possible-solution-percentage-of-time-series-over-its-sma-simple-moving-average-compared-against-a-weighted-index">Possible solution: Percentage of time series over its SMA (Simple Moving Average) compared against a weighted index</h1>

<p>A <a href="https://en.wikipedia.org/wiki/Moving_average">SMA (Simple Moving Average)</a> is often used to reduce the fluctuation of a time series and also to see its trend easily, when current value is over or under the SMA. This can be applied to any type of time series.</p>

<p>So knowing the percentage of time series over its SMA might be a good way to evaluate the health of the whole market and not only the heavy weighted components if we just look the index. In fact, comparing it with the index can be quite insightful.</p>

<h1 id="sp500-and-its-components">SP&amp;500 and its components</h1>

<p>As an example, I will use the S&amp;P500 Stock Market Data, where some <a href="http://www.kaggle.com/camnugent/sandp500/data">quotes are available in Kaggle</a>, to calculate the percentage of stocks over their SMA of 30 weeks and compare it with SP&amp;500.</p>

<p>The code can be found in <a href="https://github.com/josepmv/dbadailystuff/blob/master/percentage%20stocks%20over%20a%20simple%20moving%20average%20compared%20against%20a%20composite%20index.ipynb">my github</a>.</p>

<p>The final plot is this:</p>

<p><img alt="Silvrback blog image " src="https://silvrback.s3.amazonaws.com/uploads/b724352e-57c8-43af-a1c6-4c12529892e6/sp500_vs_percentage_components_over_sma30w.png" /></p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://dbadailystuff.com/print-markdown-in-the-html-widget-using-markdown-package#42086</guid>
          <pubDate>Fri, 17 Aug 2018 10:30:07 +0200</pubDate>
        <link>http://dbadailystuff.com/print-markdown-in-the-html-widget-using-markdown-package</link>
        <title>Print Markdown in the HTML widget using Markdown package</title>
        <description></description>
        <content:encoded><![CDATA[<p>I&#39;ve uploaded a <a href="https://github.com/josepmv/dbadailystuff/blob/master/Print%20Markdown%20in%20the%20HTML%20widget%20using%20Markdown%20library.ipynb">Jupyter Notebook in Github</a> explaining two ways to print Markdown in a Jypyter Notebook:</p>

<ul>
<li>Using the IPython <code>Markdown()</code> class.</li>
<li>Using the <a href="https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#HTML">HTML ipywidget</a> and the <a href="https://pypi.org/project/Markdown/">markdown package</a>.</li>
</ul>

<p>The first option is straightforward, but the second one is much more powerful because can be used with other widgets, as shown in the following screenshot:</p>

<p><img alt="Silvrback blog image " src="https://silvrback.s3.amazonaws.com/uploads/d3170b15-09ce-4fea-8722-dfa217920bc5/print_markdown_with_ipywidgets.png" /></p>
]]></content:encoded>
      </item>
  </channel>
</rss>