teleren/devto huggingface dataset:
How to fetch Stock Data using PANDAS DATAREADER in Python?
Tags: python, beginners, api, programming
Published: 2021-10-12 08:39:49

You can perform marvelous and creative things in Python and, it's a vast community. The more you go deeper, things start becoming fascinating.

Today in this article we are going to fetch Stock Data in Python using PANDAS DATAREADER from various Sources.
So, it's going to be amazing :)

![Python](https://cdni.iconscout.com/illustration/free/thumb/programming-1970022-1662901.png)

### ◼️Installing Raw Packages
- First you need to install raw packages in Python like NumPy, Pandas, Plotly and Pandas Datareader.<br>

<h4>NumPy Installation using CMD</h4>
```cmd
pip install numpy
```
<h4>Pandas Installation using CMD</h4>
```cmd
pip install pandas
```

<h4>Pandas DataReader Installation using CMD</h4>
```cmd
pip install pandas-datareader
```

<h4>Plotly Installation using CMD</h4>
```cmd
pip install plotly==5.3.1
```
<hr>
### ◼️After Installing Raw Packages let's import it in Python File
- Create a Python Notebook File [.ipynb extension after file name]

```python
# Raw Packages
import numpy as np
import pandas as pd
import plotly.graph_objs as go
```
```python
# Data Sources
from pandas_datareader import data,wb
```
```python
# Convert date in right format
# Today's date as variable
from datetime import date
```
```python
# Start Date means from which date we want to start fetching Stock Data?
# End Date means till which date we want to fetch Stock Data?
startdate = pd.to_datetime('2018-07-15')
enddate = pd.to_datetime(date.today())
```
<hr>
### ◼️Importing Stock Data from Yahoo
- Pandas Datareader plays a important role in it. How? See, DataReader consider four Parameters - <b>Ticker Name[Stock Name],Source name[Yahoo],Start Date, End Date</b>.
- Source Name actually means from where you want to fetch Data?
```python
# For Indian NSE Stocks use .NS after Stock Name
# Example:
# data.DataReader("INFY.NS", 'yahoo', startdate, enddate)
data.DataReader("SPY", 'yahoo', startdate, enddate)
```
![Yahoo Finance Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b812oixngrb2qf0di558.jpg)
<hr>

### ◼️Importing Stock Data from Google Finance
```python
# Just Changing our Source name in Second Parameter
# data.DataReader("INFY.NS", 'yahoo [Changing to stooq for Google Finance]', startdate, enddate)
data.DataReader("AAPL", 'stooq', startdate, enddate)
```
![Google Finance Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jn8cqx97bntpcmdr06h.jpg)

### ◼️Importing Stock Data from AlphaVantage
- For using this you need to register your account on <a href="https://www.alphavantage.co/">AlphaVantage</a> and get your API key
```python
# Forex Data
# Conversion from GBP to USD
data.DataReader("GBP/USD",'av-forex',startdate,enddate,api_key='YourAPIKEY')
```
![AlphaVantage Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vaiy4n0vxectjyshawrs.jpg)

<h6>Hope you this Post was helpful to you 😁🤘</h6>
See you soon in next Post till then GoodBye👋
Introducing KuberLogic – an open-source platform that deploys and manages self-healing PaaS on top of any K8S cluster.
Published: 2021-10-12 08:19:27

Kuberlogic is a new PaaS model platform for deploying, managing, and scaling software hosted on the Kubernetes cluster. The solution provides API, monitoring, backups, and integration with SSO right out of the box. Check out the website for more info: https://kuberlogic.com/kuberlogic-new-open-source-paas-solution-from-cloudlinux/
Failed to create bus connection: No such file or directory Hatası Çözümü
Tags: linux, debian, centos, dbus
Published: 2021-10-12 08:04:48

Merhabalar, bugün benim de karşılaşmış olduğum ufak bir sorunun çözümünü sizlere sunacağım. Umarım faydalı olur.

Bu hata ile karşı karşılaşanlar genelde aşağıdaki iki komutu çalıştırdığında karşılaşmakta:
- hostnamectl
- timedatectl

Komutlar çalıştırıldığında ise aşağıdaki gibi bir output döndürmekteler.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pd2h1qpq9xkiuq8gka2l.png)

