import React, {Component} from "react" import {Badge, Button, Container, Table} from "react-bootstrap" import {socket} from '../'; import {PositionCloseMessage, PositionProp} from "../types"; export class PositionTable extends Component<{ positions: Array }> { constructor(props) { super(props) } stateVariantFromStr(state: string): string { const lower_state = state.toLowerCase() let res: string; if (lower_state.includes("profit")) { res = "success" } else if (lower_state.includes("break")) { res = "primary" } else { res = "danger" } return res } plColorFromStr(amount: number): string { if (amount > 0) { return "success" } else { return "danger" } } tableData() { return this.props.positions.map((position: PositionProp) => { let row_bg = ""; if (!position.state.toLowerCase().includes("break")) { row_bg = "table-" + this.plColorFromStr(position.amount) } return ( {position.state} {position.symbol} {position.base_price.toFixed(2)} {position.amount.toFixed(5)} {position.profit_loss.toFixed(2)} {position.profit_loss_percentage.toFixed(2)} % ) }) } render() { return (

Open positions

{this.tableData()}
State Symbol Base price Amount P/L P/L % Action
) } }