Skip to content

Commit 3f6124c

Browse files
committed
Added get_stock_market_tick_data func
1 parent 515020c commit 3f6124c

6 files changed

Lines changed: 61 additions & 3 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from .BaseAPI import BaseAPI
2+
3+
class StockMarketTickDataAPI(BaseAPI):
4+
5+
def get_stock_market_tick_data(self, api_token: str, symbol: str, from_timestamp: str, to_timestamp: str, limit: int):
6+
7+
endpoint = 'ticks'
8+
9+
query_string = ''
10+
11+
if symbol is None:
12+
raise ValueError("symbol is empty. Need to add symbol to args")
13+
if from_timestamp is None:
14+
raise ValueError("from_timestamp is empty. Need to add from_timestamp to args")
15+
if to_timestamp is None:
16+
raise ValueError("to_timestamp is empty. Need to add to_timestamp to args")
17+
18+
query_string += '&s=' + str(symbol)
19+
query_string += '&from=' + str(from_timestamp)
20+
query_string += '&to=' + str(to_timestamp)
21+
22+
if limit is not None:
23+
query_string += '&limit=' + str(limit)
24+
25+
26+
return self._rest_get_method(api_key = api_token, endpoint = endpoint, querystring = query_string)

eodhd/APIs/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
from .FinancialNewsAPI import FinancialNewsAPI
1919
from .OptionsDataAPI import OptionsDataAPI
2020
from .IntradayDataAPI import IntradayDataAPI
21-
from .EodHistoricalStockMarketDataAPI import EodHistoricalStockMarketDataAPI
21+
from .EodHistoricalStockMarketDataAPI import EodHistoricalStockMarketDataAPI
22+
from .StockMarketTickDataAPI import StockMarketTickDataAPI

eodhd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99

1010
# Version of eodhd package
11-
__version__ = "1.0.24"
11+
__version__ = "1.0.25"

eodhd/apiclient.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from eodhd.APIs import OptionsDataAPI
3737
from eodhd.APIs import IntradayDataAPI
3838
from eodhd.APIs import EodHistoricalStockMarketDataAPI
39+
from eodhd.APIs import StockMarketTickDataAPI
3940

4041
# minimal traceback
4142
sys.tracebacklimit = 1
@@ -845,6 +846,33 @@ def get_eod_historical_stock_market_data(
845846
from_date=from_date,
846847
order=order
847848
)
849+
850+
def get_stock_market_tick_data(
851+
self,
852+
symbol,
853+
from_timestamp,
854+
to_timestamp,
855+
limit=None
856+
):
857+
"""
858+
Available args:
859+
symbol - , for example, AAPL.US, consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}.
860+
This API works only for US exchanges for the moment,
861+
then you can use 'AAPL' or 'AAPL.US' to get the data as well for other US tickers.
862+
from_timestamp and to_timestamp - use these parameters to filter data by datetime.
863+
Parameters should be passed in UNIX time with UTC timezone,
864+
for example, these values are correct: “from=1627896900&to=1630575300” and
865+
correspond to ' 2021-08-02 09:35:00 ' and ' 2021-09-02 09:35:00 '.
866+
limit - the maximum number of ticks will be provided.
867+
"""
868+
api_call = StockMarketTickDataAPI()
869+
return api_call.get_stock_market_tick_data(
870+
api_token=self._api_key,
871+
symbol=symbol,
872+
to_timestamp=to_timestamp,
873+
from_timestamp=from_timestamp,
874+
limit=limit
875+
)
848876

849877

850878
class ScannerClient:

example_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,8 @@ def main() -> None:
130130
resp = api.get_eod_historical_stock_market_data(symbol = 'AAPL.MX', period='d', from_date = '2023-01-01', to_date = '2023-01-15', order='a')
131131
print(resp)
132132

133+
resp = api.get_stock_market_tick_data(from_timestamp = '1627896900', to_timestamp = '1630575300', symbol = 'AAPL', limit = 1)
134+
print(resp)
135+
133136
if __name__ == "__main__":
134137
main()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# This call to setup() does all the work
1717
setup(
1818
name="eodhd",
19-
version="1.0.24",
19+
version="1.0.25",
2020
description="Official EODHD API Python Library",
2121
long_description=long_description,
2222
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)