Check out our new platform 👉 https://thecapital.io/
Published in · 6 min read · Dec 8, 2020
--
In the traditional finance system, order books have served traders well. While it serves its purpose, things have changed with the rapid pace of technological advancement. The trading floor has gone online, and every minute and second is the difference between big gains or heavy losses in the market. Having a broker manage the fluctuations in prices can be an enormous task, especially in the cryptocurrency market.
In the Digital and Information Age, things have been improved upon. This is through the use of algorithmic trading. As the name implies, this a form of trading in which decisions can be made automatically using algorithms written into software. Many traders are familiar with bots that perform and execute trades on a daily basis. They were one of the original forms of software used in trading automation. This is followed by apps and later with blockchain-based smart contracts.
Conditions are written into code and executed on the network. This leaves traders with more time to worry about other things. It saves time and money because an automated system of trading can help traders buy or sell the moment an event occurs in the market. It can also help with risk management, report generation, and scheduling tasks. Traders who rely on the older order book system may stand to lose if they are even a few seconds or at worse, minutes or hours late.
The Benefits Of Trading Automation
To name a few of the main benefits when using algorithmic trading from a development perspective:
- Use industry standard REST API
- Supports OAuth for delegated access
- Automates orders through smart contracts and apps
- Programmable access to data feeds (oracles)
Industry-standard API (Application Programming Interface) allows developers access to supported calls and functions in a familiar setting. This layer of abstraction removes the complexity involved in developing an application from the bottom up when there are routines that can be invoked from libraries available from various vendors providing it as a service. From the use of Web3.JS to more customized algorithm generation tools that support the REST development framework.
Using access delegation protocols like OAuth allows users to login with their app through an already existing account that is connected to a platform. This is a more convenient way for users to login to financial apps online, with a valid identity that can be linked to either a digital identity provider or a social media account. This discourages fake accounts, trolls, and spam bots from accessing the network, though does not necessarily prevent it. What is important is that if you already have an established identity, you can use your existing account to run the software.
One of the main applications of algorithmic trading is with AMM (Automated Market Makers) which deploys smart contracts. It is a fully automated trading environment, whenever there is a transaction. Prior to that, order books had to be approved to execute a transaction. With AMM, order books are automated by the system, and smart contracts that run the code can be written to add specific trading conditions that could maximize a trader’s position.
It is important that traders in the cryptocurrency market remain resilient and alert due to price volatility. An important way to keep track of the latest price action is the use of oracle feeds. This allows traders to have an idea of which markets to sell an asset (arbitrage opportunities) and which to avoid (price divergence). Up to the minute and second information is helpful in making better trading choices through the best price discovery. It also reduces risk and losses for the trader when they make the best decision.
The Tools And Implementation
Developers and traders can use available tools offered as services online. Many of them provide an API key along with resources to connect apps to their system. QuantConnect, AlgoTrader, and InteractiveBrokers are some of the resources that provide software for algorithmic trading. It is important to look deeply at the services being offered and what the benefits are. Each company has general features and their own type of service that distinguishes them from everyone else. That is the feature to review.
With the trading tools, traders should be able to use the software to help them automate decision making in events like the following:
Purchase x amount of a digital asset when its 50 day moving average goes above the 200 day moving average or sell x amount of a digital asset if its 50 day moving average drops below the 200 day moving average
In pseudocode, the algorithm would look like:
Let 50day = <value of 50 day MA>
Let 200day = <value of 200 day MA>If 50day > 200day then:
function(purchase x amount of asset H)
Else If 50day < 200day then:
function(sell x amount of asset H)
This can be implemented in real-time to execute only once when the condition is met. The program will monitor this condition from the moment it is deployed, using technical analysis. Once the condition is met, the code executes and then terminates the program.
Here is an example from QuantConnect on how to create a program to consolidate data to build bars. The program will do the following routines:
- Create the consolidator object.
- Bind an event handler to handle the new bars.
- Register it with the subscription manager to start receiving data.
Here is the sample code written in Python (From QuantConnect):
from datetime import datetime, timedelta
class DataConsolidationAlgorithm(QCAlgorithm): def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2016,1,1) #Set Start Date
self.SetEndDate(datetime.now()) #Set End Date
# Find more symbols here: http://quantconnect.com/data
self.AddEquity("SPY", Resolution.Minute)
# define our 30 minute trade bar consolidator. we can
# access the 30 minute bar from the DataConsolidated events
thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=30))
# attach our event handler. The event handler is a function that will
# be called each time we produce a new consolidated piece of data.
thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteBarHandler
# this call adds our 30-minute consolidator to
# the manager to receive updates from the engine
self.SubscriptionManager.AddConsolidator("SPY", thirtyMinuteConsolidator)
def ThirtyMinuteBarHandler(self, sender, bar):
'''This is our event handler for our 30-minute trade bar defined above in Initialize(). So each time the consolidator produces a new 30-minute bar, this function will be called automatically. The sender parameter will be the instance of the IDataConsolidator that invoked the event '''
self.Debug(str(self.Time) + " " + str(bar))
def OnData(self, data):
pass
Other services where algorithmic trading can be used are provided by digital exchanges like Binance and Kraken. They offer an API Key that allows traders to access trading, funding, and management features available on the exchanges. An API Key is needed in order to access the API calls made to the exchanges. The API Key allows access from an app only to the trader who owns the account.
Synopsis
Information is key when it comes to trading in the open market. The use of more automated methods has a big advantage for algorithmic traders. It is more convenient, faster, and updated than traditional trading techniques where the trader has to be online to make a trade. When the software has been programmed to make decisions, the trader can wake up knowing they had an automated sell order for an asset that was dropping rapidly within a 1-hour timeframe while they were asleep. This helps cut losses and prevent a trip to what is called “REKT City.”
Like any system online, cybersecurity concerns abound. The main concern here is if you have junior traders and developers coding algorithmic trades for the first time. Mistakes can be made and the consequences are very dire. A poorly coded smart contract, for example, can lead to traders losing all their funds. If the logic is flawed, the condition could fail to execute and cause more harm than good. That is why the code needs to be reviewed, tested, and audited to verify its integrity and reliability. If the developer does not have the knowledge to build secure and reliable programs, that will be a problem.
There are risks in trading, whether it is done in the traditional manner or through an algorithmic method. There are many complex conditions and situations in the market. It is important to have some mitigation in place, and automated systems can help provide that. There are unforeseen circ*mstances like black swan events that cannot be prevented. They just suddenly happen and if there are no mitigations in place, traders risk losing everything. Applying algorithmic trading methods can be used for advantage but be very careful. Algorithms make things easier, but don’t assume it is perfect. When developing an application for algorithmic trading, it really requires planning and quality assurance. It can be the solution so long as it takes security and reliability seriously.