Blog

Introduction to SqlAlchemy queries – part 1





The select() is the base function to query data in SQLAlchemy. The select() function translates SQLAlchemy-style query int SQL SELECT adjusted to the applied back-end database. The query mechanism introduced in SQLAlchemy 2.0 and above is different compared to the earlier framework versions.

SQLAlchemy select queries

Continue reading “Introduction to SqlAlchemy queries – part 1”

Synthetic time series generation





Artificial neural networks rely heavily on large sets of data to train their models. However, with the constantly evolving data privacy regulations around the world, obtaining high-quality data becomes increasingly challenging, mainly due to security or privacy reasons. Read more and find out how to generate synthetic time series for you machine learning models.
Synthetic time series generator

Continue reading “Synthetic time series generation”

Testing a web application with pytest in two simple examples





Flask application testing is usually associated with web frameworks which automate the tests performed across different web browsers, e.g. Selenium. However, not always there is a need to use such a complex tool and quite often most of the web application can be tested with the popular and universal pytest framework.

Testing web applications with pytest

Continue reading “Testing a web application with pytest in two simple examples”

LSTM for stock prices forecasting


You probably read stories about artificial neural networks which predict stock prices. Some of them are even published as scientific papers. These algorithms were supposed to make their owners rich. Supposedly, it was enough to construct the network, feed it with stock prices, and get prices for the next hour, day or even a week. Is there any truth in such stories?

Prediction with LSTM

Continue reading “LSTM for stock prices forecasting”

ARMA for market prediction – does it work?





ARMA process predicts the future taking into account past values and errors. When making predictions, we often reach the past to find a pattern which can repeat itself in the future. Such patterns may have roots in seasons, days (business days and weekends), or time of day (day and night). However, rarely does same pattern happen multiple times. Unexpected events related to politics, the economy and daily life in general, disrupt any ready-to-use templates. Therefore, we need models like ARMA that simultaneously use past data as a template for estimates and can also include unpredictable events distorting this template.
ARMA process

Continue reading “ARMA for market prediction – does it work?”

Web-gui for Python logs





Logging can help you better understand the flow of a program and discover undesirable behaviour, which you might not even consider while developing. Logs give you information about scenarios that an application is going through. You can label this information according to its importance: debug, info, warning and errors. Logs can provide more insights than a stack trace by telling you what the program state was before it arrived at the line of code where the error occurred.

Logs browser in Flask
Logs browser in Flask

Continue reading “Web-gui for Python logs”

Save on taxes understating FIFO or LIFO

FIFO and LIFO are two popular methods for the computation of capital gains. Understanding the differences between them allows you to save on taxes. How much money? Even up to 25% of your capital gains if you live in a country with such high taxes. Usually, the savings are less than this, but still can be a significant amount. How can I do this? By applying the so-called optimisation of your portfolio, which will allow you to reduce tax or prolong its payment. But, to optimise, you need to understand how your broker calculates your capital gains.

Savings
Continue reading “Save on taxes understating FIFO or LIFO”

Calculating capital gains using FIFO queue

According to the first-in-first-out (FIFO) valuation method of capital gain, it’s assumed that equities are sold in the order in which they’re bought. In other words, the oldest shares are sold first. A detailed description of this method can be found in many places, e.g. here. In this post, I will focus on the implementation of the FIFO method in Python.

Fifo queue
Continue reading “Calculating capital gains using FIFO queue”