我需要帮助确定为交易金融工具(股票、外币、crpyto 等)的机器学习模型创建目标变量的最佳方法。
以下是一些有助于回答问题的示例数据。
Time: When the data was recorded
Price: Is the current price of the instrument and is the price I would be buying at.
price_good: Price level that I need to sell at to make a profit
price_bad: Price level that I need to sell at to minimize losses
good_id: Returns the ID of the first row where price >= price_good
bad_id: Returns the ID of the first row where price <= price_bad
target: If good_id < bad_id, target = 1. Else target = 0
我的理想情况是 price_good 发生在 price_bad 之前。我遇到的问题是如何正确设置目标字段。我有两种方法可以解决这个问题-
选项 #1 -此选项使用所有数据,对创建目标字段没有限制,但在生产中的工作方式略有不匹配。
id time price price_good price_bad good_id bad_id target
1 01-01-19 100 110 90 4 nan 1
2 01-02-19 105 115 95 4 nan 1
3 01-03-19 109 120 99 4 nan 1
4 01-04-19 121 131 111 nan 5 0
5 01-05-19 110 120 97 nan nan nan
选项 #2 -此选项不使用所有数据,并且在初始行达到其目标之前不允许设置目标,这就是它在生产中的工作方式。
id time price price_good price_bad good_id bad_id target
1 01-01-19 100 110 90 4 nan 1
2 01-02-19 105 115 95 nan nan nan
3 01-03-19 109 120 99 nan nan nan
4 01-04-19 121 131 111 nan 5 0
5 01-05-19 110 120 97 nan nan nan
“生产中”是指在模型构建后它将如何工作。例如,如果我的模型预测 id:1 将达到 target_good,那么在该交易达到与选项 #2 一致的 price_good 或 price_bad 之前,我将无法进行任何其他交易。但是,如果我有更多的资金可以投资,我将丢失有关我可以从选项 #1 进行的所有其他交易的信息。
如果我选择选项#1,模型有时会“过度拟合”,因为它的数据在时间上更接近,并且使用的信息大多相同。
如果我选择选项 #2,它可以更准确地表示它在生产中的工作方式,但我会丢失大量数据点。例如,如果我从 id:2 而不是 id:1 开始呢?我最终会得到构建模型的不同数据点。我可以从多个地方开始测试以找到最佳的起始位置,但这需要大量的迭代和资源来测试。
关于如何正确建模的任何提示?谢谢!