AndrewRademacher / gdax

MIT License
7 stars 1 forks source link

Error in $[0].price: expected Double, encountered String #88

Open PaNaVTEC opened 6 years ago

PaNaVTEC commented 6 years ago

Hi, I am trying to use this sdk to make a simple app but when i try to do:

main = do
  gdax <- createGdax
  fills <- listFills gdax Set.empty Set.empty
  putStrLn $ show fills
  return ()

it throws:

Preprocessing library gdaxPortfolio-0.1.0.0...
Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2: can't find source for GdaxPortfolio
in src, .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/autogen

--  While building package gdaxPortfolio-0.1.0.0 using:
      /home/panavtec/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build lib:gdaxPortfolio exe:gdaxPortfolio --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
gdaxPortfolio: MalformedGdaxResponse "Error in $[0].price: expected Double, encountered String"

I've been investigating the types:

data Fill
  = Fill {_fillTradeId :: ! {-# UNPACK #-}(Network.GDAX.Types.Shared.N:TradeId[0])Network.GDAX.Types.Shared.TradeId,
          _fillProductId :: !Network.GDAX.Types.Shared.ProductId,
          _fillPrice :: {-# UNPACK #-}Double,
          _fillSize :: {-# UNPACK #-}Double,
          _fillOrderId :: !Network.GDAX.Types.Shared.OrderId,
          _fillCreatedAt :: !time-1.6.0.1:Data.Time.Clock.UTC.UTCTime,
          _fillLiquidity :: !Network.GDAX.Types.Shared.Liquidity,
          _fillFee :: {-# UNPACK #-}Double,
          _fillSettled :: !Bool,
          _fillSide :: !Network.GDAX.Types.Shared.Side}
    -- Defined in ‘Network.GDAX.Types.Private’
instance Show Fill -- Defined in ‘Network.GDAX.Types.Private’

But in the API specification the example data is:

[
    {
        "trade_id": 74,
        "product_id": "BTC-USD",
        "price": "10.00",
        "size": "0.01",
        "order_id": "d50ec984-77a8-460a-b958-66f114b0de9b",
        "created_at": "2014-11-07T22:19:28.578544Z",
        "liquidity": "T",
        "fee": "0.00025",
        "settled": true,
        "side": "buy"
    }
]

So I think the types has changed since this has built and is crashing.

Thanks!

CarlosMChica commented 6 years ago

+1