Hello world in quantitative trading

Since I started on this field the focus has been to be able to build a set of

I found this training course with the slides posted, where Michael Halls-Moore explains the basis of the backtesting with Python and Pandas.

Things to remind

  • Taxonomy of trading strategies: forecasting, mean reversion, momentum and high frequency trading.
  • Review of the backtesting pitfalls: the same ones that mentioned by Ernie Chang.
  • Things to do after you perform the moving average crossover strategy:
    • Multi-symbol portfolio.
    • Risk management (the most important topic).
    • True event-driven backtesting, realistic handling of transaction costs, fees…

Moving Average Crossover Strategy

this is defined as the “Hello World” of quantitative trading. It’s included a specific article,

Exponentially weighted moving average (EWMA)

EWMA is a type of infinite impulse response filter that applies weighting factors which decrease exponentially. The weighting for each older datum decreases exponentially, never reaching zero.

Code written in Python 2

The proposed code is in python 2, but here you can find a guy that adapted it to python3. It uses Quandl library for obtaining financial data easily.

 

 

Learning when to “sell”

I learned some time ago that it is more difficult to define when to sell than when to buy.

Now during the learning process about trading I learned a couple of tips. Both of them are basic and valid for long term investment.

  • Check the average of 200 days and when the value of the stock suddenly grows provoking an increase in the distance with respect the 200 days average, then it can be a good moment to sell.
  • Analyse the fundamentals and check if the value is expensive.

For sure, both checks can be combined.

Intellectual property valuation

Management of Intellectual property (IP)

The intangible assets created through the processes of innovation represent a major share of the value of today’s businesses. The IP rights associated with those assets are the legal underpinning for potential returns on investment in that innovation. Despite their fundamental importance, the understanding of IP and IP rights does however
differ widely amongst businesses large and small.

Valuation methods

There are several valuation methods but the lack of standard type of valuations have negative impact in the efficiency to trade with IP; hence this has negative impact on the I+D researchs.

Lack of a standard set of methods for the valuations, but!

there are other standards provided by the World Intellectual Property Organization (WIPO).

WIPO is leading the definition of all aspects of IP, one of the areas of WIPO (there are others as patents, trade marks, industrial design…). There are so much advance on these topics and it’s an industry itself.

  • All relevant countries are associated with WIPO.
  • WIPO Standards on Industrial Property Information and Documentation.
  • WIPO Pearl: WIPO’s multilingual terminology portal gives access to scientific and technical terms derived from patent documents.
  • Global Design Database : enables free, simultaneous searches of more than 1,760,000 industrial designs registered under the WIPO-administered Hague System and/or in participating national collections.
  • ROMARIN – International Trademark Search. It allows you to search detailed information on all international marks registered under WIPO’s Madrid System.

I miss a section where they provide training and certification services. The standarization of the knowledge and the existence of a certification program enable companies to acquire the knowledge at their level. This would also give to the WIPO more visibility into the corporate business world.

(An example of a patent captured from Global Design Database)

 

Love Yourself Like Your Life Depends On It

Ravikant, Kamal has written this short book where there is not a extra adjective or word so you can concentrate in the goal of the book.

For my memories some of the topics described in the book:

  • Darkness is the absence of light, any negative though is darkness.
  • How do you remove it?, do you fight, fear or worry?Do you push or drown away sadness and pain?  Doesn’t work.
  • Look for the window, pull out a rag, and start cleaning. Just clean.
  • See the light of positive things that there is outside of the window.
  • Mental loop:
    • Repeat and repeat it, like a groove in rock created by water.
  • Meditation:
    • Music, 7 – 10 minutes, “I love myself”
    • Mirrow, 5 minutes.
  • Memory: reinforce the pathways.
  • Do the exercise about the thoughts that affects to you, differenciate if they are real or not real. Identify when something is real or when the mind is hijacked.
  • Surrender: “I used the fear as energy, driving me forward, pushing to achieve, pushing to succeed, paying no attention to my body, to the present, and I paid the price“. “Often, the price for not being present is pain“.
  • Real growth comes through intense, difficult, and challenging situations.

 

 

