Algo Trading News Headlines 8/29/2018

Brazilian crypto trading platform hacked, over 264000 user data leaked

(www.coingeek.com)

Portal do Bitcoin reported that the hack was initially brought to light through a YouTube video posted by Investimentos Digitais. A total of 14,500 accounts containing a total of 5,813 BTC, currently worth about $40 million, were reportedly affected by the security breach.

Photo by  Pedro Menezes  on  Unsplash

Photo by Pedro Menezes on Unsplash

Forecasting Market Movements Using Tensorflow

(alpaca.markets)

In this post we’ll be looking at a simple model using Tensorflow to create a framework for testing and development, along with some preliminary results and suggested improvements.

$6 Billion Daily Crypto Volume is Being Faked, How Can it be Combated?

(www.ccn.com)

Earlier this week, the Blockchain Transparency Institute (BTI) published a report claiming that the global crypto exchange market is faking $6 billion of its daily volume. The researchers at BTI evaluated the user activity and traffic of the market’s biggest crypto exchanges, comparing their projected trading volume to other metrics.

Empower Sebi to crack down on erring CAs, says panel

(http://www.asianage.com/)

New Delhi: The fair market committee report submitted to securities market regulator Sebi has many more unpleasant surprises for various market-connected entities. For instance, it opens a pandora’s box on whether Sebi has jurisdiction over errant chartered accountants or not.

/

Algo Trading News Headlines 8/27/2018

Trading Places — Lines Blurred Between Traders And Programmers

(seekingalpha.com)

The recent WSJ article focused upon details from Adam Korn, a 16-year veteran at Goldman. He stated that success today depends less on trusting one’s gut, rather much of a trader’s job is embedded in the computer code or algorithms, which do much of the work now.

What is the real story though, what has all this computerized algorithmic trading truly done, how much value has it truly created? One question I would like to ask, is there a correlation between the explosion of our debt levels and this newly digitized financial age?

Photo by  Phil Botha  on  Unsplash

Photo by Phil Botha on Unsplash

Major Russian Airline Tests Blockchain in Bid to Track Fuel Payments

(www.coindesk.com)

According to S7, the application shares data about fuel demand on a shared ledger, a copy of which is managed by each of the three parties. Further, payments for the fuel can be conducted on the network, with digital invoices created via smart contract during each transaction.

Python Notebook Research to Replicate ETF Using Free Data

(alpaca.markets)

ETF is one of the great investment products in the last decade, and it has allowed so many people to gain the exposure to the wide range of assets easily at low cost. It is easy to buy a share of ETF without knowing what’s in there, but as a tech-savvy guy yourself, you may wonder how it works. By reconstructing the fund yourself, you may even come up with something better.

Trading Lesson: Don’t Touch That Dial. More to Come, Hedge Your Bets

(www.moneyshow.com)

In my 30 years as a trader, I’ve never seen a market like this. If the bots remain faithful to their programs, we are still likely to see higher stock prices over the next few weeks to months.

STEROID Launches New Automated Cryptocurrency Trading Algorithm

(www.bitcoinexchangeguide.com)

Algorithms run our online world, for the most part, a majority of everything done online is associated with an algorithm in one way or another. It only makes sense therefore that they would be used in the financial world as well. That is why STEROID has been developed, to create a functioning opportunity for traders on crypto exchanges.

Here’s how artificial intelligence can be used to beat the market

(www.cnbc.com)

CNBC’s Bob Pisani is joined by Sam Masucci, ETF Managers Group CEO, to discuss how he’s using an AI program to pick stocks.

/

Python Notebook Research to Replicate ETF Using Free Data

ETF is one of the great investment products in the last decade, and it has allowed so many people to gain the exposure to the wide range of assets easily at low cost. It is easy to buy a share of ETF without knowing what’s in there, but as a tech-savvy guy yourself, you may wonder how it works. By reconstructing the fund yourself, you may even come up with something better.

In this article, we present some basis for you to start your research easily in python to science the ETF world. You can find the complete notebook in GitHub.

Photo by  Kevin Ku  on  Unsplash

Photo by Kevin Ku on Unsplash

What is ETF by the way?

ETF stands for Exchange-Traded Fund. Unlike other types of funds, its shares are traded in exchanges like individual company’s common stocks. The fund is managed by an ETF company and manages portfolio based on the strategy, often diversifying the exposure spread across the market.

One of the most popular ETF is SPY, that tracks S&P 500 index performance. Because of its convenience to manage the risks, not only has it been used by individual investors, but also robo advisors construct their portfolio using ETFs. The convenience doesn’t come for free, of course, and there is an associated cost called expense ratio, that varies an ETF to another.

An ETF’s return comes from the returns of underlying assets it holds. ETFs can hold not just individual stocks but also options and swaps, but in the case of market index ETF like SPY, it constructs a simple long position portfolio.

If the constituents are simply long only stocks, is it easy to run some simulation even in python? If it’s possible to build your own ETF-like portfolio, you don’t even need to pay ETF cost? The answer is YES.

Recreating ETF

Various services provide ETF constituent data either through their website or API, with paid and unpaid style. Some provide even historical data. We recommend to find your best services by yourself, but here we automate the process by Selenium to save your time copying and pasting the list of underlying stocks of particular ETF.

get_etf_holdings() will return the list of constituents in pandas DataFrame format, and the columns include weight in the portfolio and an actual number of shares holding as of today. 

Note this does not come with the price data, but you can pull the historical price data from IEX API for free.

get_closes() will take the constituent data from get_etf_holdings() and return the daily closing price history for the last month from IEX API.

Simulate SPY performance

Before doing something unique, let’s just check if our assumption is correct. The task here is to calculate the historical performance of reconstructed portfolio and compare that with the actual ETF.

Remember the constituent list we have is the one as of today. The fund may have rebalanced, but we assume that’s not the case and we build our portfolio a month ago. Putting altogether, we get something like this.

1_OZI7PVciSwZS3MuNxxAudA.png

Even though we took the constituent data as of today, and applied it to simulate the last month, the result isn’t too different. This means this ETF hasn’t changed the holding shares significantly.

So, I don’t need to buy ETF but just buy these stocks?

It’s a natural question whether you can replicate ETF portfolio by buying only underlying stocks.

Yes, you can, only if you have more than $260,000,000,000 ($260BN) which is SPY’s market cap today. But no, you don’t have it, so let’s see how it changes if you do so with $10K. The resulted portfolio we get after some calculation is as below.

The actual total market value of this portfolio is about $2K. The reason why it diverges from the original target is because you don’t buy fractional shares. All fractions are truncated, resulting to much smaller. On the flip side, we found that we can build something similar to SPY with smaller amount of dollar. Running the same historical plotting, we get this.

1_wneCpDX4nv__MddVlztFIw.png

The divergence is much bigger compared to the first one, and the volatility increased, but in terms of the return, it is not too bad. As a study, it is great to see the actual example like this that more diversified portfolio has less volatility, as the modern portfolio theory teaches.

Summary, and now what?

We presented some python research with actual notebook to study how ETF works, and did some simple experiments. You can look at the complete notebook here.

You can try it in your environment! We recommend to clone the notebook and extend the study for your purpose from here. Potential questions you may ask are:

  • what if the cash size is bigger, or smaller?
  • how about other index ETF such as QQQ?
  • how much dollar do you need to have at least one share for each?
  • can you replicate the return more precisely by rebalancing frequently?
  • can you build something similar by using other set of stocks too?

Research is always fun, and you should continue asking these questions. It is a great moment that this kind of research can be done in a day with only your laptop.

We leave it to the readers to what to do from here, but please let us know what you find if you do something in the comment, or to our Twitter @AlpacaHQ! We hope you will leverage the technology to automate your investments.

/

Algo Trading News Headlines 8/23/2018

Barclays hires AI specialist from Goldman intrading revamp

(www.fnlondon.com)

The hire is another sign of Barclays’ intent to ensure its markets business can compete with rivals in the City and on Wall Street, which are increasingly turning to new technologies to improve performance and cut costs.

No Quant Is Safe as Global Stress Hits Risk Parity Where It Hurts

(www.bloomberg.com)

Risk-parity’s travails might test faith in the trading style over traditional allocations. It’s among the worst-performing categories tracked by JPMorgan, falling 1.2 percent this year. That compares to a 2.1 percent gain for long-short equity funds, 1.7 percent for macro funds, and 2.9 percent for balanced mutual accounts, according to data published by the U.S. bank earlier this month.

UBS trials Netflix-style algorithms for trading suggestions

(www.cnbc.com)

UBS is looking at applying recommendation algorithms to suggest trades to its asset management and hedge fund clients, similar to those used by a host of consumer technology companies.

Market makers, takers and fakers: US exchanges are losing fast

(bravenewcoin.com)

The great ETF debate rages on and there’s a lot of conjecture as to why the SEC should or shouldn’t approve one. But what needs to be addressed foremost is the immaturity and unreliability of many of the exchanges that bitcoin derives its “global spot price” from — that number now over 210 — and the obstacles they may encounter going forward.

Indicators That Could Have Made You 626% ROI During The Recent Bloodbath

(cryptodaily.co.uk)

Those indicators are the 5 EMA and 10 EMA as can be seen on the daily chart for BTC/USD. These indicators have been signaling the direction of every bullish and bearish wave throughout the correction period.

/

Algo Trading News Headlines 8/22/2018

Wall Street Erases the Line Between Its Jocks and Nerds

(www.wsj.com)

There used to be a strict hierarchy: Traders made money and won glory while programmers wrote code and stayed out of sight. Those days are over. Meet the straders. Part risk-taking trader and part computer-whiz “strategist,” they are prowling the halls at Goldman Sachs Group Inc., erasing a once-religious line between the jocks and the nerds.

Photo by  FOTOGRAFIA .GES  on  Unsplash

Israel’s Central Bank Wants Increased Regulation on Algorithmic Trading

(www.calcalistech.com)

Over 90% of the activities on the Tel Aviv Stock Exchange are algorithmically performed, according to a new research published by Israel’s central bank last week. While the number of algorithmic automated high-frequency trading (HFT) activities on the exchange is higher than most stock exchanges, the actual rate of transactions they execute, between 23% and 35%, is significantly lower than global standards, the report said.

Global Algorithmic Trading Market 2018–2025 by Business Players: Virtu Financial, KCG, DRW Trading, Optiver

(threepmnews.com)

Geographically, the global Algorithmic Trading market is designed for the following regional markets: USA, EU, Europe, China, Japan, Southeast Asia, India. It also studies the revenue market status, analysis of main manufacturers. It deciphers the Sales Price and Gross Margin Analysis and Global Sales Price Growth Rate, Marketing Trader or Distributor Analysis. The role of traders and distributors is emphasized in this research. The complete analysis of Algorithmic Trading Market on the global scale provides key details in form of graphs, statistics and tables which will help the market players in making key business decisions.

Wall Street Finds Limits with Current AI Applications

(www.wsj.com)

“A lot of work needs to be done to translate (AI) advancements into benefits for finance,” said Ambika Sukla, executive director of machine learning and AI at Morgan Stanley, at an AI conference Tuesday. “As we work on some of these new models, it’s important to proceed carefully and have a human in the loop.”

Machine Trading: Deploying Computer Algorithms to Conquer the Markets

(www.wiley.com)

Algorithmic trading is booming, and the theories, tools, technologies, and the markets themselves are evolving at a rapid pace. This book gets you up to speed, and walks you through the process of developing your own proprietary trading operation using the latest tools.

Comparing 3 Different Types of Neural Network Architectures in Finance

(blog.alpaca.markets)

When working on a machine learning task, the network architecture and the training method are the two key factors to turning a set of data-points into a functional model. But where should different training methods be applied? How do they work? And which is “best”? In this post, we list up three types of training methods and make comparisons among Supervised, Unsupervised and Reinforcement Learning.

Coinscious Introduces Crypto Prediction Machine Built to Synergize AI and the Blockchain

(www.benzinga.com)

Every day, people spend significant amounts of time reading financial news and checking cryptocurrency prices, gathering information that they hope can lead to better decisions. However, the quantity of information available is overwhelming and calls for effective tools and suitable methodologies to enable us to distill data into actionable insights. By processing large data sets quickly, machine learning algorithms can use news sources such as the Financial Times, The Washington Post, or Twitter to provide key insights.

/

Algo Trading News Headlines 8/17/2018

Startup Raises $23 Million To Make Crypto Trades Faster And Stealthier

(www.forbes.com)

Silicon Valley-based cryptocurrency trading platform Sfox has raised $23 million in new investment, led by venture firms Tribe Capital and Social Capital. The 20-person startup aims to help investors make large trades by routing their orders to multiple places, enabling faster execution and better prices. Khosla Ventures, startup accelerator Y Combinator, and crypto investors Blockchain Capital and Digital Currency Group also participated in the Series A funding round. Forbes estimates Sfox has reached $15 million in revenue over the past 12 months.

Photo by  John-Paul Henry  on  Unsplash

Blockchain Firm Exscudo To Add Trading Robots Support On Its Crypto Exchange

(blocktribune.com)

Exscudo is currently testing a trading terminal API that will allow Exscudo exchange users to utilize a trading robot that automatically makes trading decisions based on market data analysis and pre-programmed set of parameters.

Forecasting Market Movements Using Tensorflow — Intro into Machine Learning for Finance

(blog.alpaca.markets)

In this post we’ll be looking at a simple model using Tensorflow to create a framework for testing and development, along with some preliminary results and suggested improvements.

The World Economic Forum warns that AI may destabilize the financial system

(www.technologyreview.com)

Compiled through interviews with dozens of leading financial experts and industry leaders, the report concludes that artificial intelligence will disrupt the industry by allowing early adopters to outmaneuver competitors. It also suggests that the technology will create more convenient products for consumers, such as sophisticated tools for managing personal finances and investments.

/

Algo Trading News Headlines 8/15/2018

Goldman Sachs, JPMorgan Strengthen Algo Trading Units With New Hires

(www.financemagnates.com)

Algo trading has been an important component for many banks in recent months, with the latest hires possibly portending a drying up of supply to meet a growing demand. In any scenario, banks have been quickly scooping up top-tier talent in the algo trading arena, with Goldman Sachs and JPMorgan emerging as the latest players to do so.

Photo by  Sean Pollock  on  Unsplash

Photo by Sean Pollock on Unsplash

Comparing 3 Different Types of Neural Network Architectures in Finance

(blog.alpaca.markets)

One good use may be in the analysis of portfolios. By clustering equities and financial instruments you can get a unique view of the distribution of exposure and risk, and either hedge accordingly or look to maximise the efficiency of exposure to one area of the market.

4 Problems with Using a Crypto Trading Bot on Exchanges

(cryptodisrupt.com)

“Get a crypto trading bot”, said a friend. “You will be swimming in cash”, he said. It was with the ultimate of best intentions that my friend advised me to use a trading bot. They are definitely a great way for crypto trading newbies to start making money and understanding how exchanges and the markets work but are trading bots simple to use? And is it really that easy to make money with them?

Can Robots Replace Day Traders on Wall Street?

(www.financemagnates.com)

Goldman Sachs has already begun to automate currency trading, and has found consistently that four traders can be replaced by one computer engineer.

/

Comparing 3 Different Types of Neural Network Architectures in Finance - Intro into Machine Learning for Finance (Part 3)

When working on a machine learning task, the network architecture and the training method are the two key factors to turning a set of data-points into a functional model.

But where should different training methods be applied? How do they work? And which is “best”? In this post, we list up three types of training methods and make comparisons among Supervised, Unsupervised and Reinforcement Learning.

Photo by  David Wright  on  Unsplash

Photo by David Wright on Unsplash

1. Supervised learning

In “Intro into Machine Learning for Finance (Part 1)” we covered some high level theory on how a network is trained to improve the accuracy of its model, but we never discussed where the target values for comparison actually come from.

Classification Task

For a classification task, its easy to see. You wish for the model to be able to identify a falling wedge pattern, for example, so you feed it sets of inputs, each labeled as either being a falling wedge or not. If the model mislabels an input the error is back-propagated to change its prediction for the future.

Regression Task

Similarly, for a regression task, the label for each set of inputs will likely be the next value in the time series. For example, you might try to make a model which can learn to predict the price at the close of the next day based on a set of previous market movements.

Both of these cases are examples of “supervised learning” where the model is trained against an already labeled set of data and the error function is calculated as the difference between the predicted output and the supervised labels for the dataset.

This is generally a very simple and efficient process, as the network weightings are updated to minimise the error between the prediction and the target output for each batch of data-points. You already have the target function/ decision process to label the data, its just a case of fitting the model to try to emulate it.

In “Forecasting Market Movements Using Tensorflow — Intro into Machine Learning for Finance (Part 2)” we put supervised learning into practice with a simple neural network to make long/short calls.

2. Unsupervised learning

Meanwhile, unsupervised learning tasks revolve around the model learning complex relationships within data that you haven’t been able to determine yet. This can be through tasks such as clustering data-points, which help to give insight to the structure of the data.

The application to real life and, indeed, trading is often harder to see, which is exactly the reason it can’t be a “supervised” task — it is trying to find relationships in the data that we haven’t found yet.

One good use may be in the analysis of portfolios. By clustering equities and financial instruments you can get a unique view of the distribution of exposure and risk, and either hedge accordingly or look to maximise the efficiency of exposure to one area of the market.

An interesting paper on the creation of diverse portfolios via clustered stocks can be found here.

3. Reinforcement learning

Reinforcement learning is an interesting mix of both supervised and unsupervised learning. While it does require a specific target function to be trained towards, the error that trains the network is deferred from the actual decision making period. The network is instead trained against a “reward” and/or “punishment” function.

The model is attempting to learn a policy of actions to be able to maximise its reward function, such as learning the optimal time to hedge a portfolio in a turbulent market.

There is no immediate profit or loss at the point when the decision is made. Instead, its reward function will be based on how successful the hedging was in protecting portfolio value in coming time-steps. If it were to hedge too early, it could miss out on market upside. Where as, if it hedged too late then the portfolio will suffer greater drawdown.

Since RL is set up to generate actions for an environment, rather than to output a simple prediction, it requires a simulated training environment for the agent to react to and interact with. This can prove challenging both in terms of basic implementation and especially in optimizing to train in any reasonable time frame.

Again, further reading on reinforcement learning for portfolio hedging can be found here.

Comparison and Drawbacks

Dataset generation:

A supervised learning task, such as classification, requires a set of label data to train against. For a simple price predictor this will only require a small pre-processing script which sets the target value as the close price the next day. However, for more complex functions it will require a much more complex algorithm, or even manual pattern identification and labeling. And, due to the large data-sets needed for effective training (10s of thousands at minimum), this can be extremely time consuming, if not infeasible.

Unsupervised learning, on the other hand, has no such issue — as its trying to find relationships in unlabeled data. However, you still need to gather the dataset for use, verify the data is clean enough and interpret the results of the model relative to the data.

Reinforcement learning is similar to supervised, as you need a reward function for the model to train towards. However, instead of a labeled dataset, per se, the model is trained against a simulated environment. This can allow for a simpler function to identify the behavior to be rewarded, but brings added complexity to the setup of the data feeds and how they interact with the model. RL also has the added issue of data requirements — needing huge datasets to train effectively.

Training times:

While both supervised and unsupervised models can require significant time and resources to train adequately, they pale in comparison to reinforcement learning due to the nature of its deferred rewards when training. So, not only will you need a larger dataset to train against for RL, but you will need more powerful machines to run the training process in a comparable time.

Meanwhile, it’s hard to contrast the training process of supervised vs unsupervised methods, as both the time per training step and the number of training steps required will vary greatly depending on the size of the network used and the optimizer/ optimizer settings.

In all cases, it’s advisable to look at using newer optimizers, such as Adam Optimizer, as they can provide faster and less noisy training for the network, achieving a more accurate fit over fewer epochs.

Overfitting:

Overfitting is a serious concern for all training types and, once again, varies more by the quality of data and architecture than type of training method.

A rule of thumb to avoid overfitting: once you’ve found an architecture than can learn to accurately predict training data, if validation accuracies diverge during training then slowly reduce the size of the network until you find the smallest network that still trains to a good accuracy on the training dataset.

If the accuracy against the validation dataset still fails to converge then your issue likely lies with lack of causation between training features and outcome, rather than overfitting of the model.

Conclusion

Each training method is suited to a specific type of machine learning task and data, with supervised being the most likely candidate to create simple trading signals and unsupervised being used for analysing relationships in data to help refine strategies.

While reinforcement learning has great promise in certain tasks, it is unlikely to be particularly feasible vs other machine learning techniques due to huge data and computing requirements.

By Matthew Tweed

/

Algo Trading News Headlines 8/10/2018

Is making money from forex an easy or a difficult thing?

(www.thesouthafrican.com)

Automated trading helps to put a trading plan into action without any participation, with the help of technologies. Automated trading minimizes the influence of your emotions. The advantage of this is that a trader doesn’t need to go deep into strategies and platform trading features.

Photo by  Thought Catalog  on  Unsplash

Top 5 Bitcoin Trading Bots for 2018

(nulltx.com)

When it comes to cryptocurrency trading, a lot of users prefer an automated approach. Although there are a few trading platforms which offer built-in algorithmic trading, trading bots are also very popular. It is interesting to see how the landscape has evolved in this regard. We ranked these bots based on their customization options.

Forecasting Market Movements Using Tensorflow

(blog.alpaca.markets)

Is it possible to create a neural network for predicting daily market movements from a set of standard trading indicators? In this post we’ll be looking at a simple model using Tensorflow to create a framework for testing and development, along with some preliminary results and suggested improvements.

New report examines the automated trading market forecast to 2025

(www.whatech.com)

This report studies the global Automated Trading market size, industry status and forecast, competition landscape and growth opportunity. This research report categorizes the global Automated Trading market by companies, region, type and end-use industry.

/

Forecasting Market Movements Using Tensorflow - Intro into Machine Learning for Finance (Part 2)

Multi-Layer Perceptron for Classification

Is it possible to create a neural network for predicting daily market movements from a set of standard trading indicators?

In this post we’ll be looking at a simple model using Tensorflow to create a framework for testing and development, along with some preliminary results and suggested improvements.

Photo by  jesse orrico  on  Unsplash

Photo by jesse orrico on Unsplash

The ML Task and Input Features

To keep the basic design simple, it’s setup for a binary classification task, predicting whether the next day’s close is going to be higher or lower than the current, corresponding to a prediction to either go long or short for the next time period. In reality, this could be applied to a bot which calculates and executes a set of positions at the start of a trading day to capture the day’s movement.

The model is currently using 4 input features (again, for simplicity): 15 + 50 day RSI and 14 day Stochastic K and D.

These were chosen due to the indicators being normalized between 0 and 100, meaning that the underlying price of the asset is of no concern to the model, allowing for greater generalization.

While it would be possible to train the model against any number of other trading indicators or otherwise, I’d recommend sticking to those that are either normalized by design or could be modified to be price or volatility normalized. Otherwise a single model is unlikely to work on a range of stocks.

Dataset Generation

(Code Snippet of a dataset generation example — full script at end of this post)

(Code Snippet of a dataset generation example — full script at end of this post)

The dataset generation and neural network scripts have been split into two distinct modules to allow for both easier modification, and the ability to re-generate the full datasets only when necessary — as it takes a long time.

Currently the generator script is setup with a list of S&P 500 stocks to download daily candles since 2015 and process them into the required trading indicators, which will be used as the input features of the model.

Everything is then split into a set of training data (Jan 2015 — June 2017) and evaluation data (June 2017 — June 2018) and written as CSVs to “train” and “eval” folders in the directory that the script was run.

These files can then be read on demand by the ML script to train and evaluate the model without the need to re-download and process any more data.

Model Training

(Code Snippet of model training — full script at end of this post)

(Code Snippet of model training — full script at end of this post)

At start-up, the script reads all the CSV files in the “train” and “eval” folders into arrays of data for use throughout the training process. With such a small dataset, the RAM requirements will be low enough not to warrant extra complexity. But, for a significantly larger dataset, this would have to be updated to only read a sample of the full data at a time, rotating the data held in memory every few thousand training steps. This would, however, come at the cost of greater disk IO, slowing down training.

The neural network itself is also extremely small, as testing showed that with larger networks, evaluation accuracies tended to diverge quickly.

1_f4hCWcbMlbEdqsVQefZCiA.png

The network “long Output” and “short Output” are used as a binary predictor, with the highest confidence value being used as the model prediction for the coming day.

The “dense” layers within the architecture mean that each neuron is connected to the outputs of all the neurons in the layer below. These neurons are the same as described in “Intro into Machine Learning for Finance (Part 1)”, and use tanh as the activation function, which is a common choice for a small neural network.

Some types of data and networks can work better with different activation functions, such RELU or ELU for deeper networks. RELU (Rectifier Linear Unit) attempts to solve the vanishing gradient problem in deeper architectures, and the ELU is a variation on this to make training yet more efficient.

TensorBoard

As well as displaying prediction accuracy stats in the terminal every 1000 training steps, the ML script is also setup to record summaries for use with TensorBoard — making graphing of the training process much easier.

While I haven’t included anything other than scalar summaries, it’s possible to record everything from histograms of the node weightings to sample images or audio from the training data.

To use TensorBoard with the saved summaries, simply set the — logdir flag to directory you’re running the ML script in. You then open the browser of your choice and enter “localhost:6006” into the search bar. All being well, you now have a set of auto-updating charts.

Training results

Node layouts: Model 1 (40,30,20,10), Model 2 (80,60,40,20), Model 3 (160,120,80,40)

Node layouts: Model 1 (40,30,20,10), Model 2 (80,60,40,20), Model 3 (160,120,80,40)

The results were, as expected, less than spectacular due to the simplicity of the example design and its input features.

We can see clear overfitting, as the loss/ error increases against the evaluation dataset for all tests, especially so on the larger networks. This means that the network is only learning the pattern of the specific training samples, rather than an a more generalized model. On top of this, the training accuracies aren’t amazingly high — only achieving a few percent above completely random guesses.

Suggestions for Modification and Improvement

The example code provides a nice model that can be played around with to help understand how everything works — but it serves more as a starting framework than a working model for prediction. As such, a few suggestions for improvements that you might want to make and ideas you could test

Input features

In its current state, the dataset is generated with only 4 input features and the model only looks at one point in time. This severely limits what you can expect it to be able to learn — would you be able to trade only looking at a few indicator values for one day in isolation?

First, modifying the dataset generation script to calculate more trading indicators and save them to the CSV. TA-lib has a wide range of functions which can be found here.

I recommend sticking to normalized indicators, similar to Stoch and RSI, as this takes the relative price of the asset out of the equation, so that the model can be generalized across a range of stocks rather than needing a different model for each.

Next, you could modify the ML script to read the last 10 data periods as the input at each time step, rather than just the one. This allows it to start learning more complex convergence and divergence patterns in the oscillators over time.

Network Architecture

As mentioned earlier, the network is tiny due to the lack of data and feature complexity of the example task. This will have to be altered to accommodate the extra data being fed by the added indicators.

The easiest way to do this would be to change the node layout variable to add extra layers or greater numbers of neurons per layer. You may also wish to experiment with different types of layer other than fully connected. Convolutional layers are often used for pattern recognition tasks with images, so could be interesting to test out on financial chart data.

Dataset labels

The dataset is labeled at “long” if price difference is >=0, otherwise “short”. However, you may wish to change the threshold to be equal to the median price change over the length of the data, to give a more balanced set of training data.

You may even wish to add a third category of “neutral” for days where the price stays within a limited range.

On top of this, the script also has the ability to vary the look ahead period for the increase or decrease in price. So it could be tested with a longer term prediction.

Conclusion

With the implementation of the suggested improvements, it is certainly possible to improve on the model to the point where it could be used as a complimentary trading indicator to a standard rule based strategy.

However, expectations should be tempered when it comes to such a simple architecture and training task. Machine learning can really set itself apart with a more refined network structure and prediction task.

As such, in the next article we’ll be looking at Supervised, Unsupervised and Reinforcement Learning, and how they can be used to create time series predictor and to analyze relationships in data to help refine strategies.

Full Script

By Matthew Tweed

/