Skip to content

Commit 8634dfa

Browse files
committed
Reduced binance api querying on cancel orders.
Fixed "Edit" button doesn't close the diaglog
1 parent 8456adf commit 8634dfa

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

Bot/FXConnector.py

+25-4
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,35 @@ def stop_listening(self):
8484

8585
@retry(**DEFAULT_RETRY_SETTINGS)
8686
def cancel_order(self, sym, id):
87+
'''
88+
:param sym:
89+
:param id:
90+
:return:
91+
{
92+
'symbol': 'ETCUSDT',
93+
'origClientOrderId': 'asd',
94+
'orderId': 1211742179,
95+
'orderListId': -1,
96+
'clientOrderId': 'xyz',
97+
'price': '100.00000000',
98+
'origQty': '5.00000000',
99+
'executedQty': '0.00000000',
100+
'cummulativeQuoteQty': '0.00000000',
101+
'status': 'CANCELED',
102+
'timeInForce': 'GTC',
103+
'type': 'LIMIT',
104+
'side': 'SELL'}
105+
'''
87106
return self.client.cancel_order(symbol=sym, orderId=id)
88107

89108
@retry(**DEFAULT_RETRY_SETTINGS)
90109
def cancel_open_orders(self, sym):
91-
orders = self.get_open_orders(sym)
92-
if orders:
93-
for order_id in orders:
94-
self.client.cancel_order(symbol=sym, orderId=order_id)
110+
return self.client._delete('openOrders',True, data={'symbol': sym})
111+
# self.client.cancel_open
112+
# orders = self.get_open_orders(sym)
113+
# if orders:
114+
# for order_id in orders:
115+
# self.client.cancel_order(symbol=sym, orderId=order_id)
95116

96117
def get_server_time(self):
97118
return self.client.get_server_time()

Bot/Strategy/EntryStrategy.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ def handle_stoploss_order(self, trigger_order_price, current_price):
213213
def cancel_current_limit_order(self):
214214
if self.current_target.is_active():
215215
try:
216-
status = self.fx.get_order_status(self.symbol(), self.current_target.id)
216+
# status = self.fx.get_order_status(self.symbol(), self.current_target.id)
217+
status = self.fx.cancel_order(self.symbol(), self.current_target.id)
217218

218-
if self.fx.cancel_order(self.symbol(), self.current_target.id):
219+
if status['status'] == 'CANCELED':
219220
canceled_time = datetime.now()
220221
self.current_target.set_canceled()
221222
self.trigger_target_updated()

admin/src/app/asset-table/asset-table.component.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,10 @@ export class AssetTableComponent implements OnInit, OnDestroy {
6363
}
6464

6565
this.tradeNotificationSubscription = this.tradeService.eventAnounces$.subscribe(res => {
66-
if (res.type === 'created') {
66+
if (res.type === 'created' || res.type === 'updated') {
6767
this.refreshTrades();
68-
// setTimeout(this.refreshTrades.bind(this), 0);
6968
}
7069
});
71-
72-
// this.onTradeInfo(null, TradeDetailMode.Create);
7370
}
7471

7572
ngOnDestroy() {

admin/src/app/trade-details/trade-details.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <h1 mat-dialog-title>
7474
</mat-accordion>
7575
</div>
7676
<div mat-dialog-actions align="end">
77-
<button mat-button type="submit" color="primary" (click)="confirm()" *ngIf="!mode.isView()" [disabled]="myControl.errors && mode.isCreate()" >{{ mode.str() }}</button>
77+
<button mat-button type="submit" color="primary" (click)="confirm()" *ngIf="!mode.isView()" [disabled]="myControl.errors && mode.isCreate()" >{{ mode.isCreate()? "Create":"Save" }}</button>
7878
<button mat-button mat-dialog-close="cancel" color="primary">Cancel</button>
7979
</div>
8080
</form>

admin/src/app/trade-details/trade-details.component.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@ export class TradeDetailsComponent implements OnInit {
104104
confirm() {
105105
this.api.addTrade(this.trade).subscribe(
106106
res => {
107-
if (this.mode.isCreate()) {
108-
109-
this.tradeService.anounce(new TradeEvent('TradeDeatails', 'created'));
110-
111-
if(!this.myControl.errors && this.dialogRef)
112-
this.dialogRef.close()
107+
if (this.mode.isCreate() || this.mode.isEdit()) {
108+
this.tradeService.anounce(new TradeEvent('TradeDeatails', this.mode.isCreate() ? 'created': 'updated'));
113109
}
110+
111+
if(!this.myControl.errors && this.dialogRef)
112+
this.dialogRef.close()
114113
},
115114
err => {
116115
this.notificationService.NotifyAlert('Trade creation error');

0 commit comments

Comments
 (0)