# Is there a bug in package Market Data?

**URL:** <https://discourse.julialang.org/t/is-there-a-bug-in-package-market-data/77751>\
**Category:** General Usage\
**Tags:** bug\
**Created:** [March 11, 2022, 2:10pm UTC](https://discourse.julialang.org/t/is-there-a-bug-in-package-market-data/77751 "2022-03-11T14:10:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [March 11, 2022, 2:10pm UTC](https://discourse.julialang.org/t/is-there-a-bug-in-package-market-data/77751/1 "2022-03-11T14:10:25Z")

</div>

Maybe the package MarketData has a small bug. I ran the following:

```julia
using Dates, DataFrames, MarketData
DataFrame(yahoo("^GSPC"))

```

The result is a dataframe with the last line duplicated. This is what is printed on the screen after running the code above:

```julia
12887×7 DataFrame
   Row │ timestamp Open High Low Close AdjClose Volume ⋯
       │ Date Float64 Float64 Float64 Float64 Float64 Float64 ⋯
───────┼─────────────────────────────────────────────────────────────────────
     1 │ 1971-02-08 0.0 98.04 96.13 97.45 97.45 2.559e7 ⋯
     2 │ 1971-02-09 0.0 98.5 96.9 97.51 97.51 2.825e7   
     3 │ 1971-02-10 0.0 97.97 96.23 97.39 97.39 1.904e7   
     4 │ 1971-02-11 0.0 98.49 96.99 97.91 97.91 1.926e7   
     5 │ 1971-02-12 0.0 98.96 97.56 98.43 98.43 1.847e7 ⋯
     6 │ 1971-02-16 0.0 99.59 97.85 98.66 98.66 2.135e7   
     7 │ 1971-02-17 0.0 99.32 97.32 98.2 98.2 1.872e7   
     8 │ 1971-02-18 0.0 98.6 96.96 97.56 97.56 1.665e7   
   ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋱
 12880 │ 2022-03-02 4322.56 4401.48 4322.56 4386.54 4386.54 4.40909e ⋯
 12881 │ 2022-03-03 4401.31 4416.78 4345.56 4363.49 4363.49 4.06208e  
 12882 │ 2022-03-04 4342.12 4342.12 4284.98 4328.87 4328.87 4.55825e  
 12883 │ 2022-03-07 4327.01 4327.01 4199.85 4201.09 4201.09 5.50633e  
 12884 │ 2022-03-08 4202.66 4276.94 4157.87 4170.7 4170.7 6.237e9 ⋯
 12885 │ 2022-03-09 4223.1 4299.4 4223.1 4277.88 4277.88 4.22018e  
 12886 │ 2022-03-10 4252.55 4268.28 4209.8 4259.52 4259.52 4.00869e  
 12887 │ 2022-03-10 4252.55 4268.28 4209.8 4259.52 4259.52 2.58114e  
                                              1 column and 12871 rows omitted

```

The last line, for March 10, 2022, is duplicated. Am I missing something or is this a bug?

Thanks.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [March 11, 2022, 2:25pm UTC](https://discourse.julialang.org/t/is-there-a-bug-in-package-market-data/77751/2 "2022-03-11T14:25:03Z")

</div>

Not a bug, but not certain what it is. You see it is also displayed on the website: [S&P 500 (^GSPC) Historical Data - Yahoo Finance](https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC)

Perhaps they are reporting after-market volume this way?

EDIT: Market is now open and that line is gone, so perhaps it was something related to overnight volume (volume was the only field that was different). Or maybe it is a bug – just at Yahoo

---

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [March 11, 2022, 2:31pm UTC](https://discourse.julialang.org/t/is-there-a-bug-in-package-market-data/77751/3 "2022-03-11T14:31:58Z")

</div>

Yes. If one is not interested in the Volume column then after removing it the problem can be fixed using `unique`.

```julia
DataFrame(yahoo("^GSPC"))[:, [:timestamp, :AdjClose]] |>
unique
12886×2 DataFrame
   Row │ timestamp AdjClose 
       │ Date Float64
───────┼──────────────────────
     1 │ 1971-02-08 97.45
     2 │ 1971-02-09 97.51
     3 │ 1971-02-10 97.39
     4 │ 1971-02-11 97.91
     5 │ 1971-02-12 98.43
     6 │ 1971-02-16 98.66
     7 │ 1971-02-17 98.2
     8 │ 1971-02-18 97.56
   ⋮ │ ⋮ ⋮
 12879 │ 2022-03-01 4306.26
 12880 │ 2022-03-02 4386.54
 12881 │ 2022-03-03 4363.49
 12882 │ 2022-03-04 4328.87
 12883 │ 2022-03-07 4201.09
 12884 │ 2022-03-08 4170.7
 12885 │ 2022-03-09 4277.88
 12886 │ 2022-03-10 4259.52
            12870 rows omitted

```

If one is interested in the volume then a better understanding of the data is needed before taking action.
