Negative prices?

Posted By: AndrewAMD

Negative prices? - 05/18/20 11:15

jcl,

You might have heard about this incident: there was an oil futures contract that traded at negative prices due to delivery issues.

Sure enough, there was an unfortunate trader using the Interactive Brokers platform. The platform said it was trading for one cent when it was in fact very negative:
https://markets.businessinsider.com...ns-on-brokerage-glitch-2020-5-1029186688

Does Zorro have the ability to trade assets with negative prices? Assume of course that the broker and plugin supports it too.

I seem to recall some shuffled-price curve backtests where prices did indeed go negative - and Zorro denied trading when the price was negative with some kind of illegal price error. In live trading, I'm hoping that I can close out such unfortunate positions instantly and not after I get the phone call from my broker.

And if not, perhaps Zorro should support this?
Posted By: jcl

Re: Negative prices? - 05/21/20 12:07

I believe Zorro cannot trade negative prices - they would trigger an error message. But even if it could, it would not have helped in that case because the price by the API would still have been 1 cent.
Posted By: danatrader

Re: Negative prices? - 05/21/20 18:08

IB said they will fix it and show negative prices in the future if they occur.
Posted By: AndrewAMD

Re: Negative prices? - 05/21/20 18:26

Originally Posted by danatrader
IB said they will fix it and show negative prices in the future if they occur.

But if Zorro does not support it, Zorro cannot make use of negative prices.

You need to understand that I am demonstrating the consequences of not supporting negative prices in such black swan events.
Posted By: jcl

Re: Negative prices? - 05/22/20 07:18

There would be probably no consequences. Zorro would just not trade.
Posted By: AndrewAMD

Re: Negative prices? - 05/22/20 12:26

Originally Posted by jcl
There would be probably no consequences. Zorro would just not trade.
If I had a long position open in positive territory, and the price goes negative, it would be a problem if I cannot close my position. It's better to close it at a slightly negative price than a very negative price.
Posted By: Spirit

Re: Negative prices? - 05/23/20 08:29

It is closed when the position has a stop.
Posted By: DdlV

Re: Negative prices? - 05/23/20 19:26

Or not. If "Zorro would just not trade" because it considers a negative price invalid, an outlier, or whatever, then the Stop isn't considered, the position wouldn't close, and just accumulate more losses...

I guess this assumes the move down is dramatic enough to blow by the Stop, but it seems AndrewAMD has a valid point...
Posted By: Spirit

Re: Negative prices? - 05/24/20 10:53

Before a price goes negative it must approach zero, and this will trigger any long stop no matter where it is.
Posted By: danatrader

Re: Negative prices? - 05/25/20 06:34

If the stop gets filled by the broker, afterwards no more.
Posted By: AndrewAMD

Re: Negative prices? - 11/24/21 13:31

Two other reasons for Zorro to support negative prices:
1) The NYSE tick index (ticker symbol $TICK in TradeStation) has negative numbers half the time. It is commonly used by various day traders.
2) Futures spreads often have negative values.

If I wanted to support these using the current Zorro version, I'd need to perform some strange workarounds.
Posted By: jcl

Re: Negative prices? - 11/25/21 10:26

Problem is that negative prices have special meanings, such as entry limits or ask/bid distinction. Thus, negative prices would break backwards compatibility.

The solution would be implementing a per-asset price offset. In fact it is already implemented - g->vAssetOffset - but currently undocumented and for a different purpose. I'll check if it can be modified for dealing with negative prices. This is no optimal solution, but would guarantee backwards compatibility.
Posted By: AndrewAMD

Re: Negative prices? - 11/25/21 13:52

Originally Posted by jcl
The solution would be implementing a per-asset price offset. In fact it is already implemented - g->vAssetOffset - but currently undocumented and for a different purpose. I'll check if it can be modified for dealing with negative prices. This is no optimal solution, but would guarantee backwards compatibility.
This would be helpful. Thanks.

Earlier, I tried to download from the $TICK symbol via the TradeStation plugin using the Download script, but Zorro immediately complained about invalid prices/ticks.
Posted By: AndrewAMD

Re: Negative prices? - 11/27/21 14:17

Here's an alternative, if it happens to be easier to implement: The date field in the T1 struct is always positive. Maybe an alternative version of the T1 struct can be used, where the date is positive/negative depending on bid/ask, and then the price can be allowed to be negative.
Posted By: jcl

Re: Negative prices? - 12/06/21 09:02

We'll use the offset solution. It will be implemented in an upcoming beta version.
Posted By: BigW

Re: Negative prices? - 06/13/22 21:20

Originally Posted by AndrewAMD
Two other reasons for Zorro to support negative prices:
1) The NYSE tick index (ticker symbol $TICK in TradeStation) has negative numbers half the time. It is commonly used by various day traders.
2) Futures spreads often have negative values.

If I wanted to support these using the current Zorro version, I'd need to perform some strange workarounds.


On the second point whats the best way to implement futures spreads (that may be negative) and apply indicators to that to trade a specific futures contract?
As a possible workaround, is it possible to use dataParse to extract the negative spread from a CSV (do the spread calc outside of Zorro) and turn that into a series that can in turn be read by indicators?
Is there a sample code snippet anywhere as a guide?
Thank you
Posted By: AndrewAMD

Re: Negative prices? - 06/14/22 01:34

Either use that respective futures combo using the contract interface, or use PriceOffset:
https://zorro-project.com/manual/en/spread.htm
https://zorro-project.com/manual/en/contract.htm
https://zorro-project.com/manual/en/combo.htm
© 2024 lite-C Forums