Pre Market/1st Min vol
ia601321
Posts: 1
Hey all,
f rom cloudquant.interfaces import Strategy
class Furdong(Strategy):
@classmethod
def is_symbol_qualified(cls, symbol, md, service, account):
return md.stat.avol > 1000
def on_start(self, md, order, service, account):
if md.stat.prev_close == 0 or md.L1.last < 1:
return
service.add_time_trigger(md.market_close_time)
def on_finish(self, md, order, service, account):
if md.L1.acc_volume < 5000000 or md.L1.last < 1:
return
gap = round(((md.L1.open - md.stat.prev_close) / md.stat.prev_close) * 100, 3)
if gap > 30.0:
s = service.time_to_string(service.system_time, format="%Y-%m-%d") + ',' + self.symbol + ',' + str(gap) + ','
service.write_file('results', s)
**Heres my script so far, its just to collect data, how would I get it to also print the pre market volume, and after hours volume on the previous day? A long side the date/symbol/gap %.
This is how it looks so far as an example: 2020-07-31,APDN,49.828, and I would like it to be: 2020-07-31,APDN,49.828, (PM Vol), (AH vol (prev working day)
Any help is appreciated!
Thanks!**
Comments
From docs
https://app.cloudquant.com/#/glossary/133
start
May be a negative integer as a reference to now (e.g. -10 ... 10 bars ago), or a specific timestamp.
Negative integer. This represents 'bars back from now'.
Timestamp. Usually computed by service.time() or service.time_interval().
So you can give it a timestamp.
https://app.cloudquant.com/#/glossary/146
service.get_market_hours(-1)
returns a tuple of the open and close timestamp for the previous trading day.
service.time_interval(h,m,s,ms) # converts hours mins seconds millis into millis for time mathematics.
So you can take the close time and add a few hours, take the open time and subtract a few hours...
So something like this can get you closer to what you want to do...