Saturday, July 18, 2020

Quant Tradin





1 Year in Quant Tradin



Image for post
Live performance of my best strategy (175% ROI in the last 9 months)
I’m approaching one year since diving full time into quant trading. My business a year ago wasn’t performing too well, and I was hoping for more control over returns — especially for more predictable ROI. That’s how it all started.
I didn’t expect this journey to be as challenging as it’s been — looking back at all the learning, re-learning, programming, re-programming, testing, re-testing, and launching strategies at some point, only to see them fail. However, there are a few strategies that make it through all the processes and become profitable. These winning strategies have some common patterns, which I tried to compile into the following lessons that I have learned over the past year.
Some of the points may appear obvious to you, as a more experienced trader. For me, each individual one was an enormous insight, sometimes followed by a big shift in how I approach the markets. I wish I had known these points beforehand, which might have saved me countless hours. The following lessons are addressed to me and in no meaningful order.

Strategically pick your markets

Trading US stocks, forex, and bonds probably is a bad idea. It is not the wisest choice, due to too much competition with the biggest players. Find your liquidity sweet spot by taking a look at markets that would support your liquidity needs; however, they shouldn’t be magnitudes larger. Play and win in niche markets by learning their rules, rather than trading where big players trade and where the game is much harder. My point is this: a strategy on Philippines stocks likely will be more profitable than the same one on US stocks.

Learn the rules and accept them

I traded a few different markets (in hindsight, I should have stuck with one). Each has different rules and is rigged in its own way. Market makers (or the most dominant players in one market) do everything to win. Assume the markets are rigged, learn the rules, and play by them, but don’t deny them by thinking markets act naturally. Don’t try to “outsmart” the markets; this likely will backfire. Look for traces (behavioral, spoofing, placed orders, and liquidity hunts) that big players leave, and use them for your advantage.

Know your priorities

There’s so much to do in quant trading: strategy development, optimization, backtesting, execution, and risk management. Don’t focus on the wrong things in the beginning — like optimizing parameters. Rather, build very basic MVP versions of each part in the equation and optimize by iterating while in production. A perfectly optimized strategy won’t help if the execution part doesn’t work correctly.

Expect to lose in your first year

Don’t start scaling as soon as you see some initial success, as it may wipe out big parts (40% in my case) of your portfolio. It will take you much more effort to make it back; instead, it’s easier to adapt proper risk measures in the first place. By having an expectation to lose (the first year at least), you won’t be tempted to put more capital than necessary into testing and learning.

Don’t rush with capital, rush with execution

I was too quick in scaling up capital without thinking about risk. On the contrary, I often found myself in analysis paralysis, promising myself to launch a new strategy after “just one more optimization”. I was over-optimizing too much. I should have just launched multiple strategies to see what works first, then optimizing in an ongoing way. Building and optimizing strategies based on theory doesn’t help, if there’s no practical feedback.

Don’t use price stops

I found there are two ways price stops can be used: either not at all or to protect against black swan events (99.9th percentile of the volatility distribution). Instead of price stops, use time stops and proper position sizing. Price stops will, as research shows, destroy a good strategy, simply due to randomness in volatility. The time dimension is much more manageable and predictable than the price dimension of a hypothesis expressed by your trade (both in backtest and in live trading). By using time stops, you are setting a time constraint in terms of how long your hypothesis is valid, which almost always reduces variance (and increases Sharpe ratio).

Know entries and exits

For each trade, know where to enter and where to exit. For me, these are set based on two rules — one being a modified formula of Average True Range. It’s almost a requirement to have pre-defined rules for entries and exits, in order to properly backtest and to know what to expect in live trading.

Know your numbers

For each strategy, you must know the expected value, hit rate, expected drawdown, longest drawdown, expected volatility, variance, Sharpe ratio, standard deviation of returns, skewness of returns, and value at risk. Also, proper bet sizing, risk of ruin, Kelly fraction, and optimal F should be strategically chosen based on how the strategy performs during the backtest.

Make risk management a priority

Wiping out 40% of capital might happen in a day; however, making it back can take many months — if not years. Use proper risk management in the first place, and be aware of the potential risk of ruin due to black swan events. It’s always a good idea to expect the worst case. It shouldn’t be a challenge for your strategies to wake up one day to a -50% market.

Use fewer parameters but know what they do

