Is it possible to use OnlineCalculatable with Simplified API?

Custom indicators, trading strategies, data export and recording and more...
blk
Posts: 44
Joined: Fri Nov 01, 2019 8:59 pm
Has thanked: 7 times

Is it possible to use OnlineCalculatable with Simplified API?

Post by blk » Thu Jun 25, 2020 6:00 pm

Hi All,

Is it possible to use OnlineCalculatable with Simplified API?

If possible do you have any examples?

Thanks

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: Is it possible to use OnlineCalculatable with Simplified API?

Post by Svyatoslav » Fri Jun 26, 2020 8:40 am

Hi,
Well... It's not something we tested, but it technically should work. Before we proceed I'd like to point out that you should be able to use simplified API to achieve the same end results in most cases, so make sure you really need OnlineCalculatable.

Now, if you still believe you do (e.g. have an external data source that provides data in chunks or some other reasons, like if you want to store data yourself in some data structure optimized for your use case), let's continue. Since you register OnlineCalculatable by sending a message to Bookmap (see examples for core API, e.g. https://github.com/BookmapAPI/DemoStrat ... sDemo.java) you should be able to do the same via simplified API Api#sendUserMessage method - it's just a proxy that sends your message directly to provider, so it's similar to provider.sendUserMessage from the core API. You might also be able to register generators and retrieve DataStructureInterface in the same way (potentially allowing you to avoid receiving historical data via simplified API and manage it yourself).
The main thing to watch out for is that for things that have names those should be unique - remember that this functionality isn't really aware of the simplified wrapper so, while wrapper provides you per-instrument instances, it's not a concept that core API is even aware off - to it all instances of your simplified API module (e.g. one for ES and one for NQ) look like part of the same module (because they are - simplified API loads as 1 module per indicator entry point and then creates per-instrument instances internally).

While we are at it... If you want to bypass simplified API even further (but don't want to switch to core API for some reasons) you might like Api#getProvider method - that gives you an instance of simplified wrapper, and you can register listeners in it (e.g. if you want to listen to some messages from your L0 module). Keep in mind that you are registering those after module is started, so you'll miss the snapshots, unfortunately, meaning it's not very good for extracting data. But you have tools in simplified API for that anyway, so probably not a big deal.

blk
Posts: 44
Joined: Fri Nov 01, 2019 8:59 pm
Has thanked: 7 times

Re: Is it possible to use OnlineCalculatable with Simplified API?

Post by blk » Sun Jun 28, 2020 2:10 pm

Hi,

thanks so much for your helpful and detailed reply. I will play with the Simplified api methods (sendUserMessage and getProvider).

The main reason I was thinking about using the onlinecalculatable was to extract orders before the addon is loaded (Similar to the Layer1AveragePrice example from github) as the simplified api only allows us to listen to order updates after it is loaded - as far as I know :).

Thanks again.

Post Reply