Compare commits
No commits in common. "master" and "1.4.11" have entirely different histories.
5 changed files with 13 additions and 128 deletions
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pricehist"
|
name = "pricehist"
|
||||||
version = "1.4.12"
|
version = "1.4.11"
|
||||||
description = "Fetch and format historical price data"
|
description = "Fetch and format historical price data"
|
||||||
authors = ["Chris Berkhout <chris@chrisberkhout.com>"]
|
authors = ["Chris Berkhout <chris@chrisberkhout.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = "1.4.12"
|
__version__ = "1.4.11"
|
||||||
|
|
|
@ -82,14 +82,18 @@ class Yahoo(BaseSource):
|
||||||
prices = [
|
prices = [
|
||||||
Price(date, amount)
|
Price(date, amount)
|
||||||
for i in range(len(timestamps))
|
for i in range(len(timestamps))
|
||||||
if (date := self._ts_to_date(timestamps[i] + offset)) <= series.end
|
if (date := self._date_from_ts(timestamps[i], offset)) <= series.end
|
||||||
if (amount := self._amount(amounts, series.type, i)) is not None
|
if (amount := self._amount(amounts, series.type, i)) is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
return dataclasses.replace(series, quote=quote, prices=prices)
|
return dataclasses.replace(series, quote=quote, prices=prices)
|
||||||
|
|
||||||
def _ts_to_date(self, ts) -> str:
|
def _date_from_ts(self, ts, offset) -> str:
|
||||||
return datetime.fromtimestamp(ts, tz=timezone.utc).date().isoformat()
|
return (
|
||||||
|
datetime.fromtimestamp(ts - offset)
|
||||||
|
.replace(tzinfo=timezone.utc)
|
||||||
|
.strftime("%Y-%m-%d")
|
||||||
|
)
|
||||||
|
|
||||||
def _amount(self, amounts, type, i):
|
def _amount(self, amounts, type, i):
|
||||||
if type == "mid" and amounts["high"] != "null" and amounts["low"] != "null":
|
if type == "mid" and amounts["high"] != "null" and amounts["low"] != "null":
|
||||||
|
|
|
@ -75,10 +75,10 @@ name="Alpha Vantage physical currency"
|
||||||
cmd="pricehist fetch alphavantage AUD/EUR -s 2021-01-11 -e 2021-01-14"
|
cmd="pricehist fetch alphavantage AUD/EUR -s 2021-01-11 -e 2021-01-14"
|
||||||
read -r -d '' expected <<END
|
read -r -d '' expected <<END
|
||||||
date,base,quote,amount,source,type
|
date,base,quote,amount,source,type
|
||||||
2021-01-11,AUD,EUR,0.63374,alphavantage,close
|
2021-01-11,AUD,EUR,0.63318,alphavantage,close
|
||||||
2021-01-12,AUD,EUR,0.63684,alphavantage,close
|
2021-01-12,AUD,EUR,0.63664,alphavantage,close
|
||||||
2021-01-13,AUD,EUR,0.63686,alphavantage,close
|
2021-01-13,AUD,EUR,0.63585,alphavantage,close
|
||||||
2021-01-14,AUD,EUR,0.63984,alphavantage,close
|
2021-01-14,AUD,EUR,0.63960,alphavantage,close
|
||||||
END
|
END
|
||||||
run_test "$name" "$cmd" "$expected"
|
run_test "$name" "$cmd" "$expected"
|
||||||
|
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
{
|
|
||||||
"chart": {
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"meta": {
|
|
||||||
"currency": "INR",
|
|
||||||
"symbol": "INR=X",
|
|
||||||
"exchangeName": "CCY",
|
|
||||||
"fullExchangeName": "CCY",
|
|
||||||
"instrumentType": "CURRENCY",
|
|
||||||
"firstTradeDate": 1070236800,
|
|
||||||
"regularMarketTime": 1726284616,
|
|
||||||
"hasPrePostMarketData": false,
|
|
||||||
"gmtoffset": 3600,
|
|
||||||
"timezone": "BST",
|
|
||||||
"exchangeTimezoneName": "Europe/London",
|
|
||||||
"regularMarketPrice": 83.89,
|
|
||||||
"fiftyTwoWeekHigh": 83.89,
|
|
||||||
"fiftyTwoWeekLow": 83.89,
|
|
||||||
"regularMarketDayHigh": 83.89,
|
|
||||||
"regularMarketDayLow": 83.89,
|
|
||||||
"regularMarketVolume": 0,
|
|
||||||
"longName": "USD/INR",
|
|
||||||
"shortName": "USD/INR",
|
|
||||||
"chartPreviousClose": 64.6117,
|
|
||||||
"priceHint": 4,
|
|
||||||
"currentTradingPeriod": {
|
|
||||||
"pre": {
|
|
||||||
"timezone": "BST",
|
|
||||||
"start": 1726182000,
|
|
||||||
"end": 1726182000,
|
|
||||||
"gmtoffset": 3600
|
|
||||||
},
|
|
||||||
"regular": {
|
|
||||||
"timezone": "BST",
|
|
||||||
"start": 1726182000,
|
|
||||||
"end": 1726268340,
|
|
||||||
"gmtoffset": 3600
|
|
||||||
},
|
|
||||||
"post": {
|
|
||||||
"timezone": "BST",
|
|
||||||
"start": 1726268340,
|
|
||||||
"end": 1726268340,
|
|
||||||
"gmtoffset": 3600
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dataGranularity": "1d",
|
|
||||||
"range": "",
|
|
||||||
"validRanges": [
|
|
||||||
"1d",
|
|
||||||
"5d",
|
|
||||||
"1mo",
|
|
||||||
"3mo",
|
|
||||||
"6mo",
|
|
||||||
"1y",
|
|
||||||
"2y",
|
|
||||||
"5y",
|
|
||||||
"10y",
|
|
||||||
"ytd",
|
|
||||||
"max"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"timestamp": [
|
|
||||||
1499641200,
|
|
||||||
1499727600,
|
|
||||||
1499814000,
|
|
||||||
1499900400
|
|
||||||
],
|
|
||||||
"indicators": {
|
|
||||||
"quote": [
|
|
||||||
{
|
|
||||||
"open": [
|
|
||||||
64.6155014038086,
|
|
||||||
null,
|
|
||||||
64.55549621582031,
|
|
||||||
64.46800231933594
|
|
||||||
],
|
|
||||||
"volume": [
|
|
||||||
0,
|
|
||||||
null,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"low": [
|
|
||||||
64.41000366210938,
|
|
||||||
null,
|
|
||||||
64.3499984741211,
|
|
||||||
64.33999633789062
|
|
||||||
],
|
|
||||||
"close": [
|
|
||||||
64.61170196533203,
|
|
||||||
null,
|
|
||||||
64.52559661865234,
|
|
||||||
64.36499786376953
|
|
||||||
],
|
|
||||||
"high": [
|
|
||||||
64.6155014038086,
|
|
||||||
null,
|
|
||||||
64.56999969482422,
|
|
||||||
64.48419952392578
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"adjclose": [
|
|
||||||
{
|
|
||||||
"adjclose": [
|
|
||||||
64.61170196533203,
|
|
||||||
null,
|
|
||||||
64.52559661865234,
|
|
||||||
64.36499786376953
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"error": null
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue