From c0abef021a1d898717cd301d6f50b72cd3d6f30d Mon Sep 17 00:00:00 2001 From: Jaime Lopez Date: Fri, 27 Dec 2024 06:48:02 -0500 Subject: [PATCH] Update --- Makefile | 3 +++ README.md | 3 +-- data/IBM.csv | 21 +++++++++++++++++++++ pybottrader/datastreamers/__init__.py | 2 +- pybottrader/datastreamers/yfinance.py | 3 ++- pybottrader/indicators/CMakeLists.txt | 6 +++--- pyproject.toml | 15 +++++++++------ 7 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 data/IBM.csv diff --git a/Makefile b/Makefile index f4e3067..98f1595 100644 --- a/Makefile +++ b/Makefile @@ -12,3 +12,6 @@ lint: typing: mypy . + +upload: + twine upload -r pybottrader dist/* diff --git a/README.md b/README.md index a4cf245..1286cbd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # PyBotTrader -API Documentation PyBotTrader is an experimental Python library designed to help create trading bots, particularly for retail traders. It offers tools for real-time financial @@ -85,7 +84,7 @@ Time Pos. Price ROI Valuation Accum.ROI ## Installation ```sh -pip install pybottrader +pip install git+https://github.com/jailop/pybottrader.git ``` Shortly, I'm going to release more documentation and more examples. diff --git a/data/IBM.csv b/data/IBM.csv new file mode 100644 index 0000000..1cffc24 --- /dev/null +++ b/data/IBM.csv @@ -0,0 +1,21 @@ +time,open,high,low,close,volume,dividends,stock splits +1732683600.0,228.8300018310547,229.19000244140625,224.27000427246094,226.9199981689453,2995100,0.0,0.0 +1732856400.0,227.75,230.36000061035156,227.19000244140625,227.41000366210938,2640300,0.0,0.0 +1733115600.0,227.5,228.3800048828125,225.50999450683594,227.38999938964844,2655900,0.0,0.0 +1733202000.0,227.24000549316406,229.11000061035156,226.6699981689453,229.0,3163800,0.0,0.0 +1733288400.0,230.0,233.74000549316406,229.35000610351562,233.49000549316406,4104200,0.0,0.0 +1733374800.0,233.5500030517578,236.52000427246094,233.4600067138672,234.75,4791100,0.0,0.0 +1733461200.0,234.42999267578125,238.3800048828125,234.22000122070312,238.0399932861328,4028400,0.0,0.0 +1733720400.0,238.0,239.35000610351562,228.91000366210938,230.0,4970400,0.0,0.0 +1733806800.0,228.39999389648438,234.38999938964844,227.8000030517578,231.72000122070312,4769500,0.0,0.0 +1733893200.0,232.69000244140625,233.0,229.1300048828125,230.1199951171875,3872700,0.0,0.0 +1733979600.0,230.66000366210938,233.88999938964844,230.3800048828125,232.25999450683594,4515700,0.0,0.0 +1734066000.0,232.25,233.77999877929688,230.25999450683594,230.82000732421875,2757400,0.0,0.0 +1734325200.0,230.72999572753906,231.02999877929688,226.8800048828125,229.3300018310547,3610300,0.0,0.0 +1734411600.0,229.22999572753906,230.1999969482422,227.6199951171875,228.97000122070312,3651300,0.0,0.0 +1734498000.0,229.0399932861328,229.0399932861328,220.02999877929688,220.1699981689453,4152500,0.0,0.0 +1734584400.0,224.4199981689453,226.1999969482422,222.97999572753906,223.9199981689453,4427200,0.0,0.0 +1734670800.0,222.72999572753906,227.67999267578125,221.67999267578125,223.36000061035156,12423200,0.0,0.0 +1734930000.0,222.80999755859375,223.74000549316406,221.0800018310547,221.92999267578125,2988100,0.0,0.0 +1735016400.0,222.27000427246094,224.44000244140625,221.5399932861328,224.41000366210938,1186200,0.0,0.0 +1735189200.0,223.30999755859375,225.39999389648438,222.5500030517578,224.88999938964844,3286500,0.0,0.0 diff --git a/pybottrader/datastreamers/__init__.py b/pybottrader/datastreamers/__init__.py index e2b9b28..7e02b0a 100644 --- a/pybottrader/datastreamers/__init__.py +++ b/pybottrader/datastreamers/__init__.py @@ -32,7 +32,7 @@ class CSVFileStreamer(DataStreamer): def __init__(self, filename: str): self.index = 0 - self.data = pd.read_csv(filename, parse_dates=True) + self.data = pd.read_csv(filename) def next(self) -> Union[dict, None]: if self.index >= len(self.data): diff --git a/pybottrader/datastreamers/yfinance.py b/pybottrader/datastreamers/yfinance.py index 0055fba..eb61141 100644 --- a/pybottrader/datastreamers/yfinance.py +++ b/pybottrader/datastreamers/yfinance.py @@ -3,6 +3,7 @@ """ from typing import Union +import numpy as np import pandas as pd import yfinance from . import DataStreamer @@ -20,12 +21,12 @@ def __init__(self, symbol, *args, **kwargs): self.data = ticker.history(*args, **kwargs) self.data.columns = [col.lower() for col in self.data.columns] self.data.index.names = ["time"] + self.data.index = self.data.index.astype(np.int64) / 1e9 self.data.reset_index(inplace=True) def next(self) -> Union[dict, None]: if self.index >= len(self.data): return None result = self.data.iloc[self.index].to_dict() - result["time"] = result["time"].to_pydatetime() self.index += 1 return result diff --git a/pybottrader/indicators/CMakeLists.txt b/pybottrader/indicators/CMakeLists.txt index b1f9148..e0c06a6 100644 --- a/pybottrader/indicators/CMakeLists.txt +++ b/pybottrader/indicators/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.15) project(indicators) -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +# set(CMAKE_CXX_STANDARD 14) +# set(CMAKE_CXX_STANDARD_REQUIRED ON) +# set(CMAKE_CXX_EXTENSIONS OFF) if(NOT TARGET pybind11::module) find_package(pybind11 REQUIRED) diff --git a/pyproject.toml b/pyproject.toml index 25e8605..4aaae26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,10 @@ dependencies = [ "numpy", "pandas", "yfinance", - "pybind11>=2.6.0", + "pybind11", "twine", + "PyQt5", + "PyQtChart", ] [project.urls] @@ -23,15 +25,16 @@ package-dir={"" = "."} [build-system] requires = [ - "setuptools>=42", - "cmake>=3.15", - "pybind11>=2.6.0", - "scikit-build-core>=0.5.0", + "setuptools", + "cmake", + "pybind11", + "scikit-build-core", + "build", ] build-backend = "scikit_build_core.build" [tool.scikit-build] -cmake.minimum-version = "3.15" +# cmake.minimum-version = "3.15" cmake.source-dir = "pybottrader/indicators" cmake.build-type = "Release" wheel.packages = ["pybottrader"]