Welcome back to our journey in learning how to program Amazon Alexa Skills via Echo voice search. In the previous article, we walked through the process of setting up an Amazon Web Services (AWS) account. Today, we’ll set up an account at the Alexa Development portal, a distinct entity from the AWS portal.
Without further ado, let’s jump in. Go to https://developer.amazon.com/public/solutions/alexa.
You should land on something like the above screen. Click on the “Sign In” button, you can create a new account from this screen if you need.
Important Note: If you already have an Amazon.com account (regular old Amazon shopping account), use those credentials to log in.
Obviously, if you’re a returning Alexa Development Portal user, you can skip the account creation process shown below. If you’re creating a new account, you’ll need to fill out a screen that will likely resemble the below, and click “Save and Continue” when you’ve finished.
Next, you should be presented with an App Distribution and Services Agreement screen. Be sure to give it a quick read. If you want to use the services, then you’ll need to agree by clicking save and continue. 🙂
The final registration step addresses payments and whether you plan to monetize the apps you develop. For the purposes of my usage, and this learning, I checked “No” to both options before proceeding.
Once you finish that step, you should find yourself in the Amazon Developer Console! Good thing we got the hard material out of the way first, huh?
This should wrap up a pretty quick introductory section for setups. Feel free to visit my previous article on getting set up with AWS, or go to my learning home page on how to start developing Alexa Skills. Thanks and see you at the next article!
Hello, hello, hello SQL fans! (Or gracious friends and family perusing the site. 🙂 ) The journey into learning SQL continues, and today we’ll cover the COUNT function. Jumping right into it, here’s our working definition of the SQL COUNT function:
The COUNT function should return the number of input rows that match a specific condition of a query.
Rather, this would appear to work similarly in concept to the COUNTIF(s) formula(s) in Excel.
COUNT Statement Syntax Examples
Here’s what a simple COUNT SQL statement might look like:
1. Basic COUNT (*) FROM SQL Statement
SELECT COUNT (*) FROM table;
Breaking it down a bit, the COUNT () function returns the number of rows returned by a SELECT clause. When you apply the COUNT () statement to the entire table, pgAdmin/PostgreSQL will scan the entire table in a sequential manner.
Additionally, you can specify a certain column count in your COUNT statement for better readability:
2. COUNT (column) FROM SQL Statement
SELECT COUNT(column) FROM table;
Similar to the COUNT(*) function, the COUNT(column) function returns the number of rows returned by a SELECT clause. However, if you have empty or NULL values, the COUNT function will not take those into account.
3. COUNT (DISTINCT column) FROM SQL Statement
If we do a bit of application from our past learnings, we can make a COUNT with DISTINCT SQL statement:
SELECT COUNT(DISTINCT column) FROM table;
Applying the COUNT SQL Function
Alright, so let’s work our way toward applying what we’ve learned. To start, let’s do the traditional probe of the table before diving in, to familiarize ourselves. Below, we’ve done a basic,
SELECT * FROM address;
As we get familiar with the table, we can scroll down and see this particular table has 605 rows in it. This will be a reference point as we continue.
Moving forward, we’ll execute a basic SELECT COUNT (*) FROM address; SQL query. Below, you’ll see a slightly different result was returned. Inst3ead of 605 rows, 603 was returned. At this point, kindly reference our note about empty / NULL values being excluded from the COUNT function.
We’ve established a general proof of concept for the SELECT COUNT statement, considering the reduced load on the server and yourself, for a quick count. Let’s now try calling specific columns. In our first exploration of the address table, we saw a number of columns, including the district. Let’s say we want to get a count for how many districts/states our customer base covers.
Above, a count of 378 distinct district values has been returned. Wow, what coverage!
A quick aside for future usage, you can also nest the column reference in its own set of parentheses, as shown and returned below.
There you have it! We’ve learned a bit about the COUNT function, what it does and how to use it. It will likely come in handy for future articles, particularly when we delve into group-by excercises. If you missed it, here’s the previous article on learning how to use SELECT WHERE and another recent article on learning how to use SELECT DISTINCT. Also, to start from the beginning, here’s my running list of articles on how to learn SQL. Cheers!
Welcome back, folks, to our foray into Amazon Alexa Skill Development. If you’ve visited the blog recently, you’ll notice I’ve been juggling a few subjects for a minute, including SQL. For context, here’s our first article, starting Amazon Alexa skill development from the absolute beginning. (Following my haphazard skill development of Silly Marketing Strategies at the beginning of the year.)
In the previous article, we prepared ourselves for skill development by downloading public sample materials from Amazon’s Alexa Skills Kit Github page. Now, we’ll look at Amazon Web Services, one of the world’s largest (is it the largest?) public cloud computing platforms.
First, navigate to https://aws.amazon.com/. Click on “Create an AWS Account”, or equivalent, if you’re seeing something different. Note: this sign-up shouldn’t incur cost for you today, unless you choose otherwise. (Quick disclaimer, I’ll obviously try to supply the most accurate information possible. However, I cannot ultimately guarantee its accuracy. That you must do for yourself.)
Here, you’ll sign up and create a new account or log in. Note: if you have a regular Amazon login, I believe you can use that here. Because I have an existing Amazon account, most of my steps will follow accordingly, however, I’ll try to recreate where I can, like below.
If you’re creating a new account, then you’ll be prompted to choose between a company account and a personal account. Below is a preview of what the personal account signup page might look like.
Next, you’ll be prompted to set up payment options. (Obviously, we’re s electing a free account for the purposes of this educational exploration.)
You’ll next be asked to verify your phone number via a call requesting a PIN shown on screen. From there, you should be able to proceed to the support plan selection screen, upon which I recommend choosing the free Basic version. After selecting all the appropriate options, you should be able to create your account!
Now that you’ve created an account, click “Sign In to the Console” or “Complete Sign Up”. You’ll re-enter your login credentials and proceed. You should now land on the Developer Console root page. (Note: Amazon, like Google, runs a ton of UI tests, so what you see may be slightly different than the below.)
The first order of business in our new account is to secure it. Click on your name in the top right and in the resulting dropdown menu, select “My Security Credentials”.
Manage / Activate your MFA, and select a virtual device. This means you’ll need to perform some setup so you can scan a QR code with your phone (via Google QR code scanner app). I’ve skipped some illustrations and details here, because I’m not sharing my details, nor should you. What a somber ending to the article! In the next post, we’ll cover signing up for the Alexa Developer Portal, as we get move toward becoming proficient Amazon Alexa Skill Developers.
Welcome back, travelers! The journey continues in learning SQL. In case you missed it, the past couple of posts were learning to use SELECT DISTINCT and Restoring an SQL database with table schema only.
Today we’re going to learn about using the SELECT clause with the WHERE statement for essential SQL queries.
A Quick Recap, or, Why SELECT WHERE is Important
As previously mentioned, we’ve covered a range of beginning SQL topics. Mainly, we’ve learned about using the SELECT statement to query all (*) or query specific columns of data from a table. Because we’ve been working with a pared down table with only a few hundred rows, it’s not a problem in this “academic” setting to return all the rows. But what if we’re working in a larger database? A recent keyword research dataset 75,000 rows long comes to mind. (Though I would imagine that too, would be a small dataset in the grand scheme of things, but I digress.)
When we start working with larger databases, granularity will become vitally important. This is where (pun not intended) the SELECT WHERE statement comes in.
Sample Syntax of the SELECT WHERE Statement
With proof of concept in mind, let’s jump into it headlong. Below is a syntax example, demonstrating what a SELECT WHERE SQL query might look like.
The SELECT statement is old news to you adventurers that have been following along. The WHERE portion of this query will be the power in this article.
More About the SELECT WHERE SQL Statement
The WHERE clause appears right after the FROM clause of the SELECT statement. The conditions listed within the WHERE clause are used to filter the rows returned from the SELECT statement. Because we’re working in pgAdmin / PostgreSQL, we’ll have available standard operators to construct the conditions. Better still, some (or most) of the operators we’ll look at are fairly universal, so these operators should work in MySQL, Microsoft SQL, Amazon Redshift, etc.
List of SELECT WHERE Operators
Below is a list of common SELECT WHERE operators. Again, most of these should be fairly universal, regardless of the SQL database management program you’re using.
|>=||Greater than or equal to|
|<=||Less than or equal to|
|<> or !=||Not equal to|
|AND||Logical operator AND|
|OR||Logical operator OR|
Plugging this back into SQL statements, we’ll be using the operators on the left to filter down and return only specific rows in our queries.
Sample SELECT WHERE Statements
Let’s cover some guiding examples that will help us apply the SELECT WHERE operators. To start, we’ll kill two birds with one stone: jogging the memory by utilizing a previous query and exploring the table we’ll be querying. Below, we’ll be a bit naughty by calling on all columns from the table.
SELECT * FROM customer;
Above, we’ll see our results and some candidate columns to query the heck out of. Let’s keep moving.
Example 1: The Basic SELECT WHERE Statement with 1 Condition, Returning Only Customers with a Certain Name
Okay, let’s say that we want to only return customers of a certain name, say, “James”. The SELECT WHERE statement will help us make quick work of this database need.
WHERE first_name = ‘James’;
If all goes correctly, we should only get back a customer with the first name James. ‘Ello James!
Side note 1: you don’t have to return the columns you’re filtering against. For example, we could return the email column and still filter by name.
Example 2: A SELECT WHERE Statement Using 2 Conditions, Returning Customers with a Certain First AND Last Name
Perhaps you’ll want to do something more targeted with your data. I know this is a narrow and frankly creepy example of calling out one name, but think maybe of a City/State or Source/Medium pairing? Anyway, with the sample dataset we have, below we use the AND logical operator to combine two conditions into one query.
WHERE first_name = ‘Jared’ AND last_name = ‘Ely’;
If executed properly against this particular sample dataset, we should be returned only the values for one fictional Mr. Jared Ely.
Quick side note 2: that we should have mentioned sooner: we’re using single quotes here because the values we’re querying against are string values. As such, the single quotes help us match format, et cetera.
Example 3: Another SELECT WHERE Statement Using 2 Conditions, Returning Customer ID’s where payment was in certain dollar amount ranges
Let’s say we are trying to identify a range of customers in our database. In this third example, we want to query Customer ID’s and names in a certain range. We could think of it as a feeble attempt to get our first customers or our most recent customers for a special email flight. Below, we’ll exercise the OR operator to accomplish our desired output.
WHERE customer_id <= 2 OR customer_id >=20 ;
Understanding the Subtle Differences Between AND / OR
Quick note about differences between the AND / OR operators. If you’re trying to filter data from two different columns, then AND is your filter. If you’re trying to get distinct values within a single column, then the OR operator will be best suited for the job.
What a world of possibilities we’ve opened! I found myself needing to slow down and pay more attention to detail in this area of learning. The nuances of selecting certain columns but filtering by others when practicing threw me for a loop once or twice.
Thanks for joining, in the next article, I’ll be covering some introductory material around the COUNT function. In the meantime, check out our running list of posts on how to learn SQL.
Introducing the SELECT DISTINCT SQL Statement
Alright, welcome back to our journey with SQL! If you’re just tuning in, we:
- Started SQL from the absolute beginning
- Got up and running with PostgreSQL and pgAdmin
- Created, restored and deleted/dropped SQL databases
- Restored databases with table schema only
- Used the SELECT clause as our “Hello World!” for SQL queries
In this article, we delve slightly deeper into SQL queries, with the consideration that SQL databases and tables can have a lot of duplicate data, and you might not always want that duplication! This is where today’s subject comes in: using the SELECT clause with the DISTINCT keyword.
Sometimes when you’re managing a database or table, you only want unique (distinct) values when executing SQL queries. Thus, you can get around a large number of duplicate values using the DISTINCT keyword.
The Basic SELECT DISTINCT Syntax
Here’s the general format of what a SELECT DISTINCT query might look like:
SELECT DISTINCT column_1,column_2 FROM table_name;
Next, we’ll take a look a very simplistic example of why you might want to only pull unique values from a database.
Why Use the DISTINCT Keyword?
So we’ve generally been working from a popular public SQL “sample” or “sandbox” database that deals with DVD rentals. In one of the tables, “film”, there are a number of columns containing a wide range of information. For example, we can see below querying the release_year column of the film table, a few films were released in 2006. If we’re looking for a unique list, this is not a good start!
Using the SELECT DISTINCT Query in pgAdmin
Working off our example above, we want to see if 2006 is the only release year. To accomplish this, let’s try the below query:
SELECT DISTINCT release_year FROM film;
Below, the query in action through pgAdmin, after hitting F5 to execute and refresh. We can see 2006 is the only unique release year in this table. Zoinks!
Let’s try another example. Perhaps we’re interested in gathering pricing information for some revenue forecasting and analysis. Below is a query we would use to get the distinct rental prices from the film table:
SELECT DISTINCT rental_rate FROM film;
We see that there are only 3 price points in this table. What fun in simplicity!
Thanks for joining! Next post, we’ll be looking at the SELECT WHERE statement. Check the SQL learning & education page for a running list of articles. Cheers!
An Introduction to this Alexa Learning Journey
So if you’ve visited my site at all in the past, you’ll notice this is the most blogging I’ve done in…ever? Put another way, a significant confluence of factors has dialed up my motivation to doggedly pursue learning and growth. So, here we are at learning Alexa skills!
A few weeks ago, I was suckered by the cheap promise of a free hoodie from Amazon, in exchange for building and publishing my first Amazon skill. You can experience the equally cheap output of that effort by saying, “Alexa, start silly marketing strategies” (again and again.)
Is it a good skill? No! Nor am I going to pull a Dollar Shave Club here either. It’s a bad skill! It’s not interactive. You just have to keep asking it over and over for some dumb buzzword-laden sentences. I promise I only account for 75% of the utterances. 🙂
Honestly, I’m thrilled to have published an Alexa skill. But there’s so much more out there! Thus, I’m embarking on yet another educational journey, this one into Amazon Alexa Voice Skill Development.
Getting Set Up with Resources You Need for Alexa Skill Development
The instructions below are for PC only. Apologies, Mac users!
- You need to create a folder directory in which we’ll be housing our various materials and code.
- Visit the Alexa Skills Kit JS Git Hub page and download all materials as a ZIP.
- Once you’ve downloaded the ZIP file, move it from your default Downloads directory, and into the folder you created in Step 1.
- Extract the ZIP file. The unzipped folder should be named, by default, “alexa-skills-kit-js-master”. Within the unzipped folder is yet another folder of the same name.
- Take the all the contents within the two folders described above, and move them into the “Alexa” directory, higher up.
- Move the contents from the “samples” folder into the main “Alexa” directory, so the skill folders (spaceGeek, reindeerGames, etc.) are in the umbrella directory.
- When you’ve completed Step 5, you should be left with A) Three text files, and a bunch of skill folders, B) an empty “samples” folder [A&B you moved up two directories into the “Alexa” umbrella folder], C) an empty “alexa-skills-kit-js-master” folder and D) the original zip file.
- Delete items B, C, and D from step 6.
- Download and install a code/text editor. I personally prefer Sublime Text 2, but a lot of folks prefer Notepad++ as well.
- A dedicated code/text editor is highly preferable here, as much of the code for the Alexa skills in JS – Node.JS in particular, I believe.
- After you’ve muddled your way through this folder architecture, go into the README file and not the order of Skills. Number the skill folders accordingly in the umbrella directory, excluding helloWorld. (You should have skills 1-9, starting with spaceGeek and ending with ChemistryFlashCards.)
Alright, that’s it for now! Next, we’ll look at setting up access to Amazon Developer and Amazon Web Services.
Getting Started in SQL Statement Fundamentals
Howdy, all, welcome back to our journey learning SQL. This post will deal with basic SQL statements. In fact, most of these SQL statements should be applicable to most major types of SQL databases (MySQL, Oracle, and so forth.)
The SELECT Statement (or Clause)
First up, we’ll start with the “Hello World” of SQL: SELECT. We’ll look at the formal conventions of the SELECT statement and some examples using the statement. A quick aside: SELECT is also often known as a clause in SQL settings. For the purpose of this article, the educational materials I’m walking through proposes clause and statement may be used interchangeably for these purposes.
SELECT is one of the most common tasks in querying data tables with SQL. Further, it has many clauses that may be combined to form a powerful query. Let’s look at the basic form of a SELECT statement. Below, you will use the SELECT statement to call in a column or some column names, separated by a comma if multiple columns, then FROM a table.
SELECT column1,column2,column3 FROM table_name;
So, breaking down again the select statement.
- Specify a list of columns in the table which you want to query via the SELECT clause
- Use a comma between each column you are querying, if multiple columns
- If you want to query all columns in a data, save yourself some time by using the * asterisk wildcard as a shortcut for selecting all columns
- After you’ve called in the appropriate columns in the SELECT clause, follow it with FROM, where you indicate the appropriate table name
Sidebar 1: Random facts about the SELECT statement and SQL language
Time for a TV timeout! Did you know that that the SQL language is case insensitive? So if you use “SELECT” or “select”, you should get the same results. For the purposes of this education and sharing, SQL clauses / keywords / statements will be typed in all uppercase caps to make the code easier to read and stand out among all this text. 🙂
Okay, just one more sidebar note! It’s generally not encouraged to use the asterisk (*) select all columns wildcard in queries. Why? If you have a robust table with a ton of columns and a great depth of data beneath those columns, you could be placing unnecessary load on yourself, the SQL server and the SQL application (pgAdmin / PostgreSQL).
Application Example 1 for the SELECT Statement
Let’s jump into executing actual SQL commands against databases in pgAdmin!
Below, I’m going to open the file tree, select “dvdrental”, then click “Tools” in the top menu, and select “Query Tool” to execute arbitrary SQL queries and statements.
You should then see the screen below if you are in pgAdmin 4. If you are in pgAdmin 3, then it should appear as a new window.
Let’s have some fun, why not go against our own advice and query a whole table? Below, you can see in the query window, we’ve typed:
SELECT * FROM actor;
Into layman’s terms from above, we’re selecting (SELECT) all columns (*) from (FROM) table actor (actor).
Important: My image example doesn’t show it below, please, put a semicolon at the end of the line! (I got hasty making screen shots. 🙂 )
After you’ve typed the query, go to the lightning bolt above the window, and click “Execute/Refresh”. I’m just going to punch F5, because I’m about that keyboard shortcut life. In the future, I’ll likely introduce a command or action, note its keyboard shortcut and use that shortcut moving forward for any other examples.
The query should run and refresh. I now have a new tab in pgAdmin, with data output returned from my query. Let’s take a look below.
Okay, so we’ve got four columns returned: actor_id, first_name, last_name, and a last_updated. You’ll also note that below the column names are quick descriptions of the data type for each column. And of course, we see our beloved celebrity data returned below, all 200 rows.
Let’s examine further the data types listed below each column name. The integer below actor_id is pretty simple, numbers. Next, the character varying, below first_name and last_name. Character varying is essentially just string text. The (45) denotes the limit on character count length. Last, the timestame with YYYY-MM-DD and military style HH:MM:SS.XX time, without time zone. We won’t worry too much about the timestamp for now.
If you’re somewhat knowledgeable in SQL, you may rightly decry our glossing over of data types. For beginners, data types will be covered in more detail later. Data types will become increasingly important later, as we execute statements such as, WHERE, in which data types make or break the query. Promise, we’ll cover data types in more detail later.
Application Example 2 for the SELECT Statement
So we kind of broke our rules in the first SELECT statement SQL query example. However, some rules were made to be bent or broken, yes? In this example, we’ll follow best practices a bit more closely and select a column or columns by name from a table within the dvdrental database.
Remembering our SELECT column1,column2,column3 FROM table_name format, consider the below, and see it typed in (with closing semicolon on the statement!
SELECT first_name,last_name FROM actor;
Before we execute and refresh via F5, please note that I’ve not included spaces between the column names and comma in the statement. Alright, below is what we see when we execute and refresh.
In our screen shot, we see at bottom right, confirmation of the query execution. In the output window, we’ll only see what was queried: first_name, last_name. So we’ve left out the actor_id and last_updated columns.
One more note on our output, you’ll notice that all 200 rows were returned for this query. If you think about enterprise level data, that could be 200 million rows, zoinks! As we progress through our material, we’ll look at the aforementioned WHERE statements and other conditions / methods to limit or control the rows in query output.
Perfect Practice Makes Perfect
For the educational benefit, we’ll reinforce and apply what we’ve learned one more time. Let’s say that we’re a business and marketing analyst back in time when DVDs were still used (it’s okay to laugh!) We need to send a New Year’s promotional email (It’s January 2017 when this post was originally published) to all existing customers. We’re going to build and execute a query to that effect.
Below, you can see we’re still in the dvdrental database, in the arbitrary query code input window, with statement: SELECT first_name,last_name,email FROM customer;
One last quick note on syntax and formatting: you can go multi-line! In the below screenshot, we have typed the same query, but added formatting. Explained: SQL will read your code as one line until it runs into the closing semi-colon (;). A common practice is that for every keyword, a new line is created in the query. (Of course, the statement is not closed via semi-colon until appropriate.) I’ve also taken one more step below from various ranging coding practices (CSS, C++, etc.) and indented the ongoing portion of the query to help visually break up the code a bit.
Woohoo, we did it! We ran our first basic SQL queries in pgAdmin / PostgreSQL. We learned how to select all columns within a table and select separate desired columns within a table. Be sure to re-visit my other articles on learning SQL, visit the previous article on restoring an SQL database with table schema only.
In our next post, we’ll learn about using a SELECT DISTINCT statement.
Howdy! Welcome back to our shared journey of learning SQL. Last time, we learned about creating, deleting and completely restoring SQL databases in pgAdmin. Today, we’ll learn about how to restore a database, but only its table schema.
Specifically, we’ll restore the table names and preferences for types of data within those tables. However, the actual data itself won’t be ported in.
Think of it as taking your house or apartment, and recreating, but you don’t move in with the furniture. (Maybe a sibling instead? 🙂 ) According to the material I’m working through, this method of database restoration is very common and is something we should have down pat.
Database Table Schema-Only Restoration, Method 1
An easy method to start this is to right click on the Databases header near the top of the file tree, and to select “Create” > “Database”. With a fresh new database, we’ll have flexibility to do some more management on the “front” side of things. (Knowing I may be abusing terminology a bit, but makes sense to me while writing this.)
For this example, I’ve finished the new database creation by naming (“OnlySchema”) and saving a new database. Below, you can see the new database in the file tree. Also, if we click through the tree as such, “Schemas” > “public” > “Tables”, we’ll notice there are no tables! (Compare that path exploration to the dvdrental database tables, where you can find 15 tables.)
Anyway, let’s get on with restoring table schema only!
- Right click on “OnlySchema” and select “Restore”
- Select the “Custom or tar” option for the Format field
- Select the file via the dialogue, or paste in your file path
- Up to this point, you should notice we’ve taken the exact same steps for a full database restore. However, #4 is where things are slightly different. Pay attention!
- As shown below, click “Restore Options”, and activate the radio button for “Only schema” to yes
- Click “Restore” and refresh!
After the refresh, we should see something like below, where if we select the tables option and view “Properties”, we’ll see 15 empty named tables.
Method 2: Schema-Only Restoration onto a Database with existing tables, data
What if we’re working with a database that contains existing tables and data? And suppose we need to restore only the schema? Perhaps an error was committed in formatting / management and must be corrected.
Fortunately, this method of restoration is extremely similar to Method 1. For this scenario, there’s one added step toward the end:
- Right click on “OnlySchema” and select “Restore”
- Select the “Custom or tar” option for the Format field
- Select the file via the dialogue, or paste in your file path
- Click “Restore Options”, and activate the radio button for “Only schema” to yes
- Here’s our jump off point, the next step is what differs from Method 1.
- Scroll down the dialogue box slightly. You should see a field and radio button for “Clean before restore”. Activate the radio button to “Yes”
- Click “Restore” and refresh!
After running the restore job and refreshing, we can verify the Schema Only and data clean prior to restoration occurred correctly. Below, we can click through the file tree down from “dvdrental” > “Schemas” > “public” > “Tables” and check the table properties to see that there are zero (0) rows of data.
I do hope these articles are serving a useful introduction to navigating pgAdmin, and getting familar with the foundations of PostgreSQL and databases. In the forthcoming articles, we’ll start learning about basic SQL syntax. To keep track of all the shared SQL posts and learnings, visit the SQL Education page for a list of articles to date. Cheers!
Before we begin, you’ll notice this post deals with finance and investing, both of which are highly risky. This site and this post is strictly educational. Nothing in this post or on this website is intended as, nor should be construed as investment advice. Kindly first visit the Disclaimers page before you proceed, taking careful note of CFTC Rule 4.41 regarding hypothetical performance. Further, investing and trading is extremely risky, to the point that 90% of participants rapidly fail. As such, your participation in investing and trading could lead to loss of principal, and even further losses beyond that in some cases. Neither this site in its entirety, nor this post, nor any portion thereof, nor any resulting discussion or correspondence related to this site and post, is intended to be a recommendation to invest or trade mutual funds, stocks, commodities, options, or any other financial instrument. I will not accept any responsibility for any losses which might result from applications of ideas expressed on this site or in this post from the techniques or systems mentioned on this site or in this post. Nothing shown is the result of an actual trade. Neither past actual performance, not simulations of performance assure future results, profitable or otherwise.
Introducing this Discussion on Algo Trading Expectations
Welcome back to the journey into algorithmic trading. Hot on the heels of an introductory article dealing with algorithmic trading concepts, and a tactical discussion on algorithmic trading software platforms, we arrive at a mental and philosophical reflection point.
This endeavor into algorithmic trading is about pushing the limits of learning, and applying a broad array of market theory concepts through a scientific lens, mathematics / statistics and computer science. However, a less popular area of algorithmic trading is psychology. Yes, psychology and the mental approach to trading are real areas, even if you’re performing 100% automated, systematic and unattended algo trading.
Well-tread ground among retail traders (non-institutional, non-hedge fund traders) is the pursuit of a “holy grail”. We are bombarded by messages everywhere, in many fields of life. Buy this, use that, and your problems will vanish. Okay, perhaps that’s an oversimplification, but I think you get the point. Onward.
The Definition (and myth) of an Algo Trading “holy grail”
In both active (discretionary) trading and algorithmic trading, the “holy grail” is usually defined as a trading strategy that is has high long term profitability with consistent returns. In short, it is the ultimate trading strategy.
Spoiler alert: the “holy grail” (based on this definition) doesn’t exist. Market regimes change, trends start, trends stop, ranges form, consolidate and eventually break out into new patterns. Even Ray Dalio’s “all weather ” hedge fund strategy was arbitraged away by a changing climate in interest rates, thanks to widespread central bank intervention on the global economy.
This begs the question, is there a “holy grail”, and if so, what is it?
A New Definition of the Algo Trading “holy grail”
Here’s a new definition: The trader can be the “holy grail”.
Long term profitability with consistent returns can be a state of existence for investors and traders. Examples abound if you study the market. However, this is not due to a single algorithm or trading strategy. The trader can be his or her own secret ingredient by doing 3 things:
1) Understanding their portfolio of algorithmic trading strategies
2) Understanding how to effectively design, backtest and optimize trading strategies
3) Understanding when to maintain their portfolio, when to execute, modify or shut down strategies according to changing market regimes
Why Does This Matter in Algorithmic Trading?
We are all subject to emotions, pressure, stressors and thoughts in all we do. Even if you have a black box algo strategy which only involves you checking the account balance periodically, I can guarantee you psychology comes into play. When (not if) your system(s) enter into drawdown (read: you lose money), your head will be full of surprise, sadness, anger and so on. Even in this scenario, especially in this scenario, your management of expectations and psychology will be the true long determinant of success.
Short version: if you expect one or two algo programs to be your ticket to decades of success, you are sorely mistaken.
Thanks for sticking through this brief, idealistic conversation on trading psychology and successful trading. In my next article walking through algo trading, I’ll be looking at setting up the MetaTrader4 platform for some basic tasks.
Notes, Legal, Disclaimers
Content and media on this site may not represent the positions of my employer(s), agents, affiliates, subsidiaries, clients and should not be interpreted as such. (The list includes, but is not limited to the aforementioned.)
This site may contain advertising and/or affiliate links.
- Case Studies
- Structured Query Language (SQL)
- Amazon Alexa / Echo Voice Skill Development
- Machine Learning
- The Complete SEO Audit
- Digital Marketing Strategy
- Savvy SEO Reporting