<![CDATA[Joe´s Blog and Projects]]>http://localhost:2368/http://localhost:2368/favicon.pngJoe´s Blog and Projectshttp://localhost:2368/Ghost 4.21Sun, 31 Oct 2021 13:58:23 GMT60<![CDATA[Monitoring the air]]>Indoor air quality - you probably never taught about this, but it's just as, if not more important than outdoor air quality, since most people spend more than half of their day indoors. So how is the air?


Quick Note: You can find this projects code and documentation

]]>
http://localhost:2368/monitoring-the-air/6172dc382815492008b98facFri, 22 Oct 2021 17:20:00 GMT

Indoor air quality - you probably never taught about this, but it's just as, if not more important than outdoor air quality, since most people spend more than half of their day indoors. So how is the air?


Quick Note: You can find this projects code and documentation on Github!


Well, lets quantify it: CO2 is the most important short-term indicator, its measured in ppm parts-per-million. If the level is too high you can't concentrate at first and then get dizzy and sleepy:

Monitoring the air
https://www.iqhome.org/image/cache/catalog/blog/air_quality/co2-ppm-table-759x800.png

So how can we test it?

With a sensor of course, we will be using the MH-Z19C, it has a range from 400-500ppm so the above chart fits perfectly in it.

Monitoring the air

Fine particles are not that important in the short term, but in the long term, it can have serious impacts on your health, its measured in particles per 0.1l of air:

Monitoring the air
https://www.airveda.com/resources/images/pm_levels.png

To sense these particles we are using the PMSA003 from Plantower:

Monitoring the air

The last major Indicator I want to use and which is a bit unusual is radioactivity, having the very harmful Radon-gas in mind.

Monitoring the air
https://www.fs-ev.org/fileadmin/user_upload/97_Service/Radonvorsorge/Radonkarte-BfS.jpg


Two major obstacles lie in detecting Radon, it comes up in waves as decayed Uran from under the house and it only emits alpha rays.

If you are panicking right now while reading this, it should only concern you if you live in an older house which might have a porous foundation and you live in one of the red areas. For me it's both.


Why is detecting alpha radiation a Problem?

It's undetectable by a traditional Geiger-Müller tube, only with quite complicated systems, the modern one being optical recognition of "impacts" on a cmos-sensor.
So how do we detect radon? Well, we don't, we detect the gamma rays from the lead and bismuth:


Since a Geiger-Müller Tube works only with very high voltages, mine takes 403V, the circuit is somewhat complicated, its partly inspired form the Multigeiger project on GitHub:

Monitoring the air

In short, we generate short pulses from the micro-controller(esp32), which generates very high voltages from the coil(Lenz's law). Stopping when the cap is charged. Then, once a gamma ray goes through the tube and making it inductive, the capacitor discharges for a microsecond which we detect.

That's basically it, the two sensors I wrote about earlier both use serial communication, the "simple" environmental sensor on the bottom right uses I2C.
For future expansion I added four more additional I2C headers, since you never know you need them until you do...


The PCB:

Monitoring the air

Beautiful, isn't it?

In retrospect I made three mistakes when designing it, cap C3 and the CO2 Sensor have the wrong footprints and I bought the wrong esp32, which is not pin-compatible to the one I planned for. So please forgive all the jumpers:

Monitoring the air

So how does the software work?

I already explained how the tube is driven, apart from that the esp32 just collects the sensors data and sends it off to my mqtt broker.

Since the "backend" is somewhat complicated I can only forward you too Andreas Spiess's perfect explanation of it: https://www.youtube.com/watch?v=JdV4x925au0


You can find the Arduino sketch in this projects Github.


Analyzing the data:
Since we are using mqtt and InfluxDB, we can easily plot the data with the popular graphing tool Grafana:

On the top left you can see the impact of mowing the lawn on the fine particles sensor about 10m from the rooms window, but still perfectly healthy levels.

On the top right you can see CO2 chart of me writing this and occasionally opening the window for 30 seconds.

Down left is the gamma-ray chart in micro Sievert, which show us the typical background radiation, no sign of radon so far, phewwww...


Conclusion:

Apart from putting my, lung-cancer-fearing heart at ease, I learned quite a lot about the components that define our air quality, be it co2 or ionizing radiation.
The pcb order was a bit rushed, causing a few mistakes to slip through, but it was only ever intended as a prototype, so if it works, it work.

On the software/hardware side I am quite astonished how much a 5$ ESP32 can do, quite a lot cheaper than an Arduino, yet so much more powerful.
I will definitely use it in future projects, like monitoring the soil moisture of my plants wirelessly or using it with a camera a long distance lorawan module to monitor local wildlife.

]]>
<![CDATA[Algorithmic Trading in Python]]>One of Charlie Munger´s,  vice chairman of Berkshire Hathaway,  best-known quotes is: “The big money is not in the buying or selling, but in the waiting”, but is this actually the case?