My best-performing strategy uses only 3 parameters. These are easy to optimize and easy to test for robustness. Know exactly what your parameters do and why they are used. The worst mistake probably is letting an optimization script generate parameter combinations, e.g., slow/fast period for multiple moving average combinations. There surely will be something that looks good on paper/in the backtest, but it is doubtful the same strategy will work in live trading.

Create a good backtest and know the ins and outs

Don’t go with some existing solution (applies to optimization, as well, by the way) — at least not before you have built multiple backtests yourself. You must understand the effect of slippage, fees, sequence of execution events, and different order types. I wrote many backtest scripts, with the first few being very intricate. My most recent version runs on 12 lines of code (mostly parallel computations), which proves, once again, that simplicity wins.

Find a good evaluation metric

Testing how the strategy performs is not enough; you must know what to look for. Of course, I started looking for high annual return. Optimizing Sharpe was better, but also not what I needed (I still wonder to this day why Sharpe ratio is considered the industry standard, since there are much better metrics). Finding the right optimization and evaluation metric is key; otherwise, you’ll build something that completely misses the goal.

Know what to look for in a strategy

To find a good evaluation metric, you need to know what you actually are looking for in a strategy, and it’s based on many personal factors (portfolio size, accepted risk, etc.). Know the characteristics of your desired strategy, as this will define what evaluation metric to choose. I prefer consistent, negatively skewed strategies, and this is what I build for.

Focus on features, not on optimization

There’s a great range of tools for optimization, genetic optimizations, non-convex optimizations, principal component analysis, statistical/Bayesian optimization, and a thousand fancy libraries. From my point of view, optimization will help improve a strategy by 10–20%; however, it won’t lead to a profitable strategy in the first place. If a strategy is bad, no optimization will help. Focus on deductive analysis and feature engineering — in simple terms, making sense out of the inputs and data.

Deep learning is overrated

I don’t get the hype. Machine learning is great, and deep learning is great, too (aka neural networks). Optimizing 10,000 parameters likely will only lead to overfitting. If the strategy isn’t working without power libraries like Tensorflow, it probably will not work in production (even if the backtest is amazing). In short, the strategy should be profitable already with something simple like a linear regression.

Better data, better features

“Data is the oil of the digital world,” someone said. I heard some hedge funds are using satellite images of parking spaces to predict stock returns. Although such kinds of data probably contain limited information (I’d guess just as good as weather forecast data), it’s still usable data and not bad by any means. My point is: focus on getting better data to then produce better features. Combine multiple weak features and strategies together, and this likely will improve returns.

Academic papers are great, but…

Academic papers are great, but they usually fall short in terms of practicality. There’s simply a mismatch in incentives between academics and traders. Academics are not traders, and traders don’t publish working strategies. Look at academic research with a grain of salt; however, don’t neglect it completely. I can’t count how many times I found a little piece of information really valuable. One paper won’t result in a good strategy, but applying insights from 20 papers might.

Fast feedback is a must

Competing with big players, especially in the HFT realm, is probably a bad idea (like I explained above). Going the opposite — holding trades for days, months, and years — also is not ideal. For me, the sweet spot is a holding time of 5 to 60 minutes. If I can’t test a strategy in 2 weeks with statistical significance (meaning more than 100 trades), I’m not investing my time in it. To test a strategy with a multi-day (and longer) holding period, I’d need months to validate, and this is not what I’m interested in.

Don’t trade only on price and price indicators

Price is a reflection of what happened in the market. It has low information about actors and their intentions. Indicators also are not useful enough, as they are just a derivation from price, and most indicators lag behind. Markets are more choppy and automated nowadays, and lagging indicators aren’t as helpful as I’d assume they were in the past.

Derivations of derivations are useful

I found a way to make indicators useful: by building features off of them. I have found that strategies would perform a lot better if indicators — let’s say the moving average — are strategically refactored into something like a second derivation, e.g., splitting MA values into bins and counting the occurrences per bin over the last X hours.

Double your timeframe

Picking a higher timeframe almost always leads to better results. This can’t repeat indefinitely, as your research is done with one specific timeframe in mind. However, if your strategy is optimized for 15 minutes, increasing the holding period from to 30 minutes almost always yields better returns with lower risk.

More risky markets, smaller positions

