Where can I get best return on investment?

Where can I get best return on investment?

5 minutes guide

Where should I start?

5 minutes guide to algorithmic trading

Where should I start?

22 March 2016

Welcome to your quick start guide on algorithmic trading 

Learning something new on the internet is like trekking in the amazon rainforest. The process is about as epic as you would imagine that to be. You may (sometimes) be lost.

 

The jungle...

— A welcoming jungle. — Photo by Ting Chang on Unsplash

Here, the objective is to avoid the Jungle Survival Training camp. This article does not pretend to be such a camp.

Instead, relax, take a comfortable seat and a good cup of coffee. (Of course, fill the cup with whatever you want.)

So, let me introduce a first post. A challenging one.

Why?

Three reasons. In only one article, you will:

      gather financial data automatically. You will be free to use it as you see fit.

      perform a simple financial performance indicator.

      Run a code. In 5 minutes, using Python.

A few words about Python and Finance. Here, you do not need to have any background in Mathematics and Finance. Concepts will be described in a simple and logical way.

You do not need to have any background in Python and Computer Science too. You just have to push a button “play” at the end. For sure, we will enter into the code line by line. I am pretty sure you will surprise your friends and family after reading this blog.

In this article, I am not offering investment, legal, or any other advice, nor am I trying to do so. This is only a tutorial for learning purposes. Any decisions, investments, or risks you take as a result of building a trading bot are your responsibility.***

In this article, I am not offering investment, legal, or any other advice, nor am I trying to do so. This is only a tutorial for learning purposes. Any decisions, investments, or risks you take as a result of building a trading bot are your responsibility.***

Data is the new gold

Well, let’s answer the question.  Where should I start ? 

“Where there is data smoke, there is business fire.” 

Thomas Redman

Before writing this post, I found this quote. Google is a wonderful tool to look for quotations (and other stuff). And this one perfectly fits my introduction.

 So, let’s determine where there is data smoke.

Actually, there is data everywhere. Sometimes free, sometimes not. A free solution is used for this tutorial. We will use Yahoo Finance.

Yahoo finance is powerful for gathering financial data. Although data is accessible directly via their website, we will use Python.

Phone a friend 

Why Python ?

No need to do manual manipulation in the website and in Excel. No need to repeat the process of gathering again and again. Everything is automated.  In other words, the dream of lazy.

More, we will use the library “pandas datareader”. Importing a library in Python is like using the lifeline “Phone a friend” in “Who Wants to Be a Millionaire?”. The friend is the coder who give you access to their code: freely and easily. Unlike the game show, there is no time constraint..

import pandas_datareader.data as web

I know if you are sitting comfortably, reading this line, you will get the key. The key is using the existing code to simplify and perform yours. the library “pandas datareader” is able to gather  data from Yahoo Finance in only one line of code.

start = dt.datetime(2020,6,1)
end = dt.datetime(2020,7,1)
tickers = ['IBM', 'TSLA']
data = {}
for t in tickers:
   data[t] = web.DataReader(t,'yahoo', start, end).reset_index()

Ok. We can get data. But what data?

A (not so) simple financial data : the stock price.

To keep it simple, a stock represents an ownership of a fraction  of a company. This fraction has a price, depending on who is buying or selling it. This is supply and demand. Every business day, every seconds, the price goes up or down.

Who is the best performer, in 3 steps

Here we are. The first use of data – with a simple indicator of financial performance.

The problem is not the data anymore but the exploration of the stocks’ performance.

Let’s take (randomly) the stocks of Amazon and Google. We will compare both stocks for the first semester of 2020.

Again, these two stocks have been chosen randomly for learning purposes. This is neither a stock analysis, nor an advice to invest. ***

Let’s open the arena to our two candidates.

Below is the graph. Are you able to determine who is the best performer?

   Step 1.  

Compare the price evolution.

At first glance, comparing the price evolution in the graph is not explicit.

We cannot say who is the best performer between the 2 stocks.

   Step 2.  Get the monthly return and compare.

The simplest indicator in Finance is the return.

A return is the change in price on a valuable object over time, which may be represented in terms of percentage change.

To make it simple, you own a precious chair valued at 100. If next month the value is 110, you could make a profit of 10. A profit of 10 for a value of 100 is then considered as a 10 per 100 return.

Comparison is the main advantage of percentage return.

Would you like to get an overview on the 6-month period?

Comparing monthly returns, month by month is not visually attractive.

   Step 3. To have a global view: get the cumulative return.

The solution is summing the monthly performance (i.e. the monthly return).

For example, cumulative return of march = return of January + return of February. The cumulative return of April = cumulative return of March + return of April and so on…

No worries about the math. Python computes everything. Cumulative return will be waited on hand and foot at the end of the article.

Show, don’t tell !

Here is the graph. Click on the 3 buttons to visualize the 3 steps.

Finally, the code…

Before to give the code, a few words about algorithmic trading.

A major disadvantage of algorithmic trading is

The performance measures are subjective depending on the chosen indicator.

Now, just have fun. Push the Run button and look at the result.

Want new articles before they get published? Subscribe to our Awesome Newsletter.

Where should I start?

Where should I start?

5 minutes guide

Where should I start?

5 minutes guide to algorithmic trading

Where should I start?

8 Dec, 2020

Welcome to your quick start guide on algorithmic trading 

Learning something new on the internet is like trekking in the amazon rainforest. The process is about as epic as you would imagine that to be. You may (sometimes) be lost.

 

The jungle...

— A welcoming jungle. — Photo by Ting Chang on Unsplash

Here, the objective is to avoid the Jungle Survival Training camp. This article does not pretend to be such a camp.

Instead, relax, take a comfortable seat and a good cup of coffee. (Of course, fill the cup with whatever you want.)

So, let me introduce a first series of 5 posts. A challenging one.

Why?

Three reasons. You will:

      gather financial data automatically. You will be free to use it as you see fit.

      perform a simple financial performance indicator.

      Run a code. In 5 minutes, using Python.

A few words about Python and Finance. Here, you do not need to have any background in Mathematics and Finance. Concepts will be described in a simple and logical way.

You do not need to have any background in Python and Computer Science too. You just have to push a button “play” at the end of each article. For sure, we will enter into the code line by line. I am pretty sure you will surprise your friends and family after reading this blog.

   Warning

In this blog, I am not offering investment, legal, or any other advice, nor am I trying to do so. This is only a tutorial for learning purposes. Any decisions, investments, or risks you take as a result of building a trading bot are your responsibility.***

Data is the new gold

Well, let’s answer the question.  Where should I start ? 

“Where there is data smoke, there is business fire.” 

Thomas Redman

Before writing this post, I found this quote. Google is a wonderful tool to look for quotations (and other stuff). And this one perfectly fits my introduction.

So, let’s determine where there is data smoke.

Actually, there is data everywhere. Sometimes free, sometimes not. A free solution is used for this tutorial. We will use Yahoo Finance.

Of course, other solution exist. We’ll talk later on this blog.

Yahoo finance is powerful for gathering financial data. Although data is accessible directly via their website, we will use Python.

Phone a friend 

Why Python ?

No need to do manual manipulation in the website and Excel sheets. No need to repeat the process of gathering again and again. Everything is automated.  In other words, the dream of lazy.

More, we’ll use the libraries “pandas datareader” and “datetime“. Importing a library in Python is like using the lifeline “Phone a friend” in “Who Wants to Be a Millionaire?”. The friend is the coder who give you access to their code: freely and easily. Unlike the game show, there is no time constraint…

Code

import pandas_datareader.data as web
import datetime as dt

I know if you are sitting comfortably, reading this line, you will get the key. The key is using the existing code to simplify and perform yours.

The library “datetime” simplifies the use of dates…

Code

start = dt.datetime(2019,12,1)
end = dt.datetime(2020,6,1)

… and the library “pandas datareader” is able to gather  data from Yahoo Finance in only two lines of code:

Code

ticker = 'GOOG'
data = web.get_data_yahoo(ticker, start, end)

Ok. We can get data. But what data?

The stock price of Google. From the the 1st December of 2019 to the 1st of June 2020.

To keep it simple, a stock represents an ownership of a fraction  of a company. This fraction has a price, depending on who is buying it or selling it. This is supply and demand. Every business day, every seconds, the price goes up or down.

You probably remarked on lines above the variable “ticker“. The value ‘GOOG‘ is for Google.  Generally, a stock is linked to a ticker symbol. Thanks to this unique identifier, a stock can be researched and traded on the market. 

Show me the data

By using the print function in Python, you can see the gathered data. (Here, the head() function returns the first 5 rows)

Code

print(data.head())

Results

Adj Close” is the column you must look at. It is the abbreviation for “Adjusted Closing Price”. The closing price is the final price traded at the end of a business day.  Here, the closing price is adjusted by taken into account all corporate event. Such as, for example, the dividends. 

No worries, a dedicated post is in preparation. A description of each indicators (High, Low, Volume, Adj Close…) will be detailed.

Time is essential when you work with data. And more when you build your trading strategy. In the code above, data is currently composed of daily price. This could be useful for a daily strategy.

To ease the learning curve, we’ll use monthly price. This is why data is resampled by taking only the end of Business Month (‘BM‘).  Finally, end of month prices of Google are printed :

Code

print(data['Adj Close'].resample('BM').ffill())

Results

The issue is not how to look for data anymore but what you could do with this data?

Let me present you the next article: Where can I get the best return on investment?

Have fun: test the code

Now, just have fun. All the code discussed above is there. Push the Run button and look at the result.

   For further

  • Change the ticker by another stock. Example: ‘AMZN‘ for Amazon, ‘APPL’ for Apple.
  • Change the start date and the end date for another period.
Want new articles before they get published?
Subscribe to our Awesome Newsletter.

5 minutes to save

5 minutes to save

TRAVEL & LIFESTYLE

Become A Travel Pro In One Easy Lesson

Marco Pitt, Senior Travelers, Italy
22 March 2016
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
“I’m a custom quote Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis leo fringilla mauris sit amet nibh”
Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh.
I’m a standard Image Caption.
Photograph by Lorem Ipsum via Unsplash
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel. Aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae. I’m a Standard Link. Justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,
Want new articles before they get published? Subscribe to our Awesome Newsletter.