Fx interest rate arbitrage 003 --- automated bot

 

Aim

This would be the final story of this series, the last step of this project is making an automatic robot to perform the strategy in a self-substantial manner.

To make a profitable strategy, it is important to minimize the cost and maximize the return of profit. This automatic robot is aimed to remove the manual operation cost ranged from executing the arbitrage opportunities to stopping the arbitrage session when it hits the margin limit level. In addition, the automation robot will pick up the correct leverage size to maximum the strategy return.

System overview

 


UI

 



Market signal

Enter position

$$ \begin{aligned} breakeven\ days & = {transaction\ cost \over swap\ return} \\ & = {{\sum_{i=1}^{N}{spread_{i} + commission_{i} + slippage_{i}}} \over {\sum_{i=1}^{N}{swap\ value_{i}}}}....... 1 \end{aligned} $$

$$ \begin{aligned} period\ return(day) & = {(lot\ size * swap\ return * day) - transaction\ cost} \\ & = ({equity \over volatility_{day}} * {\sum_{i=1}^{N}{swap\ value_{i}}} * day) \\ & \ \ \ \ - ({\sum_{i=1}^{N}{spread_{i} + commission_{i} + slippage_{i}}})...... 2 \end{aligned} $$ 



arb_group_id equity spread swap breakeven_days 10_days_v 15_days_v ... selected_days lot_size projection
1 500 8 4 2 1000 1300 ... 10 0.5 56
2 500 12 6 5 1100 1500 ... 15 0.3 90

We select the execution arbitrage group by evaluating the projection return. By scanning the breakeven_days, we will assume the operation duration of the arbitrage is n+1 level of days. For example, when breakeven_days is 2, we will pick the level 2 which is 10 days. Once we have the duration of operation, we can calculate the project for 30 days.

By sorting this projection value, we pick the arbitrage group with the biggest return value.

Exit position

  • Manually triggered by trader
  • Swap becomes negative
  • Free margin is not enough
  • Connection lost between gateways and arbitrage manager
     

Workflow

Data from gateways


 

Actions from arbitrage manager --- automation and manual


 

Start arbitrage --- success and fail


 

Close position when connection lose



Message structure


Message type Field name Data type Description
connection request broker_name string

account_name string

id int
interest arbitrage action action string start, stop

symbol string

side int 0: short, 1: success

lot_size double
interest arbitrage action reply success string F, S
account info account company string broker name

account server string account name

account balance double

account equity double

account free margin double

account profit double

strategy profit double profit under the same magic number
interest arbitrage order info ticket int

lot_size double

order profit double

order swap profit double

order type int Buy, sell
interest arbitrage waving info symbol array, string

n days volatility min array, int unit: pips, repeat n: 5, 10, 15, 20, 25

n days volatility 0.8 median array, int

n days volatility 0.9 median array, int

n days volatility max array, int

creation time array, datetime
interest arbitrage swap info account company array, string broker name

account server array, string account name

symbol array, string

swap long array, double

swap short array, double

spread array, int unit: pips

creation time array, datetime

Comments