Trade in markets that are more volatile, because volatility is good for opportunity. Just be aware of the risks and adjust position size accordingly. It can be much more profitable to trade markets that are 10x as volatile while having 1/10th of the position. The risk to reward curve is not as linear as I thought — looking at you Bitcoin!

Trading fees make a huge difference

By doubling the holding time as mentioned, the role of fees already is reduced. Optimizing strategies specifically to avoid large fees is even smarter. Depending on the strategy (especially for higher frequencies), fees make up more than 50 percent of returns. This means optimizing fees should be one of the highest priorities, whether that means using less market orders, using better brokers, or negotiating better deals with existing brokers.

Familiarize yourself with your trading environment

Mentioned above under becoming more familiar with one niche market, this applies even more so to brokers, exchanges, their APIs, downtimes, and latencies. You should know their APIs in and out, especially since many brokers have intricate and hidden functionalities that can really help one’s performance (conditional orders, better fill/status information on orders, bulk operations, etc.).

Afterthoughts

Thanks for reading. The amount of things I’m learning day by day is not slowing down, even though I’m approaching the 2000 hours mark for quant trading. I think this is one of the few industries where, with passing time, the learning curve gets steeper, which actually makes me excited about the coming months/years. Finally, in case I missed something — or if you want to get in touch — please reach out to me via email. 


Artificial Intelligence (AI) Unit

Blockchain Startup Bitfury Launches Artificial Intelligence Unit




Blockchain startup BitFury launched an artificial intelligence (AI) unit.

“Data is the new oil”
Bitfury chief executive officer and co-founder Valery Vavilov reportedly said that the company’s dive into AI is motivated by the need to analyze and extract information from great quantities of data. He reportedly noted that data is becoming the new oil and stated:
“We have collected so much data, but only 2% of all this data has been analyzed; 98% is sitting idle and waiting to be analyzed.”
Vavilov also reportedly explained that the AI unity of the firm is still researching possible applications of artificial intelligence. Still, he also promised that next year BitFury will have more information about the AI-enabled products that the company intends to develop and offer to its clients.
AI a potential danger to crypto
Former vice president and managing director of computer hardware producer AAEON Technology Europe, Fabrizio Del Maffeo, has been appointed to lead the AI unit of the firm.
Meanwhile, Stockholm-based software engineer and cryptocurrency trader, Eric Wall, commented on Twitter suggesting that the application of AI to blockchain data analysis is a danger to Bitcoin’s (BTC) fungibility.
“AI/[Machine Learning] ML to be trained to identify users and to flag coins that have been used with privacy-enhancing techniques (PETs), no doubt. Using PETs better become standard wallet behaviour quickly, if we care at all about the fungibility of Bitcoin.”
According to Crunchbase, BitFury has received $170 million in funding so far, and Reuters claims that it is one of a handful of blockchain companies with at least a $1 billion valuation.
As Cointelegraph explained in a recent dedicated piece, show impressive potential when combined and are already being integrated.

Monday, August 26, 2019

Artificial Intelligence

M A R V E L L O U S B E N

Relevance of Blockchain for Democratizing Artificial Intelligence

 There exists a huge opportunity to use free computing space in the world more efficiently. According to a rough estimate, around 90% of the total 4 billion computers across the globe has a free capacity at any moment in time. This figure does not include free capacities available across other devices like smartphone and tablets. In effect, all these excess capacities are wasted and turned out to be unproductive.



Sensing the opportunity, many start-ups today are exploring new and innovative ways to use this excess capacity for the various applications of the blockchain. As blockchain works on the principle of distributed ledger technology, it provides the infrastructure for idle capacity to provide support for transactions and other blockchain processes. Some of the solutions provided by the blockchain developers in this regard include data storage and web hosting. However, the more exciting area which can be specifically leveraged by the idle capacity solution is the field of artificial intelligence.

ABRA Here..




Artificial Intelligence

Undoubtedly, artificial intelligence has caught the attention of every stakeholder in the technology development and adoption ecosystem. Many experts argue that using blockchain solutions in the area of data storage and web hosting, one can speed up wider distribution of algorithm and data which, in turn, will have a direct positive impact on the development of artificial intelligence. That said, many technology experts are apprehensive about the fact that big guns in the technology industry such as Facebook, IBM, Google have already started dominating the artificial intelligence field which could possibly lead to the monopoly of these big firms in this emerging technology area. These organizations control a major chunk of digital data which is necessary to promote the machine learning program, and there is a compelling need to democratic data if we want to have a development of artificial intelligence for the greater good of the community.

