Skip to content

Commit

Permalink
Merge pull request #193 from tradingstrategy-ai/guard-tokensniffer-tax
Browse files Browse the repository at this point in the history
Add guard for tokensniffer data
  • Loading branch information
hieuh25 authored Jan 5, 2025
2 parents 689b08c + 5db9194 commit 75e2915
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tradingstrategy/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ def get_buy_tax(self, epsilon=0.0001, rounding=4) -> float | None:

if not self.has_tax_data():
return None

raw_buy_fee = self.token_sniffer_data["swap_simulation"].get("buy_fee")
if raw_buy_fee is None:
return None

fee = float(self.token_sniffer_data["swap_simulation"]["buy_fee"]) / 100
fee = float(raw_buy_fee) / 100
if fee < epsilon:
return 0
return round(fee, rounding)
Expand All @@ -246,8 +250,12 @@ def get_sell_tax(self, epsilon=0.0001, rounding=4) -> float | None:

if not self.has_tax_data():
return None

raw_sell_fee = self.token_sniffer_data["swap_simulation"].get("sell_fee")
if raw_sell_fee is None:
return None

fee = float(self.token_sniffer_data["swap_simulation"]["sell_fee"]) / 100
fee = float(raw_sell_fee) / 100
if fee < epsilon:
return 0
return round(fee, rounding)
Expand Down

0 comments on commit 75e2915

Please sign in to comment.