<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Derek Shing on Medium]]></title>
        <description><![CDATA[Stories by Derek Shing on Medium]]></description>
        <link>https://medium.com/@hpshing?source=rss-fd209fefcb2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3NufqUI_WuO5sMMd.jpg</url>
            <title>Stories by Derek Shing on Medium</title>
            <link>https://medium.com/@hpshing?source=rss-fd209fefcb2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:06:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hpshing/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Open Data — Real-Time Occupancy Status Of Parking Meter In Downtown Los Angeles]]></title>
            <link>https://medium.com/@hpshing/open-data-real-time-occupancy-status-of-parking-meter-in-downtown-los-angeles-e7584fefdba3?source=rss-fd209fefcb2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7584fefdba3</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[parking]]></category>
            <category><![CDATA[open-data]]></category>
            <dc:creator><![CDATA[Derek Shing]]></dc:creator>
            <pubDate>Fri, 20 Sep 2019 08:35:08 GMT</pubDate>
            <atom:updated>2019-09-20T08:46:57.726Z</atom:updated>
            <content:encoded><![CDATA[<h3>Open Data — Real-Time Occupancy Status Of Parking Meter In Downtown Los Angeles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dTvkRtaIZaF9-GC8Dd4jxg.jpeg" /></figure><p>If you travel in Downtown Los Angeles a lot, you will know that finding a parking space in that area is tough. At that moment, you will like to know where is the closest parking space available right now. Fortunately, The City of Los Angeles release some open data which make it possible.</p><h4>About the Data</h4><p>The City of Los Angeles have 2 open dataset about street meter. They are:</p><ul><li><a href="https://data.lacity.org/A-Livable-and-Sustainable-City/Parking-Meter-Occupancy/e7h6-4a3e">Parking Meter Occupancy </a>— Last known occupancy state of those City of Los Angeles Parking Meters equipped with occupancy detector sensors. Updated in real-time, as available.</li><li><a href="https://data.lacity.org/A-Livable-and-Sustainable-City/LADOT-Metered-Parking-Inventory-Policies/s49e-q6j2">LADOT Metered Parking Inventory &amp; Policies</a> — inventory of all on-street metered parking spaces in the City of Los Angeles. Includes Space/Meter ID, block-level address, hourly rate, metered time limit, meter operating hours, enforced parking restrictions, and coordinates.</li></ul><p>Combining these two dataset, we would be able to request the information like location, rate and, the most important, real time occupancy status of parking meter. We can then further filter our target meter, for example, those within 0.5 miles from a restaurant and display on a map.</p><h4>The Application</h4><p>To demonstrate some use case of the dataset. I create a simple web app that take an address as input and show all the vacant parking meter within 0.5 mile. <a href="https://laparkingmeter.herokuapp.com/address">Here is the web application link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*6D_-IJmX1DXXvA5nd7MykQ.jpeg" /><figcaption>Enter the destination address</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*88b3GbeUBK9bBk_UvMoz4A.jpeg" /><figcaption>Parking meter nearby are shown on the map (destination in red, meter in blue)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*X2E7qMGEIm7qZpOpbPz4Vw.jpeg" /><figcaption>Copy the address to your navigation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*wEX6abKOYfkmCmcTF_DMsQ.jpeg" /><figcaption>You find the vacant parking space! ^^</figcaption></figure><p>Finally, here is my <a href="https://github.com/derek-shing/LAParking">Github link</a>, enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7584fefdba3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Financial News Scraper (Part 2)]]></title>
            <link>https://medium.com/@hpshing/automated-financial-news-scraper-part-2-63323acd19ca?source=rss-fd209fefcb2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/63323acd19ca</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Derek Shing]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 18:05:17 GMT</pubDate>
            <atom:updated>2019-09-17T18:05:17.323Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last article, we have finished a function which can scrape the financial new in <a href="http://www.seekingalpha.com/">www.seekingalpha.com</a> and store in our Postgres database. However, we still need a person to manage the server and invoke the function manually which is not completely automated.Our goal is to create a pipeline that will gather financial news daily without any human operator involved. AWS lambda function is my solution. Below is the summary of steps to create this pipeline:</p><ol><li>Create a IAM Role</li><li>Create S3 account</li><li>Create a deployment packages</li><li>Upload the deployment packages to S3</li><li>Create Lambda function, using the created IAM Role and link the code to our deployment packages in S3</li><li>Use CloudWatch to schedule the lambda function to be executed daily.</li></ol><p>Below are some detail notes and screenshot in each main Steps:</p><h4>Create a IAM Role</h4><p>To create the simplest Lambda function, we can just click ‘create function’ in the console and use the default setting. However, our news scraper function depend on the packages such as request and sqlalchemy causing the file size excess 10MB. We must upload the deployment package to S3. A role that allow Lambda function to access S3 then become necessary.</p><p>Use the IAM role console to create a role, then attach the policy of S3 full access to the role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFH-44yFkK1c9eYSrsphWQ.png" /><figcaption>click IAM service in the main console</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQDAbTazjRH3f1PcaXk6Ng.png" /><figcaption>Click Role at the left menu then click Create role</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEfJgrdMRXV7I6X6dNM_pQ.png" /><figcaption>choose Lambda to allow lambda functions to call AWS services</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6dntDggUtzWQ1qV6IFY5w.png" /><figcaption>Attach the AmazonS3fullAccess policy to the role</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jf_oECRuDEiu8v9zMVqrAg.png" /><figcaption>Follow the step on the screen and you will create a IAM role</figcaption></figure><h4>Create S3 account</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rr5KiPyqvdDaLsOy69OTLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ekssh0k6sTQrFJ9LcdMA0A.png" /></figure><h4>Create deployment package</h4><p>A deployment package is a zip file containing your function and all of it’s dependencies. If you use pipenv to handling dependencies of your project, you can use the code below to get the dependencies file</p><pre>mkdir output<br>pipenv lock -r &gt; requirements.txt<br>pip install -r requirements.txt --no-deps -t output</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*I3KVITqEYeAN_iB0dbHwaw.png" /></figure><p>We then zip all the modules we want and upload to our S3 account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RbP1WxIEubf_MQk2pRYrzw.png" /></figure><h4>Create Lambda function</h4><p>Use the AWS console to create a lambda function and make sure:</p><ul><li>Use your newly created role as your execution role</li><li>link your code entry to your deployment package in S3</li><li>the Handler is the format of your function filename.function_name</li><li>Set your timeout to suit your function</li></ul><h4>Create schedule</h4><p>Finally , we can use the ‘Add tigger’ button to create our schedule. To create a daily schedule, we will choose CloudWatch Event and use cron to create the rule. Cron is a utility that used to schedule command. The format is like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*kbsNkO4JQejqkjgv.png" /></figure><p>My Cron expression is <strong>cron(0 17 * * ? *), </strong>meaning run the web-scrap function every day at 17:00.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63323acd19ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Financial News Scraper (Part 1)]]></title>
            <link>https://medium.com/@hpshing/automated-financial-news-scraper-part-1-31ece553cd57?source=rss-fd209fefcb2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/31ece553cd57</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Derek Shing]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 18:04:10 GMT</pubDate>
            <atom:updated>2019-09-17T18:04:10.191Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why?</h4><p>In any data analysis procedure, the data itself is obviously the core element. All the machine learning model can not work without training data. Hence, how to gather enough data become the first problem we need to tackle. Financial news is a source of valuable source of data in NLP within financial industry.The news itself worth a lot. That’s give us a reason to scrap the data and store in our own database, if better, automatically.</p><p>In this post, we will see how we can:</p><ol><li><em>Scrap the data we want from website</em></li><li><em>Preserve the data in AWS Postgres database</em></li></ol><h4>Step 1 : Scrape information using requests and beautiful soup</h4><p>First, import the libraries we need to use</p><pre><strong>from  </strong>bs4 <strong>import </strong>BeautifulSoup<br><strong>import </strong>requests</pre><p>Second, make a request to get the information from the website we want and use BeautifulSoup to parse it</p><pre>url = &quot;<a href="https://seekingalpha.com/market-news">https://seekingalpha.com/market-news</a>&quot;<br>page = requests.get(url)<br>soup = BeautifulSoup(page.text)</pre><p>Third, we need to understand the Website structure. We can right click on the element that we interested in and click<em> inspect</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQockJbZ5UOkcNcwTts-6w.png" /></figure><p>From the source code, We know the following:</p><p>The heading is the text in the &lt;a&gt; tag</p><p>the url is one of the attribute in the &lt;a&gt; tag</p><p>id and date are the attributes of the &lt;li&gt; tag</p><p>Hence , we can use the <em>find_all() </em>function to extract the information we want.</p><pre>news = soup.find(name=<strong>&quot;ul&quot;</strong>, attrs={<strong>&#39;class&#39;</strong>:<strong>&quot;item-list&quot;</strong>,<strong>&#39;id&#39;</strong>:<strong>&#39;latest-news-list&#39;</strong>})<br>root = “<a href="https://seekingalpha.com/">https://seekingalpha.com</a>&quot;</pre><pre>root = <strong>&quot;https://seekingalpha.com&quot;<br></strong>id_list = [i[<strong>&#39;id&#39;</strong>] <strong>for </strong>i <strong>in </strong>news.find_all(name=<strong>&#39;li&#39;</strong>, attrs={<strong>&#39;class&#39;</strong>:<strong>&#39;item&#39;</strong>})]<br>heading_list = [i.text <strong>for </strong>i <strong>in </strong>news.find_all(<strong>&#39;a&#39;</strong>)]<br>url_list = [root+i[<strong>&#39;href&#39;</strong>] <strong>for </strong>i <strong>in </strong>news.find_all(<strong>&#39;a&#39;</strong>)]<br>date_list = [i[<strong>&#39;data-last-date&#39;</strong>] <strong>for </strong>i <strong>in </strong>news.find_all(name=<strong>&#39;li&#39;</strong>, attrs={<strong>&#39;class&#39;</strong>:<strong>&#39;item&#39;</strong>})]<br>date_list2 = [i.split()[0] <strong>for </strong>i <strong>in </strong>date_list]<br>id_list2 = [i.split(<strong>&#39;-&#39;</strong>)[2] <strong>for </strong>i <strong>in </strong>id_list]]</pre><h4>Step 2 : connect to store data using sqlalchemy and AWS RDS</h4><ol><li>Import the packages from sqlalchemy:</li></ol><pre><strong>from </strong>sqlalchemy <strong>import </strong>create_engine<br><strong>from </strong>sqlalchemy <strong>import </strong>MetaData, Table<br><strong>from </strong>sqlalchemy <strong>import </strong>Column, String, Integer<br><strong>from </strong>sqlalchemy.ext.declarative <strong>import </strong>declarative_base<br><strong>from </strong>sqlalchemy.orm <strong>import </strong>sessionmaker</pre><p>2. Get all the information of the Database. These include endpoint, port number, user name, password and database name. Then create a connection string as the format below.</p><pre>POSTGRES_ADDRESS = ‘ ’ ## End Point<br>POSTGRES_PORT = ‘’ ##Port #<br>POSTGRES_USERNAME = “ ” ## CHANGE THIS TO YOUR PANOPLY/POSTGRES USERNAME<br>POSTGRES_PASSWORD = ‘ ’ ## CHANGE THIS TO YOUR PANOPLY/POSTGRES PASSWORD <br>POSTGRES_DBNAME = ‘ ’ ## CHANGE THIS TO YOUR DATABASE NAME <br># A long string that contains the necessary Postgres login information <br>postgres_str = (‘postgresql://{username}:{password}@{ipaddress}:{port}/{dbname}’.format(username=POSTGRES_USERNAME, password=POSTGRES_PASSWORD, ipaddress=POSTGRES_ADDRESS,port=POSTGRES_PORT, dbname=POSTGRES_DBNAME))</pre><p>3. Pass the connection string to create_engine function</p><pre>db =create_engine(postgres_str)</pre><p>4. Define a class in python that can match the table in the database.</p><pre>base = declarative_base()</pre><pre>class News2(base): <br> __tablename__ = ‘news’<br> new_id = Column(Integer, primary_key=True)<br> date = Column(String)<br> heading = Column(String)<br> url = Column(String)<br> summary = Column(String)</pre><pre>Session = sessionmaker(db) <br>session = Session()</pre><pre>base.metadata.create_all(db)<br>session.commit()</pre><p>5. For each of the record , create a instance of the ‘news’ object and use session.add() to insert the record to database.</p><pre><strong>for </strong>i <strong>in </strong>range(len(id_list2)):<br>    new = News2(new_id=id_list2[i], date=date_list2[i], heading=heading_list[i], summary=point_list[i],<br>                url=url_list[i])<br>    session.add(new)<br>    session.commit()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3K6DC8bwpeZTceKJeaX5qA.png" /><figcaption>Use database client to check the data in our database</figcaption></figure><p>Now, We have the function to scrape the data and save it in our database. Our next step will be invoke the function regularly and automatically. This can be achieved by using serverless service, in my case, AWS lambda function. We will see how to setup the AWS lambda function in the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31ece553cd57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Much Can You Earn By Flipping Supreme Products?]]></title>
            <link>https://medium.com/@hpshing/how-much-can-you-earn-by-flipping-supreme-products-371caa0dd59c?source=rss-fd209fefcb2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/371caa0dd59c</guid>
            <category><![CDATA[earnings]]></category>
            <category><![CDATA[fashion]]></category>
            <category><![CDATA[analysis]]></category>
            <dc:creator><![CDATA[Derek Shing]]></dc:creator>
            <pubDate>Fri, 08 Feb 2019 07:44:24 GMT</pubDate>
            <atom:updated>2019-02-08T07:44:24.962Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*Jxd9vMUIUjphe_uhcg2I6Q.png" /></figure><p>Background:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*B4XjS_6o0BhAqZdUyyUVNw.jpeg" /></figure><p>Supreme is an American skateboarding shop and clothing brand established in April 1994. Its brand name has gotten more popular in recent years because of its marketing strategy. Every Thursday during each season, Supreme will release a new drop of products. Because demand for these products is so high, many people can profit by buying and selling these products immediately online, the most popular site is StockX.com. The question is how much you can expect to earn?</p><h4>A College Student Can Earn $600 Every Week During The Season, Really?</h4><p>Supreme released 829 items at their drop day at 2018. Based on the asking price at StockX.com, a few individual products can bring you over $2000 in profits alone. Not only this, each of the top 20 products can bring you over $300 profit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*oWNvTgdPaBy0A1UsGrw_Rg.png" /></figure><p>One more surprise, there are 129 products which can generate over $100 by flipping them. If you flip each of them once, you can earn $46,393 extra in 2018. This chart shows how products were released over the last year</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*tKIjSkQn7EIO7OEs-IsOBg.png" /></figure><h4>Collaboration Is The King, Box Logo Is The Second</h4><p>Supreme worked with a number of companies to release their limited edition products. These products usually sold out in a second when released followed by a massive increase in price in the second market. Below are some examples of the partners company in 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*PCPn_mFEYyYnwdtTKdE9mw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*_CqsfG_zfFNMzntqVV2Q5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*Xshrdg4lRV8-fOSanbxUew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*1EUTTaQuXWCp0KtSS83a_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*mic0vaKdjBJOmzIUL4fWuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Mhzkx10EYaDZykICfSxsig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*Pfw0JL_XDw55mOt9fyRm0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*Uuk8Ooa5ti4CPll3qyGDAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*t8V5fy0zTK8WZqmPBRPzjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*4MbpgXSN3upAmfjemYb73Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*2fNL17A_kg5dQX_8uPJMtg.png" /></figure><h4>Reference:</h4><ul><li><a href="https://supremedatabase.com/">Supreme Database</a></li><li><a href="https://stockx.com/">StockX: Buy and Sell Sneakers, Streetwear, Handbags, Watches</a></li></ul><p>My Jupyter Notebook for web scrap:</p><p><a href="https://drive.google.com/open?id=1RViL35yrzU7qzAZ_f8gMFqigT1YZ4wJ_">https://drive.google.com/open?id=1RViL35yrzU7qzAZ_f8gMFqigT1YZ4wJ_</a></p><p>My Jupyter Noebook for Data analysis and visualization:</p><p><a href="https://drive.google.com/open?id=1umghAooZByZpkqH9E_kWmv8ucpXp5ui2">https://drive.google.com/open?id=1umghAooZByZpkqH9E_kWmv8ucpXp5ui2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=371caa0dd59c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>