Skip to content
This repository was archived by the owner on Mar 12, 2023. It is now read-only.

Commit b5760a1

Browse files
Merge pull request #3 from HarryLudemann/start-script
Added asyncio to backtesting and data collection methods - Start script
2 parents 40194cd + bb570e2 commit b5760a1

9 files changed

Lines changed: 163 additions & 264 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
2828
- name: Run tests
2929
run: |
30-
pytest
30+
python -m pytest

Example/example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from trader import StockAlgorithm, run
1+
from trader import StockAlgorithm, run, backtest
22
from datetime import datetime
33

44
class Algorithm(StockAlgorithm):
@@ -10,13 +10,12 @@ def init(self):
1010
self.Symbol = "TSLA"
1111
self.StartDate = datetime.now().strftime("%Y-%m-%d") # current time
1212
self.Cash = 100000
13-
self.Data_Source = 'yfinance'
13+
self.Data_Source = 'alphav'
14+
self.API_KEY = 'your_api_key'
1415
self.Adjusted = False
1516
self.Interval = "1m"
1617

1718
def on_data(self, data):
18-
# print open item in data tuple
19-
#print(data[1]['open'])
2019
print(data)
2120

2221
def stats(self):
@@ -26,4 +25,6 @@ def stats(self):
2625
test_algo = Algorithm()
2726
test_algo.init()
2827

28+
backtest([test_algo])
2929
run([test_algo])
30+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Algorithm(ForexAlgorithm):
129129
test_algo = Algorithm()
130130
test_algo.init()
131131

132-
backtest(test_algo)
132+
backtest([test_algo])
133133
```
134134

135135
### Development:

requirements.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1+
aiohttp==3.7.4.post0
2+
alpha-vantage==2.3.1
3+
async-timeout==3.0.1
14
atomicwrites==1.4.0
25
attrs==21.2.0
36
backcall==0.2.0
4-
beautifulsoup4==4.9.3
7+
bleach==4.0.0
58
certifi==2021.5.30
9+
chardet==4.0.0
610
charset-normalizer==2.0.4
711
colorama==0.4.4
8-
cycler==0.10.0
912
debugpy==1.3.0
1013
decorator==5.0.9
14+
docutils==0.17.1
1115
idna==3.2
16+
importlib-metadata==4.6.3
1217
iniconfig==1.1.1
1318
ipykernel==6.0.1
1419
ipython==7.25.0
1520
ipython-genutils==0.2.0
1621
jedi==0.18.0
1722
jupyter-client==6.1.12
1823
jupyter-core==4.7.1
19-
kiwisolver==1.3.1
24+
keyring==23.0.1
2025
lxml==4.6.3
21-
matplotlib==3.4.2
2226
matplotlib-inline==0.1.2
27+
multidict==5.1.0
2328
multitasking==0.0.9
2429
numpy==1.21.1
2530
packaging==21.0
2631
pandas==1.3.1
2732
parso==0.8.2
2833
pickleshare==0.7.5
29-
Pillow==8.3.1
34+
pkginfo==1.7.1
3035
pluggy==0.13.1
3136
prompt-toolkit==3.0.19
3237
py==1.10.0
@@ -37,14 +42,24 @@ python-dateutil==2.8.1
3742
python-decouple==3.4
3843
pytz==2021.1
3944
pywin32==301
45+
pywin32-ctypes==0.2.0
4046
pyzmq==22.1.0
47+
readme-renderer==29.0
4148
requests==2.26.0
49+
requests-toolbelt==0.9.1
50+
rfc3986==1.5.0
4251
six==1.16.0
43-
soupsieve==2.2.1
4452
toml==0.10.2
4553
tornado==6.1
54+
tqdm==4.62.0
55+
trader-python==0.0.2
4656
traitlets==5.0.5
57+
twine==3.4.2
58+
typing-extensions==3.10.0.0
4759
urllib3==1.26.6
4860
wcwidth==0.2.5
61+
webencodings==0.5.1
4962
wincertstore==0.2
63+
yarl==1.6.3
5064
yfinance==0.1.63
65+
zipp==3.5.0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
88
long_description = "\n" + fh.read()
99

10-
VERSION = '0.0.1'
10+
VERSION = '0.0.2'
1111
DESCRIPTION = 'Run/Backtest/Create Easy Python Trading Algorithms'
1212
LONG_DESCRIPTION = 'A package that allows easy to write, run and backtest algorithms for stocks, forex and crypto from pre-written data sources eg. alpha vantage, yfinance'
1313

@@ -20,7 +20,7 @@
2020
description=DESCRIPTION,
2121
long_description_content_type="text/markdown",
2222
packages=find_packages(),
23-
install_requires=['pandas', 'yfinance', 'requests'],
23+
install_requires=['pandas', 'yfinance', 'alpha_vantage', 'requests'],
2424
keywords=['python', 'harryludemann', 'trader', 'backtest', 'trader-python'],
2525
classifiers=[
2626
"Development Status :: 1 - Planning",

trader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from trader import data
2-
from trader.start import backtest, run, StockAlgorithm, ForexAlgorithm
2+
from trader.start import backtest, standard_backtest, run, StockAlgorithm, ForexAlgorithm

0 commit comments

Comments
 (0)