squancy / stockai

An open-source service for analyzing the most important Hungarian stocks.

Home Page:https://www.pearscom.com/stockai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stock AI

An open-source service for analysing the most important Hungarian stocks.

Stock AI is a basic aritifical intelligence program that, with the help of some well-known indicators and moving averages, computes a single suggestion in order to decide whether a certain stock worth buying or not.
The calculations, functions and AI are mainly written in JavaScript, the data gathering and manipulation on the server-side are in PHP and the structure and styling is simple HTML and CSS.

All the data for the stocks are collected from data.portfolio.hu.

Note: the reliability of the 3rd-party stock data provider is not 100% so you may experience bugs & incorrect output but those are out of the software's control.

Currenly available indicators

RSI (Relative Strength Index)

The formula is 100 - [100 / (1 + U / D)] where U indicates increasing prices during an n period and D indicates decreasing prices during an n period. On Stock AI it is calculated with a 14 day time interval.

Momentum

The formula is (closing price of today - closing price n days before) / (closing price n days before) * 100 + 100. On Stock AI it is calculated with a 14 day time interval.

Stochastic

The formula is %K = 100 * ((Z - Ln) / (Hn - Ln)) and %D = SMA3(%K) where Z is the last closing price, Ln is the lowest price during the n period, Hn is the highest price during the n period and SMA3 is a simple moving average with a 3 day time interval. On Stock AI it is calculated with a 6 day time interval.

Moving averages

SMA (Simple Moving Average)

The formula is (n1 + n2 + n3 + ... + ni) / i.

EMA (Exponential Moving Average)

The formula is (last closing price * x%) + (last EMA * (100 - x%)) where x% = 2 / (1 + n), n is the time interval and for the first time (when there is no last EMA) last EMA is a simple moving average. Due to the lack of data, the first SMA time interval is calculated as follows:
- if x% >= 0.4 then n = 5
- if 0.4 > x% >= 0.2 then n = 7
- otherwise n = 9
On Stock AI there are EMA3, EMA9 and EMA14 calculated with a 3, 9 and 14 day time interval, respectively.

Signs, weights and summary

Strong sell

Indicates a confident and strong sign to sell a certain stock. Weighted as 2x.

Sell

Indicates a probable sign to sell a certain stock. Weighted as 1x.

Sell sign

Indicates an uncertain and weak sign to sell a certain stock. Weighted as 0.75x.

Neutral

Indicates uncertainty and indifference. Does not have a weight.

Buy sign

Indicates an uncertain and weak sign to buy a certain stock. Weighted as 0.75x.

Buy

Indicates a probable sign to buy a certain stock. Weighted as 1x.

Strong buy

Indicates a confident and strong sign to buy a certain stock. Weighted as 2x.


How summary is calculated?

Both sell and buy signs are summed up so that the maximum value for a certain stock is 13. Obviously, sell sum and buy sum cannot be 13 at the same time. If one of them has the maximum value the other one has to be 0, therefore either sell sum - buy sum or buy sum - sell sum will always return in a positive value. Taking this assertion to be true, the summary is calculated as follows:

- if buy sum - sell sum is positive and buy sum - sell sum >= 11 trade sign is Strong buy

- else if buy sum - sell sum is positive and buy sum - sell sum >= 9 trade sign is Buy

- else if buy sum - sell sum is positive and buy sum - sell sum >= 7 trade sign is Buy sign

- else if sell sum - buy sum is positive and sell sum - buy sum >= 11 trade sign is Strong sell

- else if sell sum - buy sum is positive and sell sum - buy sum >= 9 trade sign is Sell

- else if sell sum - buy sum is positive and sell sum - buy sum >= 7 trade sign is Sell sign

- else trade sign is Neutral

Email service

You can also give your email address and every time a stock changes at least +/-2% you will get a notification about it.

Nice TODOs

  • Replace the old AJAX request in analysis.js with the newer ES6 fetch API + async/await functions just like in email.js
  • Adding more indicators (due to the lack of data it might be a challenging problem)
  • A broader analysis on the stocks containing market sentiment, P/E ratio etc. (may mix both technical and fundamental analysis)
  • anything you think would be great ...

Trying out

git clone https://github.com/squancy/stockai/

You will need a local server to test it like XAMPP or LAMP and PHP + MySQL. The database in SQL can be found in sql/db.sql.
Then open main.php in your browser and it should work fine (depending on the reliability of the 3rd party data provider).

If you still have any question feel free to check Stock AI or contact me via e-mail.

About

An open-source service for analyzing the most important Hungarian stocks.

https://www.pearscom.com/stockai

License:MIT License


Languages

Language:JavaScript 42.5%Language:Hack 27.5%Language:PHP 20.7%Language:CSS 6.6%Language:TSQL 2.6%