alpacahq / alpacahq/alpaca-py

Add duration parameter to run method in DataStream

Aperta
#492 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
1.5k
Fork
397
Merge medio
1g 16h
PR unite (30g)
6

Descrizione

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe.

I wanted to create a unit test where I track an instrument for a period of time and then stop it to go and check if the data has been processed correctly. However I could only see the keyboard interrupt and I think it would be good to have a parameter where you can allow the instrument to run for a certain amount of time. This could then be used for syncing up with opening hours of the instrument so you're not unnecessarily running a script.

### Describe the solution you'd like.

A simple parameter in the run method that allows you to enter a duration, this could be in the form of a datetime time delta object. You then start two tasks running with the asyncio library, one being the data collection and the other being a timer to check if the duration has been exceeded. The two tasks will then return whichever one finishes first which in this case will be the timer as the other task loops indefinitely.

### Describe an alternate solution.

_No response_

### Anything else? (Additional Context)

_No response_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.