Skip to content

Luke/dpe 3219 candle api trades integration #187

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

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

lukecaan
Copy link
Member

@lukecaan lukecaan commented May 15, 2025

See associated UI changes in this PR :: https://github.com/drift-labs/protocol-v2-mono/pull/3593

@lukecaan lukecaan marked this pull request as ready for review May 25, 2025 13:28
}

constructor(
marketSymbol: MarketSymbol,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what situation will the initialSubscriber have a different marketSymbol than this argument passed in? if there isn't, will be good to get the marketSymbol from the initialSubscriber instead


this.closeConnection(1000, 'Connection reset');

this.subscribe();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be awaited? otherwise the resetConnectionMutex doesn't have any value I feel

trades: JsonTrade[];
};

export class DataApiWsClient {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this client make use of the MultiplexWebSocket class?

@@ -30,6 +30,7 @@
"watch": "yarn clean && tsc --watch",
"clean": "rm -rf lib",
"test": "npx mocha -r ts-node/register tests/**/*.ts",
"test:": "npx mocha -r ts-node/register",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this incomplete?

}
}

this.subscribeToApi();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel sus about this implementation...

we are subscribing to the API on object creation, but we don't have any information about the subscription from the consumer's POV.

e.g. we do const marketDataApiSubscription = new ApiSubscription(...)

but this code don't know anything about the underlying subscription, whereas we'd usually have something like const subscription = await marketDataApiSubscription.subscribe()

return getCompatibleTradeSubscriptionLookupKey(this.config);
}

get candleSubscriptionsLookupKey() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to document these as "Any candle subscription key that matches this key can use this ApiSubscription"

same for trade

newSubscription.tradeSubscriptionsLookupKey;

const existingTradeSubscription =
this.compatibleTradeSubscriptionLookup.get(tradeSubscriptionLookupKey);
Copy link
Contributor

@ChesterSim ChesterSim Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not obvious to me yet, but why is the first ApiSubscription (because compatibleTradeSubscriptionLookup.get returns the first in the list) expected to be the existing trade subscription? should we not check for all in the list?

constructor(
marketSymbol: MarketSymbol,
resolution: CandleResolution,
env: UIEnv,
Copy link
Contributor

@ChesterSim ChesterSim Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this - can get from initialSubscriber

- * We could more optimally close Subscription A and make Subscriber C use Subscription B
- * We're not doing this for the same of simplicity. In the future we could add this optimisation if it becomes necessary.
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this overall documentation helps a lot, I'd really wished that individual classes and methods are documented too

}
}

get(subscriptionLookupKey: TradeSubscriptionLookupKey): ApiSubscription {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return type should be ApiSubscription | null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants