waifod / quant_finance_models

Project containing the implementations of quantitative finance models
MIT License
5 stars 1 forks source link

Figure out a way to get real market data using HTTP APIs #30

Closed david-alvarez-rosa closed 11 months ago

david-alvarez-rosa commented 1 year ago

Figure out a way to get real market data using HTTP APIs.

Possibly using something already implemented (finding a C++ library online) — do not reinvent the wheel.

david-alvarez-rosa commented 1 year ago

Pretty interesting this Python library using Yahoo API that we could mimic in C++ https://github.com/pydata/pandas-datareader/blob/main/pandas_datareader/yahoo/options.py

@Waifod, worth a look 👁️

david-alvarez-rosa commented 1 year ago

Just found out that Yahoo finance vends public APIs for options.

curl https://query1.finance.yahoo.com/v7/finance/options/aapl

Returns a nice JSON with all the information needed except the risk-free interest rate, that we will need to get it from another endpoint probably?

david-alvarez-rosa commented 1 year ago

Worth a look this blog / doc for Yahoo Finance API -> https://cryptocointracker.com/yahoo-finance/yahoo-finance-api

waifod commented 1 year ago

Assuming that we do switch to our own cURL-based implementation, what about removing the yahoo-finance module?

david-alvarez-rosa commented 1 year ago

Indeed, good point, we need to remove it.

david-alvarez-rosa commented 1 year ago

Removed yahoo-finance in #64.

david-alvarez-rosa commented 11 months ago

Extract

"bid": 132.74,
"ask": 132.75,

And then, with this provide a quote that is that pair bid & ask.

Then implement methods for retrieving the above values in the MarkeDataProvider

  double GetAssetAskPrice(const asset::AssetTicker& asset) const noexcept;
  double GetAssetBidPrice(const asset::AssetTicker& asset) const noexcept;

For the spot price, it depends on the type of trade. Might be the other way around

if sell -> ask
if buy -> bid

For the asset volatility

double GetAssetVolatility(const asset::AssetTicker& asset) const noexcept;```

we would need to get data of underlying asset price (either closing or opening prices) from the past months, and then compute it manually.

For the interest rate

double GetInterestRate() const noexcept;



we can just hard-coded (set it manually inside the code).  **This is already implemented.**
waifod commented 11 months ago

Tackled by https://github.com/Waifod/quant_finance_models/commit/8f0fc614a0b4a56d9af12650623a190a313dbc0e.