Distribution of Lithium, a challenge

Electric vehicles

Almost all is written about the impact of the electric vehicles on our lives and how the trend of the consumer, the industry and the governments are doing around it.

Once you go in deep, this new industry generates bottlelnecks that are opportunities to the people and companies working around the electric vehicle industry. The batteries are the core component of them and the lithium the main component of the batteries (graphite and cobalt could also been seen as examples).

Lithium extraction and distribution

Lithium is not a problem itslef, there is identified 40 million tonnes of lithium resources, the problem is to extract it and obtain as much as possible. Here there is an example of a company (Lilac Solutions) I found that is competing to improve the way the process is performed. This picture helped me a lot to understand the challenge:

Metronome (MTN)

Metronome (“MTN”) is one of the crypto currencies that will be launched at the end of 2017. They define themselves as first cross-blockchain cryptocurrency, making decentralization possible and delivering inst itutional-class endurance.

Reading some articles from founder (Jeff Garzik) it enable the users to jump from one currency to others, so an individual can avoid the volatility of a currency moving the assets to other currency.

Applying the tragedy of commons principles, if everybody changes their positions from one currency to other, doesn’t it increase the volatility?

European Green Vehicles Initiative (EGVI)

I had a conversation with some friends that started with the following question:

Does it make sense to me to purchase a Diesel van or I should wait to the electric van?

To purchase a car/van is an investment to be analyzied, the disruption that is coming in terms of electric vehicles makes that some type of models do not make sense anymore.

This is specially important as the law is being adapted to fulfill the CO2 targets we have in the EU. Nobody wants to purchase a diesel van and 5 years later the valuation is zero because basically you cannot circulate in the city (there are local authorities applying this type of practices in big cities).

For cars the situation is different, the market already offers solutions and the trend is clear through the electric vehicles. The government is also promoting the procurement of electric vehicles through subventions, so these are things you can add to the analysis of cost.

The habits

are changing a lot, in my case, now we do not use the car at all during the week, and we only do it during weekends when we go out of city. I have jumped from doing 25.000 kms / year to drive just 11.000 kms / year.

In the city we live there are sharing car companies, so you can access to a car whenever you need.

We are asking ourselves if it makes sense to purchase a car or not.

European Green Vehicles Initiative,

EGVI is a is a contractual public-private partnership dedicated to delivering green vehicles and mobility system solutions which match the major societal, environmental and economic challenges ahead.

I have read the electrification roadmap defined for Europe which contains a lot of data related to:

  • Stakeholders implied on this revolution.
  • Forecast of readiness of the industry.
  • Level of CO2 targets estimated and how they can be achieved.
  • What are the legal aspects that need to change.
  • How the electric net needs to evolve.
  • What are the expected benefits of the changes.
  • Logistics challenges for the transport of energy, the peaks of compsumption…
  • Scenarios about the penetration of electric vehicles during next 15 years.
  • The importance of the research projects and the local investments in the different countries for the right deployment of the whole thing in the different regions.
  • How this initiative is founded by Horizon 2020 framework.

The document answers a lot of questions about where we are going to, and there are so many other challenges that right now are still not known.

In a nutshell, if you want to purchase a van now, you can do it, it will be useful for the next 10 – 15 years. The electrification roadmap document details that for vans there are still so many technical challenges that they need to be resolved, and they give a pesimistic forecast that the peaks of high presence of new sold vehicles will be happening around 2030.

Bitcoin, 21 million limit

The number of bitcoins has a limit,this constrains the market availability and the behavior of the value. Bitcoins are divisible in infinite number of parts, so this facilitates the situation on the market space.

There is a mathematical explanation for having around 21 million limit:

Calculate the number of blocks per 4 year cycle:

6 blocks per hour
* 24 hours per day
* 365 days per year
* 4 years per cycle
= 210,240
~= 210,000

Then you can sum all the block reward sizes (rewards are divided by 2 every 4 years):

50 + 25 + 12.5 + 6.25 + 3.125 + ... = 100

Finally, you multiply the two figures:

210,000 * 100 = 21 million.

The estimation is to reach this limit around 2033.

The question is that the reward to complete a block is decreasing with time. Could it be the case that one day to mine bitcoins is not profitable?

Legal aspects

The legal aspects of use in terms of virtual currencies are evolving differently. In Canada and US there are currently specific laws and taxation fees for these environments. Other countries are lagging from these areas. The EU is still not communicating a common pathforward about virtual currencies.

There is a lot of evolution on legal aspects and the number of transactions to be done

There are a good bunch of companies that are communicating that they will enable transactions with bitcoins by 2019.

Internet of Food & Farm 2020

Read, learn, make questions to myself and start again. So this week I learn the existence of this plan named: Internet of Food & Farm 2020.

The heart of the project is formed by 19 use cases grouped in 5 trials with end users from the Arable, Dairy, Fruits, Vegetables and Meat verticals and IoT integrators that demonstrate the business case of innovative IoT solutions for a large number of application areas.

This program in part of the IoT European Large Scale Pilots program.

The program is also linked to the Smart Spesialization Platform.

The different investment roadmaps are key to understand the direction that the high level investment done by the EU is going on.

 

Pirineos with the bike

I have been able to travel again a week to the Pirinees mountains with the mountain bike. This is a journey I love to do and I was able to do it after 2 years off.

The first thing is to prepare me physically. 7 weeks riding at least 3 times a week made the difference. This time I prepare the days of training combining climbing, long rides and specific workouts with high slopes.

The speed during the routes is very slow, and this helped me to be at the same pace of the group. It’s vacations, not a ride, so we stop to take pictures, talk to people and this type of things.

We have stayed in Castejón de Sos and Ainsa.

The routes we have done were:

  1. Day 1: Castejón de Sos –  Integral de Gallinero: 40 kms, 1600m positive high. 6 hours ride. Good feelings as I rested some days and the pace was slow. We extended the original ride going to Gabás, so we added an extra downhill. The fact that this week I rested help too.
  2. Day 2: Villanova- Rabaltueras: 20 kms, 1050, positive high, 3 hours. The slopes were more complicated, but the ascend was only 10kms. The downhill is in a forrest and it was very good to stop from time to time an enjoy the views. The cows were in the middle of the path when we were downhilling, so a technical stop was required.
  3. Day 3: Ainsa – Viaje al Inframundo: 55 kms, 1585 positive high, 7:30 hours. We wanted to do this one some years ago, but in summer is not suitable because of the heat. Even today it was a hot day. The travel to infraworld is a ride reaching some abandoned towns and old houses were there is nobody. Today we did not see anybody in almost 40 kms. It was a large day but it was a nice day, as the route description says: it’s a bad route for the body and good for the soul.
  4. Day 4: Ainsa, raining, so no bike today.. so the alternative was a gastronomic route with special meet of the region.
  5. Day 5: Ainsa, Portillo del Vallés: 39 kms, 1360 positive high, 5 hours. We picked this route due to a local rider told us there were less posibilities of mud. The worst part was the start of the downhill on the north face with a lot of water there. The other paths where fine. We started at 13:00 as the whole morning was raining. It was a good decision as finally we were lucky and no more rain falled. The path over a river with stones was fantastic.
  6. Day 6: Ainsa: Saravillo – Ainsa: 37 kms 960 positive high and 1400 negative high. We took the van till Saravillo, there we started going to Badaín, then we stopped to take lunch in Laspuña. After lunch we went to Araguás, Torrelisa and finally Ainsa. The final path over the badlands was amaizing.

You can find all available routes here:

  • For the 2 of Castejón de Sos: Puro Pirineo.
  • For the 3 of Ainsa: Zona zero . We have to thanks again to the guys of the Intersport store in Ainsa for the guidance on the routes and the election of the best ones taking into account our directions and the weather.

Only 2 falls without consequences and the bike without any incident, what else can I ask for?

I hope I can come back next year.