Spreads

Discussion in 'Hook Up' started by comtrader83, Nov 18, 2024.

  1. I have traded spreads for most of the last 40 years. I am interested in creating an algorithm based on the criteria I have used. It would be specific to contracts settled by physical delivery. How do I get started ? Thanks.
     
  2. Sekiyo

    Sekiyo

    You can ask chatGPT. All you need is a virtual private server, python and an API to get data and send orders. It's going to be a lot of tinkering, passing error to chatGPT and googling + parsing documentation.
     
    p0box4 and TrailerParkTed like this.
  3. maxinger

    maxinger

    You are highly experienced.
    You don't need help.


    In fact,
    You should help us with spreading thing.
     
  4. If you go Schwab, you can do thinkScript.
     
  5. Your best bet would be to find someone that is familiar with the broker you use.

    Trading algorithms, while they can be generic for all brokers, have a lot of specifics related to the API they are connecting to. Your broker's API will define a great percentage of your code.

    If you want people to help, you can start by telling which broker are you planning to use, then they could recommend you ways to go.
     
  6. Let's see if we can move this forward, I am willing to share my experiences with regards to spreads to see if an alog is possible. The most important aspect of any futures contract settled by physical delivery is a level playing field that allows the long to take delivery/ the short to make delivery. Where the specifications of the contract become skewed to the advantage of either the long or short, it will become manifested in the spreads. Usually it is to the advantage of the long (the spreads gravitate to an inverse), but there are exceptions. Not sure if the specifications can be applied to an algorithm.
     
  7. If you can describe it in great detail, someone will be able to code it.
     
  8. The need for an automated strategy to trade commodity spreads is supported by the events surrounding WTI during April of 2020. The May futures traded at negative values on May 20 (last trading day) because there were no consequential bids for the May/ June spread. The lack of support for the spread was the result of limited delivery space, that is, there was little to no interest in the arbitrage of the front two months due to a lack of delivery space. Ultimately it was a flaw in the contract specifications that was exploited by the short (an uneven playing field) that contributed to the events of April 20. That an uneven playing field existed should have been obvious to anyone that trades spreads. The oil fund that liquidated a long position on April 20 would have benefitted from an automated system, only one example of the void that exists with respect to spreads.
     
  9. The breach of carrying charges in April 2020 was preceded by breaches in 2009 and 2016 WTI, albeit to a lesser extent. In each case, a butterfly spread was profitable (short- long 2x-short).
    Until the lack of delivery space is addressed, it is possible for the nearby spread to be breached again. It should be noted that each of the three cases there was a perception of burdensome supplies and the nearby was trading at the $20-$30 range.
    Nearby spreads typically invert when there is less chance of the short making delivery, i.e. less threat of delivery. Grain spreads are susceptible to inversions when stocks are cut as a result of reduced yields (smaller crop= reduced threat of delivery). However, even in years of a short crop the Nov-Jan beans / and the Dec-March corn will typically be inclined to smaller inversions than the deferred spreads because those spreads are closest to harvest, a time during the marketing year when supplies are most plentiful. However, I know from my years on the trading floor that the composition of the open interest (spec vs. commercial) can have a large impact on the spreads, probably the easiest aspect of a spread to include in an algo.
     
  10. Before leaving the May (K) 2020 WTI, it is interesting to compare how different trading strategies approached the crude oil market leading up to April 2020. From a personal perspective, I had a relative contact me regarding the oil market. While a very experienced equities trader with a multinational insurance co., she had little to no experience with commodities. Her trading strategies have always been based on technical analysis, hence her view that oil was "cheap". I replied something to the effect, "if you buy oi, don't buy the K". My point here is that whatever strategy used for trading commodity futures, it should be complemented by a basic understanding of calendar spreads. The K 2020 WTI should be a case study for those interested in trading commodities. I have personally traded on the other side of billion $ funds simply because they had little to know knowledge of spreads. The point I have been trying to make with this thread is that there is a very real need for an algorithm to trade spreads. It has been that way for the decades that I have traded, little has changed with respect to spreads.
     
    #10     Nov 30, 2024