Content uploaded by Nicolus Rotich

Author content

All content in this area was uploaded by Nicolus Rotich on Mar 26, 2022

Content may be subject to copyright.

LEVERAGING EVX: A HIGHLY

SCALABLE FINANCIAL

MARKETS INDICATOR FOR

DEFI

[Technical whitepaper – release 2– revision 1.0]

March 26,2022– DeFinance Technologies R

contents

1Executive summary 2

2Problem Description 3

2.1Seasonalityproblems............................. 3

2.2Systemic risk ampliﬁcation . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.3Liquidityconstraints ............................. 4

3Research and Methods 5

3.1TheWorkingofEVX ............................. 5

3.2TheMethods.................................. 7

3.3Populating Buy-Sell Signals . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.4Productionmodels .............................. 8

4Case study 8

4.1Assetsscreening................................ 8

4.2Optimized assets selection . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5Risk assessment and monitoring 10

5.1Drawdownoptimization .......................... 10

5.2Otherimportantratios ............................ 10

6The business model 12

6.1DeFinanceEconomics ............................ 12

6.2SubscriptionBasis............................... 12

7Summary 13

1

executive summary 2

abstract

Financial assets trading using application programming interfaces (API) is increas-

ingly becoming common for both individuals and companies. With API, it is im-

portant that the traders get their trading signals accurately in order not to lose their

capital amidst the highly volatile markets. Generating buy-sell signals for newer

markets such as cryptocurrency or decentralized ﬁnance (DeFi) is more complex

compared to conventional markets. This release of the white paper entails a newly

developed ﬁnancial markets indicator (EVX) and leverages methods of artiﬁcial in-

telligence (pattern recognition and machine learning) to determine the buy-sell con-

ditions.

1 executive summary

Finance as a discipline has for a long time been known to be an art. Particularly

that of managing money ﬂow streams. Other literature deﬁnes ﬁnance as a disci-

pline concerned with allocation or investment of assets over space and time, often

under the constraints of risks and uncertainties. It therefore entails the actors as

participants, aiming to price assets based on factors such as: risk levels, expected

rate of returns on investment (ROI), time value of money, etc. The last few decades

have however overseen tremendous unprecedented evolution in the history of ﬁ-

nance, both as a discipline and the actors aforementioned. As opposed to humans

as the sole actors hitherto, standalone algorithmic trading engines have also joined

the block.

The ultimate objective in most asset trading activities is knowing when to get into

and out of a trade. Obviously, by “when” we not only imply the time aspect, but

must also take into account other factors such as the market forces of demand, sup-

ply, asset quantities, and the prices that are likely to to maximize our gains. Success

in asset trading is therefore heavily dependent on accurate timing of the trades

[1]. There are a handful of technical indicators that are well established and tested,

some of which are: simple moving average (MA), exponential MA, stochastic os-

cillator, MA convergence divergence (MACD), Bollinger brands, relative strength

index (RSI), Fibonacci retracement, Ichimoku cloud, standard deviation, and aver-

age directional index (ADX) among others. The rule of the thumb however, is that

we do not use a single indicator in isolation. In fact hardly does each one of these

indicators work for a foreseeable future when implemented inherently. Instead, it

takes the correct combination of these algorithms.

However much the above indicators have been applied successfully, there are prob-

lems associated with each one of them, resulting in a range of errors from pure

mathematical to simple dysfunctions due to market dynamics. In essence, all these

indicators boil down to two words overbought and oversold. The fundamental ob-

jective in all with no exception, is to determine the characteristics of assets before,

during, and after changing hands.

The focus of this whitepaper is to introduce an excess volume-based methodology

that attempts to estimate and compare the bids and the ask volumes, and uses them

to project the following attributes of the target market:

i The dynamic bid-ask volumes, besides the static (total) volume provided by

the exchanges and data providers

ii Determine the exact bid-ask spread, and

*DeFinance Technologies Oy, Helsinki, Finland

problem description 3

iii Use these information to estimate an averaged index quantifying all the con-

ventional indicators in one go, which is then used to generate buy-sell signals.

