Skip to content

Commit

Permalink
Links to symbols from positions
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Oct 24, 2023
1 parent 94731c9 commit f7ef65f
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 143 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@chakra-ui/system": "^2.6.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@stoqey/ib": "stoqey/ib#28221927a59401301acaca5958b203c7441414f5",
"chakra-react-select": "^4.7.3",
"@stoqey/ib": "stoqey/ib#1c0d41909b3b3c5beaf47d0ddbe94e954bf39f6b",
"chakra-react-select": "^4.7.4",
"chart.js": "^4.4.0",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
Expand All @@ -59,11 +59,11 @@
"sequelize": "^6.33.0",
"sequelize-typescript": "^2.1.3",
"sqlite3": "^5.1.6",
"winston": "^3.10.0",
"winston": "^3.11.0",
"yahoo-finance2": "^2.8.0"
},
"devDependencies": {
"@babel/core": "^7.23.0",
"@babel/core": "^7.23.2",
"@chakra-ui/storybook-addon": "^5.0.1",
"@storybook/addon-actions": "^7.4.6",
"@storybook/addon-essentials": "^7.4.6",
Expand All @@ -72,25 +72,25 @@
"@storybook/components": "^7.4.6",
"@storybook/react": "^7.4.6",
"@storybook/react-vite": "^7.4.6",
"@storybook/testing-library": "^0.2.1",
"@storybook/testing-library": "^0.2.2",
"@types/cors": "^2.8.14",
"@types/express": "^4.17.18",
"@types/express": "^4.17.19",
"@types/json-stringify-safe": "^5.0.1",
"@types/node": "^18.18.3",
"@types/react": "=18.2.21",
"@types/react-dom": "^18.2.10",
"@types/node": "^18.18.5",
"@types/react": "=18.2.28",
"@types/react-dom": "^18.2.13",
"@types/react-router-dom": "^5.3.3",
"@types/validator": "^13.11.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/validator": "^13.11.3",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/plugin-react": "^4.1.0",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.1",
"eslint": "^8.50.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-rxjs": "^5.0.3",
"eslint-plugin-storybook": "^0.6.14",
"eslint-plugin-storybook": "^0.6.15",
"http-proxy-middleware": "^2.0.6",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
Expand All @@ -103,7 +103,7 @@
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2",
"vite": "^4.4.11",
"webpack": "^5.88.2"
"webpack": "^5.89.0"
},
"engines": {
"node": ">=18.18.0"
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/Portfolio/Position/OptionRow.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { DeleteIcon, EditIcon, SearchIcon } from "@chakra-ui/icons";
import { IconButton, Td, Tr } from "@chakra-ui/react";
import { IconButton, Link, Td, Tr } from "@chakra-ui/react";
import { FunctionComponent, default as React } from "react";
import { Form, Link as RouterLink } from "react-router-dom";
import { OptionPositionEntry } from "../../../../routers/positions.types";
import { formatNumber } from "../../../utils";
import Number from "../../Number/Number";
import { ContractLink } from "../Contract/links";
import { PositionLink } from "./links";

type Props = { portfolioId: number; item: OptionPositionEntry };
Expand All @@ -28,7 +29,11 @@ const OptionRow: FunctionComponent<Props> = ({ portfolioId, item, ..._rest }): R
<>
<Tr id={`${item.id}`}>
<Td isNumeric>{formatNumber(item.quantity)}</Td>
<Td>{item.option.symbol}</Td>
<Td>
<Link to={ContractLink.toItem(portfolioId, item.underlying.id)} as={RouterLink}>
{item.option.symbol}
</Link>
</Td>
<Td isNumeric>{formatNumber(item.option.strike, 1)}</Td>
<Td>{item.option.expiration}</Td>
<Td>{item.option.type == "P" ? "Put" : "Call"}</Td>
Expand Down
15 changes: 14 additions & 1 deletion src/app/components/Portfolio/Position/PositionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const PositionsTable: FunctionComponent<Props> = ({
return result;
};

const getUnderlyingId = (a: PositionEntry | OptionPositionEntry): number => {
let result: number;
switch (a.contract.secType) {
case ContractType.Stock:
result = a.contract.id;
break;
case ContractType.Option:
result = (a as OptionPositionEntry).underlying.id;
break;
}
return result;
};

return (
<>
<TableContainer>
Expand Down Expand Up @@ -96,7 +109,7 @@ const PositionsTable: FunctionComponent<Props> = ({
<Tr key={item.id}>
<Td isNumeric>{formatNumber(item.quantity)}</Td>
<Td>
<Link to={ContractLink.toItem(portfolioId, item.contract.id)} as={RouterLink}>
<Link to={ContractLink.toItem(portfolioId, getUnderlyingId(item))} as={RouterLink}>
{item.contract.symbol}
</Link>
</Td>
Expand Down
2 changes: 1 addition & 1 deletion src/bots/importer.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,12 @@ export class ImporterBot extends ITradingBot {
}

protected process(): Promise<any> {
const parser = new XMLParser();
return fetch(
`https://gdcdyn.interactivebrokers.com/Universal/servlet/FlexStatementService.SendRequest?t=${this.token}&q=${this.query}&v=3`,
)
.then((response) => response.text())
.then((XMLdata) => {
const parser = new XMLParser();
const jObj = parser.parse(XMLdata);
if (jObj["FlexStatementResponse"].Status == "Success") {
return this.fetchReport(
Expand Down
Loading

0 comments on commit f7ef65f

Please sign in to comment.