@@ -46,7 +46,7 @@ def execute(self, new_price):
46
46
if self .validate_all_orders (targets ):
47
47
return
48
48
49
- alloc = self .prepare_volume_allocation (targets )
49
+ alloc = self .prepare_volume_allocation (targets , self . get_single_price ( new_price ) )
50
50
51
51
if alloc :
52
52
self .place_orders (alloc )
@@ -75,7 +75,7 @@ def validate_all_orders(self, targets):
75
75
def validate_all_completed (self , targets ):
76
76
return all (t .status .is_completed () for t in targets )
77
77
78
- def prepare_volume_allocation (self , targets ):
78
+ def prepare_volume_allocation (self , targets , current_price = 0 ):
79
79
currency_balance = self .get_balance_for_side ()
80
80
81
81
bal = self .trade .get_cap (currency_balance .avail ) + (
@@ -101,10 +101,16 @@ def prepare_volume_allocation(self, targets):
101
101
adjusted_balance = round (bal / price , 8 )
102
102
103
103
vol = self .exchange_info .adjust_quanity (t .vol .get_val (adjusted_balance ))
104
+
104
105
t .calculated_volume = vol
105
106
107
+ if not self .exchange_info .is_within_multiplier_range (price , current_price ):
108
+ self .logWarning ('Target price {:.8f} is not within exchange multipliers. {}'
109
+ .format (price , self .exchange_info .msg_mutliplier_range_error (current_price )))
110
+ continue
111
+
106
112
if vol == 0 :
107
- self .logWarning ('No volume left to process order @ price {:.0f }' .format (price ))
113
+ self .logWarning ('No volume left to process order @ price {:.8f }' .format (price ))
108
114
continue
109
115
110
116
if bal - vol < 0 :
@@ -117,7 +123,7 @@ def prepare_volume_allocation(self, targets):
117
123
# if self.last_target_smart() and t == last_target:
118
124
# continue
119
125
orders .append ({
120
- 'price' : self . exchange_info . adjust_price ( price ) ,
126
+ 'price' : price ,
121
127
'volume' : vol ,
122
128
'side' : self .trade_side ().name ,
123
129
'target' : t })
0 commit comments