|
|
|
@ -35,9 +35,7 @@
|
|
|
|
|
// }).show();
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
// fetch latest data for the UI
|
|
|
|
|
let updateAllData;
|
|
|
|
|
// trigger background tasks to store data
|
|
|
|
|
let storeMarketData;
|
|
|
|
|
let storeBalances;
|
|
|
|
|
let storeBitcoinPrice;
|
|
|
|
@ -49,12 +47,28 @@
|
|
|
|
|
fetch('{{ url_for("api.get_ticker_data") }}')
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
document.getElementById('get_ticker_data').innerHTML = JSON.stringify(res);
|
|
|
|
|
});
|
|
|
|
|
fetch('{{ url_for("api.get_balances") }}')
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
document.getElementById('get_balances').innerHTML = JSON.stringify(res)
|
|
|
|
|
});
|
|
|
|
|
fetch('{{ url_for("api.get_bitcoin_price") }}')
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
document.getElementById('get_bitcoin_price').innerHTML = JSON.stringify(res)
|
|
|
|
|
});
|
|
|
|
|
fetch('{{ url_for("api.get_orders") }}')
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
document.getElementById('get_orders').innerHTML = JSON.stringify(res)
|
|
|
|
|
});
|
|
|
|
|
fetch('{{ url_for("api.get_trade_history") }}')
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
document.getElementById('get_trade_history').innerHTML = JSON.stringify(res)
|
|
|
|
|
});
|
|
|
|
|
fetch('{{ url_for("api.get_balances") }}');
|
|
|
|
|
fetch('{{ url_for("api.get_bitcoin_price") }}');
|
|
|
|
|
fetch('{{ url_for("api.get_orders") }}');
|
|
|
|
|
fetch('{{ url_for("api.get_trade_history") }}');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.state.looping) {
|
|
|
|
@ -78,7 +92,7 @@
|
|
|
|
|
console.log('storing trade history');
|
|
|
|
|
fetch('{{ url_for("tasks.store_trade_history") }}');
|
|
|
|
|
}, 60000);
|
|
|
|
|
updateAllData = setInterval(getAllData(), 10000);
|
|
|
|
|
updateAllData = setInterval(getAllData, 10000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
@ -88,7 +102,7 @@
|
|
|
|
|
<div>
|
|
|
|
|
<p>market making is started</p>
|
|
|
|
|
<button onClick={() => {
|
|
|
|
|
this.setState({looping: false});
|
|
|
|
|
this.setState({...this.state, looping: false});
|
|
|
|
|
clearInterval(storeMarketData);
|
|
|
|
|
clearInterval(storeBalances);
|
|
|
|
|
clearInterval(storeBitcoinPrice);
|
|
|
|
@ -101,28 +115,23 @@
|
|
|
|
|
<div>
|
|
|
|
|
<p>market making is stopped</p>
|
|
|
|
|
<button onClick={() => {
|
|
|
|
|
this.setState({looping: true});
|
|
|
|
|
this.setState({...this.state, looping: true});
|
|
|
|
|
getAllData();
|
|
|
|
|
}}>Start</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<p id="get_ticker_data"></p>
|
|
|
|
|
<p id="get_balances"></p>
|
|
|
|
|
<p id="get_bitcoin_price"></p>
|
|
|
|
|
<p id="get_orders"></p>
|
|
|
|
|
<p id="get_trade_history"></p>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this.setState(prevState => {
|
|
|
|
|
// let jasper = { ...prevState.jasper }; // creating copy of state variable jasper
|
|
|
|
|
// jasper.name = 'someothername'; // store the name property, assign a new value
|
|
|
|
|
// return { jasper }; // return new object jasper object
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
const domContainer = document.querySelector('#container');
|
|
|
|
|
const root = ReactDOM.createRoot(domContainer);
|
|
|
|
|
root.render(e(App));
|
|
|
|
|
|
|
|
|
|
// setInterval(function() {
|
|
|
|
|
// fetch('{{ url_for("tasks.store_ticker_data") }}');
|
|
|
|
|
// }, 10000)
|
|
|
|
|
|
|
|
|
|
</script>
|