Bu sorunu çözebilmek için öncelikle **dbus** adlı servisin çalıştığından emin olunmalıdır.

``` 
systemctl status dbus
```

Eğer bu komut sonrası dönüt aşağıdaki gibi ise servisin bulunmadığını söylemektedir.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lwn3emb8xlzbn51dcmz.png)
 
Bu durumda aşağıdaki komut ile servis yüklenir:
```
apt install dbus
```

Sonrasında servis otomatik olarak active hale gelmiş olabilir. Yine de kesinlik kazandırmak için servisi başlatmalı ve "enable" hale getirmeliyiz. Böylelikle makine her başladığında çalışır duruma gelebilmektedir.
``` 
systemctl start dbus
systemctl enable dbus
```

Eğer "systemctl status dbus" komutunun dönütü aşağıdaki gibi ise servis bulunmakta fakat aktif olmadığı anlamına gelmektedir.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ncrmbcftcyho77fin9k.png)
 
Servis aktif edilir:
``` 
systemctl start dbus
```

Böylelikle dbus servisi sorunu çözümlenmiş olur. Eğer bu işlemlere rağmen çözüm sağlanılmamış ise bunun sebebi /var/run ile /run arasındaki gerekli symbolic linkin bozulmuş olması olabilir. Bunun için aşağıdaki komutlar çalıştırılır ve servisin durumuna bakılır:
```
sudo rm /var/run -R
sudo ln -s /run /var
sudo reboot
```
Refactor time convertion from postgresql to php.
Tags: tutorial, tip, php, postgres
Published: 2021-10-12 08:02:55

In my application I had the following query:

```sql
select 
  appointment.doctor_id,
  appointment.date,
  date_part('epoch',appointment.date::DATE + schedule.time_zero - INTERVAL '2 hours')::INT AS date_that_should_have_booked_in_unix_time
from
  appointment
join
  schedule on appointment.schedule_id = schedule.id
order by date asc
```

With the query above I retrieve the overbooked appointments for a doctor's schedule. I wanted to refactor the part of the query:

```sql
date_part('epoch',appointment.date::DATE + schedule.time_zero - INTERVAL '2 hours')::INT 
```

Into php, then I will run a test to ensure that the refactored code follows the original query. 

The test is:


```php
use Carbon/Carbon;
use PDO;

//Code here with initialized database connection and appropriate mocks

// Instead of fixed string assume that values come from db
$date_that_should_have_booked_in_unix_time = new Carbon('2021-12-10')->setTime('13:00:00');

$sql =<<<SQL
select 
  appointment.doctor_id,
  appointment.date,
  date_part('epoch',appointment.date::DATE + schedule.time_zero - INTERVAL '2 hours')::INT AS date_that_should_have_booked_in_unix_time
from
  appointment
join
  schedule on appointment.schedule_id = schedule.id
order by date asc
SQL;

/**
* @var PDO $dbh
*/
$result = $dbh->query($sql);

$this->assertEquals($result->date_that_should_have_booked_in_unix_time,$date_that_should_have_booked_in_unix_time->unix());

//Yes some other code here
```

As you will see the test will fail. A reason why is because Carbon's takes by default local time zone and before converting the time into unix time it converts it first into UTC time.

What we need to do is specifically to set the time and date into UTC regardless the time zone so the test above to work.

Therefore the line of code above:

```php
$date_that_should_have_booked_in_unix_time = new Carbon('2021-12-10')->setTime('13:00:00');
```

Must be written:

```php
$date_that_should_have_booked_in_unix_time = new Carbon('2021-12-10','UTC')->setTime('13:00:00');
```

So we bypass the timezone convertion and we get the local time into appropriate unix time.
100 algos in 100 days (Day 27)
Published: 2021-10-12 07:56:16

###Max Stack

This is in a few places as having a stack which keeps track of the min/max

Here we set up two stacks simultaneously in the MaxStack class. With some logic we only push to the MaxStack if the number is greater. Only pop if we are popping the top value of the MaxStack too.

I am always tempted to add properties to the class but it seems the solution rarely does this.

Also, remember if they give you an implementation of a class already then use it!
CosmosDB: FROM Property
Tags: azure, cosmosdb, andreacarratta, clouddevelopment
Published: 2021-10-12 07:54:15

🌎 CosmosDB: FROM Property

🧪 Hai mai sperimentato la select dalle Property?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ay4gaojlnyywdj3sr6g2.jpg)

Come promesso oggi è arrivato il primo articolo della settimana sul mio blog.  Di cosa si tratta?

Ho deciso di mostrarvi un piccolo -ma a mio avviso utile- tips per le interrogazioni in CosmosDB.

🤫 Sfruttando questa tecnica potrete ottenere tutti i valori associati ad Property senza fare scorrere tutti i documenti presenti all'interno del container. 

Se volete scoprire come, non dovrete fare altro che leggere il tips sul mio blog ...

[CosmosDB: FROM Property](https://links.devandreacarratta.it/5-tN)

Happy cloud!
Flutter General Page Structures
Tags: flutter, dart
Published: 2021-10-12 07:49:13

In this lesson, we will talk about the widgets we use while designing our screen in Flutter in general, and their features and usage areas. In other words, we can say that they are structures where we adjust how we place our elements, such as a little alignment and button/image. It may also be the bone structure. We will cover page design, widget design and features.

## Center

First, we can start with the Center widget. Center widget means **align center**. It places the enclosed element in the *center of the screen*. And since the Center widget can only have *one widget*, it uses *child*.

As an example, you can try writing the code and how it looks like below:

```dart
const Center(
        child: Text(
          "Baransel Arslan",
          style: TextStyle(fontSize: 20),
        ),
      )
```

If you write the code in the body part of `Scaffold`, we can notice that the `Text` widget it contains is located in the center of the page, as we can see below.

<img alt="Flutter Center widget" src="https://baransel.dev/post/flutter-general-page-structures/center-flutter.png" style="height:75%;width:75%;"/>

## Container
Continue this post on my blog! [Flutter General Page Structures](https://baransel.dev/post/flutter-general-page-structures/).
Create Find My Location Application using HTML CSS & JavaScript.
Tags: javascript, webdev, html, css
Published: 2021-10-12 07:30:28



* What is GeoLocation API 

* Practical usage of Callback functions 

* Promise over Callback 

* Implementing Dark Mode and Light Mode

#javascript #geolocator #html #css 

{%youtube wEx0Iu5kAzQ%}

Timeline :
00:00 Introduction 
00:12 Demo of Find My Location Application 
00:48 Launching VSCode from command prompt 
01:00 Creating Application Files & HTML Coding 
02:12 Introduction to Geo-location API 
04:01 Practical usage of Callback function 
07:30 Promise 
09:54 geocode.xyz/ API Location details 
14:20 Country API 
17:13 Recap on Location details part 
18:40 Create HTML Markup and Styling 
20:09 linear-gradient() background & CSS gradient generator
23:27 Apply Google Font
25:28 Rending data on Screen 
28:16 Toggling Dark & Light Mode
Factorial
Tags: codechef, programming, math, java
Published: 2021-10-12 07:27:54

[Click Here to read Problem Statement ](https://www.codechef.com/problems/FCTRL)

**Input:**
There is a single positive integer T on the first line of input (equal to about 100000). It stands for the number of numbers to follow. Then there are T lines, each containing exactly one positive integer number N, 1≤N≤109.

**Output:**
For every number N, output a single line containing the single non-negative integer Z(N).

**Sample Input:**
6
3
60
100
1024
23456
8735373

**Sample Output:**
0
14
24
253
5861
2183837 

**Solution:**
To run code [click here](https://gouravmk.hashnode.dev/factorial)
```
import java.util.*;
public class Template {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum1=0;

int arr[] = new int[n];
for(int i= 0; i<n;i++) {
	arr[i] = sc.nextInt();
}

for(int i = 0 ; i<n; i++) {
	if(arr[i]<5) {
		System.out.println("0");
	}else {
		
		int temp = arr[i];
		
		while(temp != 0) {
			temp = temp/5;
			sum1+=temp;
		
		}
		
		System.out.println(sum1);
		sum1=0;
		temp=0;
	}
}
sc.close();
}
}
```
Merges and conflicts
Tags: opensource, javascript, osd600
Published: 2021-09-30 20:31:22

## New features
In the last update, my friend - Dustin - helped to add Markdown as a valid input for [my tool](https://github.com/minhhang107/mh-ssg). Markdown syntaxes are different from HTML syntaxes and he has worked on converting some of them. This time I decided to add two more: 
1. [inline code](https://github.com/minhhang107/mh-ssg/issues/8) 

2. [horizontal rule](https://github.com/minhhang107/mh-ssg/issues/9)

The implementation was quite simple. I created two `regex` to find any instances of the `single backticks` and `---`, then used `replace()` to update them into `<code>...</code>` and `<hr>` respectively.
    

## Working with merges
I created two new branches for the two features so I could work on them separately. The first branch to resolve [issue-8]() was a simple [fast-forward merge](https://github.com/minhhang107/mh-ssg/commit/bca2d96119c251e6d18894c2f460f51dc1719b65). 
As I tried to merge the second branch, the terminal gave me a warning message of conflict. I used VSCode to compare the differences and decided that I needed both changes. I realized that even if I choose `Accept both changes` in VSCode, I still need to double check and modify the code so that the two changes would fit together. Then the second branch was successfully merged with the [3-way recursive merge](https://github.com/minhhang107/mh-ssg/commit/813e9f844b937ec78235930172cea493f5acb7dc) into the `main`.

## Final thoughts
This week, I've got a better idea of how `branches` and `commits` connect with each other. I also learned how `branches` work, how they are created and merged.
When seeing the conflict, I also tried using `git diff` to identify the conflicts. It's a quick way to review if the difference is small (eg: a few lines of code), but I think it would be overwhelming if the 2 branches have lots of difference. In such cases, using other text editors that provide visual comparison (eg: VSCode) can make it much easier to track the changes since we can compare them side by side.
Easy Button: Not So Easy
Published: 2021-10-12 06:50:10

There is a lot that goes into developing a deceptively simple CTA button built on JavaScript. There is a lot to consider in each stage of the process without leaving design holes. For a team project, I worked on creating a button that would be rendered onto a web page.

## Troubles
At first our team was not sure how to properly edit the styles built into the open-wc boilerplate that we started on. We assumed that we needed to implement constructors a certain way, coming from Java programming, but using CSS was enough for styling.

## Successes
The team's design process for the button was relatively smooth. The button started out similar to the one provided in the open-wc boilerplate. We knew what the design consideration was from the outset, which is going to be a red Staples "That Was Easy" button.

## What I Learned
I learned how different the development process is with web components as opposed to Java or Python programming. Writing states and attributes to create the CTA experience required some out-of-the-box thinking. In the future, we would like to add more attributes to enhance the experience, particularly for on-click functions.

Repo: https://github.com/Viable-Slime/Button
What is Javascript's closures ?
Tags: javascript, webdev, tutorial
Published: 2021-10-12 05:07:53

If you are a Javascript developer. It's 99.9% likely that you might have used closures, but might not clearly know what was closures.

Let's try to understand it in this article 😉.

## What is Javascript's closures ? 🤔

The definition of closures in MDN docs says : 

**A closure is a combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.**

You can see [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) 😄.

Now, let's try to make it clearly and understand it 💐.

We have *index.js* file and here code of it is in below.
```
const myName = 'Ray'

// I used arrow function here. (ES6)
const printName = () => {
   console.log('My name is : ' + myName);
}

printName();
```
If you're a developer, you probably know the result.
Right 😉, the result will be : 
```
My name is Ray
```

You probably don't realize that code block above is using **closures** 🤗.

### 🥳 Let's break code block above down 🥳.

The way closures works in Javascript is that every scope has access to everything outside of its scope. For example :
You have a file *index.js* above, it is one scope. You also have **printName** function is another scope.
You can see **myName** is an external variable outside **printName** function. But it's acctually available inside **printName** function.

One more thing that's really interesting here 🥳.
Let's change code block above to code block below.
```
let myName = 'Ray'

// I used arrow function here. (ES6)
const printName = () => {
   console.log('My name is : ' + myName);
}

myName = 'TaiMD99'

printName();
```
When you run this code, the result will be
```
My name is TaiMD99
```
The **printName** function is not taking value of **myName** that is defined when it is defined. It's actually taking the current live value of **myName** variable.

I hope that this article is useful for you and helps you to clearly understand Javascript's closures and how it works 🥳🥳🥳.

If you have any question about Javascript's closures, comment below.

## Thanks for reading 🙏.
Reflections on Passing AWS Solutions Architect Associate Exam
Tags: aws, beginners, certificate, programming
Published: 2021-10-12 06:21:11

_With the distribution of remote work, one has more time for personal and career development. Since winter 2020, I have been working entirely remotely. It gave the enormous possibilities to excel career-wise also._

Cloud certifications are significant in terms of structuring the knowledge and improving it. 
I started with AWS in 2018 with the corporate program for upskilling the employees by nurturing the program of certification. 
With zero experience back then, I passed the [AWS Developer Associate exam](https://igorsoroka.medium.com/how-i-passed-aws-certified-developer-associate-exam-44085cec18b9).

### Community

People are social creatures. That is why we need to go and do something together. I did my first certificate with my peers from the big company. Many people also did the same studies. Most of them had zero or minimal knowledge of the AWS ecosystem. The atmosphere was very supportive.

This time I studied alone with no extrinsic motivation like extra cash to the salary because of my contracting endeavors. However, I have created a challenge with a couple of people from the community. There we were posting every day about the actions for the studying. It was looking like that:

```
Watching lecture on Cloud Guru about Load Balancers - 30 minutes #dayN
```

### Consistency and Passive Learning

I had doubts in the middle of the challenge that it would work. But the everyday work on the topics related to the exam helped to be in the context. Our brain is wired to like repetitive things. 

Another point relates to the idea of learning when one is not focused primarily on the task. During this certification, I studied more while doing my jogging routine or driving. If the topic is familiar to the person, it will be beneficial to listen without watching. I think summary videos of ACloudGuru courses were helpful.

### Big Picture

The questions in the Solutions Architect exam are more scenario-based. I have experience with passing the Developer one. It is important not only how to use services in combination. The key for passing is to look at the interaction between the elements together with the technical requirements.

For the practice in architecting, it would be great to watch short videos on the various topics ([This is my architecture](https://aws.amazon.com/architecture/this-is-my-architecture.)). At least, it gives the idea of how to think in scenarios and particular situations. Exam-wise, practice tests are helping for solving cases. The official one from the AWS itself or Udemy ones.

### My tips on passing the exam

- Course on preparation - ACloudGuru or CloudAcademy
- Focus on practical knowledge
    - QwikLabs
    - Above mentioned cloud schools
- Topics: VPC (very important to know how to set up end-to-end), On-premises migration and integration, Storage options for S3, EBS/EFS difference and types, Auto-scaling groups, EC2 types usage scenarios
- Practice Exams (Udemy course or [book](https://www.amazon.com/dp/111950421X/))
Its time to learn Typescript
Tags: webdev, typescript, beginners, opensource
Published: 2021-10-12 05:57:41

Javascript has been a very popular language. From being a scripting language that used to run in a browser to having node runtime environment has taken it to another level. At present we can build scalable website with js libraries like `react` and also build cross platform mobile applications with `react-native`. In the backend we can develop highly scalable api with `express` and so on. That means we can do everything with javascript. 

Despite of being very popular javascript has got some drawbacks. In order to overcome these Microsoft introduced an open source language named Typescript which is a superset of javascript. It has got a good number of benefits over javascript. Lets point out those in brief here.

- As ts is a superset of js, we can easily start learning ts in an existing js project. We can start by simply replacing `.js` extions to `.ts`.
- The main purpose of ts is `Type Safety` which means we must assign types to a data. This has made the life of every js developer easier by thousand times. Javascript has [many weird functionalities](https://dev.to/alim1496/some-interesting-facts-about-javascript-1apg) and almost all of these can be eradicated by assigning scrict type to each data.
- Typescript supports classes, inheritances and interfaces. This feature ease all object oriented programmers a lot.
- We can detect type errors in compile time with the help of ts. In larger projects this saves a lot of time and work. IDEs like **VS Code**, **atom** etc have excellent support of ts.
- We can use ES6 and beyond features in ts and compiler will convert it to ES5 or our required version. This means all the latest features of js are fully supported by ts.
- Day by day the popularity of ts is increasing. Tech giants are using it and the number of contributors is also increasing. This yields a large community to get support from.
- Another very big advantage of ts is that we can use it with almost all popular js frameworks and libraries. We can use it with react, react-native and also in node js development.

So without any hesitation and delay we should learn this beautiful language and bring our skillset to another level.

Happy Learning!!!!