Yahoo Finance - Historical Intraday Download - download

does anybody know why the code below does not bring data after 16:55hr? The market actually closes at 18:00 in Brazil. This happens for all tickers ending in ".SA" in Yahoo Finance.
import yfinance as yf
data = yf.download("PETR4.SA", group_by="Ticker", period='1mo', interval='5m',prepost = True)
data['ticker'] = "PETR4.SA"
data
Thanks!

This is kind of an interesting question. I checked the code. I've been working with several providers, including Yahoo Finance, and I believe it could be more a "pre definition" on the API than a programming/requisition mistake.
As the stock negotiations at B3 normally take place until 17:00 pm (-3 UTC, São Paulo Timezone), the function is returning the last valid computed value i.e. 16:55 pm.
As an exercise I tried to change the time in-between the data from "5m" to "2m" and I spotted the last value at 16:58 pm (same logic). I don't know how to bypass that.
It appears to be the way it works.

Related

Initialize Variables in Power Automate Flow

I am wondering about power automate flow and I issues I had.
I am trying to set up initialize variables for checking time (european standard time) in my rules.
Expression looks like this -
startOfHour(convertFromUtc(triggerOutputs()?['body/receivedDateTime'],'Central European Standard Time','t'), 't')
Under variables I have condition which (True/Not) like this -
YES - time is greater than 22:30 PM
NO - time is less than 8:00 AM
If condition is true, my e-mail is forwarded to another outlook mailbox.
If not, nothing happened.
But this flow doesn't work :D
Can you help me resolve it ?
Thanks a lot !
First part prtscrn
Second part prtscrn
Given the information provided, I suggest the following:
Get the current time.
Convert it to the desired time zone. You can use the built in function to avoid calculation errors.
Convert only hour and minute to Integer. For example, 14:33 would be 1433.
Compare integers. This is: if time is greater than 2230 and less than 830, then forward email.
The flow might look like this:

Fail to get real time prices from Alpha Vantage API. Prices are one day old

I am trying to get the latest Intraday prices from Alpha Vantage API. Currently it is Friday, 9:16PM Eastern European Time. I am trying to get Tesla stock. Markets are still open. However, The API call returns me yesterday's data only. What could be the problem?
ts = TimeSeries(key='API_KEY', output_format='pandas')
data, meta_data = ts.get_intraday(symbol='TSLA',interval='1min', outputsize='full')
print(data.head(5))
print(meta_data)
1. open 2. high 3. low 4. close 5. volume
date
2020-04-16 16:00:00 746.06 746.830 745.530 745.6800 83342.0
2020-04-16 15:59:00 746.57 746.715 745.090 746.1958 53268.0
2020-04-16 15:58:00 746.90 747.465 746.490 746.6250 36746.0
2020-04-16 15:57:00 747.52 747.760 746.827 747.2147 25910.0
2020-04-16 15:56:00 747.95 747.990 746.800 747.2800 33869.0
{'1. Information': 'Intraday (1min) open, high, low, close prices and volume', '2. Symbol': 'TSLA', '3. Last Refreshed': '2020-04-16 16:00:00', '4. Interval': '1min', '5. Output Size': 'Full size', '6. Time Zone': 'US/Eastern'}
1. open 2. high 3. low 4. close 5. volume EMA
I had the same problem and wasn't able to solve it yet. But in my case only some stocks are not up to date. For example 'IBM' is up to date but 'TSLA' and 'AAPL' not. I also have written an email to the technical support 2 days ago. If I ever get a response with the explanation I will write you. I have checked this not only with the python module also with the direct API call.
My code:
https://github.com/SebNik/TradingBot
I also noticed this and contacted Alpha Vantage. I got this response:
Thank you for reaching out! For Nasdaq-listed securities such as MSFT, the data is refreshed daily at 4:30pm ET on our API platform.
So looks like real-time data is not provided for Nasdaq-listed items. This could be the issue here.

Betfair API output time zone off sometimes

I am laying bets through the Betfair API and noticed something very strange. For some events the time is off on both market and event results.
My account date and time are set to Europe/London. Not that it matters, the API outputs whatever zone it wants anyway, apparently at random (sometimes GMT other times London or whatever other timezone, but the ISO timestamp does not include +0100 or whatever GMT offset), all this despite the fact that my account is set to EU/London.
For example let's take this event Superettan / Jonkopings Sodra v Varnamo
The API output is:
{"event"=>{"id"=>"28836884",
"name"=>"Jonkopings Sodra v Varnamo", "countryCode"=>"SE",
"timezone"=>"GMT", "openDate"=>"2018-08-13T18:00:00.000Z"
}, "marketCount"=>2}
Their website however says the event starts at 17:00 GMT / 18:00 London (now GMT+1).
There are hundreds examples like this. Cannot get anything out of Betfair support, they take days/weeks to reply and when they do they just send some canned message.
Has someone seen this issue before? Or perhaps I am missing something?
Later edit: I had to dump all their market data to reach this conclusion: it appears that when their API says the timezone is GMT the event is actually on London, so GMT+1 right now, and for every other timezone (Eu/London, Perth, US...) the time is actually on GMT. Not sure what's up with that. Still investigating.
All times returned by Betfair are in UTC - that's just the way the API works. They also supply time zones which may or may not be correct. Use the time zones as an indication of the local time of the event. However, the time zones are very "hit and miss", so don't rely on them to be correct. In fact, over time you will notice lots of "data errors" for non-pricing info on Betfair markets. This is just the way it goes. so don't expect them to fix the errors
Event.openDate is documented as "The scheduled start date and time of the event. This is Europe/London (GMT) by default" while Event.timezone is defined as "[the] timezone in which the event is taking place."
So, in one sense, the openDate in your API output is correct because it says 18:00. However, it's incorrect because it includes the Zulu 'Z' suffix indicating GMT / UTC. The inclusion of 'GMT' in the timezone field: a) is wrong; and b) just serves to confuse matters, IMHO.
Instead, I've started to use MarketCatalogue.marketStartTime which is defined as "The time this market starts at..." which isn't quite the same as openDate but, if they're going to be different, usually on Betfair you're more interested in when the market goes in-play than when the actual match / race / game begins.
The Events I'm using to validate this approach seem to work better this way. Bearing in mind that the UK moves from BST on 27 October to GMT on 28 October, from the API I'm receiving these as MarketCatalogue.marketStartTime:
Liverpool v Cardiff: "2018-10-27T14:00:00.000Z" [Correct: 14:00 GMT is 15:00 BST]
F1 Mexico Grand Prix [qualifying]: "2018-10-27T18:00:00.000Z" [Correct: 18:00 BST is 19:00 GMT]
Burnley v Chelsea: "2018-10-28T13:30:00.000Z" [Correct: 13:30 GMT is 13:30 GMT]

How to get latest updated record from sys_user table which is modified at or after certain time stamp in ServiceNow

I want to fetch record from the sys_user table which is updated at or after certain time stamp.
for that I have created rest request as
https:/service-now.com/api/now/v1//table/sys_user?sysparm_query=sys_updated_on>=javascript:gs.dateGenerate('2017-10-30','01:25:00')
I had converted current time which is in IST format into GMT and pass it to dateGenerate() function.
Problem statement -
I don't want to convert the IST to GMT, is there any way by which i can identify ServiceNow instance time zone at runtime and convert given time into that time stamp and get the users.
If i can pass this date and time in UTC format.
Ahoy!
This is a great question, and something that's quite difficult in ServiceNow (dealing with time-zones).
As such, I've written a tool to manage this for you. It's totally free!
The tool is called TimeZoneUtil, and can be found here:
https://snprotips.com/blog/2017/9/12/handling-timezones-in-servicenow-timezoneutil
You simply need to initialize a GlideDateTime object, set its' time-zone to IST, use setDisplayValue() to set its' time based on IST current time, then use .getValue() to get that same time in system time.
This is because getDisplayValue()/setDisplayValue() work based on time-zone, whereas setValue()/getValue() always return the corresponding system time.
EDIT: In order to make this a little more clear, I'll provide some example usage below.
var tz = new TimeZoneUtils(); //initialize with current time
gs.print(tz.getOffsetHours()); //prints out "-7" in my instance, as the system time is in Pacific.
tz.setTimeZone('Asia/Kolkata'); //sets the time-zone to IST/UTC+5.5
gs.print(tz.getOffsetHours()); //prints "5.5".
gs.print(tz.getGDT().getDisplayValue()); //Prints the current time in IST (2017-11-01 20:52:31 at the moment).
gs.print(tz.getGDT().getValue()); //Prints the current time in system time (2017-11-01 15:23:12 at present).
gs.print(new TimeZoneUtils().setTimeZone('Asia/Kolkata').getDisplayValue()); //Single line, also prints current time in IST: 2017-11-01 20:52:31
The first 6 lines there, demonstrate basic usage and explain how it works.
The eighth line however, demonstrates usage on a single line, which you can use inside a query string. For example:
sysparm_query=sys_updated_on>=javascript:new TimeZoneUtils().setTimeZone('Asia/Kolkata').getDisplayValue()
Hope this helps!
Tim Woodruff
Author, Learning ServiceNow & Building Powerful Workflows
Owner/Founder, SN Pro Tips

How to get rid of reminder time issue in slack?

I am currently using slack, it’s a great team work tool. I have one issue though: when I create a remind say, /remind me “abc” at night, it sets the reminding time as 3pm. but this is not night, i would like to have 6pm, or better I can set it myself (i.e., set tonight as 6pm). How can I achieve this? - btw, i live in US west coast
You can use the time itself or a relative time:
/remind me "abc" at 6pm CST
/remind me "123" tomorrow night at 8pm CST
/remind me "youandme" 5 hours from now
You can also set your timezone data by exploring the /tz command
You can set it on the account level by following the instructions here.

Resources