Skip to content

Commit

Permalink
update api orders endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
TranceGeniK committed Dec 20, 2019
1 parent b3044f3 commit 51ec4a1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 49 deletions.
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-tools",
"version": "0.4.5",
"version": "0.4.6",
"private": true,
"author": "Maiis Trancegenik <[email protected]>",
"scripts": {
Expand All @@ -23,19 +23,19 @@
"lodash": "^4.17.15",
"open": "^6.4.0",
"reconnecting-websocket": "^4.2.0",
"vue": "^2.6.10",
"vue": "^2.6.11",
"vue-notification": "^1.3.20",
"vuetify": "^2.1.13"
"vuetify": "^2.1.15"
},
"devDependencies": {
"@vue/cli-service": "^3.12.1",
"electron": "^6.1.5",
"electron": "^6.1.7",
"node-sass": "^4.13.0",
"sass": "^1.23.7",
"sass-loader": "^7.3.1",
"vue-cli-plugin-electron-builder": "^1.4.3",
"vue-cli-plugin-electron-builder": "^1.4.4",
"vue-cli-plugin-vuetify": "^0.6.3",
"vue-template-compiler": "^2.6.10",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.4.3"
},
"postcss": {
Expand Down
9 changes: 8 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@
::-webkit-scrollbar-thumb {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.8);
}
@media (min-width: 960px) {
.container {
max-width: 100%;
}
}
</style>
9 changes: 5 additions & 4 deletions src/components/Home/Home.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@
<v-btn-toggle
v-model="orderTypeId"
mandatory
class="mb-2"
color="primary"
>
<v-btn small mb-3>
<v-btn small>
Ladder
</v-btn>
<v-btn small mb-3>
<v-btn small>
Limit
</v-btn>
<v-btn small mb-3>
<v-btn small>
Market
</v-btn>
</v-btn-toggle>
<v-switch v-model="$ui.showRiskManagementPane" class="risk ma-2 mt-0" color="primary"
<v-switch v-model="$ui.showRiskManagementPane" dense hide-details class="risk ma-2 mt-0" color="primary"
label="Risk Pane"></v-switch>
</div>

Expand Down
40 changes: 29 additions & 11 deletions src/plugins/bybitApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import axios from 'axios';
import CryptoJS from 'crypto-js';
import ReconnectingWebSocket from 'reconnecting-websocket';


export default {
install(Vue, defaultOptions = {}) {
Vue.prototype.$bybitApi = new Vue({
Expand Down Expand Up @@ -242,10 +241,11 @@ export default {
symbol: this.currentSymbol,
take_profit: takeProfit,
stop_loss: stopLoss,
trailing_stop: trailingStop
} ;
trailing_stop: trailingStop,
};
try {
let res = await axios.post(this.url + 'open-api/position/trading-stop',
let res = await axios.post(
this.url + 'open-api/position/trading-stop',
this.signData(data));
console.log(res);
if (res.data.ret_msg === 'ok') {
Expand All @@ -259,7 +259,7 @@ export default {
type: 'error',
});
}

} catch (e) {
console.error(e);
this.$notify({
Expand All @@ -270,10 +270,10 @@ export default {
},
async placeOrder(data) {
try {
let res = await axios.post(this.url + 'open-api/order/create',
let res = await axios.post(this.url + 'v2/private/order/create',
this.signData(data));
console.log(res);
if (res.data.ret_msg === 'ok') {
if (res.data.ret_msg === 'OK') {
this.$notify({
text: 'Order placed',
type: 'success',
Expand All @@ -297,10 +297,11 @@ export default {
try {
let data = {
order_id: id,
symbol: this.currentSymbol,
};
let res = await axios.post(this.url + 'open-api/order/cancel',
let res = await axios.post(this.url + 'v2/private/order/cancel',
this.signData(data));
if (res.data.ret_msg === 'ok') {
if (res.data.ret_msg === 'OK') {
this.$notify({
text: 'Order cancelled',
type: 'success',
Expand All @@ -316,8 +317,25 @@ export default {
}
},
async cancelAllOpenOrders() {
for (let i = 0; i < this.openOrders.length; i++) {
this.cancelOrder(this.openOrders[i].order_id);
try {
let data = {
symbol: this.currentSymbol,
};
let res = await axios.post(this.url + 'v2/private/order/cancelAll',
this.signData(data));
if (res.data.ret_msg === 'OK') {
this.$notify({
text: 'Orders cancelled',
type: 'success',
});
} else {
this.$notify({
text: res.data.ret_msg,
type: 'error',
});
}
} catch (e) {
console.error(e);
}
},
async cancelAllBuyOpenOrders() {
Expand Down

0 comments on commit 51ec4a1

Please sign in to comment.