[Simplified API] PositionListener Issue in v7.1.0 build:7

Custom indicators, trading strategies, data export and recording and more...
Gregory
Posts: 9
Joined: Thu Apr 11, 2019 10:13 pm
Has thanked: 4 times

[Simplified API] PositionListener Issue in v7.1.0 build:7

Post by Gregory » Thu Apr 25, 2019 3:38 pm

Bookmap version 7.1.0 build:7

After thorough testing, I have concluded that the PositionListener isn't being called. This can be confirmed by running OrdersDemoNoHistory.java in the DemoStrategies repo here:

Code: Select all

https://raw.githubusercontent.com/BookmapAPI/DemoStrategies/8980c39106f57926559b6ac74e27b1f1b25312b9/Strategies/src/main/java/velox/api/layer1/simplified/demo/OrdersDemoNoHistory.java

https://github.com/BookmapAPI/DemoStrategies
Orders are executed, however onPositionUpdate never seems to be called. How else can we poll the system for positions? Is there a similar method to poll for orders, aside from verifying them as them populate onOrderUpdated?

Thanks,
Greg

AndreyR
Posts: 274
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 14 times
Been thanked: 49 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by AndreyR » Fri Apr 26, 2019 8:54 am

Hi Gregory,
was that live or replay mode? We've been solving the issue with position listener in the replay mode but the live mode must be working.

Gregory
Posts: 9
Joined: Thu Apr 11, 2019 10:13 pm
Has thanked: 4 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by Gregory » Fri Apr 26, 2019 1:48 pm

We're talking about replay mode. Is there another way during replay to poll the system for positions? Also is there a similar method to poll for orders, aside from verifying them as them populate onOrderUpdated?

AndreyR
Posts: 274
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 14 times
Been thanked: 49 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by AndreyR » Fri Apr 26, 2019 6:44 pm

Yes, there is, but not within the Simplified API.
Please take a look at "AveragePrice" from DemoStrategies, class Layer1ApiAveragePositionPriceDemo.
There is an object dataStructureInterface you can get a list of TreeResponseInterval-s from.
The 0-th element of the list will be a collection of aggregated events which happened no later than t0 moment;
enery n-th element (assumed n > 0) will be an aggregation of events from (t0 + n * intervalWidth) moment to (t0 + (n - 1) * intervalWidth) moment.
Take a look at CaclulateValuesInRange method as an example of getting a list of orders.
As soon as you get a list of orders, you're able to calculate your position based on orders' status.

IAMMYSELF
Posts: 5
Joined: Thu Aug 13, 2020 6:09 pm

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by IAMMYSELF » Thu Aug 13, 2020 6:15 pm

Hi AndreyR,
it seems that the issue about the PositionListener is still here!

Have you news about it?

thank you...
 

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

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by Svyatoslav » Fri Aug 14, 2020 8:29 am

Hi. We don't currently provide position info or balance in replay and client-side simulated trading mode. We are planning to improve the simulator at some point, but currently it's not done.

IAMMYSELF
Posts: 5
Joined: Thu Aug 13, 2020 6:09 pm

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by IAMMYSELF » Sun Aug 16, 2020 8:11 am

I am not in replay mode but in real time mode....however the trading mode is simulated...

So, is it working only in real time and real account trading, right?

thank you for your response

AndreyR
Posts: 274
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 14 times
Been thanked: 49 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by AndreyR » Mon Aug 17, 2020 1:11 pm

Right. It will be fixed but the date has not been set yet.

blk
Posts: 19
Joined: Fri Nov 01, 2019 8:59 pm
Has thanked: 2 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by blk » Wed Aug 19, 2020 12:41 pm

Is there a way to know (using the API) if you are on Live or Sim/Replay? That way we can workaround this issue using an internal "Position Listener" based on what is executed after the code/addon is loaded.

AndreyR
Posts: 274
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 14 times
Been thanked: 49 times

Re: [Simplified API] PositionListener Issue in v7.1.0 build:7

Post by AndreyR » Fri Aug 21, 2020 11:24 am

hi blk! No way to detect sim mode at the moment. You can figure out Live or Replay by comparing current and provider timestamps.
1) get provier time:
- (for Simplified Api) implement TimeListener, override onTimestamp method

Code: Select all

    @Override
    public void onTimestamp(long t) {
- (for non-simplified) get time from provider

Code: Select all

long t = provider.getCurrentTime();
2) subtract provider time from current nano time

Code: Select all

long a = NanoClock.currentTimeNanos();
Log.info("" + (a - t));
For Live data the result will typically be around 1 * 10^6 (nanos) but it depends. For Replay it will be significantly greater.

Post Reply