forked from NBG-Fintech3/Ducimus-Investments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orders.php
143 lines (120 loc) · 6.16 KB
/
orders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
header('Content-type: text/html; charset:utf8');
include('inc/header.inc.php');
include('inc/connect.inc.php');
$timer = 60;
$arb1 = rand(653, 901);
$arb2 = rand(401, 600);
# $js_arbitrage = exec('node /var/www/html/trading/js/main.js');
#
?>
<div id="menu">
<ul>
<li><a href="index.php" >EXCHANGES</a></li>
<li><a href="orders.php" style="background-color:#d6d6c2">ORDERS</a></li>
</ul>
</div>
<?php
if (isset($_POST['json_refresh'])){
$sql_select_10_query = "SELECT * FROM arbitrage";
$last_10_arbitrage_data = mysql_query($sql_select_10_query, $con);
}
if (isset($_POST['close_action'])){
$output = exec('python /var/www/html/trading/deploy.py');
echo "<span style='text-align:center'><p style='font-size:18px'><b><font color='green'><b>PERFECT : </font> Action 'close' has been submitted!</b></p></span><br/><br/>";
}
if (isset($_POST['update_pair_amount'])) {
if (empty($_POST['pair'])) {
echo "<span style='text-align:center'><p style='font-size:18px'><b><font color='red'><b>WARNING : </font> Pair field is empty.</b></p></span><br/><br/>";
}
elseif (empty($_POST['amount'])) {
echo "<span style='text-align:center'><p style='font-size:18px'><b><font color='red'><b>WARNING : </font> Amount field is empty.</b></p></span><br/><br/>";
}
else {
$update_pair_amount_Query="UPDATE actions SET
pair = '$_POST[pair]', amount = '$_POST[amount]' WHERE id = '$_POST[id]'";
mysql_query($update_pair_amount_Query, $con);
echo "<span style='text-align:center'><p style='font-size:18px'><font color='green'><b>PERFECT : </font> New value's been submitted!</b></p></span><br/><br/>";
# $js_arbitrage = exec("python -c 'import deploy; print deploy.beta()'");
# $js_arbitrage = exec('python /var/www/html/trading/py/lef/arbitrage.py');
}
}
if (isset($_POST['find_arbitrage'])) {
$py_arbitrage = exec('python /var/www/html/trading/py/lef/arbitrage.py');
}
echo
"<table width='80%' >
<meta http-equiv='refresh' content='";echo $timer; echo"' >
<tr style='background-color:#FFFFF0'>
<th>PAIR & AMOUNT</th>
<th>CLOSE</th>
</tr>";
$sql_select_actions_query="SELECT * FROM actions";
$store_sql_select_actions = mysql_query($sql_select_actions_query, $con);
while ($record = mysql_fetch_array($store_sql_select_actions)){
echo
"<form action='' method='POST'>
<tr style='border-style:none'>
<td style='border-style:none'>
<input type='text' name='pair' value='$record[pair]'/><input type='hidden' name='id' value='$record[id]'/>
<input type='text' name='amount' value='$record[amount]'/>
<input type='submit' name='update_pair_amount' value='SUBMIT'/>
</td>
<td style='border-style:none'>
<input type='submit' name='close_action' value='SUBMIT'/>
</td>
</tr>";
}
echo "</table>";
echo "<table width='100%'><br>
<tr style='background-color:#FFFFF0'>
<th>ARBITRAGE :</th>
</tr>";
echo "<table width='100%'>
<tr style='background-color:#FFFFFF'>
</tr>";
echo "<form action='orders.php' method='POST'>
<tr style='border-style:none'>
<td style='border-style:none'>
<input type='text' id='arbitrage' name='arbitrage' value='$py_arbitrage' />
<input type='submit' name='find_arbitrage' value='SUBMIT'/>
</td>
</tr>";
echo "</table>";
$sql_account_data = "SELECT * FROM account_info";
$account_data = mysql_query($sql_account_data, $con);
echo "<table width='100%' display: inline-block' ><br><br>
<tr style='background-color:#FFFFF0'>
<th>ACCOUNT INFO</th>
</tr>";
while ($record2 = mysql_fetch_array($account_data)){
echo "<form action='orders.php' method='POST'>
<tr style='border-style:none; background-color:#ccffcc'>
<td >
<div name='account'>OKEX : $record2[okex]</div>
<div name='account'>HITBTC : $record2[hitbtc]</div>
<div name='account'>TOTAL : $record2[total]</div>
<div name='account'>TIMESTAMP : $record2[import_date]</div>
<input type='submit' name='account_refresh' value='REFRESH'/> <!-- THIS IS FOR PYTHON CALL -->
</td>
</tr>";
}
echo "</table>";
$record3 = mysql_fetch_array($last_10_arbitrage_data);
echo"<br><form id='form1' method='post' action='orders.php' style='text-align:center'>
<fieldset>
<legend style= 'margin-left:40%'>JSON Return: </legend>";
while ($record3 = mysql_fetch_array($last_10_arbitrage_data)){
echo"<div style='text-align:center'> $record3[pair] - $record[arbitrage]</div>";
echo"<div>$record3[arbitrage]</div>";
}
echo"</fieldset>
<input type='submit' style='margin-left:46.7%' name='json_refresh' value='REFRESH'/>
</form>";
?>
<br><br><br><br>
</div>
<br><br>
<?php
include('inc/footer.inc.php');
?>