Serving the Quantitative Finance Community

 
User avatar
tagoma
Topic Author
Posts: 18794
Joined: February 21st, 2010, 12:58 pm

on running code today at a specific time

June 23rd, 2021, 8:06 pm

Easy question. In pseudocode/from a conceptual/logics perspective what is an appropriate/elegant way to launch a function (python, C++, ...) at say 07:00am today (we don't care about timezone)?  I mean something like:
if time == 07:00am:
    foo()
doesn't seem quite OK.
An actual use case may be along: the script is launched and it waits for a specific time to start all the machinery that downloads data from a webpage updated at that specific time (minus a small time delta).. 
Thank you for your suggestions.
 
User avatar
bearish
Posts: 6638
Joined: February 3rd, 2011, 2:19 pm

Re: on running code today at a specific time

June 23rd, 2021, 9:37 pm

I’d probably use scheduled tasks (Windows) or cron (Linux). I don’t think you want to do it inside your code. But I’m not an expert.
 
User avatar
katastrofa
Posts: 10257
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

Re: on running code today at a specific time

June 23rd, 2021, 9:51 pm

 
User avatar
Cuchulainn
Posts: 65000
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

Re: on running code today at a specific time

June 23rd, 2021, 10:22 pm

Python, the insatiable gas guzzler

https://pypi.org/project/pyJoules/
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
tagoma
Topic Author
Posts: 18794
Joined: February 21st, 2010, 12:58 pm

Re: on running code today at a specific time

June 24th, 2021, 7:51 pm

thank you friends for your suggestions.
Bearish. OK. on Windows they have VisualCron.
kata i didn't know the schedule library.
Cuch. I don't quite get your answer.

Anyways I would really have been interested on learning from you guys what is appropriate for "when it is that time, call that function", in programming logics.
 
User avatar
katastrofa
Posts: 10257
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

Re: on running code today at a specific time

June 29th, 2021, 6:50 pm

Scheduling algorithm design is the whole branch of computer science, but you are asking how to simply "phrase" a very basic schedule in pseudocode language?
IF scheduling instant t:
   THEN launch nuclear strike
 
User avatar
Cuchulainn
Posts: 65000
Joined: July 16th, 2004, 7:38 am
Location: Drosophila melanogaster
Contact:

Re: on running code today at a specific time

June 29th, 2021, 8:10 pm

On toy computers a nuclear strike with Python is whaahy. In the good old 1970s IBM days even humble programmers has a virtual machine with JCL

https://en.wikipedia.org/wiki/Job_Control_Language

I did an AI search and found this

https://pypi.org/project/jobcontrol/

Who knows?
"Compatibility means deliberately repeating other people's mistakes."
David Wheeler

http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
tagoma
Topic Author
Posts: 18794
Joined: February 21st, 2010, 12:58 pm

Re: on running code today at a specific time

July 31st, 2021, 10:10 pm

hello. thank you friends for your additional questions/comments/suggestions.
yes, kata it is exactly what i'm after.