Skip to content

Tiingo crypto volume unmarshal error: volume should be float64, not int64Β #352

@whencanibe

Description

@whencanibe

Describe the bug
Fetching crypto data (e.g. btcusd) from Tiingo fails with:

json: cannot unmarshal number 20297.44489644 into Go struct field TiingoEndOfDay.volume of type int64

Stocks have integer volume so this doesn't show up there, but crypto volume can be fractional. Tiingo returns float for crypto pairs.

To Reproduce
Steps to reproduce the behavior:

  1. Run indicator-sync with a Tiingo API key targeting btcusd:

go run ./cmd/indicator-sync
-source-name tiingo
-source-config YOUR_API_KEY
-target-name filesystem
-target-config /tmp/data
btcusd

  1. See error in logs:
    Unable to decode data. error="json: cannot unmarshal number 20297.44489644 into Go struct field TiingoEndOfDay.volume of type int64"

Expected behavior
btcusd data synced to the target repository without error.

Additional context
Volume and AdjVolume in TiingoEndOfDay (tiingo_repository.go:58,73) are int64.
I think changing both to float64 fixes it.

A similar volume type issue was discussed in #126 for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions