0

I have the following problem : I want to loop and give a condition based on a dataframe. More precisely, I would like the following condition : If the value in "volatility" is decreasing on 3 following days, then I should purchase bitcoin at the high price of the day, and sell bitcoin at the low price of the day.

Here is my dataframe :

enter image description here

I've written the code to compute the final value of my portfolio, but I can't manage to find the code that would apply the condition.

Thanks in advance

EDIT : I've been asking to use df.head().to_dict()

Here's what it gives me : enter image description here

  • 1
    if you are buying at `high` and `selling` at day's `low`, is it profitable strategy? – Divyank Aug 21 '22 at 10:45
  • I don't think so either, but it's the instruction – Varun Amran Aug 21 '22 at 10:46
  • 1
    Please provide some representative data of your dataset, maybe using df.head().to_dict(). Have a look [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Yolao_21 Aug 21 '22 at 12:12
  • Hi, I've read the link but I don't understand what you need... – Varun Amran Aug 21 '22 at 12:32
  • 1
    @VarunAmran, a small version of your dataframe - a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example), that we can easily copy and paste into out environments. Include it here **not** as a picture, but as text that we can copy. [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/q/285551/14627505) – Vladimir Fokow Aug 21 '22 at 15:31

0 Answers0