Fix asset filter
This commit is contained in:
@@ -14,35 +14,43 @@ def get_allowed(group, base, quote, direction):
|
||||
# If our base has allowed == False, we can only short it, or long the quote
|
||||
base_rule = AssetRule.objects.filter(group=group, asset=base).first()
|
||||
if base_rule:
|
||||
if base_rule.status == 6:
|
||||
mapped_status = update_status_from_mappings(base_rule.status, group)
|
||||
if mapped_status == 6:
|
||||
# Always allow
|
||||
return True
|
||||
elif base_rule.status == 7:
|
||||
elif mapped_status == 7:
|
||||
# Always deny
|
||||
return False
|
||||
elif base_rule.status == 3:
|
||||
elif mapped_status == 3:
|
||||
if direction == "long":
|
||||
return False
|
||||
elif base_rule.status == 2:
|
||||
elif mapped_status == 2:
|
||||
if direction == "short":
|
||||
return False
|
||||
|
||||
# If our quote has allowed == False, we can only long it, or short the base
|
||||
quote_rule = AssetRule.objects.filter(group=group, asset=quote).first()
|
||||
if quote_rule:
|
||||
if quote_rule.status == 6:
|
||||
mapped_status = update_status_from_mappings(quote_rule.status, group)
|
||||
if mapped_status == 6:
|
||||
# Always allow
|
||||
return True
|
||||
elif quote_rule.status == 7:
|
||||
elif mapped_status == 7:
|
||||
# Always deny
|
||||
return False
|
||||
elif quote_rule.status == 3:
|
||||
elif mapped_status == 3:
|
||||
if direction == "short":
|
||||
return False
|
||||
elif quote_rule.status == 2:
|
||||
elif mapped_status == 2:
|
||||
if direction == "long":
|
||||
return False
|
||||
|
||||
if not base_rule and not quote_rule:
|
||||
if group.when_no_data == 7:
|
||||
# Always deny
|
||||
return False
|
||||
elif group.when_no_data == 6:
|
||||
# Always allow
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user