마켓메이킹 알고리즘 - makesmeiking algolijeum

알고리즘 트레이딩 (Algorithmic Trading) – 전략 (34)

마켓메이킹 (Market Making) 전략 – 단순한 재고관리 전략


지난 시간에는 단순히 Bid-Ask측에 대칭적으로 지정가 주문을 유입한 형태의 마켓메이킹 전략에 대해 살펴보았다. 이 경우는 정보기반 거래자의 유해성 주문으로 인해 주가가 한 쪽 방향으로 움직이면, 마켓메이커는 재고가 과도하게 늘어나는 위험이 있었다. 이번 시간에는 마켓메이커가 재고량에 따라 지정가 주문 위치를 변경하여 재고를 관리하는 경우에 대해 살펴보기로 한다.

전략의 시나리오는 아래 그림과 같다. 처음에는 Bid-Ask 측 모두 2번째 호가 위치에 지정가 주문을 접수한다 (1번째 호가 위치는 움직임이 너무 빨라 2번째로 하였음). 주가가 지속적으로 하락 한다면 Bid 측 지정가 주문이 체결될 가능성이 더 높으므로 매수 재고가 증가하게 된다. 이 때 매수 재고가 +10개를 초과하면 Bid 측 지정가 주문 위치를 3번째 호가로 변경한다. 그러면 Bid 측 주문의 체결 가능성이 낮아지므로 매수 재고는 감소할 것이다. 반대로 주가가 지속적으로 상승 한다면 Ask 측 주문이 체결될 가능성이 높아지므로 매도 재고가 증가하게 된다. 이 경우도 매수측과 동일하게 매도 재고량에 따라 호가의 위치를 조정한다.

아마도 위의 시나리오가 가장 단순한 형태의 재고 관리 전략일 것이다. 재고가 작을 때는 Bid-Ask 측의 지정가 주문 위치가 대칭적이며 (2번째 – 2번째), 재고는 증가하더라도 수익 곡선은 (표면적으로나마) 증가할 것이다. 재고가 많아지면 Bid-Ask 측의 지정가 주문 위치가 비 대칭적이며 (2번째 – 3번째, 혹은 3번째 – 2번째), 재고는 감소하고, 재고가 조정되는 동안은 손실이 발생하여 수익 곡선은 하락할 것이다.

위의 전략 시나리오를 Market Simulator에서 재현해 보기로 한다. Simulator의 클라이언트 측에 아래와 같이 스크립트를 작성하였다. Bid 측 스크립트와 Ask 측 스크립트는 별개의 쓰레드 (Thread)로 서로 독립적으로 실행된다.

1. 유해성 주문이 없는 경우

아래 결과는 정보기반 거래자의 유해성 주문이 없는 경우이다. 유해성 주문이 없어도 주가는 오르거나 내릴 수 있으므로 재고 관리는 필요하다. 유해성 주문이 없으므로, Bid-Ask 측 체결률이 유사하므로, 수익 곡선은 지속적으로 우상향할 가능성이 크다. 전체적으로 보유 재고량은 정상성 (Stationary)을 가진 시계열처럼 일정 범위 안에서 안정적으로 움직이고 있다. 그림에서는 매수 재고량이 +10을 초과한 경우가 2번 있었으나, 곧 바로 감소하는 것을 볼 수 있다. 매수 재고량이 감소하는 동안은 수익 곡선도 감소하게 된다.

2. 유해성 주문이 있는 경우

아래 결과는 유해성 주문이 있는 경우이다. 유해성 주문의 강도는 +3 단계로 높은 편이므로 주가는 지속적으로 상승한다. 이 경우는 정보기반 거래자가 강력한 매수 신호를 가지고 있으며, 정보기반 거래자의 공격성이 매우 높은 단계이다. 전체적으로는 매도 재고가 많이 쌓이고 있는 모습이다. 이것은 주가가 지속적으로 상승하였기 때문에 Ask 측에 유입된 지정가 주문이 더 많이 체결되었기 때문이다.

보유 재고가 매도 쪽으로 치우쳐 있으나, 재고 관리를 통해 재고량은 (평균이 “-” 인) 정상성을 (Stationary) 띠고 있어 그런대로 안정적인 모습이다. 그림에서는 매도 재고가 -10을 초과한 경우가 3번 있었으며, 재고가 관리되는 동안은 손실이 발생하고 있다. 수익 곡선을 보면 대체적으로 수익이 발생한다고 보기는 어렵지만, 유해성 주문이 있으면서 재고 관리를 하지 않은 경우 (이전 포스트)보다 많이 개선된 것을 알 수 있다. 즉, 재고가 과다하게 쌓이지 않으면서도 수익 곡선의 형태가 개선되었다. 이것이 재고 관리 전략의 효과이다. 물론, 강도 높은 유해성 주문으로 인해 수익 곡선의 편차나 MDD는 다소 큰 편이다.

단순한 재고 관리를 통해서도 마켓메이킹 전략의 성과가 개선된다는 것을 확인해 보았다.  재고 관리를 더욱 더 효과적으로 한다면 성과는 더욱 개선될 것이다. 사실 마켓메이킹 전략의 핵심은 재고 관리에 있다고 해도 과언이 아닐 것이다. 시장미시구조론 관련 논문들을 찾아보면 마켓메이킹의 재고 관리 방법을 연구한 것들이 많이 있다. 그 중 대표적인 것이 Stoll (Ho & Stoll)의 모형이나, Avelladena & Stoikov 모형 같은 것 들이 있다. 앞으로는 이런 모형을 토대로 좀 더 개선된 재고 관리 전략을 소개해 보기로 한다.

[출처]34. 마켓메이킹 (Market Making) 전략 – 단순한 재고관리 전략|작성자아마퀀트

트레이딩전략

1.
여의도가 빙하기입니다.

빙하기때 생존하는 방법중 하나는 복지부동(伏地不動)입니다. 움직임을 최소화하여 위험에 노출될 가능성을 줄여서 생존확율을 높이는 전략입니다. 최근 증권사들이 너도나도 자기매매부서를 폐쇄하는 것이 바로 이런 전략입니다. 다른 하나는 발상의 전환((發想轉換)입니다. 변동성이 부족하고 유동성도 적더라도 무언가 남이 보지못하는 틈새를 공략하는 방법입니다. 혹 일본만화를 좋아하는 분들이면 아실만한, 이누야사가 사용하였던 기술인 바람의 상처(風の凶)같은 것이죠.(^^) 사실 후자는 비용이 많이 드는 방법이라 쉽게 택할 수 없습니다. 준비를 하지 못한 경우에는 실행 조차 불가능합니다. 결국 복지부동이 살 길입니다. 완전 처세술입니다.

서론이 길었습니다. The Complete MoneyScience을 매일 방문합니다. 물론 RSS를 통해 제목을 주로 읽습니다. 아주 오랫동안 트레이딩전략에 관한 논문들이 거의 올라오지 않는 듯 합니다. 세계적으로 변동성과 유동성이 작기 때문에 연구자들의 관심이 더할 것이 아닐까 추측해 봅니다. 물론 아주 개인적인 느낌일 수도 있습니다.

2.
지난 몇 달동안 올라온 논문중 두 편에 관심이 가더군요. 오늘은 두편의 논문을 소개합니다.

첫째는 한동안 한국도 관심이었던 Market Making입니다. 제목은 ‘Robust Market Making’입니다. Robust라는 말을 찾아보면 “건장한,힘드는,독한,억센”이라는 뜻이지만 영어로 하면 “the ability of a system to resist change without adapting its initial stable configuration”라는 뜻을 가집니다. ‘변화에 대응하는 능력이 있도록’ 설계한 전략이라는 말이겠죠?(^^) 쉬운 논문은 아닙니다.

둘째는 Latency artrage와 관련한 논문입니다. 대체거래소가 몇 개가 등장할 때 모르지만 레이턴시를 이용한 거래소간 차익거래가 이론적으로 가능한 환경입니다. 아래를 가시면 논문을 요약하여 한장의 포스터로 만들어놓았고 동영상으로 표현했습니다.

Latency Arbitrage, Market Fragmentation, and Efficiency: A Two-Market Model

아래는 논문입니다.

A market maker provides liquidity to the market by standing ready to both buy and sell an asset at stated bid and ask prices. They are common for both Forex markets and stock exchanges, and there are even many firms acting as market makers for bitcoin and other cryptocurrencies. The value of market making to traders is that they are able to execute trades immediately, rather than having to wait for a matching order to appear. In exchange, the market maker generates a profit by setting an appropriate spread between the bid and ask prices. A market making algorithm must determine appropriate bid and ask prices to maximise profits. There are two trade offs that a market maker must consider when trying to achieve optimal market behaviour.

Firstly, there is a trade off between volume and margin. If the market maker’s bid ask spread is too conservative, few of his trades will be fulfilled. On the other hand, if his spread is too aggressive, many trades will be fulfilled but he will make very little money from each trade. So the bid ask spread must be sufficiently attractive to other market participants while still remaining profitable for the market maker.

Secondly, while market makers can profit from the bid ask spread, they are exposed to risk due to price changes on the inventory of the asset that they must hold. If the price drops, the inventory may have to be sold at less than it was acquired for. The market maker must therefore design a quoting algorithm which optimally sets bid and ask prices to generate a profit, while also minimising inventory risk. A market maker may hope to buy and sell in approximately equal quantities to avoid accumulating a large inventory. Market making algorithms are relevant not just to genuine market makers, but to any market participant that both buys and sells an asset. One mechanism a market making algorithm can use to reduce inventory risk is to provide more conservative bid estimates when it is already long a significant inventory.

Market making strategies differ from more general trading strategies in that the latter may take on a large position based on some view of the direction the market will move in, while the market maker attempts to avoid this risky bet as much as possible.

The Avellaneda-Stoikov model

The Avellaneda-Stoikov model is a simple market making model that can be solved for the bid and ask quotes the market maker should post at each time \(t\).

We consider the case of a market maker on a single asset with price trajectory \(S_t\) evolving under brownian motion

\[ dS_t = \sigma dW_t.\]

While this implies a normally distributed price rather than lognormally distributed, the difference is not significant over small time horizons where \(S_t\) does not move too much from its original value.

Let \(S_t^b\) and \(S_t^a\) represent the bid and ask quotes of the market maker at time \(t\), and let \(N_t^b\) and \(N_t^a\) represent the total number of market participants who have bought and sold from the market maker respectively. The model assumes that buyers arrive to purchase from the market maker at random, with an average frequency that decreases as the bid price \(S_t^b\) drops further below \(S_t\). Similarly, the frequency at which sellers arrive to sell to the market maker arrive with an average frequency that decreases as the ask price \(S_t^a\) rises further above \(S_t\). This means that the more conservatively the market maker sets his bid and ask quotes, the less likely he is to make trades.

Furthermore, the model assumes that the market maker must keep his inventory \(q_t\) between some values \(-Q\) and \(Q\). He does this by not posting a bid quote when his inventory reaches \(Q\), and similarly for an ask quote.

For simplicity, the model assumes that each buyer purchases exactly one unit. Since the market maker earns \(S_t^a\) whenever a buyer arrives, and spends \(S_t^b\) whenever a seller arrives, his cash account satisfies the equation

\[dX_t = S_t^a dN_t^a – S_t^b dN_t^b.\]

We assume that the market maker wishes to optimize his behavior over some time interval \([0,T]\). We want to find functions of time \(S_t^b\) and \(S_t^a\) which maximise the expected value of his final holdings of cash and inventory

\[X_T + q_TS_T.\]

However, in such problems it is also typical to penalise the variance of this quantity in the optimization to factor in risk aversion. One can optimize such a function using stochastic control theory. For the exact form of the solutions and for more details see The Financial Mathematics of Market Liquidity by Gueant.

Toplist

최신 우편물

태그