For instance, setting EVX to a certain index value, a combination of equiva-

lent RSI =value 1,ADX =value 2, ...Indicator N=value n are simultane-

ously set and used automatically.

The hypothesis of excess volume method is to aim and position the user into a trade

only when the asset’s supply is just enough to be available, the market demand is

there (liquidity), and the price is just right to yield a reasonable return on invest-

ment. The biggest hurdle to algorithmic trading is the markets’ unpredictability,

that leads to inconsistencies in the results produced by most systems in the long-

term.

The outgoing rationale thus justiﬁes the need for continuous search for better algo-

rithms in order to sustain the competition with arising needs for high frequency,

yet accurate ﬁnancial operational and technical analysis. We therefore introduce a

new technical indicator dubbed Excess Volume Index (EVX). At best EVX tries to

consolidate the problems associated with aforementioned earlier forms of market

indicators and address them all in one. An important point to note with the in-

dex is how it takes easily accessible data (OCHLV), and extract up to 95% accurate

bid-ask spread, not only as a percentage, but actual volumes of successful bids and

asks. It then uses this information to estimate the momentum index that can easily

be incorporated to populate buy-sell signals that are then sent as requests through

application programming interface(s) (API).

2 problem description

The problems associated with applying these old indicators can be categorized into

the following groups:

•Seasonality problems

•Systemic risk ampliﬁcation

•Liquidity constraints

2.1 Seasonality problems

Even the best algorithm today ends up mischaracterizing the buy-sell conditions

when sufﬁcient run-time is provided. An ideal algorithm should be able to with-

stand seasonal changes resulting from stock market climate, social and political

sentiments, regardless of the extent of the time it is in use. The challenge of course

is capturing these effects and successfully corroborating them within the guiding

mathematical principles. By taking into account not only the actors, but also their

projected intentions following an event, and the rate at which they act when they

do, EVX attempts to model the gradients in which the asset prices and volumes

changes based on these factors. By doing this, the algorithm naturally attains

semi-immutable characteristics to an extent of high scalability where as little as

one month backtesting data can be used to forecast as long as one year’s expected

returns on investment. All these, while retaining the algorithm’s rigour.

problem description 4

2.2 Systemic risk ampliﬁcation

Systemic risk is nowadays conventional wisdom, especially after the ﬁnancial cri-

sis of 2008. By deﬁnition, systemic risk is the risk that the ﬁnancial system ceases

to perform its function of allocating capital to the most productive use because of

ﬁnancial difﬁculties among a signiﬁcant number of ﬁnancial institutions [2]. The

view that the architecture of the ﬁnancial system plays a central role in shaping sys-

temic risk is increasingly starting to be accepted as an explanation [3]. The speciﬁc

aspect of architecture referred to, is the interconnectedness. When a one system is

more connected to other systems, it is exposed to a higher level of systemic risk[4].

But what does EVX indicator has to do with systemic risk? Well, there is a noticeable

trend between say the tanking in the US $ market and (the rise in) speciﬁc assets

in the NYSE. The same case applies to the cryptocurrency market, and is even

more severe due to the high correlation between say some top alt-coins and the

bitcoin market. There is thus a noise signal affecting mostly all known market

indicators due to this interconnectedness. A clearer signal is obtained by ﬁltering

out these noises through direct estimation of the bid-ask volumes, and thus the

spread, together with an assessment whether the asset is overbought or oversold.

The buy signals are thus generated not only based on the market and momentum

movements, but also on deeply characterized nature of each asset encoded in the

algorithm. EVX thus leverages all the above strengths to return a superior algorithm

that maximizes gains while minimizing susceptibility to the asset’s risks such as

volatility and draw downs.

2.3 Liquidity constraints

There are two exemplary problems when designing asset trading algorithms: the

easy problem entailing deﬁnition of the variables, deciding on sufﬁcient time frames

or ticker intervals, setting the type of order, be it limit, market, stop-limit or any of

the many order types. Then there is the hard problem: deciding when to open a

position and when to close, is not enough. You also want to make sure there is

sufﬁcient in(out)ﬂow of resources. This is to imply that when you open a position,

you should be able to close it whenever you want. While this is seemingly obvious,

some assets do not have sufﬁcient liquidity, and may not exit the portfolio at the

rate it is required – what would be termed as slippage.

Liquidity is not inherently an asset property, but but a complexity of the condi-

tions in which the asset was bought, together with those in which about to be sold.

For instance, an asset acquired while it was overbought will generally have more

difﬁculty to dispose (even if the market shows proﬁtability) than one acquired in

oversold conditions. This aspect of liquidity or lack of it thereof is addressed by

using EVX, as it will attempt to trade only when the odds are tilted towards the

trader’s favor. With EVX, populating the buy signals is as easy as setting the per-

cent in which the asset needs to be oversold before buying. The inverse problem is

used under oversold conditions, and when the right timing is used, more than half

of the liquidity constraints of a portfolio are addressed by the EVX.

research and methods 5

3 research and methods

3.1 The Working of EVX

The proﬁt model describing change between the selling and buying price is the most

practical artifact we know of in the world of merchandising and entrepreneurship

today. It is simply the difference between the two prices of an asset, call the selling

price y, and bought at xboth in US $ per share. In the strictest sense the change, c

according to this model is expressed as follows:

c=|y|−|x|(1)

We desire that we get out of a trade when the change is positive, rather the differ-

ence between the closing and opening rates is sufﬁciently greater than zero. The

problem with the model in Eq.(1) is that it looks at only two points, the beginning

and the end of the transaction time frame, also known as the ticker interval. An

ideal model is the one that projects and describes the change as a ﬂuid continuum,

aiming to capture what happens both between and within the time frame in which

the transaction occurs.

The excess volume concept also implies that the successful bids volume, Bare nec-

essarily more than asks, Aat the close of the trading time represented by the ticker

interval if any proﬁt is to be made. As we always do, we test this hypothesis with

historical data, where we are only given in form of open, high, close, low and vol-

ume (OHCLV). A trade thus has a high expectancy when B >> A. That is the

hypothesis of excess volume methodology. But how we determine these volumes

from historical data is the focus here, as this determines the bid-ask spread and

most importantly constitutes feature extraction used to obtain the training and pre-

diction data for machine learning models.

To successfully model the intricacies between and within the ticker intervals, we

introduce an old mathematical concept referred to as perturbation theory. This means

we are seeking for (non-linear) function(s) that estimates the original independent

variable, i.e. cin this case. EVX hypothesizes that the change in price is initiated

and led by the difference between the bids and ask volumes. In other words, the

inﬁnitesimal change can be described with differentials as follows:

δV =

N

X

i=0

(Bi±Ai)(2)

The hypothesis can thus be summarized in into the following mathematical theo-

rems:

Theorem 1.: At the start of the change, the bid-ask volume spread is the highest, and as the

change progresses, the volume difference spread tightens, zeroing in at the last millisecond

of the ticker interval.

Proof. We have that c=|y|−|x|. We can perturb the change such that it becomes: c=

2|y|−[f(V)+|x|]. These two equations are innately the same, with the assumption

that f(V)will build up to equal exactly yat the end of the ticker interval. Then,

the change will be given simply as c=2y −(y+x)same as the original form. The

rest of the exercise in the following sections is thus to estimate the function of asset

volumes, f(V)in terms of OHCLV as given by most ﬁnancial data providers.

Theorem 2.: The product of the evolving change in price and the inﬁnitesimal volume in

Eq.(2)yields the bid-ask spread.

research and methods 6

Proof. By above deﬁnition: the volume spread can be expressed in the following

manner: cδV =Bδy −Aδx. As the change progresses towards the end of the ticker

interval, the differentials can now be treated as full partial derivatives as will be

seen in the next sections. The differentials δy ≈δx =2y −yn−x, where ynis a

constant function of volume as described in the perturbed change.

The second derivative of volume with respect to bids, asks volumes, opening and

closing prices will be given as follows:

∂2V

∂B∂y =1

cand (3)

∂2V

∂A∂x = − 1

c(4)

Combining the two equations in Eq.(4) (subtraction) gives us a full partial differen-

tial equation of the following form when the price change is introduced:

∂2V

∂B∂y ±∂2V

∂A∂x =2

c∂c

∂y +∂c

∂x (5)

The LHS of Eq.(5) opens up a new discussion with the ±symbol. What this means

is that we now have inﬁnite solutions to the equation. The three obvious solutions

are as follows:

c=|y|−|x|, (6)

c=2|y|−(yn+|x|)and (7)

V=B+A(8)

We have two solutions for the price change, but only one for the volume spread.

The ultimate desire is to estimate the exact values of asks, A and bids B, and track

their percentage changes giving rise to the EVX momentum indicator. Once these

values are estimated, the momentum indicator will then be calculated and used to

generate the buy-sell signals. EVX indicator therefore does the following:

i It informs us when to send a buy signal, as we desire to enter into a trade only

when bids are higher than the asks, and the spread is wide enough.

ii We also desire to exit the trade when conditions in [i] above are still valid.

Meaning, there is a high expectancy of proﬁtability when we conduct our

trading activities within the window when B >> A.

When the change in price is presumed to take the classical form of Eq.(1), the sign

of LHS of Eq.(5) is (+), both sides of the equation reduces to zero i.e.:

∂2V

∂B∂y +∂2V

∂A∂x =2

c∂c

∂y +∂c

∂x (9)

where c=y−x, and V=B+A:

∂c

∂y +∂c

∂x =0(10)

The above system is thus non-trivial. On the other hand, when the change is taken

to be the perturbed form:

∂2V

∂B∂y −∂2V

∂A∂x =2

c∂c

∂y +∂c

∂x (11)

Where c=2y −(yn+x). It is seen that the RHS remains 2/c, since:

∂c

∂y +∂c

∂x =1(12)

research and methods 7

This prompts the need to establish function(s) of volume that will fully satisfy the

equation. A unique solution will effectively split the bids and asks into exact values

and always corresponds to the whole range of data on the OHLCV data as provided

by the exchanges. The methods section is designated to prove that such functions

exists and how they can be leveraged to populate the buy-sell signals.

3.2 The Methods

3.2.1 Problem formulation

Excess volume index by deﬁnition is the percentage change in the bids-ask volumes

over the time frame in which the computations are taken, also referred to as the

ticker interval. The premise of the hypothesis is that if the spread has increased by

a certain amount in the last ticker interval, the same trend is expected to continue in

the next time frame provided such time interval is sufﬁciently small. This implies

that the indicator is estimated as follows:

EVX =B−A

A(13)

We are required to establish the exact amounts of B and A for each ticker interval

in order to estimate the momentum indicator. There are two ways to achieve this:

Analytically or numerically. We can solve either of Eq.(11) or Eq.(12) with appropri-

ate boundary conditions as set in section 3.1. In order to solve Eq.(11) analytically,

the problem is necessarily set as follows:

VBy −VAx =2

c,

V(x,0)=V(x),

V(0,y)=V(y),

V(x,y)=F(y)+G(x)

(14)

Alternatively, solving Eq.(11) analytically will entail the following formulation:

cy−cx=1,

c(0,y)=c(x),

c(x,0)=c(y),

c(x,y)=E(y)+H(x)

(15)

3.2.2 Solution

The above formulation results in the thinking that asks, A and bids, B are ex-

pressible as pure functions of the opening and closing prices respectively following

d’Alembert’s solution where then:

V∂c

∂y +V∂c

∂x =F(y)+G(x)(16)

The price changes in Eq.(1) and (10) are thus reﬂected as the characteristic equations.

The solution in Eq.(16) can therefore be wrapped up into a mathematical theorem.

Theorem 3.In an exchange volume-space topology, the change in asset prices are the axes

surrounded by contours of constant (excess) volume. The gradients between the peaks and

the troughs dictates the buy-sell signals generated.

case study 8

Figure 1: Illustration of excess volume contours

3.3 Populating Buy-Sell Signals

Upon estimating the bid-ask spread from historical data, these values are then run

through a rigorous pattern recognition attempting to replicate future (un-seen) sce-

narios. Generating the buy-sell signals with EVX then become as simple as drawing

a matrix between the asset’s asks, bids, and current (open and close) prices. The

determinants of the matrix dictates whether it is worth-wile entering or exiting a

trade. The following equations summarizes the buy-sell conditions:

det

A y

B x

> 0 For the buy signal ... and (17)

det

A x

B y

>0For the sell signal ... ....... (18)

3.4 Production models

EVX indicator is accompanied by two production grade machine learning classi-

ﬁcation algorithms as complete python packages. The documentation on how to

apply the models is brieﬂy described in the python package indexing page (PyPi).

The exact parameters used to obtain the draw-downs shown in this whitepaper and

achieve the desired backtesting metrics are considered proprietary, and thus are not

included in the free download pages.

4 case study

4.1 Assets screening

Volatility, industry exposure, market size, and trading liquidity among other com-

mon market risks forms the core of any well constructed portfolio. This is besides

the notion that the assets constituting the portfolio (stock universe) possesses a

highly non-linear correlation to each other, and thus to the overall impact on the

case study 9

trading [5]. The algorithm needs to start somewhere. This initial phase entails ran-

domly selecting assets, downloading historical data and running the screening to

assess long-term performance of the asset. In this phase, the algorithm returns the

list of assets when subjected to extreme requirements of zero maximum draw down

(MDD) with a speciﬁed set stop-loss. Here is an example of selected assets from the

bitcoin market:

(a) Initial coin list. (b) Summary metrics.

(c) Sell reasons statistics

Figure 2: Trades simulation for screening.

The above results were obtained through trades simulation with a stop loss of 7.4%

and a starting capital of 0.15 BTC for 225 days.

4.2 Optimized assets selection

The second phase involves knocking-off the assets that are susceptible to large draw

downs over a long period of time. Supposing that the the trader now decides to

remove the assets that are unproductive or by manipulating the stop loss range. He

will then remain with a list with zero-tolerance to losses as depicted in the ﬁgure

below:

(a) Intermediate coin list. (b) Summary metrics.

(c) Sell reasons statistics

Figure 3: Trades simulation for zero tolerance.

risk assessment and monitoring 10

5 risk assessment and monitoring

The most important part of any trading strategy is risk assessment. At DeFinance,

we have managed to leverage agile techniques to implement and monitor trading

risks and we continue to make improvements on a daily basis.

5.1 Draw down optimization

This phase involves setting allowable risk by the trader. Of importance here is

striking the balance between acceptable MDD and the instances of trades entered.

Setting a strictly low MDD means the trader does not enter into too many trades

or open too many positions at ago. While this minimizes the risk, it also reduces

the gains. However, with a certain acceptable range of MDD, the trader is able to

enter into as many trades as he may need. The following example shows trades

simulation under the same conditions, but the trader has accepted some losses in

order to increase the trade volumes. This ends up with an MDD of only 19.73%

which is well below the generally accepted value of 20%:

(a) Final coin list. (b) Summary metrics.

(c) Sell reasons statistics

Figure 4: Optimized trades with acceptable risk allowance. Initial amount: 0.0184 BTC, posi-

tions opened: 4, testing time period 458 days (Nov. 2019 - Feb. 2021)

5.2 Other important ratios

Besides maximum draw-down, we also use conventional as well as newly devel-

oped risk assessment parameters such as Sharpe, Sortino, Burke, Calmar, Sterling

and proﬁt-to-draw-down ratios. In addition, we have compiled a number of in-

house risk management methodologies in relation to the developed algorithm. The

evx-coefﬁcient for instance, is an aggregation of above ratios such that:

α=PN

i=0ri

CV (19)

Where alpha is the evx-coefﬁcient, CV is the coefﬁcient of variability based on the

daily proﬁt percentages, while rare individual representations of the risk assess-

ment ratios earlier described. The second aggregate beta, is obtained as a linear

