is it possible to limit the filled volume of a trade?

Posted By: qin

is it possible to limit the filled volume of a trade? - 02/01/23 10:39

In backtest mode, is it possible to limit the filled volume of a trade by a percentage of the next bar's volume?
Posted By: Grant

Re: is it possible to limit the filled volume of a trade? - 02/01/23 13:22

Yes, by using marketVol(-1), + setting the PEEK flag, not using the LEAN flag and having a Zorro S licence, see https://zorro-project.com/manual/en/price.htm

Needless to say that this won't work in TRADEMODE, plus there's the risk of a margin call during high volumes.
Posted By: qin

Re: is it possible to limit the filled volume of a trade? - 02/01/23 14:36

Thank you very much. By default, with daily bars, order is filled right before the market closes. So, is it possible to limit the filled volume of a trade by a percentage of the current bar's volume?
For example, I enterLong(1000), the current bar's volume is 2000, I set a parameter 10%, means only 2000*10% = 200 can be filled by the end of this bar, this should be done by system automaticly.
Posted By: Grant

Re: is it possible to limit the filled volume of a trade? - 02/01/23 15:04

Sure, by using something like this

Code
double PctVol = 0.1;

enterLong(round(marketVol() * PctVol));


Side note: personally I would never base my position size on the current volume. This can lead to enormous trade positions.
Posted By: qin

Re: is it possible to limit the filled volume of a trade? - 02/02/23 07:16

Very interesting. Let me make it clearer.
First, set Fill flag to 3, that means with daily bars, this mode simulates trading at the market open price of the next day.
We use daily bars.

In backtest mode, suppose I enterLong(1000) at current bar, it should be filled at next bar's open price. But the next bar's volume is 2000,
I think at most 10% can belong to me, so my order should be filled by 10%*2000=200 shares, the left 800 shares cannot be filled.
You suggest to peek, but in practice, you can't peek. I think this should be treated by zorro automaticly. I wonder if zorro can do this?
Posted By: Grant

Re: is it possible to limit the filled volume of a trade? - 02/02/23 07:59

Ah, I thought you traded forex/crypto/futures, hence my remark about the potential high volumes.

Setting the PEEK mode is only needed when you use future price/volume data, not with current data like 'marketVol()'
© 2024 lite-C Forums