2020-12-12 20:18:25 +00:00
|
|
|
|
import React, { Component } from "react";
|
2020-12-14 13:55:33 +00:00
|
|
|
|
import { Col, Container, Nav, Navbar, Row } from "react-bootstrap";
|
2020-12-13 11:27:50 +00:00
|
|
|
|
import HCard from "./HCard";
|
2020-12-13 19:32:33 +00:00
|
|
|
|
import RPlot from "./RPlot";
|
2020-12-14 14:50:31 +00:00
|
|
|
|
import { NewTickData, PositionState, socket } from "../";
|
|
|
|
|
import { PositionTable } from "./Tables";
|
2020-12-13 19:32:33 +00:00
|
|
|
|
|
|
|
|
|
type AppState = {
|
|
|
|
|
current_price: number,
|
|
|
|
|
current_tick: number,
|
2020-12-14 14:50:31 +00:00
|
|
|
|
last_update: Date,
|
|
|
|
|
positions: Array<PositionState>
|
2020-12-13 19:32:33 +00:00
|
|
|
|
}
|
2020-12-12 20:18:25 +00:00
|
|
|
|
|
2020-12-14 14:50:31 +00:00
|
|
|
|
|
2020-12-12 20:18:25 +00:00
|
|
|
|
class App extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-13 19:32:33 +00:00
|
|
|
|
state = {
|
|
|
|
|
current_price: 0,
|
|
|
|
|
current_tick: 0,
|
2020-12-14 14:50:31 +00:00
|
|
|
|
last_update: new Date(),
|
|
|
|
|
positions: []
|
2020-12-13 19:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
socket.on("new_tick", (data: NewTickData) => {
|
2020-12-14 14:50:31 +00:00
|
|
|
|
this.setState({
|
|
|
|
|
current_price: data.price,
|
|
|
|
|
current_tick: data.tick,
|
|
|
|
|
last_update: new Date(),
|
|
|
|
|
positions: data.positions
|
|
|
|
|
})
|
2020-12-13 19:32:33 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-12 20:18:25 +00:00
|
|
|
|
render() {
|
|
|
|
|
return (
|
2020-12-14 13:55:33 +00:00
|
|
|
|
<div className="d-flex flex-fill flex-column">
|
|
|
|
|
<Navbar bg="light" expand="lg" className="border-bottom">
|
|
|
|
|
<Navbar.Brand href="#home">Rustico - BfxBot</Navbar.Brand>
|
|
|
|
|
</Navbar>
|
|
|
|
|
|
|
|
|
|
<Container fluid className="mt-2 border flex-fill d-flex">
|
|
|
|
|
<Row className="flex-fill">
|
|
|
|
|
{/* Toolbar column */}
|
|
|
|
|
<Col md={4} lg={4} className="border-right">
|
|
|
|
|
<Row className="justify-content-center border-bottom py-2">
|
|
|
|
|
<HCard title="Current tick:" content={String(this.state.current_tick)} update={this.state.last_update}></HCard>
|
|
|
|
|
<HCard title="Current price:" content={String(this.state.current_price)} update={this.state.last_update}></HCard>
|
|
|
|
|
</Row>
|
2020-12-14 14:50:31 +00:00
|
|
|
|
<Row>
|
|
|
|
|
<PositionTable />
|
|
|
|
|
</Row>
|
2020-12-14 13:55:33 +00:00
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
{/* Graph column */}
|
|
|
|
|
<Col md={8} lg={8} className="flex-fill">
|
|
|
|
|
<div className="border-bottom mt-2">
|
|
|
|
|
<h2>Price graph:</h2>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<RPlot />
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
{/* <Row className="flex-grow-1 border-top border-bottom">
|
|
|
|
|
<RPlot />
|
|
|
|
|
</Row> */}
|
|
|
|
|
</Container >
|
|
|
|
|
<footer className="footer fixed-bottom py-3 bg-light border-top">
|
|
|
|
|
<Container className="text-center">
|
|
|
|
|
<span className="text-muted">Made with ❤️ by the Pepe</span>
|
|
|
|
|
</Container>
|
|
|
|
|
</footer>
|
|
|
|
|
</div>
|
2020-12-12 20:18:25 +00:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|