A daily commercial position for 60,000 hectares
- Client: Soy and corn producer, Mato Grosso, Brazil
- Scale: 60,000 hectares on 4 farms, 14,000 delivery tickets per harvest, 11 buyers
- Team: 2 engineers, 9 weeks
- Stack: Common Lisp, PostgreSQL, a vision model for ticket photos
The client
The client grows soy and a second crop of corn (safrinha) on 60,000 hectares across four farms. It sells to trading houses and crushers through fixed-price forwards, to-be-priced contracts and barter deals that pay for seed and fertilizer with future grain.
Three numbers nobody had
A grain producer’s commercial position comes down to three numbers per crop: how much is committed, how much is delivered, and how much is still in the field. This producer knew each of them once a month, when someone reconciled the delivery tickets (romaneios) against the contracts. The tickets, 14,000 a harvest, arrived from buyers as PDFs and photos.
So the producer sold forward cautiously, and still twice paid penalties for under-delivering on one contract while grain sat unsold in another farm’s silo. Barter made it worse. A fertilizer deal signed before planting is a commitment to deliver a set number of 60 kg bags of soy at harvest, but it lived in the input purchasing records, not with the sales. And nobody checked the moisture and impurity discounts the buyers took on each ticket.
Farm management software tracks planting, inputs and yields per field; trading software assumes a trader’s book. Neither handled barter settled in grain, and neither could check a buyer’s discounts against the producer’s own samples.
What we built
- A position per crop and harvest: expected yield per field, committed volume per contract and delivered volume per ticket, updated as tickets arrive.
- Ticket reading from buyers’ PDFs and photos, with every moisture and impurity discount checked against the contract’s classification table and the producer’s own samples.
- Barter contracts recorded as grain obligations, so an input purchase shows up as committed volume the day it is signed.
- Price exposure in reais and dollars, against Chicago futures and local basis.
Results
- Open position known daily instead of monthly
- R$2.1 million in incorrect classification discounts recovered in the first harvest
- No under-delivery penalties since go-live, against two in the harvest before
- 12 percentage points more of the crop sold forward, at prices fixed when the market offered them
The first claims were rejected
The first discount claims went to buyers backed only by the producer’s own moisture readings, and the buyers rejected most of them: a reading from an unsealed sample proves nothing. From the second month, every truck left the farm with a sealed sample whose number was written on the truck’s invoice (nota fiscal), and each claim went out with that sample’s lab result attached. The R$2.1 million was recovered on those claims.