CAFECA-IO / BAIFA

https://baifa.vercel.app
GNU General Public License v3.0
0 stars 0 forks source link

Validate balance sheet with clean data #225

Closed arealclimber closed 11 months ago

arealclimber commented 1 year ago

檢驗到 9/5 16:00

arealclimber commented 1 year ago

https://api.tidebit-defi.com/balance-sheet?date=2023-09-05

{
    "success": true,
    "code": "00000000",
    "reason": "ERROR_MESSAGE.SUCCESS",
    "data": {
        "id": "balance_sheet-1693872000_1693958399",
        "date": "2023-09-04T16:00:00.000Z",
        "assets": {
            "totalAmountFairValue": -2464.337454738,
            "weightedAverageCost": -2464.337454738,
            "details": {
                "accountsReceivable": {
                    "totalAmountFairValue": -2464.337454738,
                    "weightedAverageCost": -2464.337454738,
                    "breakdown": {
                        "USDT": {
                            "name": "USDT",
                            "amount": "1726.57194526199999",
                            "fairValue": "1726.57194526199999"
                        },
                        "ETH": {
                            "name": "ETH",
                            "amount": "-2.24",
                            "fairValue": "-3658.1104"
                        },
                        "BTC": {
                            "name": "BTC",
                            "amount": "-0.02",
                            "fairValue": "-532.799"
                        }
                    }
                },
                "cryptocurrency": {
                    "totalAmountFairValue": 0,
                    "weightedAverageCost": 0,
                    "breakdown": {}
                },
                "cashAndCashEquivalent": {
                    "totalAmountFairValue": 0,
                    "weightedAverageCost": 0,
                    "breakdown": {}
                }
            }
        },
        "nonAssets": {
            "totalAmountFairValue": 0,
            "weightedAverageCost": 0,
            "details": {
                "accountsReceivable": {
                    "totalAmountFairValue": 0,
                    "weightedAverageCost": 0,
                    "breakdown": {}
                },
                "cashAndCashEquivalent": {
                    "totalAmountFairValue": 0,
                    "weightedAverageCost": 0,
                    "breakdown": {}
                }
            }
        },
        "liabilities": {
            "totalAmountFairValue": -2572.547157664,
            "weightedAverageCost": -2572.547157664,
            "details": {
                "accountsPayable": {
                    "totalAmountFairValue": -4039.707157664,
                    "weightedAverageCost": -4039.707157664,
                    "breakdown": {
                        "USDT": {
                            "name": "USDT",
                            "amount": "-4596.982357664",
                            "fairValue": "-4596.982357664"
                        },
                        "ETH": {
                            "name": "ETH",
                            "amount": "1.32",
                            "fairValue": "2155.6722"
                        },
                        "BTC": {
                            "name": "BTC",
                            "amount": "-0.06",
                            "fairValue": "-1598.397"
                        }
                    }
                },
                "userDeposit": {
                    "totalAmountFairValue": 1467.16,
                    "weightedAverageCost": 1467.16,
                    "breakdown": {
                        "USDT": {
                            "name": "USDT",
                            "amount": "1467.16",
                            "fairValue": "1467.16"
                        },
                        "ETH": {
                            "name": "ETH",
                            "amount": "0",
                            "fairValue": "0"
                        },
                        "BTC": {
                            "name": "BTC",
                            "amount": "0",
                            "fairValue": "0"
                        }
                    }
                }
            }
        },
        "equity": {
            "totalAmountFairValue": 27.9951,
            "weightedAverageCost": 27.9951,
            "details": {
                "retainedEarnings": {
                    "totalAmountFairValue": 27.9951,
                    "weightedAverageCost": 27.9951,
                    "breakdown": {
                        "USDT": {
                            "name": "USDT",
                            "amount": "27.9951",
                            "fairValue": "27.9951"
                        },
                        "ETH": {
                            "name": "ETH",
                            "amount": "0",
                            "fairValue": "0"
                        },
                        "BTC": {
                            "name": "BTC",
                            "amount": "0",
                            "fairValue": "0"
                        }
                    }
                },
                "capital": {
                    "totalAmountFairValue": 0,
                    "weightedAverageCost": 0,
                    "breakdown": {}
                }
            }
        }
    }
}
arealclimber commented 1 year ago

驗算方法參考https://github.com/CAFECA-IO/BAIFA/issues/204#issuecomment-1727373991

from API         from DB    
accountsReceivable amount fair value deviation value of amount deviation value of fair value accountsReceivable amount fair value
BTC -0.02 -532.799 1.076923077 1.13451064 BTC 0.26 3961.017519
ETH -2.24 -3658.1104 1.691358025 1.822021926 ETH 3.24 4450.137258
USDT 1726.571945 1726.571945 0.8067609922 0.8067609922 USDT 8934.9038 8934.9038
total -2464.337455   1.142069015 total 17346.05858
               
accountsPayable amount fair value     accountsPayable amount fair value
BTC -0.06 -1598.397 1.375 1.655739368 BTC 0.16 2437.549243
ETH 1.32 2155.6722 0.5147058824 0.4229872353 ETH 2.72 3735.917698
USDT -4596.982358 -4596.982358 1.381827721 1.381827721 USDT 12039.4149 12039.4149
total -4039.707158   1.22180494 total 18212.88184
               
userDeposit amount fair value     userDeposit amount fair value
BTC 0 0     BTC 0 0
ETH 0 0     ETH 0 0
USDT 1467.16 1467.16 0.9479319096 0.9479319096 USDT 28177.71859 28177.71859
total 1467.16   0.9479319096 total 28177.71859
               
retainedEarnings amount fair value     retainedEarnings amount fair value
BTC 0 0     BTC 0 0
ETH 0 0     ETH 0 0
USDT 27.9951 27.9951 0.9964758834 0.9964758834 USDT 7943.86313 7943.86313
total 27.9951   0.9964758834 total 7943.86313