Creating and testing arbitrage strategies - page 7

 
pronych:
All right. We'll talk about it when you go for limit orders with these legs.))
I agree, it will be a bit difficult to control a swarm of limit orders ))
 

I will start a new topic.

This question may arise when we are defining liquidity for arbitrage position.
How to correctly recalculate the liquidity of a cross pair in USD units on a best-band (and why)?

1) directly through major in base currency
2) via major in quoted currency

Example: Volume on the EURCHF Best Bund is 2 million units. You have to check this volume in USD. What should we do? We look at the EURUSD ticker and estimate how much EUR 2 million is. Or, we estimate the CHF volume at the current exchange rate and then use the USD/DCHF tenge to determine the volume in USD?

 
GaryKa:

I will start a new topic.

This question may arise when we are defining liquidity for arbitrage position.
How to correctly recalculate the liquidity of a cross pair in USD units on a best-band (and why)?

1) directly through major in base currency
2) via major in quoted currency

Example: Volume on the EURCHF Best Bund is 2 million units. You have to check this volume in USD. What should we do? We look at the EURUSD ticker and estimate how much EUR 2 million is. Or, we estimate the CHF volume at the current exchange rate and then calculate the volume in USD using the USDCHF dial?

And through the value of the tick, no?
 

I have seen the solution via TickValue. But the case is general (not MT) and besides, I'll be honest, manipulating TickValue gives me a headache. I'd like a simple explanation, which would be easy to remember.

So far it's like this:

On Ask gangs, we have an offer for sale, so the sellers have the goods(base currency) available. We just calculate its cost in another quotation currency (USD). On the opposite side of the bid bank we have no product available to buy, but we have funds (in the quoted currency). Through the corresponding major, recalculate these funds.

Total:

  • for Ask gangs count (1) way
  • For Bid gangs we calculate in (2) way
 
You're joking... Or I don't understand what you're saying. So you think that 1 lot volume for example on EURUSD is equal to 1 lot volume on any other symbol?
 
GaryKa: ... So, you think that 1 lot volume for example on EURUSD is equal to 1 lot on any other symbol?

For pairs with the same base currency, the comparison by lots is acceptable, because the units are the same. For example volumes for EURCHF and EURUSD.


papaklass:

Some sellers EURUSD ASK-band = 2.0 million, i.e. sellers want to sell 2 000 000 / 100000 = 20 lots of EUR and buy 2 000 000 / 136345 = 14.67 lots of USD.

Other GBPUSD sellers ASK-band = 3.5 million, i.e. sellers want to sell 3 500 000 / 100000 = 35 lots of GBP and buy 3 500 000 / 164349 = 21.3 lots of USD.

As a result we have that at the moment they want to buy 14.67 + 21.3 = 35.97 lots USD for euro and pound. You can calculate any currency this way.

In this example you have major pairs that have the same quote currency. Just comparing by lots is not acceptable: 20 lots of eur and 35 lots of pound. Therefore convert and obtain volumes in USD lots: 14.67 and 21.3, which can already be compared.


The question was a little different? How do you calculate the volume for a cross pair? Show me with or without lots. For example, how to compare the volume of EURCHF and AUDNZD?

GaryKa: ... How to correctly recalculate liquidity on a cross pair's best band in USD units (and why)?
 

Here ' s another option for the arbitrage position, to calculate lots for each symbol to trade as much liquidity as possible without converting to common units.

Suppose we have a triangular arbitrage of type A/B, B/C, C/A

1) Start from the first symbol to the last. Take volume A on the first pair (remember as order size of A/B) and calculate volume B (convert A to B). If the obtained volume is larger than that of B/C, we go to point 2. If it is smaller, we memorise this volume (as Order size for B/C), calculate C, compare it, etc. We have successfully reached the end of the chain -> we already have volumes for orders, exit.

