How do i save the value of buy in pi

Assume i wrote a script to buy a share at 52 week high and sell when my buy price is 2% more than current price. How do I achieve this in pi?