mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Fix percentile computing for ranges, fix limit adjusts by premium
This commit is contained in:
@ -210,8 +210,8 @@ class Logics:
|
|||||||
premium = order.premium
|
premium = order.premium
|
||||||
price = exchange_rate * (1 + float(premium) / 100)
|
price = exchange_rate * (1 + float(premium) / 100)
|
||||||
else:
|
else:
|
||||||
order_rate = float(
|
amount = order.amount if not order.has_range else order.max_amount
|
||||||
order.amount) / (float(order.satoshis) / 100000000)
|
order_rate = float(amount) / (float(order.satoshis) / 100000000)
|
||||||
premium = order_rate / exchange_rate - 1
|
premium = order_rate / exchange_rate - 1
|
||||||
premium = int(premium * 10000) / 100 # 2 decimals left
|
premium = int(premium * 10000) / 100 # 2 decimals left
|
||||||
price = order_rate
|
price = order_rate
|
||||||
|
|||||||
@ -101,9 +101,11 @@ def compute_premium_percentile(order):
|
|||||||
if len(queryset) <= 1:
|
if len(queryset) <= 1:
|
||||||
return 0.5
|
return 0.5
|
||||||
|
|
||||||
order_rate = float(order.last_satoshis) / float(order.amount)
|
amount = order.amount if not order.has_range else order.max_amount
|
||||||
|
order_rate = float(order.last_satoshis) / float(amount)
|
||||||
rates = []
|
rates = []
|
||||||
for similar_order in queryset:
|
for similar_order in queryset:
|
||||||
|
similar_order_amount = similar_order.amount if not similar_order.has_range else similar_order.max_amount
|
||||||
rates.append(
|
rates.append(
|
||||||
float(similar_order.last_satoshis) / float(similar_order.amount))
|
float(similar_order.last_satoshis) / float(similar_order.amount))
|
||||||
|
|
||||||
|
|||||||
@ -349,6 +349,7 @@ export default class MakerPage extends Component {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip placement="top" enterTouchDelay="0" enterDelay="1000" enterNextDelay="2000" title="Set a fix amount of satoshis">
|
<Tooltip placement="top" enterTouchDelay="0" enterDelay="1000" enterNextDelay="2000" title="Set a fix amount of satoshis">
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
|
disabled={this.state.enableAmountRange}
|
||||||
value="explicit"
|
value="explicit"
|
||||||
control={<Radio color="secondary"/>}
|
control={<Radio color="secondary"/>}
|
||||||
label="Explicit"
|
label="Explicit"
|
||||||
@ -421,7 +422,7 @@ export default class MakerPage extends Component {
|
|||||||
if (this.state.limits == null){
|
if (this.state.limits == null){
|
||||||
var max_amount = null
|
var max_amount = null
|
||||||
}else{
|
}else{
|
||||||
var max_amount = this.state.limits[this.state.currency]['max_amount']
|
var max_amount = this.state.limits[this.state.currency]['max_amount']*(1+this.state.premium/100)
|
||||||
}
|
}
|
||||||
// times 0.98 to allow a bit of margin with respect to the backend minimum
|
// times 0.98 to allow a bit of margin with respect to the backend minimum
|
||||||
return parseFloat(Number(max_amount*0.98).toPrecision(2))
|
return parseFloat(Number(max_amount*0.98).toPrecision(2))
|
||||||
@ -431,7 +432,7 @@ export default class MakerPage extends Component {
|
|||||||
if (this.state.limits == null){
|
if (this.state.limits == null){
|
||||||
var min_amount = null
|
var min_amount = null
|
||||||
}else{
|
}else{
|
||||||
var min_amount = this.state.limits[this.state.currency]['min_amount']
|
var min_amount = this.state.limits[this.state.currency]['min_amount']*(1+this.state.premium/100)
|
||||||
}
|
}
|
||||||
// times 1.1 to allow a bit of margin with respect to the backend minimum
|
// times 1.1 to allow a bit of margin with respect to the backend minimum
|
||||||
return parseFloat(Number(min_amount*1.1).toPrecision(2))
|
return parseFloat(Number(min_amount*1.1).toPrecision(2))
|
||||||
@ -520,7 +521,7 @@ export default class MakerPage extends Component {
|
|||||||
<FormHelperText>
|
<FormHelperText>
|
||||||
<Tooltip enterTouchDelay="0" placement="top" align="center"title={"Let the taker chose an amount within the range"}>
|
<Tooltip enterTouchDelay="0" placement="top" align="center"title={"Let the taker chose an amount within the range"}>
|
||||||
<div align="center" style={{display:'flex',alignItems:'center', flexWrap:'wrap'}}>
|
<div align="center" style={{display:'flex',alignItems:'center', flexWrap:'wrap'}}>
|
||||||
<Checkbox onChange={(e)=>this.setState({enableAmountRange:e.target.checked}) & (e.target.checked ? this.getLimits() : null)}/>
|
<Checkbox onChange={(e)=>this.setState({enableAmountRange:e.target.checked}) & this.handleClickRelative() & (e.target.checked ? this.getLimits() : null)}/>
|
||||||
{this.state.enableAmountRange & this.state.minAmount != null? <this.rangeText/> : "Enable Amount Range"}
|
{this.state.enableAmountRange & this.state.minAmount != null? <this.rangeText/> : "Enable Amount Range"}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user