Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Jun 14, 2024
1 parent 0dd293d commit 282193c
Show file tree
Hide file tree
Showing 10 changed files with 1,859 additions and 1,402 deletions.
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
"@chakra-ui/system": "^2.6.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@stoqey/ib": "stoqey/ib#ce245005089569ba2f6cc20bec9862693f4b7952",
"@tanstack/react-table": "^8.16.0",
"chakra-react-select": "^4.7.6",
"chart.js": "^4.4.2",
"@stoqey/ib": "stoqey/ib#ad5268d57acb845268e53d032a40067e7adf8ecd",
"@tanstack/react-table": "^8.17.3",
"chakra-react-select": "^4.8.0",
"chart.js": "^4.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"fast-xml-parser": "^4.3.6",
"fast-xml-parser": "^4.4.0",
"formik": "^2.4.6",
"framer-motion": "^11.1.9",
"framer-motion": "^11.2.10",
"json-stringify-safe": "^5.0.1",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
Expand All @@ -60,51 +60,51 @@
"sequelize-typescript": "^2.1.6",
"sqlite3": "^5.1.7",
"winston": "^3.13.0",
"yahoo-finance2": "^2.11.2"
"yahoo-finance2": "^2.11.3"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.7",
"@chakra-ui/storybook-addon": "^5.1.0",
"@eslint/compat": "^1.0.1",
"@storybook/addon-actions": "^8.0.10",
"@storybook/addon-essentials": "^8.0.10",
"@storybook/addon-links": "^8.0.10",
"@storybook/cli": "^8.0.10",
"@storybook/components": "^8.0.10",
"@storybook/react": "^8.0.10",
"@storybook/react-vite": "^8.0.10",
"@eslint/compat": "^1.1.0",
"@storybook/addon-actions": "^8.1.8",
"@storybook/addon-essentials": "^8.1.8",
"@storybook/addon-links": "^8.1.8",
"@storybook/cli": "^8.1.8",
"@storybook/components": "^8.1.8",
"@storybook/react": "^8.1.8",
"@storybook/react-vite": "^8.1.8",
"@storybook/testing-library": "^0.2.2",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/json-stringify-safe": "^5.0.3",
"@types/node": "^20.12.11",
"@types/react": "^18.3.1",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/validator": "^13.11.9",
"@vitejs/plugin-react": "^4.2.1",
"@types/validator": "^13.11.10",
"@vitejs/plugin-react": "^4.3.1",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.2",
"eslint": "^9.2.0",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-rxjs": "^5.0.3",
"eslint-plugin-storybook": "^0.8.0",
"http-proxy-middleware": "^3.0.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"lint-staged": "^15.2.7",
"patch-package": "^8.0.0",
"prettier": "^3.2.5",
"prettier": "^3.3.2",
"rxjs": "^7.8.1",
"storybook": "^8.0.10",
"stylelint": "^16.5.0",
"storybook": "^8.1.8",
"stylelint": "^16.6.1",
"stylelint-config-standard": "^36.0.0",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0",
"vite": "^5.2.11",
"webpack": "^5.91.0"
"typescript-eslint": "^7.13.0",
"vite": "^5.3.0",
"webpack": "^5.92.0"
},
"engines": {
"node": "^20.12.2"
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/Portfolio/Position/PositionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ const PositionsTable: FunctionComponent<Props> = ({
</Tbody>
<Tfoot>
<Tr fontWeight="bold">
<Td isNumeric>
<Number value={thePositions.reduce((p, v) => (p += v.quantity), 0)} />
</Td>
<Td>Total</Td>
<Td></Td>
<Td></Td>
<Td></Td>
<Td>{currency ?? "Base"}</Td>
<Td></Td>
<Td isNumeric>
Expand Down
22 changes: 22 additions & 0 deletions src/app/components/Portfolio/Statement/OptionStatementProps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Flex, Text } from "@chakra-ui/react";
import { default as React } from "react";
import { OptionStatementEntry } from "../../../../routers/statements.types";

type Props = { portfolioId: number; statement: OptionStatementEntry };

const OptionStatementProps = ({ statement, ..._rest }: Props): React.ReactNode => {
return (
<>
<Flex justifyContent="center" gap="2">
<Text w="110px" as="b" textAlign="right">
Quantity:
</Text>
<Text w="200px" textAlign="right">
{statement.quantity}
</Text>
</Flex>
</>
);
};

export default OptionStatementProps;
10 changes: 10 additions & 0 deletions src/app/components/Portfolio/Statement/StatementEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ const StatementEdit: FunctionComponent<Props> = ({ ..._rest }): React.ReactNode
</Flex>
)}

{/* Option properties */}
{theStatement.statementType == StatementTypes.OptionStatement && (
<Flex justifyContent="center" gap="2">
<Text w="90px" as="b" textAlign="right">
Quantity:
</Text>
<Field name="quantity" w="200px" />
</Flex>
)}

<Flex justifyContent="center" gap="2" mt="1">
<IconButton
aria-label="Back"
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/Portfolio/Statement/StatementShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import BondStatementProps from "./BondStatementProps";
import CorpoStatementProps from "./CorpoStatementProps";
import DividendStatementProps from "./DividendStatementProps";
import InterestStatementProps from "./InterestStatementProps";
import OptionStatementProps from "./OptionStatementProps";

type Props = Record<string, never>;

Expand All @@ -26,6 +27,7 @@ const StatementShow: FunctionComponent<Props> = ({ ..._rest }): React.ReactNode
<>
<VStack>
<BaseStatement portfolioId={parseInt(portfolioId)} statement={theStatement} />

{theStatement.statementType == StatementTypes.InterestStatement && (
<InterestStatementProps portfolioId={parseInt(portfolioId)} statement={theStatement} />
)}
Expand All @@ -38,6 +40,10 @@ const StatementShow: FunctionComponent<Props> = ({ ..._rest }): React.ReactNode
{theStatement.statementType == StatementTypes.CorporateStatement && (
<CorpoStatementProps portfolioId={parseInt(portfolioId)} statement={theStatement} />
)}
{theStatement.statementType == StatementTypes.OptionStatement && (
<OptionStatementProps portfolioId={parseInt(portfolioId)} statement={theStatement} />
)}

<Flex justifyContent="center" gap="2" mt="1">
<IconButton aria-label="Back" icon={<ArrowBackIcon />} variant="ghost" onClick={(): void => navigate(-1)} />
<IconButton aria-label="Edit" icon={<EditIcon />} variant="ghost" as={RouterLink} to="edit" />
Expand Down
4 changes: 4 additions & 0 deletions src/bots/account.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class AccountUpdateBot extends ITradingBot {

private async createAndUpdateLegs(order: IbOpenOrder, transaction: Transaction): Promise<IbOpenOrder> {
if (order.contract.secType == SecType.BAG) {
if (!order.contract.comboLegs) {
logger.error(MODULE + ".createAndUpdateLegs", "BAG comboLegs are missing!", order);
return Promise.resolve(order);
}
return order.contract.comboLegs!.reduce(
async (p, leg) =>
p.then(async () =>
Expand Down
5 changes: 5 additions & 0 deletions src/bots/importer.bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const transactionStatusFromElement = (element: any): StatementStatus => {
if (element.notes == "A") return StatementStatus.ASSIGNED_STATUS;
else if (element.notes == "Ep") return StatementStatus.EXPIRED_STATUS;
else if (element.notes == "Ex") return StatementStatus.EXERCISED_STATUS;
else if (element.notes == "Ca")
return StatementStatus.CANCELLED_STATUS; // Cancelled
else if (element.openCloseIndicator == "O") return StatementStatus.OPEN_STATUS;
else if (element.openCloseIndicator == "C") return StatementStatus.CLOSE_STATUS;
else if (element.assetCategory == "CASH") return StatementStatus.UNDEFINED_STATUS;
Expand Down Expand Up @@ -107,6 +109,9 @@ const transactionDescriptionFromElement = (element: any): string => {
case StatementStatus.CLOSE_STATUS:
description += "Closed";
break;
case StatementStatus.CANCELLED_STATUS:
description += "Cancelled";
break;
default:
description += element.notes;
}
Expand Down
1 change: 1 addition & 0 deletions src/models/equity_statement.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const StatementStatus = {
EXPIRED_STATUS: 3,
ASSIGNED_STATUS: 4,
EXERCISED_STATUS: 5,
CANCELLED_STATUS: 6,
} as const;
export type StatementStatus = (typeof StatementStatus)[keyof typeof StatementStatus];

Expand Down
2 changes: 2 additions & 0 deletions src/routers/statements.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ router.post("/id/:statementId(\\d+)/SaveStatement", (req, res): void => {
return InterestStatement.update({ country: data.country! }, { where: { id: statementId } });
case StatementTypes.TaxStatement:
return TaxStatement.update({ country: data.country }, { where: { id: statementId } });
case StatementTypes.OptionStatement:
return OptionStatement.update({ quantity: data.quantity }, { where: { id: statementId } });
default:
return [0];
}
Expand Down
Loading

0 comments on commit 282193c

Please sign in to comment.