2) Do a cyclic shift (was A/B, B/C, C/A became B/C, C/A, A/B ), and go back to point 1)

 
papaklass: ... Express the volumes for these currencies through the collateral required at position opening. Thus, obtain the volumes of these currencies in USD and compare them.
Good suggestion.

Let's calculate on our own how much margin will (must) be deducted from us in the USD deposit currency if:

- We want to buy 1 lot of EURCHF.
To buy EURCHF is to buy EUR for CHF. We do not have CHF. We borrow them or we buy them ourselves (with 1:1 leverage). In other words, we have USD (deposit) and we have to buy CHF (or not to buy if credit is available in CHF) in order to buy EUR. It means that in order to buy EURCHF, we have to really (leverage 1:1) or virtually sell USDCHF (selling USD from the deposit, buying CHF), at a market (worst-case) price.

- We want to sell 1 lot of EURCHF.
Selling EURCHF is selling EUR for CHF. We do not have EUR (we have nothing to sell). We either borrow them or buy them ourselves (with 1:1 leverage). In other words, we have USD (deposit) and we have to buy EUR (or not to buy, if credit is provided to us in EUR) to buy CHF. It means that to sell EURCHF, we must actually (leverage 1:1) or virtually buy EURUSD (selling USD from the deposit, buying EUR), at the market (worst-case) price.

Bottom line:
  • when buying EURCHF, the USD margin for credit should be calculated using USDCHF prices
  • on EURCHF sale, USD margin for credit must be calculated using EURUSD prices


Now let's go over your code. In my opinion, the function lacks an argument that would be responsible for the direction of the deal. You have variable marginCurrency, which is always defined as base currency. So, accordingly, margin for both selling and buying EURCHF is always calculated through EURUSD.

   string marginCurrency = StringSubstr( StringTrimLeft( smb ), 0, 3 );

...


   if( calcCurrency == "" ){
      calcCurrency = GetSymbolByCurrencies( marginCurrency, accCurrency );
      mode = true;
     
      if( calcCurrency == "NULL" ){
         calcCurrency = GetSymbolByCurrencies( accCurrency, marginCurrency );
         mode = false;
      }
   }


P.S. I'm wondering how much your margin calculations now coincide with the MT calculations, especially since there have been similar claims to them before.

 
papaklass:

Judging by the silence, not everything is clear.

Answer with figures to the question: "How do you calculate the volume for a cross pair? Show me with or without lots. For example, how do you compare volumes on EURCHF and AUDNZD?"

To find out the difference in lots, I divide the rates of major currencies in the numerator. The pledge currency is the currency that is in the numerator.

EURUSD / AUDUSD -> 1.36368 / 0.90639 = 1.50451, i.e. the volume of AUDNZD position to be opened must be 1.50 times more than EURCHF.

Why do I divide the majors?

I do not understand this post. So, counting in this way you conclude that the volume on AUDNZD (in USD) is approximately 1.5 times larger than the volume on EURCHF (in USD). Right?

 
papaklass: ... Now about my code for margin calculation. I've commented on it in detail. Isn't it hard to read and understand? Margin is calculated by another function... Look at the code after the comment "//receive the current price for the specified direction".

papaklass calm down or we'll slide into an argument. I looked at your code before I commented, did you look at my comment? Carefully?


My complaint to your method of calculation (by the example of EURCHF calculation) .

GaryKa: ... You always calculate the security for both selling and buying EURCHF through EURUSD.

After the comment "//fetch the current price for the specified direction" you always calculate the prices at the same symbol both when you buy and sell , while I believe you must calculate them at different symbols (justification above).

   prc = Dbl_If( dir == OP_BUY, MarketInfo( calcCurrency, MODE_ASK ),
                                MarketInfo( calcCurrency, MODE_BID ) );

In the EURCHF example, you always have EURUSD.


P.S. that was unnecessary, sorry

GaryKa: ... In my opinion, the function is missing the argument that would be responsible for the direction of the trade ...