Blockchain use in Artificial Intelligence

Experts pin their hope on the blockchain technology to democratic artificial intelligence data. As the application of blockchain allows the financial transactions to happen without any middlemen, its use in artificial intelligence can help a large number of stakeholders to access the data and idle computing power without any intervening centralized authority. Efforts have already started, and many companies have established marketplaces based on the blockchain allowing for buying and selling of the data. The primary motive behind this move is to make the data available democratically, and people with impressive academic and professional credential are backing such enterprises. Kaasy and Skynet are examples of organizations involved in the sale and purchase of data. However, Hardon network seems to have taken the lead in providing solutions to the real-life problems using the concept of shared computing power. Hardon uses the marketplace it has created to get solutions regarding artificial intelligence. The network categorizes the sounds and images in a manner that can be processed for some different applications including the classification of images and face detection. People on this network bid for various tasks and applications and Hardon assign these tasks to the connected devices and pays a part of the bid which is aligned with the demand. This means if there is a high demand for computation, the prices for the bid will be higher and in case of low demand, the bid prices will be lower. This distributed model for the computing used by the Hardon offers many advantages over the traditional network; the most prominent one being is its capability to scale up computational resources. With the increase in demand, prices will rise, and that will attract more existing and new users to offer their computational capacity, thereby helping the scaling process. The network has recently announced that Aikon will launch it as the first dService which will allow the users to use its Vision API for recognizing and categorization of images.

M A N K I D I M A N D A

Prospects of Blockchain for Artificial Intelligence

The use of blockchain technology in the field of artificial intelligence has just now started, and it will take a long time for the distributed ledger to gain a strong footing in this specialized technology area. However, the most important contribution of blockchain technology in artificial intelligence is to make data available to all the stakeholders without any kind of centralized and corporate control. This means all the benefits and advantages of artificial intelligence can be shared democratically without any undue interference or domination of a few big companies.



Blockchain Technology and Artificial Intelligence are Two Different Things

 If you search for the definition of blockchain and artificial intelligence on the internet, the chances are high that Google throws back results which are not similar in their description. And that’s because these technological innovations are indeed different from each other and should be taken in their specific contexts. It will be a mistake on our part to club them together although one can always argue that technical excellence and competence remain at the heart of both these technologies.

If we take a look at any of the initial coin offerings (ICOs) floated between 2017 and 2018, one thing becomes very much apparent is the way the companies promote the blockchain and artificial intelligence in an integrated manner. The promotion brags ICOs as some kind of miraculous project marrying artificial intelligence with blockchain for providing a one-stop solution for all business needs of clients. Some companies have gone one step further and projected images of robots, astronauts, and other fine prints related to artificial intelligence on their offerings.

Different Domain Areas

It is sad to witness the obsession of many organizations to club together artificial intelligence and blockchain technology. Artificial intelligence is a term which is used to encompass a wide variety of technological innovations which are aimed to make computers work in a smart manner. It will include all the tools and technologies that will help to enhance efficiency while effectively contributing to achieving objectives of the organization. Blockchain technology, on the other hand, is a term related to cryptocurrency and open ledger technique, primarily dealing in the domain of financial technology firms. Of late, the blockchain has entered into many fields including the supply chain, distribution management, energy, and power distribution, agro-export business, etc., although the technology is more known in the domain of financial transactions. The adoption of blockchain makes the transactions more safe and secure, in addition to saving cost and time and this is the primary benefit associated with this open ledger technology. Chances of having any kind of fraud are greatly reduced by blockchain adoption, and although it makes things more efficient, it is not necessarily aiming to make computers and equipment smarter like artificial intelligence.

Converging Areas

The question of whether blockchain technology and artificial intelligence will ever come together in a manner that is being wrongly touted by many organizations today remains a contentious issue of debate. There is a strong possibility of these technologies merging together for some kind of for interface or application but for that to happen; we require close coordination between these advancements in terms of conceptual integration, technological advances, synching of objectives, and unanimity towards achieving a common end-goal. Regulation in both of these emerging areas of technology is also going to play an important part. In an ideal situation, regulatory bodies and governments must come up with a legislative framework for cryptocurrency and artificial intelligence and implement it in a manner that should encourage both of these industries to grow in a desirable manner. The regulatory framework should not be too harsh else it will dampen the innovative spirit, but at the same time, it should be effective enough to discourage any mala fide intent to cheat or pulling a fast one on the intended users. In fact, in the case of blockchain technology and cryptocurrency, we have witnessed a growth in some countries which have a proper crypto framework in place than the places where the regulations are loosely defined, giving a window of opportunity for fraudsters to deceive investors. The concerns related to regulating artificial intelligence is still in the nascent stage and need to be worked upon to arrive at a common ground of understanding.

Technological experts and influencers feel that the possible area of amalgamation where blockchain and artificial intelligence come together could be an example of a robot scanning chips embedded in human bodies to confirm the transactions done by them on their private blockchain. Of course, arriving at such a scenario will take some time though going by the breakneck speed of technological revolutions, it can be safely assumed that we will witness such scenes at airports or banks sooner than we can actually imagine.


Thursday, August 1, 2019

CRYPTO. BANK COMMITTEE.



Live: Crypto, Blockchain Hearing at US Senate Banking Committee
Edited By MarvellousBen
During today’s United State Senate Banking Committee hearing on the regulatory framework for cryptocurrencies and blockchain, Cointelegraph will be updating live with the most important developments.

The July 30 hearing, titled “Examining Regulatory Frameworks for Digital Currencies and Blockchain,” follows the previous hearings in mid-July that examined the regulatory hurdles surrounding Facebook’s Libra.

Circle CEO Jeremy Allaire will be a witness today in front of the Senate Committee on Banking, House, and Urban Affairs on behalf of The Blockchain Association, along with Rebecca M. Nelson, a specialist in international trade and finance, and Mehrsa Baradaran, a professor of law at University of California, Irvine School of Law.

For more detailed information on the witnesses, Cointelegraph has a dedicated analysis here.

11:25 a.m. EST

Crapo: I want the U.S. to stay at the forefront of this technology, which both has incredible potential and incredible risk.

11:22 a.m. EST

Nelson: Facebook has changed the debate about cryptocurrencies

11:15 a.m. EST

Barabadan sees similarities in the resistance of tech companies to regulation in the same way that big banks are resistant to regulation.

11:16 a.m. EST

Brown asks what lessons we can apply to tech companies after the 2008 financial crash, and Barabadan says that there is a fear that the U.S. will lose its tech edge if it doesn’t let these companies grow unfettered.

11:13 a.m. EST

Brown: “If there aren’t really new products, why would we need rules and regulations?”—Brown going off the idea that the ideas are the same for financial instruments, just new technology backing them.

11:10 a.m. EST

Crapo: how does Libra gain global acceptance if it’s facing every country’s different regulatory climate?

Allaire: some of these cryptocurrencies are just open source software that exists on the internet and runs everywhere the internet exists (“even interstellar”).

Allaire: “Digital money will move frictionlessly, everywhere in the world, at the speed of the internet, hopefully with a high level of security and data protection.”

11:08 a.m. EST

Allaire notes that there are larger opportunities for digital assets and blockchains outside of the United States. When looking for locations, Circle wants a high bar from a regulatory perspective, from a custody risk in particular, as well as clear definitions.

11:04 a.m. EST

U.S. Senator Jon Tester of Montana appears concerned about Libra being compromised the same way that a credit or debit card can be.

“Would it kill cryptocurrency in the laws that we are probably going to be passing […] if we stipulated that it had to be a 1:1?”

11:02 a.m. EST

Nelson brings up money laundering as a big concern for cryptocurrencies around the globe, but says that some licensing, reporting, and transparency requirements can help with these concerns.

11:01 a.m. EST

Nelson thinks that some crypto hubs are using regulation as a way to attract crypto to their borders, using clarity and certainty to bring people in to their jurisdictions.

10:58 a.m. EST

U.S. Senator Christopher J. Van Hollen of Maryland on real-time settlement: “Our failure to have moved forward with this technology […] is costing millions of Americans, billions of dollars every day.”

10:56 a.m. EST

Cortez Masto asked Baradaran why digital currencies cannot bank the unbanked. She responds that the problem is that these people live in “banking deserts.”

Baradaran: “How does any digital-based currency help when people are operating in cash?”

10:53 a.m. EST

U.S. Senator Catherine Marie Cortez Masto of Nevada believes in the potential of blockchain, and the importance of leading in this technology over China.

10:51 a.m. EST

Schatz: “I don’t doubt the potential for this tech, I just don’t think that it’s going to actually bank low-income communities, and I don’t think you’ve persuaded anybody here that it’s going to do so.”

10:49. a.m. EST

Schatz keeps bringing up the idea that not everyone has a smartphone, and so it’s hard to place bets on this technology to solve all of our problems and “leap over all existing ones.”

Allaire rebuts by saying that technological innovation can be slow, comparing now to the beginning of the internet, of the slow implementation of broadband.

10:48 a.m. EST

U.S. Senator Brian Schatz of Hawaii asks if we are anywhere close to democratizing the use of technological products, following up on the overall financial inequality topic.

Schatz: “What it sounds like to me is tech people wanting to wave a wand and skip a bunch of steps and avoid the tough political of doing things for people.”

10:42 a.m. EST

U.S. Senator Mark Warner of Virginia is asking about the literal meaning of the 1:1 backing of the Libra.

Allaire comments that while the first wave of these types of digital currencies were focused on establishing a global digital currency, the critical mainstream use cases for the financial services sector has needed the development of stable coins, with Libra as an example.

Allaire now brings up the Circle consortium’s USD Coin as another example.

Warner responds by asking: if there is a basket of currencies backing the Libra, doesn’t that create currency risk?

Warner: “If you have a 100% reserve, where is Libra going to make money on this?”
ABRA Trade.
10:36 a.m. EST

Baradaran is now speaking about the ways that people have tried to bank the unbanked and how those past attempts have failed, aligning those past failures with some of the stated goals of cryptocurrencies.

Baradaran admits that while  blockchain is “amazing,” the hearing is about digital assets and the blockchain, and what is really going on in these markets. She repeats that the problems of the unbanked are policy problems, not technological.

10:34 a.m. EST

Allaire notes that we should regulate digital assets, but that we need new definitions of them as an asset class.

10:31 a.m. EST

Allaire: “Regulations around the custody of assets is a really critical need.”

Crapo then brings up Poloniex moving to Bermuda, and Allaire says that there is a big problem for digital assets fitting into definitions in our current financial systems.

“Unfortunately, in the United States, the guidance that the SEC has given is extremely, let’s just say, narrow, in terms of what they deem to not be a security.”
Trade Easygoing
10:29 a.m. EST

Professor Mehrst Baradaran: “There is yet to be an innovative technology that has eliminated the risks and frauds and crimes that regulation is meant to combat.”

Moving to the blockchain doesn’t protect from these risks, in Baradaran’s opinion.

10:23 a.m. EST

Professor Mehrst Baradaran believes it’s natural that people have embraced Bitcoin in the aftermath of the 2008 financial crisis.

However, she adds that the current problems in our economy are issues of policy, not of technology, so blockchain is not necessarily the answer. According to Baradaran, we already have a public ledger, it’s called the Federal Reserve.
Trading On The Go.
10:22 a.m. EST:

Dr. Rebecca M. Nelson thinks Facebook could be a game changer for cryptocurrencies, but it has raised both regulatory and systemic concerns before it can be implemented.

10:18 a.m. EST:

Allaire thinks that current restrictive atmosphere has led companies to domicile overseas, rather than in the U.S, and that Congress should define digital assets as a new asset class.

Allaire: “We are in the process of moving our international facing services and products out of the United States.”

10:15 a.m. EST:

Jeremey Allaire speaks about his views on the troubles of our current financial system, including cybercriminals, hostile nations, and a lack of equal access.

Allaire: “There absolutely can be a better future ahead, one built on digital assets and blockchains.”

10 a.m. EST:

Senator Michael Crapo of Idaho: These technologies are inevitable, they could be beneficial, and the United States should lead in this sector.

Senator Sherrod Brown of Ohio: “Facebook has proved over and over […] that they can not be trusted. But they don’t care. They move fast, they break things. Minor things, like our political discourse and journalisms and relationships and privacy. Now they want to break our currency and payment systems, hiding behind the phrase ‘innovation.”’  

Soccer Sports CNC