How did 炒 semantically shift to mean 'speculate' and 'perform badly (in a test or exam)'? to stir fry; to sauté
  
  炒飯、炒麵 / 炒饭、炒面 [Cantonese]  ―  caau2 faan6, caau2 min6 [Jyutping]  ―  fried rice; chow mein
  (slang) to sack; to fire
  
  ⇒ 炒魷魚
  (Cantonese) to speculate in
  
  炒股票 [Cantonese]  ―  caau2 gu2 piu3 [Jyutping]  ―  to speculate in stocks
  
  炒樓 / 炒楼 [Cantonese]  ―  caau2 lau4-2 [Jyutping]  ―  to speculate in property
  (Hong Kong Cantonese) to perform badly (in a test or exam)
  



I don't grasp  炒's semantic field.  炒's shift from 1 to 2 is the same as English's "fire", correct? Why Do We Say “You’re Fired” When You Lose Your Job? – History Spaces



  What to do with such a person? When the unproductive and problematic individual was away from his dwelling place, the others in the communal group would gather there and set it on fire and burn it to the ground. When the person returned he and/or she would see what was done and know immediately they were no longer wanted as a member of the communal group. With no place to live, they had to leave, with the likelihood of survival being slim.


Brad Green, studied at Southern Utah University Answered Jun 30, 2015.


  Much more verifiable is the explanation from tribal communities, where the entire tribe survived because of contributions by all for the survival of the tribe. When one member of the tribe was lazy, or consumed much more than they produced, the tribe would set fire to their dwelling while they were away as an act of showing them that that person was not wanted and that the tribe was unconcerned with that person's survival. They would cast them out from the tribe, usually to their death because of their lack of ability to provide for themselves by them-self.



But how did 2 shift to 3? How does employment dismissal relate to financial speculation?
Doubtless employees who miff their jobs, can be dismissed. But 4 refers to tests or exams? Employees don't usually write tests or exams.
炒魷魚 is a Cantonese slang for 'fire' (from a job)

In olden time, many employees would live in the employer's place. When an employee was fired, He had to 執包袱 (roll up his belongings in a bundle to pack them) and leave.

炒魷魚 got the meaning of 'fired' because when you stir fry squid, they would roll up like a bundled package and that resembling the action of '執包袱' (pack up and leave) . Nowadays, we use 炒 (fire from job) as a shorthand for 炒魷魚

As for 炒 in 炒股票 (to speculate in stocks) and 炒樓 (to speculate in property). It is short for  炒買，炒賣

Meaning quickly acquire and quickly sell off stock or property to make a quick profit (different from normal investment) like making a quick stir fired dish. Since 炒 means 'to stir'  The act of 炒股票 and 炒樓 also imply 'stir up the market'


  (Hong Kong Cantonese) to perform badly (in a test or exam)


This meaning of '炒' came from another slang '炒車' (having a car accident) You can imagine cars being threw around in an accident like food being stirred in a wok. 炒 therefore, took on the meaning of 'to ruin' extended to --> perform badly (in a test or exam)