combination of the ratios, with beta coefﬁcients assigned on the basis of the ratio’s

risk assessment and monitoring 11

relative signiﬁcance as follows:

B=PN

i=0βiri

Rdσ2√365 (20)

In the above system, σ2is annualized variance (of daily proﬁts), and Rd, the mean

daily returns percent. Coefﬁcients βare assigned through some optimization rou-

tine such as hyperopt. These methods are especially important when comparing

strategies and portfolios. Further optimization is often necessary, for instance to get

the right combinations of the last two parameters, that yields the desired results.

A continuous evaluation of these parameters in addition to live-testing during the

pilot-scale project has enabled us to move from dismally performing equity to a

much promising system. The following images present plots of equity curve before

and after implementation of the described methods.

Figure 5: Equity before optimization

Figure 6: Equity after optimization

the business model 12

Where Equity, Eis evaluated as a cumulative integral of daily average returns, Rd

for the entire backtesting period, tas follows:

E(t)=Zt

0

Rd(t)dt (21)

6 the business model

6.1 DeFinance Economics

Figure 7: DeFinance Economics Illustration

There are a couple of reasons why a trader would choose to use the trading sys-

tem. Conventional(manual) trading not only expose the trader to potential loses

due to inept operations, but also excessive emotional strain and stress from trend

following that may not be necessarily accurate. DeFinance trading is envisaged as

a service provider aiming to shield the trader from immense volatility in the new

DeFi arena. The ecosystem involves the client depositing trade-able amount of as-

set(s) in our predeﬁned exchange and linking the credentials namely, the API-key

and API-secret used to authenticate to the respective exchange(s). The ﬁnal step is

for the operator to initiate buy (and sell) orders sending. This is only necessary if

the exchange doesn’t support direct client authentication. The bot thus orchestrates

continuous trend following and submission of the orders on behalf of the trader

whenever market imperfections are detected on a 24/7basis.

6.2 Subscription Basis

The very nature of continuous operations implies that the headless operation must

be deployed and hosted onto a distributed computing environment – cloud service.

As this involves an overhead cost to the service provider, this cost is transferred

along with the trading fees, and applicable taxes to the client. The service provider

then charges a set minimum subscription fee for overhead charges, and a commis-

sion based on the expected increase in the stake currency at the end of the agreed

contractual period. In this way, the service not only helps the trader to maximise the

returns from bullish trading, but also to increase trading volumes while reducing

the risks by avoid unnecessary trading during high volatility seasons.

summary 13

7 summary

We have presented a justiﬁed case for a new ﬁnancial markets indicator and how it

can be leveraged to maximize gains while at the same time minimizing risks in the

volatile market of decentralized ﬁnance. It is worth noting however that backtesting

results do not necessarily directly translate to the future outcomes due to the nature

of assets unpredictability. While the algorithm has proven promising during the

proof of concept (POC) test period with beta users, there is still a need to exercise

caution on its applicability on your own as we continue improving its accuracy. For

further information concerning our operations, consultations on implementation,

and partnering negotiations, contact DeFinance R

team.

references

[1] Antonio C Briza and Prospero C Naval Jr. Stock trading system based on the

multi-objective particle swarm optimization of technical indicators on end-of-

day market data. Applied Soft Computing,11(1):1191–1201,2011.

[2] Anton Korinek et al. Systemic risk: Ampliﬁcation effects, externalities, and

policy responses. Technical report, 2009.

[3] Daron Acemoglu, Asuman Ozdaglar, and Alireza Tahbaz-Salehi. Systemic risk

and stability in ﬁnancial networks. American Economic Review,105(2):564–608,

2015.

[4] Lei Fang, Jiang Cheng, and Fang Su. Interconnectedness and systemic risk:

A comparative study based on systemically important regions. Paciﬁc-Basin

Finance Journal,54:147–158,2019.

[5] Una-May O’Reilly, Tina Yu, Rick Riolo, and Bill Worzel. Genetic programming

theory and practice II, volume 8. Springer Science & Business Media, 2006.