Investments interfaces

12 posts
Re: Investments interfaces

Nikolay
MMEX Developer

Posts: 2250
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
ecb sample

Code: Select all
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
<gesmes:subject>Reference rates</gesmes:subject>
<gesmes:Sender>
<gesmes:name>European Central Bank</gesmes:name>
</gesmes:Sender>
<Cube>
<Cube time="2016-01-12">
<Cube currency="USD" rate="1.0836"/>
<Cube currency="JPY" rate="127.79"/>
<Cube currency="BGN" rate="1.9558"/>
<Cube currency="CZK" rate="27.021"/>
<Cube currency="DKK" rate="7.4612"/>
<Cube currency="GBP" rate="0.7508"/>
<Cube currency="HUF" rate="317.75"/>
<Cube currency="PLN" rate="4.3568"/>
<Cube currency="RON" rate="4.5333"/>
<Cube currency="SEK" rate="9.2483"/>
<Cube currency="CHF" rate="1.0855"/>
<Cube currency="NOK" rate="9.6388"/>
<Cube currency="HRK" rate="7.6672"/>
<Cube currency="RUB" rate="82.6895"/>
<Cube currency="TRY" rate="3.2842"/>
<Cube currency="AUD" rate="1.546"/>
<Cube currency="BRL" rate="4.3704"/>
<Cube currency="CAD" rate="1.537"/>
<Cube currency="CNY" rate="7.1276"/>
<Cube currency="HKD" rate="8.4094"/>
<Cube currency="IDR" rate="14965.6"/>
<Cube currency="ILS" rate="4.2711"/>
<Cube currency="INR" rate="72.4603"/>
<Cube currency="KRW" rate="1308.87"/>
<Cube currency="MXN" rate="19.2772"/>
<Cube currency="MYR" rate="4.783"/>
<Cube currency="NZD" rate="1.6547"/>
<Cube currency="PHP" rate="51.296"/>
<Cube currency="SGD" rate="1.557"/>
<Cube currency="THB" rate="39.368"/>
<Cube currency="ZAR" rate="17.9737"/>
</Cube>
Re: Investments interfaces

Nikolay
MMEX Developer

Posts: 2250
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
Request
Code: Select all
http://query.yahooapis.com/v1/public/yql?q=SELECT * FROM yahoo.finance.historicaldata WHERE symbol in('RUB=X') AND startDate='2015-01-01' AND endDate='2016-01-01'&format=xml&env=store://datatables.org/alltableswithkeys


XML (fragment)
Code: Select all
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="261" yahoo:created="2016-01-13T07:04:17Z" yahoo:lang="ru-RU">
<results>
<quote Symbol="RUB%3dX">
<Date>2016-01-01</Date>
<Open>73.815</Open>
<High>73.815</High>
<Low>73.40</Low>
<Close>73.23</Close>
<Volume>000</Volume>
<Adj_Close>73.23</Adj_Close>
</quote>
<quote Symbol="RUB%3dX">
<Date>2015-12-31</Date>
<Open>73.815</Open>
<High>73.815</High>
<Low>73.41</Low>
<Close>73.23</Close>
<Volume>000</Volume>
<Adj_Close>73.23</Adj_Close>
</quote>


Parser

Code: Select all
bool mmMainCurrencyDialog::HistoryDownloadBce()
{
    wxString XmlContent;
    const wxString l = "http://query.yahooapis.com/v1/public/yql?q=SELECT * FROM yahoo.finance.historicaldata WHERE symbol in('RUB=X') AND startDate='2015-01-01' AND endDate='2016-01-01'&format=xml&env=store://datatables.org/alltableswithkeys";
    if (site_content(l, XmlContent) != wxURL_NOERR)
            return false;
    wxStringInputStream XmlContentStream(XmlContent);
    wxXmlDocument XmlDocument;
    if (!XmlDocument.Load(XmlContentStream))
        return false;
    if (XmlDocument.GetRoot()->GetName() != "query")
        return false;
    wxXmlNode* XmlRoot = XmlDocument.GetRoot()->GetChildren();
    while (XmlRoot->GetName() != "results")
        XmlRoot = XmlRoot->GetNext();
    if (XmlRoot->GetName() != "results")
        return false;
    wxDateTime HistoryDate;
    XmlRoot = XmlRoot->GetChildren(); //Go inside <Cube>
    while (XmlRoot) //<Cube time="2015-07-03">
    {
        wxXmlNode* XmlRate = XmlRoot->GetChildren();
        CurrencyHistoryRate CurrencyHistory;
        CurrencyHistory.BaseCurrency = "EUR";
        CurrencyHistory.Currency = XmlRoot->GetAttribute("Symbol").Mid(0, 3);;
        while (XmlRate) //<Cube currency="USD" rate="1.1096"/>
        {
            HistoryDate.ParseDate(XmlRate->GetAttribute("Date"));
            wxLogDebug("Name:%s | %s", XmlRate->GetName(), XmlRate->GetNodeContent());
            const wxString value = XmlRate->GetNodeContent();
            const wxString name = XmlRate->GetName();
            if (name == "Date")
                CurrencyHistory.Date.ParseDate(value);
            else if (name == "Close")
               value.ToDouble(&CurrencyHistory.Rate);
            else if (name == "Adj_Close")
                _BceCurrencyHistoryRatesList.push_back(CurrencyHistory);
            XmlRate = XmlRate->GetNext();
        }
        XmlRoot = XmlRoot->GetNext();
    }
    if (_BceCurrencyHistoryRatesList.size() == 0)
        return false;
    return true;
}
Who is online

Users browsing this forum: No registered users and 1 guest