AI for farmingMiddleLesson 1224 min read

Market prices and selling smart

Price data can show trends, and a moving average smooths out daily ups and downs. Learn to read prices calmly, and why no tool can tell you tomorrow's price.

Lesson in motion

In 60 seconds

Market prices and selling smart

Price data can show trends, and a moving average smooths out daily ups and downs. Learn to read prices calmly, and why no tool can tell you tomorrow's price.

1/4
In simple words
Your weight on a scale goes up and down a little each day, depending on what you ate. To see if you are really growing, you look at the average over a week. A moving average does the same for prices: it hides the daily wobble so you can see the real direction.
Crop prices change every day. They depend on how much produce arrives at the market, demand, quality, season, transport and many other things. Seeing prices from several markets helps a farmer choose when and where to sell, and bargain with more confidence.

Where price information comes from

  • Government portals publish daily arrivals and prices from many mandis (agricultural markets). Agmarknet is one such portal.
  • e-NAM is a national online platform that links mandis for trading. Check its current coverage for your crop and market.
  • Local traders, farmer producer organisations (FPOs) and other farmers are also sources.

Reading a price trend

Daily prices jump around. A moving average helps. A 7-day moving average for today is the average of the last 7 days' prices. Tomorrow, you drop the oldest day and add the new one. The line it makes is smoother and shows the trend.
Python: a 3-day moving average by handpython
prices = [20, 22, 19, 25, 24, 26, 23]   # made-up daily prices

window = 3
for day in range(window - 1, len(prices)):
    last = prices[day - window + 1 : day + 1]
    avg = sum(last) / window
    print(f"day {day + 1}: price {prices[day]:3d}   3-day average {avg:.1f}")

Simple rules, and their limits

Some people use simple rules such as "today's price is above the 7-day average, so prices are rising". Rules like this describe what has happened. They do not know about a big harvest arriving next week, a festival, or a change in export rules.
Reading prices poorly
  • Deciding from one day's price
  • Believing an app that 'predicts' tomorrow's price exactly
  • Forgetting transport cost, storage losses and quality grade
Reading prices well
  • Looking at the trend over days or weeks
  • Comparing a few nearby markets
  • Counting transport, storage and quality before comparing prices
Watch out
Storing produce to wait for a better price has real risks: spoilage, pests, storage cost and the need for cash. Whether to wait, sell, or take a loan against stored produce is a personal financial decision. This lesson is not financial advice. Talk to your FPO, agriculture officer or a trusted bank officer, and read every loan's terms carefully.
Real example
Ravi, a student in Nashik, builds a small dashboard for his father's onion sales. It shows the 7-day average price at three nearby mandis. It does not tell his father what to do. It helps him ask better questions: "Why is this market higher? Is the grade different? Is it worth the transport?"
Try this. For one crop you know, write down the price you heard on three different days this month. Is it going up, down, or just jumping around?

Watch and read more

Lab

A moving-average function and a simple 'above or below average' description of made-up prices.

~20 min

The problem

This runs in your browser. The prices are made-up numbers, not real market data, and the rule is for learning only. It is not advice about when to sell.

  1. Complete moving_average(prices, window). It returns a list the same length as prices. The first window - 1 items are None (not enough days yet). Each later item is the average of that day and the window - 1 days before it.
  2. Complete describe(prices, window). It compares the last price with the last moving average and returns "above average", "below average" or "at average".
  3. Run it and look at the chart.
  4. Write two lines: what does the rule miss that a farmer would know?

Practice lab

Edit the code and run it. Python runs in your browser — nothing is sent to our server.

Output

No output. Add print(...) to see values.

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1The price jumps above its 7-day average for one day and then falls back. Why might a simple rule be fooled, and what could reduce this?Reveal

One high day can come from a small, high-quality lot or a short-term shortage. A rule that reacts to every day will flip often. Using a longer window, waiting for two or three days above the average, or comparing several markets reduces false signals. But every rule still only looks at the past.

Q2An app claims its AI predicts next week's price with high accuracy. What would you ask?Reveal

Ask how accuracy was measured: on which crops, markets and years, and whether the test was on data the model had not seen. Ask how it did in unusual periods, such as sudden rule changes. Ask whether it shows a range instead of one number. And ask who pays for the app, in case it benefits from farmers selling at a certain time.

Please sign in to continue.

Questions people ask

Can AI predict crop prices?

Some tools try, using past prices, arrivals and weather. Predictions can sometimes help as a rough guide, but prices depend on many things that are hard to foresee, like sudden rules or events far away. Be very careful with any tool that sounds sure about future prices.

Why use a 7-day average and not a 30-day one?

A short window reacts fast but stays bumpy. A long window is smooth but slow to show a real change. Many people look at both. There is no single correct window.

Why are prices different in two nearby mandis?

Quality grades, how much arrived that day, local demand, and traders present can all differ. Before comparing, check that you are comparing the same crop, variety and grade, and count the cost of getting there.

Should I take a loan to store my crop and wait?

That is a financial decision with risks that depend on your situation. This course cannot advise you on it. Ask a trusted bank officer, your FPO or agriculture officer, and understand all terms before signing anything.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in to take the test and save your progress