Creating machine learning target function - Python Programming for Finance p. 10 | Summary and Q&A
TL;DR
This tutorial is about creating a function for mapping data in Python for finance, specifically for determining whether a company is a buy, sell, or hold based on percent change pricing information.
Key Insights
- 🥹 The mapping function in this tutorial is used to determine whether a company is a buy, sell, or hold by analyzing future percent change pricing information.
- 🥹 The function takes arguments representing future prices and compares them to a threshold of 2% for making the buy, sell, or hold decision.
- 🐼 By mapping the function to a pandas data frame, the process can be performed efficiently for multiple companies.
- 😫 Building a strategy around this function involves buying companies with potential 2% price increases and setting stop losses for decreases.
- 🙂 The accuracy of the strategy is not expected to be high, but it aims to generate a slight edge over random decisions.
- 👻 The function allows for flexibility in passing any number of parameters using the "args" argument.
- 🔃 Mapping functions in pandas can be useful for performing row-wise calculations on data frames.
Transcript
Read and summarize the transcript of this video on Glasp Reader (beta).
Questions & Answers
Q: What is the purpose of mapping a function to a pandas data frame in Python for finance?
Mapping a function to a pandas data frame allows us to create a new column that indicates whether a company is a buy, sell, or hold based on percent change pricing information.
Q: How is the buy, sell, or hold decision determined in the function?
The function checks if any of the future prices for a company exceed a predefined threshold (2%) and returns a buy. If any of the prices fall below the negative threshold, it returns a sell. Otherwise, it returns hold.
Q: What are the possible values returned by the mapping function?
The function can return three values: 1 for buy, -1 for sell, and 0 for hold.
Q: What are some considerations for building a strategy based on this mapping function?
A strategy based on this mapping function could involve buying a company when its price is expected to rise by 2% in the next seven days and setting a stop loss for a 2% decrease. The goal is to hit the target before any potential crashes occur.
Summary & Key Takeaways
-
The tutorial focuses on writing a function that will be mapped to a pandas data frame to create a new column indicating whether a company is a buy, sell, or hold.
-
The function takes arguments that represent the future percent change pricing information for different companies.
-
If any of the future prices exceed a certain threshold (in this case, 2%), the function returns a buy; if any of the prices fall below the negative threshold, it returns a sell; otherwise, it returns hold.