Skip to content

Commit

Permalink
Minor changes & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Jan 4, 2025
1 parent 371be36 commit c2142c5
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 189 deletions.
8 changes: 8 additions & 0 deletions src/app/components/Portfolio/Setting/SettingEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ const SettingEdit: FunctionComponent<Props> = ({ ..._rest }): React.ReactNode =>
))}
</Field>
</Flex>
<Flex justifyContent="center" gap="2">
<Text w="180px" as="b" textAlign="right">
Covered calls Delta:
</Text>
<Text w="200px">
<Field name="ccDelta" type="number" />
</Text>
</Flex>
<Flex justifyContent="center" gap="2">
<Text w="180px" as="b" textAlign="right">
Covered calls Roll:
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/Portfolio/Setting/SettingShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const SettingShow: FunctionComponent<SettingShowProps> = ({ ..._rest }): React.R
<Text w="180px" as="b" textAlign="right">
Premium:
</Text>
<Number textAlign="left" w="120px" value={thisItem.minPremium} color={"-"} />
<Number textAlign="left" w="120px" value={thisItem.minPremium} decimals={2} color={"-"} />
</Flex>
<Flex justifyContent="center" gap="2">
<Text w="180px" as="b" textAlign="right">
Expand All @@ -76,6 +76,12 @@ const SettingShow: FunctionComponent<SettingShowProps> = ({ ..._rest }): React.R
{strategy2String(thisItem.ccStrategy)}
</Text>
</Flex>
<Flex justifyContent="center" gap="2">
<Text w="180px" as="b" textAlign="right">
Covered calls delta:
</Text>
<Number textAlign="left" w="120px" value={thisItem.ccDelta} decimals={2} color={"-"} />
</Flex>
<Flex justifyContent="center" gap="2">
<Text w="180px" as="b" textAlign="right">
Covered calls Roll:
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/Portfolio/Setting/SettingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const SettingsTable: FunctionComponent<Props> = ({ content, ..._rest }): React.R
<Td>Symbol</Td>
<Td>Lookup</Td>
<Td>NAV Ratio</Td>
<Td>Prem.</Td>
<Td>CSP strat.</Td>
<Td>CSP Roll</Td>
<Td>CC strat.</Td>
<Td>CC delta</Td>
<Td>CC Roll</Td>
<Td>Actions</Td>
</Tr>
Expand All @@ -49,9 +51,15 @@ const SettingsTable: FunctionComponent<Props> = ({ content, ..._rest }): React.R
<Td isNumeric>
<Number value={item.navRatio} isPercent color="-" />
</Td>
<Td isNumeric>
<Number value={item.minPremium} decimals={2} color="-" />
</Td>
<Td>{strategy2String(item.cspStrategy)}</Td>
<Td>{strategy2String(item.rollPutStrategy)}</Td>
<Td>{strategy2String(item.ccStrategy)}</Td>
<Td isNumeric>
<Number value={item.ccDelta} decimals={2} color="-" />
</Td>
<Td>{strategy2String(item.rollCallStrategy)}</Td>

<Td>
Expand Down
9 changes: 8 additions & 1 deletion src/bots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,13 @@ export class ITradingBot extends EventEmitter {
console.log("ignored", type, tick);
}
});
// GBP prices are in pences, fix it
if (contract.currency == "GBP" && contract.secType != SecType.CASH) {
if (dataset.ask) dataset.ask /= 100;
if (dataset.bid) dataset.bid /= 100;
if (dataset.price) dataset.price /= 100;
if (dataset.previousClosePrice) dataset.previousClosePrice /= 100;
}
let price: number | null = null;
if (dataset.ask && dataset.bid) price = (dataset.ask + dataset.bid) / 2;
else if (dataset.price) price = dataset.price;
Expand Down Expand Up @@ -1179,7 +1186,7 @@ export class ITradingBot extends EventEmitter {
},
).then(() => price);
} else {
return price ? (contract.currency == "GBP" ? price / 100 : price) : price;
return price;
}
});
}
Expand Down
Loading

0 comments on commit c2142c5

Please sign in to comment.