add get balance from 3commas
This commit is contained in:
parent
bce225d3ff
commit
f1132f8269
|
|
@ -10,28 +10,29 @@ use function GuzzleHttp\json_decode;
|
||||||
|
|
||||||
class ThreeCommasController extends Controller
|
class ThreeCommasController extends Controller
|
||||||
{
|
{
|
||||||
public function getTrades(){
|
private $baseUrl = 'https://3commas.io';
|
||||||
|
private $api_version = '/public/api/ver1/';
|
||||||
|
private $api_key = 'fd2465a6fa0e455986ef99a51dea14c759bf2feb8f5344558715b1176a3680e8';
|
||||||
|
private $api_secret = '7a43c6de51fc9d4d10f1889bc0bd816d1da63d24c4b0ef357f35e4eb95c5f5e6fef355b891cee3960d7cfc872f328c38906ac17a7152610098eb14940f29cb5643c58c09a7de5fa63859ffe1baedf01ba0c3fa3f30757f33bf5d5f7f2e22e3539f70109e';
|
||||||
|
|
||||||
|
|
||||||
$baseUrl = 'https://3commas.io';
|
public function getTrades(){
|
||||||
$api_version = '/public/api/ver1/';
|
|
||||||
$end_point = 'smart_trades';
|
$end_point = 'smart_trades';
|
||||||
$url = $baseUrl . $api_version . $end_point;
|
$url = $this->baseUrl . $this->api_version . $end_point;
|
||||||
$api_key = 'fd2465a6fa0e455986ef99a51dea14c759bf2feb8f5344558715b1176a3680e8';
|
|
||||||
$api_secret = '7a43c6de51fc9d4d10f1889bc0bd816d1da63d24c4b0ef357f35e4eb95c5f5e6fef355b891cee3960d7cfc872f328c38906ac17a7152610098eb14940f29cb5643c58c09a7de5fa63859ffe1baedf01ba0c3fa3f30757f33bf5d5f7f2e22e3539f70109e';
|
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'api_key' => $api_key,
|
'api_key' => $this->api_key,
|
||||||
'secret' => $api_secret,
|
'secret' => $this->api_secret,
|
||||||
'scope' => 'active',
|
'scope' => 'active',
|
||||||
'limit' => 50
|
'limit' => 50
|
||||||
];
|
];
|
||||||
$query = http_build_query($params);
|
$query = http_build_query($params);
|
||||||
$signature = hash_hmac('sha256', $api_version . $end_point . '?' . $query, $api_secret);
|
$signature = hash_hmac('sha256', $this->api_version . $end_point . '?' . $query, $this->api_secret);
|
||||||
|
|
||||||
$client = new Client([
|
$client = new Client([
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'APIKEY' => $api_key,
|
'APIKEY' => $this->api_key,
|
||||||
'Signature' => $signature
|
'Signature' => $signature
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
@ -40,31 +41,26 @@ class ThreeCommasController extends Controller
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignals(){
|
public function getBalance(){
|
||||||
// Initialize the client
|
$end_point = 'accounts';
|
||||||
$api = new Client([
|
$url = $this->baseUrl . $this->api_version . $end_point;
|
||||||
'base_uri' => 'https://app.signalprofits.com/',
|
|
||||||
'cookies' => true, // You have to have cookies turned on for this API to work
|
$params = [
|
||||||
]);
|
'api_key' => $this->api_key,
|
||||||
|
'secret' => $this->api_secret,
|
||||||
|
];
|
||||||
|
$query = http_build_query($params);
|
||||||
|
$signature = hash_hmac('sha256', $this->api_version . $end_point . '?' . $query, $this->api_secret);
|
||||||
|
|
||||||
// Login
|
$client = new Client([
|
||||||
$api->post('app/login', [
|
'headers' => [
|
||||||
'form_params' => [
|
'Content-Type' => 'application/json',
|
||||||
'identity' => 'john@eutrading.co.uk', // use your actual username
|
'APIKEY' => $this->api_key,
|
||||||
'password' => 'l0uis0404!', // use your actual password
|
'Signature' => $signature
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
$response = $client->request('GET', $url . '?' . $query);
|
||||||
// Fetch
|
$data = json_decode($response->getBody());
|
||||||
$response = $api->get('app/login');
|
return $data;
|
||||||
// and decode some data
|
}
|
||||||
$boxscore = $response->getBody();
|
}
|
||||||
|
|
||||||
// And logout
|
|
||||||
$test = $api->get('wp-admin/admin-ajax.php?action=get_signals&limit=100');
|
|
||||||
$test2 = $test->getBody();
|
|
||||||
// $test2 = json_decode($test->getBody());
|
|
||||||
return $test2;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
|
|
@ -11,21 +11,25 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "^0.18",
|
"axios": "^0.18",
|
||||||
"bootstrap": "^4.0.0",
|
"bootstrap": "^4.3.1",
|
||||||
"cross-env": "^5.1",
|
"cross-env": "^5.1",
|
||||||
"jquery": "^3.2",
|
"jquery": "^3.2",
|
||||||
"laravel-mix": "^2.0",
|
"laravel-mix": "^2.0",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
"popper.js": "^1.12",
|
"popper.js": "^1.14.7",
|
||||||
"vue": "^2.5.17"
|
"resolve-url-loader": "^2.3.1",
|
||||||
|
"sass": "^1.17.3",
|
||||||
|
"sass-loader": "^7.1.0",
|
||||||
|
"vue": "^2.6.10",
|
||||||
|
"vue-template-compiler": "^2.6.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ajv": "^6.5.5",
|
"ajv": "^6.10.0",
|
||||||
"bulma": "^0.7.2",
|
"bulma": "^0.7.4",
|
||||||
"cryptocurrency-icons": "^0.9.0",
|
"cryptocurrency-icons": "^0.11.0",
|
||||||
"imagemin": "^6.0.0",
|
"imagemin": "^6.1.0",
|
||||||
"img-loader": "^3.0.1",
|
"img-loader": "^3.0.1",
|
||||||
"vue-material-design-icons": "^2.4.0",
|
"vue-material-design-icons": "^2.8.0",
|
||||||
"vue-router": "^3.0.2",
|
"vue-router": "^3.0.2",
|
||||||
"vue-trading-view": "^1.0.1"
|
"vue-trading-view": "^1.0.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -3,15 +3,15 @@
|
||||||
<section class="section tv-top-container" :class="{'colapse': tvTopContainerColapse}">
|
<section class="section tv-top-container" :class="{'colapse': tvTopContainerColapse}">
|
||||||
<div class="container is-fullhd">
|
<div class="container is-fullhd">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-11 tv-top-column" :class="{'expand': tvTopContainerExpand}">
|
<div class="column is-9 tv-top-column" :class="{'expand': tvTopContainerExpand}">
|
||||||
<VueTradingView :options="{
|
<VueTradingView :options="{
|
||||||
symbol: 'BINANCE:BTCUSDT',
|
symbol: 'BINANCE:BTCUSDT',
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
allow_symbol_change: true,
|
allow_symbol_change: true,
|
||||||
autosize: true,
|
autosize: true,
|
||||||
interval: 60,
|
interval: 60,
|
||||||
hide_side_toolbar: false,
|
hide_side_toolbar: false,
|
||||||
}" />
|
}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<span class="icon icon-circle" v-on:click="colapseTvTopContainer">
|
<span class="icon icon-circle" v-on:click="colapseTvTopContainer">
|
||||||
|
|
@ -24,6 +24,31 @@
|
||||||
<i class="mdi mdi-24px mdi-arrow-expand-down" v-on:click="expandTvTopContainer"></i>
|
<i class="mdi mdi-24px mdi-arrow-expand-down" v-on:click="expandTvTopContainer"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="column is-2">
|
||||||
|
24 Hour Stats
|
||||||
|
<div class="columns">
|
||||||
|
|
||||||
|
<div class="column is-one-quarter">
|
||||||
|
<img src="/images/cryptocurrency-icons/svg/color/btc.svg" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="column is-three-quarters">
|
||||||
|
<big class="text-primary"
|
||||||
|
style="font-weight:600; font-size:2.5rem;">{{financial(balance_btc_amount, 3)}}</big><br>
|
||||||
|
<span
|
||||||
|
:class="{'text-error': day_profit_btc < 0, 'text-success': day_profit_btc > 0}">{{financial(day_profit_btc, 6)}}</span>
|
||||||
|
<span>{{day_profit_btc_percentage}}%</span><br>
|
||||||
|
AVAIL: <span class="text-secondary">{{btc_to_trade}}</span>
|
||||||
|
<br><br>
|
||||||
|
<big class="text-primary"
|
||||||
|
style="font-weight:600;">{{financial(balance_usd_amount, 2)}}</big><br>
|
||||||
|
<span
|
||||||
|
:class="{'text-error': day_profit_usd < 0, 'text-success': day_profit_usd > 0}">{{financial(day_profit_usd, 2)}}</span>
|
||||||
|
<span>{{day_profit_usd_percentage}}%</span><br>
|
||||||
|
AVAIL: <span class="text-secondary">{{financial(usd_to_trade, 2)}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -53,12 +78,13 @@
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a class="button is-dark" @click="sort('profit_percentage'), activeFilter = 'profit'">
|
<a class="button is-dark" @click="sort('profit_percentage'), activeFilter = 'profit'">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<i class="mdi mdi-24px" :class="[ activeFilter == 'profit' && currentSortDir =='asc' ? 'mdi-chevron-up' : 'mdi-chevron-down' ]"></i>
|
<i class="mdi mdi-24px"
|
||||||
|
:class="[ activeFilter == 'profit' && currentSortDir =='asc' ? 'mdi-chevron-up' : 'mdi-chevron-down' ]"></i>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Profit %
|
Profit %
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="button is-dark" @click="sort('id')">Age</a>
|
<a class="button is-dark" @click="sort('id')">Age</a>
|
||||||
<a class="button is-dark" @click="sort('to_currency_code')">Coin</a>
|
<a class="button is-dark" @click="sort('to_currency_code')">Coin</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -76,12 +102,14 @@
|
||||||
<div class="coin-card is-clear-fix">
|
<div class="coin-card is-clear-fix">
|
||||||
<div>
|
<div>
|
||||||
<div class="tokenicon-wrap is-pulled-left push-right">
|
<div class="tokenicon-wrap is-pulled-left push-right">
|
||||||
<img v-bind:src="'/images/cryptocurrency-icons/svg/color/' + trade.to_currency_code + '.svg'" />
|
<img
|
||||||
|
v-bind:src="'/images/cryptocurrency-icons/svg/color/' + trade.to_currency_code + '.svg'" />
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div class="">
|
||||||
<big class="text-primary">{{ trade.to_currency_code }}</big>
|
<big class="text-primary">{{ trade.to_currency_code }}</big>
|
||||||
<span class="is-pulled-right push-right">
|
<span class="is-pulled-right push-right">
|
||||||
<big :class="{'text-error': trade.profit_percentage < 0, 'text-success': trade.profit_percentage > 0}">{{trade.profit_percentage}}%</big>
|
<big
|
||||||
|
:class="{'text-error': trade.profit_percentage < 0, 'text-success': trade.profit_percentage > 0}">{{trade.profit_percentage}}%</big>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -151,6 +179,25 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fetchBalance() {
|
||||||
|
axios.get('/api/3commas/getbalance')
|
||||||
|
.then(response => {
|
||||||
|
this.balance = response.data,
|
||||||
|
this.balance_btc_amount = this.balance[0].btc_amount,
|
||||||
|
this.day_profit_btc = this.balance[0].day_profit_btc,
|
||||||
|
this.day_profit_btc_percentage = this.balance[0].day_profit_btc_percentage,
|
||||||
|
this.btc_to_trade = this.balance[0].available_for_trading.BTC,
|
||||||
|
this.balance_usd_amount = this.balance[0].usd_amount,
|
||||||
|
this.day_profit_usd = this.balance[0].day_profit_usd,
|
||||||
|
this.day_profit_usd_percentage = this.balance[0].day_profit_usd_percentage,
|
||||||
|
this.usd_to_trade = this.balance[0].available_for_trading.USDT
|
||||||
|
// console.log(this.balance[0].available_for_trading.BTC)
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log('Error: ', e.response.data)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
formatPrice(num) {
|
formatPrice(num) {
|
||||||
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
|
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
|
||||||
var zero = '0',
|
var zero = '0',
|
||||||
|
|
@ -171,8 +218,8 @@
|
||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
|
|
||||||
financial(x) {
|
financial(x, y = 8) {
|
||||||
return Number.parseFloat(x).toFixed(8);
|
return Number.parseFloat(x).toFixed(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -195,6 +242,8 @@
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.fetchTrades();
|
this.fetchTrades();
|
||||||
|
this.fetchBalance();
|
||||||
|
setInterval(() => this.fetchBalance(), 10000);
|
||||||
setInterval(() => this.fetchTrades(), 10000);
|
setInterval(() => this.fetchTrades(), 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,5 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('3commas/gettrades', 'ThreeCommasController@getTrades');
|
Route::get('3commas/gettrades', 'ThreeCommasController@getTrades');
|
||||||
|
Route::get('3commas/getbalance', 'ThreeCommasController@getBalance');
|
||||||
Route::get('getsignals', 'ThreeCommasController@getSignals');
|
Route::get('getsignals', 'ThreeCommasController@getSignals');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue