Skip to content

Commit 745a8c6

Browse files
committed
Improved Min Notional handling. Simplified Exit Details
1 parent 951e5c3 commit 745a8c6

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

Bot/ExchangeInfo.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def adjust_quanity(self, q, round_down=True):
3434
res = float(Decimal(q) if self.stepSize == 0.0 else Decimal(q).quantize(self.stepSize, rounding=ROUND_DOWN if round_down else ROUND_UP))
3535
return float(min(max(res, self.minQty), self.maxQty))
3636

37-
def adjust_price(self, q, round_down=True):
38-
res = round(Decimal(q), 8)
37+
def adjust_price(self, p, round_down=True):
38+
res = round(Decimal(p), 8)
3939

4040
if self.tickSize: # if tickSize Enabled
4141
res = res.quantize(self.tickSize, rounding=ROUND_DOWN if round_down else ROUND_UP)
@@ -51,6 +51,9 @@ def adjust_price(self, q, round_down=True):
5151
def is_quanity_above_min(self, q):
5252
return q > self.minQty
5353

54+
def is_min_notional_ok(self, q, p):
55+
return q * p >= self.minNotional
56+
5457

5558
class ExchangeInfo:
5659
__shared_state = {}

Bot/FXConnector.py

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def create_limit_order(self, sym, side, price, volume):
168168

169169
# @retry(stop_max_attempt_number=MAX_ATTEMPTS, wait_fixed=DELAY)
170170
def create_stop_order(self, sym, side, stop_price, price, volume):
171+
self.logInfo("Creating Stop Order:{}; {} Vol:{:.08f}, Trigger Price {:.08f}, Limit Price {:.08f}".format(side, sym, volume, stop_price, price))
171172
return self.client.create_order(
172173
symbol=sym,
173174
side=side,

Bot/Strategy/EntryStrategy.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,21 @@ def handle_stoploss_order(self, trigger_order_price, current_price):
167167

168168
# if was sold externaly
169169
if not self.exchange_info.is_quanity_above_min(vol):
170-
self.logInfo(
170+
self.logError(
171171
'Volume {} is less than min allowed by pair rules {}. Marking target as completed.'.format(vol,
172172
self.exchange_info.minQty))
173173
self.current_target.set_completed()
174174
self.trigger_target_updated()
175175
return
176176

177+
if not self.exchange_info.is_min_notional_ok(vol, limit):
178+
l = self.exchange_info.adjust_price(limit)
179+
v = self.exchange_info.adjust_quanity(vol)
180+
self.logError(
181+
'Min notional "price * volume" ({:.08f}*{:.08f}={:.08f}) is less than allowed by pair rules {:.08f}; Trigger Price {}'.format(l, v, l * v, self.exchange_info.minNotional, self.exchange_info.adjust_price(trigger_order_price))
182+
)
183+
return
184+
177185
try:
178186
order = self.fx.create_stop_order(
179187
sym=self.symbol(),

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Configuration For Exit Targets
88
</mat-panel-description>
99
</mat-expansion-panel-header>
10-
<mat-expansion-panel>
10+
<!-- <mat-expansion-panel>
1111
<mat-expansion-panel-header>
1212
<mat-panel-title>
1313
Default Settings
@@ -25,7 +25,7 @@
2525
</mat-form-field>
2626
</td></tr>
2727
</table>
28-
</mat-expansion-panel>
28+
</mat-expansion-panel> -->
2929
<div class="trade-section">
3030
<table class="full-width" cellspasing=0>
3131
<tr *ngFor="let exitTarget of trade.exit.targets">
@@ -70,9 +70,14 @@
7070
</td>
7171
</tr>
7272
</table>
73-
<button mat-icon-button class="resume-btn" matTooltip="Add Target" (click)="addNewTarget()">
73+
<button mat-icon-button class="resume-btn" matTooltip="Add Target" (click)="addNewTarget()"
74+
[disabled]="!(!lastAddedTarget || (lastAddedTarget && lastAddedTarget.vol && lastAddedTarget.price))">
7475
<mat-icon>add_circle_outline</mat-icon>
7576
</button>
77+
<mat-form-field appearance="standard" style="display: block; width: 30%;">
78+
<mat-label>Smart Target Threshold</mat-label>
79+
<input matInput type="text" id="targetPrice" name="targetPrice" [(ngModel)]="trade.exit.threshold">
80+
</mat-form-field>
7681
</div>
7782
</mat-expansion-panel>
7883

0 commit comments

Comments
 (0)