import React from "react" import { Component } from "react" import { Container, Table } from "react-bootstrap" import { NewTickData, PositionState, socket } from '../'; export class PositionTable extends Component<{}, { positions: Array }> { constructor(props) { super(props) } state = { positions: [] } componentDidMount() { socket.on('new_tick', (data: NewTickData) => { this.setState({ positions: data.positions }) }) } tableData() { return this.state.positions.map((position: PositionState, idx) => { return ( {position.id} {position.symbol} {position.profit_loss.toFixed(2)} {position.profit_loss_percentage.toFixed(2)} % ) }) } render() { return (

Open positions

{this.tableData()}
ID Symbol P/L P/L %
) } }