AI stock price prediction (using deep learning in Python).

2019-03-13 記
Topic: IT業界

MATLAB, which is a numerical computation platform and can also perform AI.For individual use.I didn't realize it was being sold so cheaply... If I had known earlier... I wonder when the Home Edition came to be. In the past, there were only versions that cost over 100,000 yen, so I think individuals were using the free "R" version. But if something like this can be used for around 16,000 yen, everyone would choose this, it's that amazing a software. This field is quite difficult if you want to delve deeply, but it seems like there's a 30-day free trial, so I'll try it out again, perhaps with a simple stock price analysis as a short-term subject, to see how it works.

■Fitting
When I ran a learning sample that I created a long time ago, it worked as is. That's good. I don't remember much, so I'm re-learning, but I think this was a function called "fitting" that performs a "similarity" processing on a noisy periodic function and displays it as a graph. The dots are the original raw data, and the waveform is the graph generated by the similarity processing. By fitting to something with a known answer, we can confirm the correctness of the method.■ Demographics
This is a sample that I created for learning purposes. It roughly predicts the future based on demographic data and displays it in a graph.■Stock Price Approximation
I tried to approximate and predict stock price data for half a year that I found on the web using a simple graph, but as expected, since I only played with it for about an hour, it's completely useless. I feel like I need to study more. I wish there was a good "theory" for this. It's fine as a toy, but it would be interesting if it could actually be useful.
Blue dots: Actual stock prices. Red line: Approximated graph.
Data: 6754 Anritsu Corporation.I've been playing with it for a few hours.
■ Blue dots: Actual past stock prices.
■ Red line: An approximate graph of past stock prices (left side) and a predicted graph for the future (right side). The assumption is that we are predicting the future using only the data from the blue dots.
■ Yellow: The answer for the future stock price.
If the red graph for the future matches the yellow circles, then the prediction is accurate. However, it's unlikely to be perfectly accurate right away. The original data contains mathematically strange (exceptional) movements, so the approximate graph also has strange spikes that cause disturbances.
If stock price predictions could be made so easily, that would be amazing... This field is difficult, but if it's just for fun, this topic is challenging and interesting. If, by chance, something useful comes out of it (which is unlikely), then it can be used.
Well, for now, it's a good topic for today's afternoon fun and learning.
Data: 6754 Anritsu Corporation.Graphs that seem useful for stock price analysis are gradually appearing.
■ The purple graph on the right: Predicted stock price.
■ The yellow circle on the right: Actual future stock price.
They are somewhat similar. The accuracy varies depending on the parameters, sometimes working and sometimes being wrong, but it is much better than it was in the evening. If you can achieve this accuracy with something created quickly, it is quite good.
I haven't used mathematics for a while, so I had forgotten it, but I am gradually remembering it through trial and error. However, I still don't understand the formula called "Gaussian process regression" that produced this result. It's not that I am amazing, but rather that MatLab's comprehensive documentation is wonderful. Well, even if you don't understand it, you can at least get an answer, but you probably need to study mathematics again to apply it.
If it goes well, I might create a stock price prediction website as a hobby? (Laugh)I don't know if I'm really going to do it, but I created a simple stock analysis website, just the top page, to get Google to recognize it quickly. This kind of thing is a long-term project, taking months or even years, so it's best to create the website first. Surprisingly, a relatively short domain name was available and I was able to get it.AI stock price prediction - https://kabu2u.com■AI's LSTM (long short-term memory network)
I tried LSTM.
MatLab is amazing. (I still don't understand the mathematical content) It can create things like this so smoothly. (I haven't tried it in Python, so I can't compare.)
I just came back from yoga, and I was thinking of quickly researching and experimenting for 30 minutes before going to bed, but MatLab allows you to create things so easily without hesitation. It's amazing.
This LSTM is used for deep learning. It's what's called AI, but it's not a super AI like Atom from manga; its reality is this kind of machine learning.
The code is taken directly from a sample, but each time I run it, the learning results are different, and sometimes a smart AI is created, and sometimes a not-so-smart AI is created. This attached image seems to be a child with relatively good results. The background is the screen that appears during learning, and the graph in the foreground is the forecast. It's amazing how similar it is to the actual graph. Well, sometimes a not-so-smart child is created, so the instability of the results is both a good and bad thing about deep learning. When a good child is created, I'm surprised. I'll look at the details of what's happening inside from tomorrow onwards.I will try to predict the second half of the data based on the first half. Of course, the error is large at the very end, but the accuracy is quite high around the connection point. AI is amazing... I don't think humans can win against this.The other day, I only used one data point (closing price) for learning. I tried using a combination of opening price, high price, low price, closing price, and volume for deep learning, but it didn't really change much... Or rather, there's a high possibility that I'm making a mistake somewhere. I don't understand it properly. I can understand the basic theory of deep learning, but trying to understand something as complex as an LSTM (long short-term memory network) makes my head spin.

I've heard rumors that deep learning uses a lot of CPU power for learning, so I might need to buy some hardware chips. I'm currently using a laptop, so I'll look for USB chips... I can't install a graphics card.Hoho. According to my so-called AI, the stock price of 1332 N is currently at 812 and will likely remain sideways for a while. This is indicated by the red line in the upper right corner. The predicted stock price in two weeks is 822, which is only a 1% increase. Therefore, this is not a buying opportunity. If you currently own this stock, it might be a good time to sell and convert it to cash. (Please do not believe this. I am writing this as a joke. It is a hobby, and it is a cute AI that has just been created. I would be troubled if someone bought this based on this information, and I cannot be held responsible.)Since last night, I have been scanning all stocks listed on the Tokyo Stock Exchange. It takes approximately 1 minute per stock to analyze the data for the past 360 days (maximum). I am using a Mac laptop with an Intel Core i7 processor. Currently, about 1200 stocks have been processed, but there are still 2400 remaining. Based on the statistics, about 10 stocks have the potential to increase by up to 10%. The AI estimates that approximately one out of every 100 stocks will rise. However, the AI's predictions can vary, so running the same stock multiple times may result in different predictions. I am not yet confident enough to blindly trust the AI's predictions and invest mechanically based solely on the results. However, it sometimes reveals unexpected stocks, and I would not be able to check all stocks listed on the Tokyo Stock Exchange myself, so it is useful for narrowing down the options. The goal is to narrow down the initial target of 3600 stocks to around 30 stocks, and then further narrow it down to 10 or fewer.Foreign exchange (FX) analysis using AI. However, it analyzes each currency individually, so it is unclear whether it is useful or not. For now, I will just observe it. FX is difficult, after all...I am running AI stock analysis on my home computer (which takes a long time), and in the afternoon, I went to Mount Takao. The top-performing stocks with rising expectations that emerged this morning have had mixed results (I haven't bought them yet), but there is still a lot of fluctuation. There might be a method of buying a single unit of each stock and immediately selling the ones that go down, while holding onto the ones that go up. Ultimately, it's impossible to know which ones will go up.

The fortune says: "Good fortune. Although you have experienced many hardships, your luck is finally opening up, and your worries will disappear, and things will succeed."
I wonder if it will come true?For the past week, I have been experimentally buying stocks selected by AI.
The AI narrowed down the list to about 30 stocks, and I checked them myself, narrowing it down to about 10 stocks. Then, I purchased some of those stocks that looked good in terms of their charts.
Last week, the overall market conditions were good, so those stocks generally showed resilience and didn't fall much. Some stocks rose. There were no explosive gains, but as long as I didn't lose money, it was okay. Overall, the results were a few percentage points up for the week. The experiment was fairly successful.
However, today (Monday), the Tokyo market plummeted, following the New York market, and some of my stocks were caught in the downturn, returning to their previous levels. Even with AI, it seems that you can't avoid being affected by a market crash... It's only natural that the overall market conditions are stronger.
Currently, the AI analyzes stocks individually, so it doesn't know about the correlation with the New York market. I think it's necessary to teach the AI about these relationships.
Rather than making it memorize the relationships, it might be enough to have it predict the New York market independently and, if it predicts a decline at night, to reduce my positions in advance.
(This image is not related to the stocks I bought.)■Google TPU
It was written that the delivery time was 3 weeks, but it actually arrived in about 10 days. It was surprisingly fast.
It cannot be used with Matlab, so I will try using it with Python later.■First attempt with Python
Since this is my first time using Python, I tried reading data that has already been analyzed in Matlab and displaying it as a graph. It might be a substitute for Matlab. Maybe I don't need to buy Matlab? If I can switch to Python during Matlab's trial period, I probably won't buy it, but Matlab is easy to use, so I'm still debating whether or not to buy it. It can also be used for things other than AI. Only Python can use Google's AI chips, and Matlab cannot, so switching to Python is essential in any case.
Python has a strange syntax that I don't often see in other languages, or rather, it's interesting in a strange way, or maybe it's just subtle, but it has the advantage of being able to use arrays, so the disadvantages of that strange syntax are offset. Well, it's a matter of getting used to it.
Also, I need to replace the main AI part, but that's still in the future.Recently, I implemented Gaussian Process regression, which I also did in Matlab, in Python. In Matlab, I skipped some parts, but the results vary significantly depending on the parameters, so I implemented it with the simplest parameters for now. This is not the main topic, as the main topic is AI. I think this is fine for now. I've been using it for a few days, and I'm gradually getting used to Python.
The only difficult thing is that Python is slower than Matlab, so it takes several seconds to run the analysis. Matlab is really excellent. It seems that Python is always slow, but since I recently bought an AI chip, the AI analysis should be fast with Python. The chip is dedicated to AI, so it's unavoidable that other processes are slow.■TensorFlow
Today, I tried implementing AI using TensorFlow 2+Python 3, but most of the information online is for TensorFlow 1, and there are few TensorFlow 2 samples. I managed to get a prototype working, but the output values seem strange, and it's not producing the correct answers. When I used MATLAB, I could create something quickly in one day, but this seems like it will take a bit longer. MATLAB is easy to use because it's a product. I'm gradually getting used to Python, so I think I can figure it out, but the need for unique rules and conversions in each library is a bit of a hassle.

By the way, the Google AI TPU chip I purchased seems to be best used with a Raspberry Pi, so I'm setting up the Raspberry Pi that I bought and left aside. It seems like it will be useful in an unexpected way. I didn't have a case for the Raspberry Pi before, but since I'm going to use it for a long time, I bought a case. When I turned it on for the first time in a while, it didn't work, so I tried to remove the Micro SD card, but it broke, so I had to buy a new one. I also re-set up the OS. It's a hassle, but there's nothing I can do about it.■ Simulation of shareholder profits and losses
Simulates and graphs the profits and losses of shareholders in a simplified manner.
The graph above shows the actual stock price fluctuations and an approximation formula. The graph in the middle is the one that was added this time, and it shows profits when the value is above 0 and losses when it is below 0. The graph is assumed to represent the average situation for all shareholders, where if the graph is above 0, it means that, on average, all shareholders are making a profit, and if it is below 0, it means that, on average, shareholders are incurring losses. Since we don't know who bought or sold, we assume that all shareholders are trading on average, but surprisingly, a graph that looks quite realistic emerges even with this assumption. If the graph is below 0, it means that everyone is losing money, and if it is above 0, it means that everyone is making a profit.
This shows that around November 2018, the stock price decreased, and the number of people incurring losses increased, but the situation has now stabilized. However, this alone cannot determine whether it is a good time to buy now. Rather, it seems that this kind of indicator could function as a signal to avoid buying. In April 2018, the stock price did not fluctuate much, but some people made a profit due to a rebound, but otherwise, most people incurred losses.
This is not AI or machine learning, but simply a simulation. However, it may be that this kind of thing is subtly useful.■ Simulation of shareholders' unrealized gains
Further analysis. Simulate the unrealized gains of shareholders and display them in a graph. It's gradually becoming more sophisticated.

With this new graph, you might notice things like the following:
■ Even though the stock price has increased many times, the (average) unrealized gain for all shareholders has not increased much until the very end (①).
■ During the final sharp stock price decline (②), the unrealized gain has not decreased that much (③). This suggests that people are firmly taking profits at higher prices.
■ During the final sharp stock price decline (④), the trading volume increased, and at the same time, the unrealized gain increased (⑤). This means that large investors might be picking up shares that were dumped by smaller investors and making a profit through a rebound.
Things that were previously invisible are now becoming visible. Analysis is interesting.Now, let's analyze this stock. This company, which was causing a stir in the news, has seen its stock price plummet (1).
As the stock price falls, the unrealized profit (estimated) also decreases (2). Finally, it hit a bottom and rebounded (3). Although the rebound has increased the unrealized profit (4), on the other hand, the shareholders' profits and losses are negative (5. Anything below the central red line is a loss), which suggests that even though the unrealized profit temporarily increased during the final rebound, many people were unable to realize that profit and ended up cutting their losses. This is just based on a simulation.
It cannot be said that this one stock represents everything, but it may suggest that "the possibility of losing money when aiming for a rebound is higher." The graph clearly shows that, even with a rebound, the average shareholder is likely to lose money.
Based on what we see here, it might be better to avoid trying to catch a rebound in stocks that are falling.
I'm not a good stock trader, you know.■Moving Average
Added buy/sell signals based on the up/down status of the moving averages (9-day, 25-day, 75-day).
This implements the algorithm that was described in a textbook-like resource called "The Ultimate Way to Read and Use Moving Averages."
The colors in the area above the signals indicate the following:
- Dark red: Strong buy signal
- Dark green: Strong sell signal
- Intermediate colors: Indicate a state in between.

Although it's based on a textbook, if you follow the signals immediately, you might be able to make some profit.
The basics are important...■MACD
Displays the MACD (MACD itself + average of MACD + histogram). Also displays the current stage with a label. Lines are added to indicate when the stage changes.■RCI
Added a stock indicator called RCI. The standard RCI has two lines, a short-term and a long-term, but I added a histogram (bar graph) similar to the MACD signal to make it easier to see (the green bar graph in the RCI area is that). It's surprisingly good, and it's strange that this display isn't available in normal stock tools.
Furthermore, since it's a hassle to compare both RCI and MACD, I added a red dot when both are positive and a green dot when both are negative to make the signal display clearer.
When you look at it this way, you can compare the signal from the moving average (above the RCI) with the signal I added (the signal between the RCI and MACD).
It's interesting to see how the long-term analysis and the short-term analysis differ. It's quite interesting. The signal I added today seems like it could be used quite a bit.■Short-term price fluctuation graph
This graph displays only the short-term price fluctuations by subtracting the moving average (trend) from the original stock price. This makes it easier to see the short-term fluctuations without being misled by the trend.
(The graph changes depending on the number of days for the moving average, so it automatically determines and displays values that are roughly aligned horizontally.)
This is an example of a graph showing the difference between the original stock price and the value of the 89-day moving average.
Originally, I was trying to perform time series analysis, but when I analyzed it, I didn't find any particularly good periodic characteristics, so I'm just displaying the graph that I created in the process. This graph, in itself, seems surprisingly useful.■Donchans Rules
The "Donchans Rules," which are known as "buy when the price exceeds the high of the past four weeks, and sell when it falls below the low of the past four weeks," have been visualized. Also, the label now displays whether the final day's closing price has exceeded the threshold. This makes it much easier to see.
Although various rules have been created, if we don't verify which rules are truly effective, it may become difficult to use due to the overwhelming number of signals.
I think I'll eventually run simulations to verify them.■Simulation
Simulate and display in red/green whether it reaches +5% or -5% from the closing price of that day.
This makes it easier to get an idea of "where it's better to buy" and "where it's better to sell."
It seems that whether the histogram (bar graph) of the RCI is protruding or not can be used as a signal.
By the way, this stock that I've been interested in recently. It's a company that was originally in 3D graphics LSI, which acquired a famous beauty salon that everyone knows. Those who know it know it, but the stock price is very strange. Sales of 50 billion yen with an operating deficit, market capitalization of 3.4 billion yen. Even though it's in the red, the cash flow is significantly positive, and the "acquisition cost" of the M&A is a heavy burden on the balance sheet for the next few years, but it will end in a few years, and I have a feeling that it will improve in the future. When sales of 50 billion yen recover to an operating profit of 5 billion yen, a market capitalization of 3.4 billion yen is unlikely, and it should at least increase to a profit, and normally it should be around the same as sales, so the upper limit would be a market capitalization of 50 billion yen, which means it's a potential tenfold return. Even if it doesn't reach that, the expectation of a doubling is possible if profitability becomes visible. There is a possibility of a significant drop due to large-scale transactions. Since the stock price is already strange, I wouldn't be surprised if it halved from here. In fact, I've been watching it since the end of March, and I've been in and out several times, but the drop after the end of March was terrible (laugh), aiming for the benefits (beauty salon vouchers). Moreover, a large-scale sell-off came afterwards, causing a 10% drop in one go. It might drop again from here, but the final earnings report will be next month, and beauty salons are a stock that women are most interested in in the summer (because they want to go to beauty salons to expose their skin). This stock looks interesting for the next six months.
→ However, after investigating further, it seems that the sales figures are likely a deceptive accounting trick. The performance looks suspicious.■Catching up to the level of Matlab
I implemented AI (deep learning) using Python + TensorFlow (Version 2). It's almost the same process as what I was doing in Matlab.
The green dot in the center-right of the graph represents the future stock price predicted by the AI. The results are relatively similar to Matlab, so the basic principles are the same.
At first, I couldn't get used to the unique way of writing in TensorFlow (Version 2), so it was difficult to create it. But after finding some samples, I was able to create it smoothly. I haven't used Google TPU chips yet, and running it on my Mac's CPU is, of course, slow. I wonder how much faster it will be when using Google TPU chips. I'll talk about that another time.
It's a simple thing, but I guess I can now consider myself a member of the AI engineering community (laughs).■FX
I have modified the system to predict stock prices, also taking into account FX (foreign exchange, USD). Until yesterday, it only considered the stock price of the relevant stock (one variable), but now it considers the stock price and the USD foreign exchange rate (two variables).
However, at first glance, the results don't seem to have changed much... It seems that verification is necessary. It's possible that there is little correlation. There might be some correlation with large-cap stocks listed on the Tokyo Stock Exchange. I think I'll try adding other factors as well.Next, analysis using three variables: "stock price, trading volume, and USD foreign exchange (FX)."
Since I can convert from one variable to two variables, it's very quick to use three variables.
Well, the appearance doesn't change much.
I wonder how the accuracy is.
Should I include the NY Dow?■Google TPU does not support LSTM
I tried to run the Google TPU chip (USB) on a Raspberry Pi, but it turned out that it does not support LSTM (RNN), and only supports classification, etc. I feel frustrated, but I learned something, so it's okay. That's why the chip is cheap. It's amazing that Google can sell even such a half-baked toy. It seems to be good for specific applications such as dynamic recognition.

- It took 30 minutes to 1 hour just to install the TensorFlow library. The Raspberry Pi is incredibly slow.
- It was originally TensorFlow Ver. 1, and Ver. 2 requires building from the source, so I tried to set up a build environment, but it took more than 24 hours to build a tool called Bazel, and in the end, the latest version of Bazel was not supported, so I had to rebuild an older version of Bazel, which was a waste of time. Even so, TensorFlow Ver. 2 didn't work properly. I'm frustrated. Since it failed on the standard Raspberry Pi OS, I tried it with Ubuntu, but the same thing happened. I wasted time, but I switched back to the original OS.
- The Raspberry Pi has an Arm CPU, so the standard libraries and Docker images provided by Google TPU cannot be used directly, and you are limited to those for the Raspberry Pi, which is inconvenient.
- The standard Python version in the OS was Ver. 3.5, so I first built Ver. 3.7 from the source, but it seems that TensorFlow does not support it, so I installed Ver. 3.6, but it didn't make much difference, so I switched back to the standard Ver. 3.5.
- I thought it might be a problem with the libraries, so I built several from the source, but it still didn't work.
- In the end, I concluded that using TensorFlow via Keras doesn't make much difference between Ver. 1 and Ver. 2, and I confirmed that both versions work on my Mac.
- The Google TPU itself does not support "training from scratch," but only "retraining." I learned that you have to create a model on a CPU, then apply a special conversion, and then convert it again on a cloud page before you can use it, but it turned out that this conversion does not support the LSTM/RNN that I want to use. I'm frustrated.

Should I buy a cheap PC and an NVIDIA GPU, or should I just put up with what I have now...?

■Creating an AI stock analysis sitehttps://kabu2u.comWe have updated the stock price AI analysis website. We will gradually add information on stocks with high volatility. We are not yet sure how detailed we should make the information, so for now, we are only publishing data that is two weeks old. We will not include future predictions for now, as it would be troublesome to receive complaints. In the future, if the accuracy improves, we may consider making future predictions a paid service. However, the accuracy is not yet high enough, so we think this is a good starting point.

■ Elliott Wave Analysis
We are currently working on Elliott Wave analysis. (Please search online for information on what Elliott Waves are.)
We initially tried to have the AI determine which wave was occurring based on the actual waveform, but it seems difficult, so we are changing our approach.
We are considering simulating Elliott Waves and having the AI learn from the simulation results before making predictions.
The figure in the upper left shows the Fibonacci sequence with alternating plus and minus signs, displayed as a graph. However, this results in negative values (which are not possible for stock prices), so we linearly raised the entire graph to make it positive, as shown in the figure in the upper right. Hmm. Something feels a little different. Instead of linearly raising the graph, we raised it using a quadratic curve, as shown in the figure in the lower left. This looks somewhat promising, but something still feels different. However, the actual stock prices also make unpredictable movements, so perhaps this level of detail is sufficient.
We have created a graph, so we will use this as a basis to create dummy stock prices and then analyze them with AI. The graph shown in the lower right is the result of that analysis.
We have now taught the AI, but the actual accuracy of the predictions remains to be seen.■Building a dedicated PC for AI analysis
I installed Ubuntu Linux on a laptop (sub PC). It originally had Windows, but it would hang up every few hours when running AI analysis, so I had to install Linux Ubuntu, and it turned out to be incredibly smooth. It seems that the era when the comfort of Linux surpasses Windows has begun. Recent versions of Windows are unstable and slow, and I feel like I'm strangling myself. Since I need WORD/Excel for office tasks, I still need Windows, but otherwise, it seems that the era when Windows is no longer necessary is coming. If I were to build something now, if I make it web-based and eliminate the need for Word/Excel/PowerPoint, I think I could do without Windows. I basically like Microsoft, but I have been troubled by the instability of recent versions of Windows. The execution speed is also faster on Linux. The Google TPU chip (USB) also worked normally.■ Features extracted and analyzed
We are extracting and analyzing features that people are likely to be aware of. The accuracy is decent, and sometimes it yields good results, depending on the stock.
Deep learning essentially imitates the movement of neurons in the brain. Therefore, it makes sense that providing features as input beforehand can improve accuracy. However, if you specialize in that way, the accuracy will plummet for stocks that are unrelated to those features. Stock price analysis is inherently difficult, so perhaps we should be content with having usable conditions.
If the features have meaning, the error will gradually decrease during deep learning and it will converge. However, if it doesn't converge, there may be a bug in the feature values, or, perhaps, the feature itself has no meaning (!). This latter realization is novel, and deep learning may be revealing that theories that are generally considered "obvious" in the stock market are actually meaningless. For example, it is often said that a golden cross of short-term and long-term moving averages is a buy signal, and similar things are said about the MACD golden cross, but in reality, there may be no meaning in that (!). This is the "possible" result of deep learning analysis. The rest will be continued tomorrow.■Trend Following
Since technical analysis seems to have low accuracy, I created an AI that simply follows the trend. It is inevitable that this AI is weak against sudden drops or surges, but it has achieved relatively good results in trend following compared to before. The thick red line represents the AI's predictions. Perhaps this type of application is inherently well-suited for AI. Humans may get bored with trend following, but we can simply have the machine perform the task diligently.

In technical analysis, I tried various methods by processing the input values, but this trend following approach has a very simple algorithm. However, if the combination of parameters is not optimal, it may not work properly. This suggests that even though the algorithm is simple, the challenge of finding the optimal parameters may be a problem that is well-suited for deep learning.■AI stock price prediction site, initial version.AI stock price prediction - https://kabu2u.comInitial version completed. We can review the model and use more computing power for deeper analysis, but considering the cost-effectiveness, this seems like a good point to draw the line for now. There are still many ideas to try, but this is a decent result considering it was created in two and a half months. One month was spent on various experiments, and another month and a half was spent on modifications for the website and other purposes. The accuracy is still lacking, but the analysis has been prioritized over time, so we will see how much the accuracy can improve as we spend more time on it. We will gradually make time-consuming modifications, such as increasing the model size if the accuracy is insufficient, but the basic functionality is complete. Currently, the display is too simple, so we plan to gradually add more features.

■ Added support lines
Support lines have been added based on the assumption of purchasing at the opening price on the day after the predicted date. This makes it a little easier to see.■Candlestick chart
Changed from a line graph of closing prices to a regular candlestick chart. It doesn't feel right unless it's like this.■Air Trade
I tried including air trade. If I could see this, I should be making more money, but maybe my performance isn't good because I can't trade mechanically and I get emotionally involved.

■Algorithm Review
I reviewed the air trade algorithm. I posted the air trade results for all stocks on the top page.

■Air Trade with Perfect Order
I tried air trading based on short, medium, and long-term lines, which is commonly called a "perfect order," but the results were not good. Maybe it's because the current market conditions are bad, or maybe it's just an urban legend that's similar to technical analysis and has no real basis.
Profit/loss average +0.5%, cumulative +0.6%.

■Algorithm Comparison
I simulated a comparison of two algorithms: one that buys when the next day's opening price is a few percentage points lower than the previous day's closing price, based on AI predictions of an upward trend, and another that buys when the next day's opening price is equal to or higher than the previous day's closing price. Although it seems like the former, "buying at a lower price," would have better results based on human intuition, the latter actually wins. This can be understood because stock prices tend to continue rising if they rise and continue falling if they fall.
The average profit/loss for each is +2.0% and +0.9%, so it might be a difference.

■Air Trade Calculation Error
I made a mistake in the air trade calculation. Yes. I thought the results were too good. The new results are as follows: approximately -1%.
Even though the market conditions have been very bad since the beginning of the year, a profit/loss of -1% can be seen as a good effort.
I want to believe that it will become positive if the market conditions recover.

Air trade 1 [Average of all target stocks] Profit/loss: +0.1% (weighted average, recent emphasis) -0.1% (average, entire period) Cumulative -1.3% (entire period)
Air trade 2 [Average of all target stocks] Profit/loss: -0.8% (weighted average, recent emphasis) -0.7% (average, entire period) Cumulative -1.5% (entire period)
Air trade 3 [Average of all target stocks] Profit/loss: -0.8% (weighted average, recent emphasis) -0.7% (average, entire period) Cumulative -1.6% (entire period)
Air trade 4 [Average of all target stocks] Profit/loss: -0.8% (weighted average, recent emphasis) -0.7% (average, entire period) Cumulative -2.2% (entire period)
Air trade 5 [Average of all target stocks] Profit/loss: -0.1% (weighted average, recent emphasis) -0.1% (average, entire period) Cumulative -0.8% (entire period)

■Market Conditions are Important
The market conditions were good today, so it recovered to positive. I need to modify it so that it becomes positive regardless of the market conditions.

Air trade 1 [Average of all target stocks] Profit/loss: +0.5% (weighted average, recent emphasis) +0.1% (average, entire period) Cumulative -0.0% (entire period)
Air trade 2 [Average of all target stocks] Profit/loss: +0.4% (weighted average, recent emphasis) +0.2% (average, entire period) Cumulative -0.1% (entire period)
Air trade 3 [Average of all target stocks] Profit/loss: +0.1% (weighted average, recent emphasis) -0.0% (average, entire period) Cumulative -0.5% (entire period)
Air trade 4 [Average of all target stocks] Profit/loss: +0.4% (weighted average, recent emphasis) +0.2% (average, entire period) Cumulative -0.0% (entire period)
Air trade 5 [Average of all target stocks] Profit/loss: -0.3% (weighted average, recent emphasis) -0.4% (average, entire period) Cumulative -1.4% (entire period)

■AI is Still a Black Box
I've started to notice predictions that seem right, but also results that are obviously wrong. However, even when I, as a human, think something is wrong, the actual stock price is even more incomprehensible, so it might be beyond the realm of understanding. AI, or deep learning, has the disadvantage of having an unknown intermediate result, which is a black box. It's difficult to explain why such results are produced. Although there is a basic logic, it is difficult for AI to explain in detail. Therefore, it is important to compare the results with reality to see if they are correct. It seems that the overall direction is somewhat correct, but the timing of when to go up and when to go down is weak. Maybe it's better to use AI to see the direction and have humans adjust the timing?

Also, when I create something like this, there are always people who come to "steal" your achievements or demand a share of the profits, criticize you, and try to belittle your contributions, like parasites. It's always frustrating to have your achievements belittled. When I do it alone, there's no one else around, and since I'm outsourcing to no one, it's clear that everything I created was made by me, and there are no people who try to belittle me or steal my achievements, so it's refreshing. In a company, there's a contradiction where the same thing created by one person is evaluated higher than the same thing created by 10 people, even though it's obvious that the former is more efficient. Even though the former has 10 times the cost-effectiveness, the latter is evaluated higher because it costs 10 times more. Superiors who don't understand IT don't understand that something can be created by one person. Because they don't understand IT, they tend to easily believe grand promises and confident people. Because they don't understand IT, they judge based on the number of people rather than results. I hope that there are not many such companies. IT professionals don't stay in such companies for long. I hope there are companies that value results. Ultimately, those at the top don't understand technology or results and judge based on the number of people. The IT industry is still a "person-month" society, and in the development industry, it's not about making something efficiently, but about creating a "ritual" of making a grand fuss for customers who have money but don't know IT, and that's what makes money. It's almost impossible to be paid based on results. That's why I don't like the development industry, and I basically only trust companies or individuals who use IT for their own business. Well, if everyone only valued results, many people might be unemployed, so maybe the IT industry is supporting people's livelihoods in a way.

■Air Trade Monitoring
The recent average of Air Trade 4 has increased to +4.3%. The number of monitored stocks has exceeded 300. It may just be a random error or luck, so we are still observing.
We are continuing to train the AI model. We are making small adjustments every day.■5 wins, 1 loss
Based on the analysis results from the other day, the air trades resulted in 5 wins and 1 loss. That's not bad.
Of course, since it's an air trade, I didn't actually buy anything.On the same day, things were even more crazy. Wow. It's an Air Tre.■OCR
I'm not buying it, but Sansan seems like it might become a legendary IPO. It's a company that went public at a loss, with low sales, but its market capitalization is 12 billion yen, which is incomprehensible.
I made a rough calculation of Sansan's dividend yield based on optimistic assumptions. This is only if the company actually grows as the president says. If it enters a period like the mobile payment market, where competition is fierce, the stock price will likely continue to decline. Technically, it's easy to imitate, so it's mainly a problem of marketing. It depends on how the major players react. Looking at this profit margin, I might be tempted to invest.Sansan is just a system that uses OCR to read business cards, right? I wonder how they managed to get listed on the stock market and make a lot of money with something like that. It's similar to Amazon in that they probably focused on marketing to achieve a monopoly and make a lot of money. I'm thinking about trying to create a trendy AI character recognition application just for fun. And the idea of creating something "Sansan compatible" to steal all their customers (lol) might be a bit too much. For now, I'll just try creating an app that infers font strings from images.

Anyway, I searched for articles about Sansan, and...It will not become popular unless it has 100% accuracy.This is a typical Japanese anecdote. It seems surprisingly complicated. Perhaps that's why it's a differentiating factor, but I don't think people around the world are necessarily looking for that level of accuracy.
Moreover, business cards might disappear altogether.

Google has an open-source OCR, so I might try it out sometime.

■ Afterwards
I've been continuously training the AI model, making fine adjustments, and the website is still running. I can't overcome the poor market conditions, so the operating results are quite difficult. It's around 1% when the market conditions are good, but it's negative when the market conditions are bad. Perhaps it's best to only use it when the market conditions are good. It's difficult to use it as is, but it's too much to scan all stocks myself, so using it as a method for a certain level of filtering seems reasonable.

Creation period:
Mid-March 2019: Downloaded Matlab and started experimenting.
Early April: First attempt with Python.
End of April: Initial version of the AI analysis website completed.
End of May: AI analysis website almost completed.
Since then, the model has been continuously trained on a dedicated PC, and adjustments are made as needed.

Topic: IT業界