mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Fix percentile computing for ranges, fix limit adjusts by premium
This commit is contained in:
parent
0be7bccc0d
commit
dc5f228fce
@ -210,8 +210,8 @@ class Logics:
|
||||
premium = order.premium
|
||||
price = exchange_rate * (1 + float(premium) / 100)
|
||||
else:
|
||||
order_rate = float(
|
||||
order.amount) / (float(order.satoshis) / 100000000)
|
||||
amount = order.amount if not order.has_range else order.max_amount
|
||||
order_rate = float(amount) / (float(order.satoshis) / 100000000)
|
||||
premium = order_rate / exchange_rate - 1
|
||||
premium = int(premium * 10000) / 100 # 2 decimals left
|
||||
price = order_rate
|
||||
|
@ -101,9 +101,11 @@ def compute_premium_percentile(order):
|
||||
if len(queryset) <= 1:
|
||||
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 = []
|
||||
for similar_order in queryset:
|
||||
similar_order_amount = similar_order.amount if not similar_order.has_range else similar_order.max_amount
|
||||
rates.append(
|
||||
float(similar_order.last_satoshis) / float(similar_order.amount))
|
||||
|
||||
|
@ -348,7 +348,8 @@ export default class MakerPage extends Component {
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip placement="top" enterTouchDelay="0" enterDelay="1000" enterNextDelay="2000" title="Set a fix amount of satoshis">
|
||||
<FormControlLabel
|
||||
<FormControlLabel
|
||||
disabled={this.state.enableAmountRange}
|
||||
value="explicit"
|
||||
control={<Radio color="secondary"/>}
|
||||
label="Explicit"
|
||||
@ -421,7 +422,7 @@ export default class MakerPage extends Component {
|
||||
if (this.state.limits == null){
|
||||
var max_amount = null
|
||||
}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
|
||||
return parseFloat(Number(max_amount*0.98).toPrecision(2))
|
||||
@ -431,7 +432,7 @@ export default class MakerPage extends Component {
|
||||
if (this.state.limits == null){
|
||||
var min_amount = null
|
||||
}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
|
||||
return parseFloat(Number(min_amount*1.1).toPrecision(2))
|
||||
@ -520,7 +521,7 @@ export default class MakerPage extends Component {
|
||||
<FormHelperText>
|
||||
<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'}}>
|
||||
<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"}
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user