Improve some regression algorithms

This commit is contained in:
Jhonathan Abreu
2025-01-17 17:39:13 -04:00
parent 9c42dff791
commit 0e4cfe679c
2 changed files with 15 additions and 1 deletions
@@ -29,6 +29,11 @@ class FuturesChainFullDataRegressionAlgorithm(QCAlgorithm):
# Demonstration using data frame:
df = chain.data_frame
for index, row in df.iterrows():
if row['bidprice'] == 0 and row['askprice'] == 0 and row['volume'] == 0:
raise Exception("FuturesChain() returned contract with no data.");
# Get contracts expiring within 6 months, with the latest expiration date, and lowest price
contracts = df.loc[(df.expiry <= self.time + timedelta(days=180))]
contracts = contracts.sort_values(['expiry', 'lastprice'], ascending=[False, True])