0

I get a list of the index composition (102 tickers) and I want to find out detailed information about them, but out of 102 queries, no more than 10 are always executed, and the ticker is randomly selected. All requests are executed via retrofit2 using RxJava3. What could be the problem? Here is the ViewModel code:

var price: MutableLiveData<CompanyInfoModel> = MutableLiveData()

    fun getCompanyInfoObserver(): MutableLiveData<CompanyInfoModel> {
        return price
    }

    fun makeApiCall(ticker: String) {
        val retrofitInstance = RetrofitYahooFinanceInstance.getRetrofitInstance().create(RetrofitService::class.java)
        retrofitInstance.getCompanyInfo(ticker)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(getCompanyInfoObserverRx())
    }

    private fun getCompanyInfoObserverRx(): Observer<CompanyInfoModel> {
        return object : Observer<CompanyInfoModel> {
            override fun onComplete() {
                // Hide progress bar
            }

            override fun onError(e: Throwable?) {
                price.postValue(null)
            }

            override fun onNext(t: CompanyInfoModel?) {
                price.postValue(t)
            }

            override fun onSubscribe(d: Disposable?) {
                // Show progress bar
            }
        }
    }

Here is the initialization of the model:

companyInfoModel = ViewModelProvider(this).get(CompanyInfoViewModel::class.java)
        companyInfoModel.getCompanyInfoObserver().observe(this, Observer<CompanyInfoModel> { it ->
            if(it != null) {
                retrieveList(Helper.companyInfoToStock(it))
            }
            else {
                Log.e(TAG, "Error in fetching data")
            }
        })

And here is the request method itself:

fun getCompanyInfo(ticker: String) {
        companyInfoModel.makeApiCall(ticker)
    }
Melowetty
  • 1
  • 1
  • Am I understanding correctly that you're trying to run over 100 http requests simultaneously? Pretty sure you hit API endpoint limits and it declines your queries. – Pawel Mar 24 '21 at 12:57
  • It seems that there should be no limits, but here's what I get from requests that were not processed: https://paste.gg/p/anonymous/3cfeb6fccd804b248948a7d3f1837511 Maybe this problem is related to this? – Melowetty Mar 24 '21 at 13:10

1 Answers1

0

Thank you, Pawel. The problem really turned out to be in the API limit, I changed the provider and everything started working as it should.

Melowetty
  • 1
  • 1