Closed BigDaddyBastonkadonkz closed 2 years ago
Try and adjust the count parameter... the return amount is set to 1 by default.
get_options_bars(derivativeId=None, interval='1m', count=1, direction=1, timeStamp=None) method of webull.webull.webull instance
get bars returns a pandas dataframe
params:
derivativeId: to be obtained from option chain, eg option_chain[0]['call']['tickerId']
interval: 1m, 5m, 30m, 60m, 1d
count: number of bars to return
direction: 1 ignores {count} parameter & returns all bars on and after timestamp
setting any other value will ignore timestamp & return latest {count} bars
timeStamp: If epoc timestamp is provided, return bar count up to timestamp. If not set default to current time.
If after hours, you have to include a timestamp to get a response.
>>> wb.get_options_bars(wb.get_options('AAPL')[-18]['call']['tickerId'], count=800, timeStamp=0).shape
(500, 6)
open high low close volume vwap
timestamp
2021-08-24 11:17:00-04:00 4.09 4.09 4.08 4.08 40.0 4.453094
2021-08-24 11:19:00-04:00 4.20 4.25 4.20 4.25 70.0 4.433309
2021-08-24 11:27:00-04:00 4.00 4.00 4.00 4.00 4.0 4.431171
2021-08-24 11:28:00-04:00 4.06 4.06 4.06 4.06 10.0 4.426650
2021-08-24 11:30:00-04:00 3.82 3.90 3.82 3.90 2.0 4.425273
... ... ... ... ... ... ...
2021-08-26 15:55:00-04:00 1.97 1.97 1.89 1.89 231.0 2.318267
2021-08-26 15:57:00-04:00 1.91 1.91 1.90 1.90 6.0 2.317484
2021-08-26 15:58:00-04:00 1.89 1.89 1.88 1.88 10.0 2.316145
2021-08-26 15:59:00-04:00 1.85 1.85 1.80 1.80 36.0 2.310420
2021-08-26 16:00:00-04:00 1.79 1.79 1.78 1.79 168.0 2.284581
[500 rows x 6 columns]
Try and adjust the count parameter... the return amount is set to 1 by default.
That's what I'm doing as a workaround, but I wanted to use the direction=1 feature to grab all bars after a timestamp. I suppose I could just set a number so high that it never hits it, but my preference is always to be intentional about the variable I specify. Cleaner code, and all.
it's just a matter of which use case you optimize for. I think count=1 by default because the most common use case is fetching the most recent bar when trying to figure how to price a trade. I wouldn't consider having to specify an intended parameter a "workaround". But, your use case is one I have quite often. A tip: the max number of bars the API will ever return in 1 request is 800. So when I'm pulling all the options data from a contract, I always set count to 800 and loop (repeating the API call) until it returns less than 800, updating the timestamp each time.
When I invoke get-options_bars with direction=1, it's supposed to return all data on or after the specified epoch date. However, it is only returning the last data point.