It's a story as old as time, the average hedge

]]>
http://localhost:2368/algorithmic-trading-in-python/6172dc382815492008b98fabThu, 26 Aug 2021 17:00:42 GMT

One of Charlie Munger´s,  vice chairman of Berkshire Hathaway,  best-known quotes is: “The big money is not in the buying or selling, but in the waiting”, but is this actually the case?

It's a story as old as time, the average hedge fund can't consistently beat the broad index funds like the S&P500 or the NASDAQ100, but I think the keyword is "average", Renaissance Technologies´ Medallion Fund for example did it.
For more than 20 years:

Algorithmic Trading in Python
Source: https://www.cash.ch/sites/default/files/public/uploads/renaissance.jpg


So how are they doing it? - Well, I wouldn't be here if I knew...
What this shows is that it is in fact possible to outperfom the market.


So what's the strategy? -  Leveraging the optionsflow.

The Proof of Concept:

Financial-wise, the biggest innovation of 2020 and 2021 in my view is the website Unusalwhales.com, as it provides the pure and unfiltered optionsflow,
it makes spotting insider trades by Nancy Pelosi, for example, Speaker of the United States House of Representatives, easy: https://unusualwhales.com/i_am_the_senate/pelosi

But how can we use this data?

Well, we can spot unusual options by volume, strike and expiry, aside from a few other factors.:

Algorithmic Trading in Python

This call option, for example, has all the characteristics of an unusual option:
- It's on the Ask Side, meaning the buyer wanted to get the option as fast as possible
- It's  5.63% out of the money(strike is @$215 and the stockprice@ $203.54)
  this is not unusual by itself, but it expires in just seven days, meaning there's a   certain urgency.


A little oversimplified Crash-Course for options:
If a call option is below its strike at expiry, here $215 on the 08/27/2021,
it expires worthless.


Conclusion of the Alert:

Someone is willing to bet $652,138.00 that Nvidias´ stock rises by atleast 5.63%
in just 7 days. Was the "speculator" right?

See for yourself:

Algorithmic Trading in Python

Malicious gossip has it that the "speculator" might have known of the DoE
Aurora supercomputer deal with Nvidia:
https://www.tomshardware.com/news/nvidia-amd-polaris-supercomputer-department-of-energy



The morality of insider trading and making 1200% profit in a week is not the question at hand, it being how we can spot and follow these high conviction bets?

There are a few Problems to overcome: the biggest one being the so called "Memestocks", for those, $AMC and $GME especially, a lot of small fishes buys so many high-risk options that they might look like a whale. So it's crucial to filter those stocks out.

Apart from that it's pretty straight forward, we search for high conviction, short term bets with favorably vast amounts of money behind it.

The Test Environment

Since I am living in Germany, we can only follow call options since we can't short a stock, likewise we can only buy stocks, since in Europe the derivatives market is not as well regulated as in the US, therefore we can only lookup the isin of an option manually as of now.

We can stream the options data, but only the live one, not the historic data, making back testing almost impossible.

To paper trade the stocks, we will be using lemon.markets, a German API focused up-and-coming fintech startup. It even allows us to try different strategies with its "spaces" system, dividing the main account into many smaller ones:

Algorithmic Trading in Python

Each Space has its own API key, as well as a portfolio, order and transaction overview. The API structure is also quite straight forward:

Algorithmic Trading in Python
https://docs.lemon.markets/img/API_Structure.png

The Results as of 09/29/2021:

You win some you lose some, but overall, we made about 14%  in 3 weeks with ~40 trades, but this being such a small timeframe we will have to see how it goes from here. Since the charting function on lemon.markets is broken right now, showing only the last day, I can't provide a chart right now, but once it is fixed, I will update this post.


BTW: The $NVDA call I analyzed above, returned 11% as of today.

]]>
<![CDATA[Nixie clock]]>One might know them from the bomb-defusing scene in the Bond movie "Goldfinger" or the Divergence Meter from Steins;Gate.
In short, its ten(0-9) wires glowing neon yellow in a vacuum tube, first replaced by seven-segment displays, they are becoming increasingly popular nowadays, because of their beauty.

]]>
http://localhost:2368/project-nixie-clock/6172dc382815492008b98faaSat, 05 Jun 2021 16:44:00 GMT

One might know them from the bomb-defusing scene in the Bond movie "Goldfinger" or the Divergence Meter from Steins;Gate.
In short, its ten(0-9) wires glowing neon yellow in a vacuum tube, first replaced by seven-segment displays, they are becoming increasingly popular nowadays, because of their beauty.

There are quite a lot of kits available online, but there is the fun in buying one?

Designing the Circuit:

The difficulty in it lies in the operating voltage of a Nixie-clock: ~170V

So I decided to use two circuits, one high-powered circuit driving the tubes and one low-powered one for switching the power to the digits on and off.
For switching, I used a quite common shift register, the SN74HC595DR
some 20k Ohm resistors and high-power transistors.

Nixie clock
Circuitplan_Nixie

As you may see, using a shift register allows us in theory to daisy-chain as many tubes together as we like to, therefore I tried to make the pcb as modular as possible, with the input on the left and output on the right:
Note: I added the RGB just for the sake of doing it, having LEDs under a Nixie clock is pure blasphemy.

Nixie clock
Nixie clock

Making it Real:

Since most of the parts are SMD components, which are too hard to solder by hand, I switched to EasyEda mid-development, because they had a list of parts, which JLCPCB could assemble, while redoing the layout, a little mishap happened:
The description was in the solder mask and not the silkscreen mask... F
Apart from that, it turned out great:

Nixie clock

Now for the moment of truth, does it actually work?
For driving the shift registers I used an Arduino Nano and for the 170V circuit a high-power supply from Ebay.
See for yourself:

Nixie clock

Since it looks rather barebone for now, my plan was to go to my local FABLAB @FAU and build a case out of wood for it, but since it's not exactly spacey in there, it has been closed since the pandemic began, so this project is not finished for now.

To be continued...

]]>
<![CDATA[Local Butchers´ Menu]]>http://localhost:2368/project-local-butchers-menu/6172dc382815492008b98fa8Sat, 08 May 2021 15:01:00 GMT

So as most of you during the Pandemic, studying or working from home, I and especially my neighbors struggled with eating a healthy meal every day, since they were used to the canteen at work and hadn't had the time to cook each day.

Local Butchers´ Menu



About two months in, a friend told me that the local butchers have a daily menu, so I tried it and it was great. But there was a problem, some meals for example had intestines in them, which many people dislike, but there are four butchers in the region, what if there was a place, which had an overview of all of their menus?
What if...


Note: The About Menu had to be reworked, it was only a proof-of-concept.


The Idea: Scrape each website every Saturday evening for next week's menu, this is more or less Mcgyvert with Airtable and Google Sheets, and show the results in a responsive app/webapp.

Note: I didn't want to use a single cent to realize this Idea

The Backend, just tables with information:

Local Butchers´ Menu


I developed the front end in React-native, via the Expo platform:

Local Butchers´ Menu
Local Butchers´ Menu

This being my first app project, I was quite surprised how fast and easy the development with expo is since you can see every change within 5 seconds.

Conclusion:

Now, about five months later I would have done a whole lot different, the scraping was a contender for the definition of Spaghetticode, and since I didn't really know Git back then, especially gitignore,the API keys are still all over the app, that's the reason why the code is not public on Github yet. But if someone wants it, just hmu.

Why it's not in the App/Playstore right now you may ask?
Well, at first only one butcher had their menu as a pdf, when I was done 3/4 used a pdf and since scraping a pdf is a whole lot more difficult, than a simple webpage, I more or less had to abandon the project.

]]>