21jake/Binance-volatility-trading-bot-JS

Bad string type in sold-assets.json

Closed this issue · 2 comments

  • The sell_at key is returned as a text when it should be numeric
  • The profit key is a text with the % symbol. Should this be a simple numeric and leave the text formatting to the front end

This is a sold-assets.json

[
    {
        "symbol": "XRPUSDT",
        "quantity": 23.4,
        "orderId": 8106,
        "bought_at": 0.98,
        "TP_Threshold": 1.113,
        "SL_Threshold": 1.0185,
        "purchase_time": "5/19/2021, 1:54:53 PM",
        "updated_at": "5/19/2021, 1:57:40 PM",
        "sell_time": "5/19/2021, 1:58:43 PM",
        "sell_at": 1.01,
        "profit": "3.06%"
    }
]

The sell_at key is numeric by default, don't really know why you got it as string type. Anyway I coerced its type just to make sure.
The profit key is formatted with the "%" on purpose, so users can easily see the profit in percentage without extra calculation. I believe the front end could easily calculate the value with the bought_at and sell_at value.

Good point on the profit percentage. Easy enough to work around. The sell_at being numeric I'll confirm once I fire up the script again today.