Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust timezone for AV when interval < 1d #4158

Merged
merged 9 commits into from
Feb 8, 2023
Merged

Conversation

hjoaquim
Copy link
Contributor

@hjoaquim hjoaquim commented Feb 7, 2023

Description

How has this been tested?

  • Please describe the tests that you ran to verify your changes.
  • Provide instructions so we can reproduce.
  • Please also list any relevant details for your test configuration.
  • Make sure affected commands still run in terminal
  • Ensure the SDK still works
from openbb_terminal.sdk import openbb
openbb.forex.load(
    from_symbol="EUR", 
    to_symbol="USD", 
    start_date="2020-11-30", 
    end_date="2022-12-01",
    source="AlphaVantage"
)

TODO:

  • Test with an interval < 1d

  • Check any related reports

Checklist:

Others

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.

@hjoaquim hjoaquim requested a review from jmaslek February 7, 2023 13:07
@reviewpad reviewpad bot added the feat XS Extra small feature label Feb 7, 2023
@hjoaquim
Copy link
Contributor Author

hjoaquim commented Feb 7, 2023

@deeleeramone would you please give me a help trying this out?

I don't have access to premium endpoints 😫 :

2023 Feb 07, 13:03 (🦋) /forex/ $ load JPYUSD --source AlphaVantage --interval 15min

Thank you for using Alpha Vantage! This is a premium endpoint. You may subscribe to any of the premium plans at https://www.alphavantage.co/premium/ to instantly unlock all premium endpoints

No historical data loaded.

Make sure you have appropriate access for the 'AlphaVantage' data source and that 'AlphaVantage' supports the requested range.

2023 Feb 07, 13:08 (🦋) /forex/ $

@reviewpad reviewpad bot added feat XL Extra Large feature and removed feat XS Extra small feature labels Feb 7, 2023
@jmaslek
Copy link
Collaborator

jmaslek commented Feb 8, 2023

NOt a bug, but I am noticing that we don't grab adjusted when it is available: https://www.alphavantage.co/documentation/#dailyadj:

Screenshot 2023-02-07 at 7 19 37 PM

Copy link
Collaborator

@jmaslek jmaslek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I uhhhh dont have a premium key either but it works. Its 19:20 locally and that looks like the latest timestamp when it previously was utc

Screenshot 2023-02-07 at 7 22 36 PM

@deeleeramone
Copy link
Contributor

I get no timestamp and some weird column, Date_Id

2023 Feb 07, 19:27 (🦋) /forex/ $ candle --raw

                                         Raw Data                                          
┏━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━┓
┃            ┃ Open  ┃ High  ┃ Low   ┃ Close ┃ Date_Id ┃ Oc_High ┃ Oc_Low ┃ Ma20  ┃ Ma50  ┃
┡━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━┩
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
├────────────┼───────┼───────┼───────┼───────┼─────────┼─────────┼────────┼───────┼───────┤
│ 2023-02-07 │ 0.008 │ 0.008 │ 0.008 │ 0.008 │ 6.000   │ 0.008   │ 0.008  │ 0.008 │ 0.008 │
└────────────┴───────┴───────┴───────┴───────┴─────────┴─────────┴────────┴───────┴───────┘
2023 Feb 07, 19:26 (🦋) /forex/ $ load JPYUSD --source AlphaVantage -i 5min

JPY-USD loaded.

Screenshot 2023-02-07 at 4 28 58 PM

@jmaslek jmaslek self-requested a review February 8, 2023 00:35
Copy link
Collaborator

@jmaslek jmaslek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess not fixed per danglewood

@hjoaquim
Copy link
Contributor Author

hjoaquim commented Feb 8, 2023

Not a bug, but I am noticing that we don't grab adjusted when it is available: https://www.alphavantage.co/documentation/#dailyadj:

Guess those are just for stocks? But indeed, we might want to use it!

@hjoaquim
Copy link
Contributor Author

hjoaquim commented Feb 8, 2023

I get no timestamp and some weird column, Date_Id

I think the default behavior is to not show tz info on the candle --raw?
So we'll need to look to the candle chart itself or export it to a csv:

image

Regarding the column Date_Id, not sure of what it represents or if it's useful - but does not relate with our discussion on the timezone.

@hjoaquim hjoaquim requested a review from jmaslek February 8, 2023 11:32
@hjoaquim
Copy link
Contributor Author

hjoaquim commented Feb 8, 2023

^ regarding my last comment, it seems that Date_Id is then used on stocks_helper.find_tendline

@jmaslek
Copy link
Collaborator

jmaslek commented Feb 8, 2023

I get no timestamp and some weird column, Date_Id

I think the default behavior is to not show tz info on the candle --raw? So we'll need to look to the candle chart itself or export it to a csv:

In qa_view.display_raw we have the following:

df1.index = [x.strftime("%Y-%m-%d") for x in df1.index]

Note this applies to all of our candle functions (doing load -i 1 on stocks then candle raw shows this as well).

The extra columns are because we dont copy the df when we do the prepare candle stuff/

Since the ticket is for tz, this solves it. Can open a new ticket for tz in candle raw

Screenshot 2023-02-08 at 10 07 26 AM

@hjoaquim
Copy link
Contributor Author

hjoaquim commented Feb 8, 2023

Can open a new ticket for tz in candle raw

Agreed. Will be a cool little detail we can add let's say with some flag

@hjoaquim hjoaquim merged commit f2c40d0 into develop Feb 8, 2023
@hjoaquim hjoaquim deleted the hotfix/fix-3883 branch February 8, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat XL Extra Large feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Forex/Load --source AlphaVantage: Timestamp is wrong, five hours ahead of now.
3 participants