Last active
February 8, 2022 15:35
-
-
Save quantra-go-algo/bc812be215eab804fb72da4294a4d5fd to your computer and use it in GitHub Desktop.
Divyant EPAT Project - quantity_calc()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quantity_calc(self): | |
if self.hedge_ratio > 0: | |
for i in range(len(self.df)): | |
if self.df.iloc[i, 8] == 1: | |
stock1_qty = 1000 | |
stock2_qty = stock1_qty * round(self.hedge_ratio, 3) *-1 | |
self.stock1_qty_list.append(stock1_qty) | |
self.stock2_qty_list.append(stock2_qty) | |
elif self.df.iloc[i, 8] == -1: | |
stock1_qty = -1000 | |
stock2_qty = stock1_qty * round(self.hedge_ratio, 3) *-1 | |
self.stock1_qty_list.append(stock1_qty) | |
self.stock2_qty_list.append(stock2_qty) | |
elif (self.df.iloc[i, 8] == 'TP')or(self.df.iloc[i, 8] == 'SL'): | |
self.stock1_qty_list.append(stock1_qty) | |
self.stock2_qty_list.append(stock2_qty) | |
else: | |
self.stock1_qty_list.append(0) | |
self.stock2_qty_list.append(0) | |
self.df['stock1_qty'] = self.stock1_qty_list | |
self.df['stock2_qty'] = self.stock2_qty_list | |
return self.df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment