add taxes

This commit is contained in:
2023-10-02 09:52:11 +02:00
parent 0026cba23d
commit 2b513a91b0
8 changed files with 54 additions and 7 deletions
+12
View File
@@ -0,0 +1,12 @@
import { useLocalStorage } from "@vueuse/core";
import { defineStore } from "pinia";
export const useMarketTaxStore = defineStore("marketTax", () => {
const brokerFee = useLocalStorage("market-brokerFee", 1.5);
const scc = useLocalStorage("market-scc", 3.6);
const applyTaxes = (price: number, sellOrder?: boolean) => sellOrder ? price * (1 - (brokerFee.value + scc.value) / 100) : price * (1 + brokerFee.value / 100);
const calculateProfit = (buy: number, sell: number) => (applyTaxes(sell, true) / applyTaxes(buy)) - 1;
return { brokerFee, scc, applyTaxes, calculateProfit };
});