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
Ticker no Timestamp #544
Comments
Hi Michele, which release of Cassandre do you use ? |
Hi Stéphane, Thank you. |
Which exchange are you using ? do you have any errors in the logs ? |
I'm using Binance, but seems that the errors is related to TickerDTO equals method. Decompiling code I see this:
so the old code. Thanks, |
@eRfO can you should me the first ticker received in your strategy? |
Yes, I tried to run now and in the console I see:
after this ticker nothing else. |
@eRfO Ok, I will create a binance account and make a test. |
Ok, thank you. |
@eRfO have the same issue ( |
Hi, @eRfO & @Tempys I made a test and it's working. Maybe you should change the release number of XChange in your This is what I set:
It works with my Binance integration test. |
@straumat it also works for me in dry mode but does not work when dry mode is false |
@Tempys it's "normal". In fact, if you ask Cassandre to check tickers every second for example, it does it. But if the server replis with the same value, cassandre will only push data if they are different from the previous one received |
@straumat as you can see, just only one ticker is emitted by the TickerFlux, I'm using BTC/EUR currency pair in my test.
|
Just a question, the above change is in 4.1.1 version? Because in the code of version 4.1.1 I keep seeing the equals method written as follows:
and in the getTimestamp method I seeing this:
so, if the current and previous ticker had null timestamps, the comparison would be made on the same value ZonedDateTime.now(), is correct? Thank you. |
@eRfO If timestamp from the server is null the |
@straumat I tried with the 4.1.2-SNAPSHOT but the result is the same: |
@eRfO @Tempys I made a simple project from my archetype, I setup my test binance account and I received several tickers. Can you take a look if it works for you ? project source |
@straumat, ok, I requested the access to the project source |
@straumat just tried, the result is the same: |
@eRfO you did |
@straumat this is the situation when a ticker is retrieved from binance, the current ticker and the previous one are different but the flux not emit a new ticker to the strategy because both timestamps are null. |
I runned your project with IntelliJ. |
@eRfO can you suppress the tech directory in your .m2 and run |
@straumat is this |
@eRfO It should be... what i don't get is how can the result be different from on my computer and yours... DO you use JDK 11? very strange... maybe we can try to make a live debug tomorrow night on discord?
|
@straumat I'm using JDK 15 but this code
|
@straumat yes, I do. If you try to change the test code with |
@eRfO what do you think I should change ? |
@straumat I think that you should add other fields in TickerDTO |
@eRfO Ok. i will study this solution but I always prefer to reproduce the problem before fixing it. Is it possible for you to run my test project with a JDK11 ? |
@straumat yes, i will do a test with jdk 11, i will let you know. |
@eRfO Hi! maybe I know what's happening. Are you asking a lot of currency pairs? |
@straumat Hi! No, I just asking for one currency pair. Why are you still in doubt about the problem? We have established that the comparison with the |
@eRfO well... before fixing a problem, I always try to reproduce it in a unit test. I think it's not bad practice as that field is mandatory for me and I retrieve it from an external source. |
@straumat I will try with the new version. In the meantime, I prepared a simple test to reproduce the problem. import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tech.cassandre.trading.bot.dto.market.TickerDTO;
import tech.cassandre.trading.bot.dto.util.CurrencyPairDTO;
import java.util.LinkedHashMap;
import java.util.Map;
import static tech.cassandre.trading.bot.dto.util.CurrencyDTO.BTC;
import static tech.cassandre.trading.bot.dto.util.CurrencyDTO.EUR;
public class TickerTimestampTest {
private static Logger logger = LoggerFactory.getLogger(TickerTimestampTest.class);
@Test
public void whenTimestampIsNullTest() throws InterruptedException {
final Map<CurrencyPairDTO, TickerDTO> previousValues = new LinkedHashMap();
int count = 0;
for (int i = 0; i < 100; i++) {
TickerDTO newTicker = TickerDTO.builder().currencyPair(new CurrencyPairDTO(BTC, EUR)).build();
TickerDTO oldTicker = previousValues.get(newTicker.getCurrencyPair());
if (!newTicker.equals(oldTicker)) {
logger.debug("TickerFlux - New ticker received : {}", newTicker);
previousValues.put(newTicker.getCurrencyPair(), newTicker);
} else {
count++;
}
Thread.sleep(100L);
}
logger.info("Count: {}", count);
Assertions.assertEquals(0, count);
}
} this testifies to the non-deterministic nature of the code. |
@straumat I changed the version to |
@eRfO I did not change the equals method yet. But I upgraded lots of libraries (spring, reactor), I set parameters to the schedule threadpools. Now, I will integrate your tests to fix the problem. |
@straumat I understood that @Tempys also had the same problem, he wrote this #544 (comment). You shouldn't be surprised that the same code have different results, is in the nature of non deterministic code, that's the point! |
@eRfO Hi, thanks a lot for the tests. I inserted it in my tests and it never fails on my computer. Does it fail every time on yours? Thanks for the help and sorry for the delay. |
@straumat Hi, yes it fails every time on my computer. |
@eRfO Hi i made a test with JDK14 and it works well. Besides, even if ZonedDatetime.now returns the same value one time, it should not always do that so you should receive, at least, some tickers. Were you able to make another try ? Thanks |
The equals has been removed with issue #585 |
Hi,
when the Ticker returrned by exchange has timestamp field to null, only the first value is posted to the strategy. This happens because the timestamp on the object is null and in the TickerFlux class there is a check on TickerDTO that compare the previuous timestamp with the new one but the getTimestamp method returns now for both instances.
Maybe you could set the timestamp directly in the mapper when the exchange doesn't.
Thanks,
Michele
The text was updated successfully, but these errors were encountered: