-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bybit tickers request endpoint and example strategy #1403
Conversation
super().__init__() | ||
self.interval = config.interval | ||
self.instrument_id = InstrumentId.from_str(config.instrument_id) | ||
self.linear_request_ticker_uuid = UUID4() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each request should have a unique UUID4
, it could cause downstream issues to be hanging onto the request_id
reference and potentially reusing it with several in-flight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this, this demo strategy is not much simpler it uses request_data
and listens on on_historical_method
callback
|
||
def on_data(self, data: DataResponse): | ||
## check generic data response by uuid | ||
if data.correlation_id == self.linear_request_ticker_uuid: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use some other method to know if this is a request ticker response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls check again the new implementation
5396626
to
6d6af21
Compare
2646619
to
6b51269
Compare
5e77731
to
86cdefb
Compare
86cdefb
to
cbc981a
Compare
|
||
|
||
class RequestDemoStrategyConfig(StrategyConfig, frozen=True): | ||
instrument_id: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also type as InstrumentId
now for configs.
return get_env_key("BYBIT_TESTNET_API_KEY") | ||
key = get_env_key("BYBIT_TESTNET_API_KEY") | ||
if not key: | ||
raise ValueError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't get_env_key
raise this exception already if not found?
from nautilus_trader.core.data import Data | ||
|
||
|
||
class BybitTickerData(Data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make this a type of Ticker
, then you don't need to define a custom data type, and data will be returned through the normal Ticker
methods and channels (see Binance for a similar pattern).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where we're initializing ts_init
or ts_event
?
Pull Request
fetch_send_tickers
inBybitDataClient
that uses this endpointbybit.data.tickers
so that strategies and other components can fetch tickers data from Bybit, when requesting it fromrequest_data
methodRequestDemoStrategy
inbybit
examples folder, that showcases the usage of this endpoint and also shows how to wire up the clock timer so that it can fetch data from this endpoint periodicallygenerate_position_status_reports
When running this demo strategy you get printed tickers response for predefined instrument every 10 seconds