openstoxlify 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 michaelahli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: openstoxlify
3
+ Version: 0.1.0
4
+ Summary: Stoxlify library for quantitative trading
5
+ Author: Michael Ahli
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: requests
9
+ Dynamic: license-file
@@ -0,0 +1,8 @@
1
+ # OpenStoxlify - Quantitative Trading API Wrapper
2
+
3
+ `openstoxlify` is a Python package for fetching market data from the Stoxlify API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install openstoxlify
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: openstoxlify
3
+ Version: 0.1.0
4
+ Summary: Stoxlify library for quantitative trading
5
+ Author: Michael Ahli
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: requests
9
+ Dynamic: license-file
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.cfg
5
+ openstoxlify.egg-info/PKG-INFO
6
+ openstoxlify.egg-info/SOURCES.txt
7
+ openstoxlify.egg-info/dependency_links.txt
8
+ openstoxlify.egg-info/requires.txt
9
+ openstoxlify.egg-info/top_level.txt
10
+ stoxlify/__init__.py
11
+ stoxlify/fetch.py
12
+ tests/test_fetch.py
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ stoxlify
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,16 @@
1
+ [metadata]
2
+ name = openstoxlify
3
+ version = 0.1.0
4
+ description = Stoxlify library for quantitative trading
5
+ author = Michael Ahli
6
+ license = MIT
7
+
8
+ [options]
9
+ packages = find:
10
+ install_requires =
11
+ requests
12
+
13
+ [egg_info]
14
+ tag_build =
15
+ tag_date = 0
16
+
@@ -0,0 +1,3 @@
1
+ from .fetch import fetch, MarketData, Quote
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,62 @@
1
+ import requests
2
+ import json
3
+ from dataclasses import dataclass
4
+ from datetime import datetime
5
+
6
+
7
+ def fetch(ticker: str, provider: str, interval: str, range_: str) -> "MarketData":
8
+ """
9
+ Fetch market data from Stoxlify API.
10
+
11
+ :param ticker: The asset ticker (e.g., BTC-USD)
12
+ :param provider: The data provider (e.g., Binance, YFinance)
13
+ :param interval: The time interval (e.g., 30m, 1h, 1d)
14
+ :param range_: The range of data (e.g., 1mo, 1y)
15
+ :return: MarketData object containing quotes
16
+ """
17
+ url = "https://api.france.stoxlify.com/v1/market/info"
18
+ headers = {"Content-Type": "application/json", "Accept": "*/*"}
19
+ payload = {
20
+ "ticker": ticker,
21
+ "range": range_,
22
+ "source": provider,
23
+ "interval": interval,
24
+ "indicator": "quote",
25
+ }
26
+ response = requests.post(url, headers=headers, data=json.dumps(payload))
27
+ response.raise_for_status()
28
+ data = response.json()
29
+
30
+ quotes = [
31
+ Quote(
32
+ timestamp=datetime.fromisoformat(q["timestamp"].replace("Z", "+00:00")),
33
+ high=q["product_info"]["price"]["high"],
34
+ low=q["product_info"]["price"]["low"],
35
+ open=q["product_info"]["price"]["open"],
36
+ close=q["product_info"]["price"]["close"],
37
+ )
38
+ for q in data["quote"]
39
+ ]
40
+
41
+ return MarketData(ticker=ticker, quotes=quotes)
42
+
43
+
44
+ @dataclass
45
+ class Quote:
46
+ timestamp: datetime
47
+ high: float
48
+ low: float
49
+ open: float
50
+ close: float
51
+
52
+
53
+ @dataclass
54
+ class MarketData:
55
+ ticker: str
56
+ quotes: list[Quote]
57
+
58
+
59
+ # Example usage
60
+ if __name__ == "__main__":
61
+ market_data = fetch("BTC-USD", "Binance", "30m", "1mo")
62
+ print(market_data)
@@ -0,0 +1,7 @@
1
+ import pytest
2
+ from stoxlify import fetch, MarketData
3
+
4
+
5
+ def test_fetch():
6
+ market_data = fetch("BTC-USD", "Binance", "30m", "1mo")
7
+ assert isinstance(market_data, MarketData)