bump quotes api version to 3. Change data type from float to double to

avoid rounding problems
This commit is contained in:
arcan1s 2015-09-21 06:17:43 +03:00
parent d20db1b888
commit 4cc44c1d59
11 changed files with 22 additions and 23 deletions

View File

@ -217,27 +217,27 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
}
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
jsonQuotes = jsonQuotes[QString("results")].toMap()[QString("quote")].toMap();
float value;
double value;
// ask
value = jsonQuotes[QString("Ask")].toString().toFloat();
values[tag(QString("askchg"))] = values[QString("ask")].toFloat() == 0.0 ? 0.0 :
value - values[QString("ask")].toFloat();
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toFloat() / values[QString("ask")].toFloat();
value = jsonQuotes[QString("Ask")].toString().toDouble();
values[tag(QString("askchg"))] = values[QString("ask")].toDouble() == 0.0 ? 0.0 :
value - values[QString("ask")].toDouble();
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toDouble() / values[QString("ask")].toDouble();
values[tag(QString("ask"))] = value;
// bid
value = jsonQuotes[QString("Bid")].toString().toFloat();
values[tag(QString("bidchg"))] = values[QString("bid")].toFloat() == 0.0 ? 0.0 :
value - values[QString("bid")].toFloat();
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toFloat() / values[QString("bid")].toFloat();
value = jsonQuotes[QString("Bid")].toString().toDouble();
values[tag(QString("bidchg"))] = values[QString("bid")].toDouble() == 0.0 ? 0.0 :
value - values[QString("bid")].toDouble();
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toDouble() / values[QString("bid")].toDouble();
values[tag(QString("bid"))] = value;
// last trade
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toFloat();
values[tag(QString("pricechg"))] = values[QString("price")].toFloat() == 0.0 ? 0.0 :
value - values[QString("price")].toFloat();
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toFloat() / values[QString("price")].toFloat();
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toDouble();
values[tag(QString("pricechg"))] = values[QString("price")].toDouble() == 0.0 ? 0.0 :
value - values[QString("price")].toDouble();
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toDouble() / values[QString("price")].toDouble();
values[tag(QString("price"))] = value;
}

View File

@ -18,7 +18,6 @@
#ifndef EXTQUOTES_H
#define EXTQUOTES_H
#include <QMap>
#include <QNetworkReply>
#include "abstractextitem.h"

View File

@ -4,6 +4,6 @@ Name=AAPL.NASDAQ
Comment=Apple Inc
X-AW-Ticker="AAPL"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=0

View File

@ -4,6 +4,6 @@ Name=EUR/RUB
Comment=EUR/RUB
X-AW-Ticker="EURRUB=X"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=1

View File

@ -4,6 +4,6 @@ Name=EUR/USD
Comment=EUR/USD
X-AW-Ticker="EURUSD=X"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=2

View File

@ -4,6 +4,6 @@ Name=GOOG.NASDAQ
Comment=Google Inc
X-AW-Ticker="GOOG"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=3

View File

@ -4,6 +4,6 @@ Name=MSFT.NASDAQ
Comment=Microsoft Corp
X-AW-Ticker="MSFT"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=4

View File

@ -4,6 +4,6 @@ Name=RTS
Comment=RTS Index
X-AW-Ticker="RTS.RS"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=5

View File

@ -4,6 +4,6 @@ Name=S&P
Comment=S&P 500 Index
X-AW-Ticker="^GSPC"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=6

View File

@ -4,6 +4,6 @@ Name=USD/RUB
Comment=USD/RUB
X-AW-Ticker="USDRUB=X"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=8

View File

@ -4,6 +4,6 @@ Name=VIX
Comment=Volatility S&P 500
X-AW-Ticker="^VIX"
X-AW-Active=false
X-AW-ApiVersion=2
X-AW-ApiVersion=3
X-AW-Interval=60
X-AW-Number=7