Skip to content

Commit acfd370

Browse files
committed
got past pylint import errors after running sudo chown -R sudo /Users/sudo/.conda/
1 parent c136ed8 commit acfd370

8 files changed

Lines changed: 32 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
#### Create and run conda environment
44

5-
`conda env create -f trading_env.yml`
5+
`conda env create -f trading_env.yml`
66
`conda activate trading_env`
77

8+
#### Overwrite env file (after updating to modules)
9+
10+
`conda env export > trading_env.yml`
11+
812
#### See backtesting 1 year returns on Nasdaq pricing data for big tech stocks
913

1014
`python3 src/backtest.py`

‎TradingAlgos.code-workspace‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

‎src/backtest.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
"""
23
This module contains functions to backtest different trading strategies.
34
"""
@@ -23,6 +24,7 @@
2324
https://www.nasdaq.com/market-activity/stocks/msft/historical?
2425
page=1&rows_per_page=10&timeline=y1)
2526
"""
27+
2628
if __name__ == '__main__':
2729

2830
# gather all the tickers from the data folder

‎src/backtesting.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def delta_high_low_yearly(stock) -> float:
168168
'''
169169
total_return = 0.0
170170

171-
for idx, row in stock.data_old_to_new.iterrows():
171+
for _, row in stock.data_old_to_new.iterrows():
172172
# print(f'{idx = }; {row = }')
173173
high = float(row['High'].strip('$'))
174174
low = float(row['Low'].strip('$'))

‎src/parse_kaggle.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import os, sys
1+
"""
2+
This module contains functions to create a graph and a CSV file with the results of the backtesting.
3+
"""
24

5+
import os
36

4-
path_stocks = 'data/kaggle/stocks/'
5-
path_etfs = 'data/kaggle/etfs/'
7+
PATH_STOCKS = 'data/kaggle/stocks/'
8+
PATH_ETFS = 'data/kaggle/etfs/'
69

710
# scraping
8-
9-
for (root, dirs, files) in os.walk(path_stocks):
11+
for (root, dirs, files) in os.walk(PATH_STOCKS):
1012
for file in files:
1113
if file.endswith('.csv'):
1214
print(file)

‎src/scrape_live_stocks.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
"""
23
This module contains functions to scrape live stocks from Yahoo Finance.
34
It uses the aiohttp library to make asynchronous requests to the Yahoo Finance website.
@@ -146,7 +147,7 @@ def create_table(frame, dataframe, style):
146147
table.column(column, width=100)
147148

148149
# Apply tags for specific columns
149-
for i, row in enumerate(dataframe.itertuples(index=False)):
150+
for _, row in enumerate(dataframe.itertuples(index=False)):
150151
tags = []
151152
if style == 'gainers' and row._4.startswith('+'):
152153
tags.append('gainers_change')

‎src/stock.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#!/usr/bin/env python3
12
"""
23
This module contains the StockData class to represent stock data for a specific ticker.
34
"""
4-
55
import os
66
import pandas as pd
77

‎trading_env.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@ channels:
33
- defaults
44
dependencies:
55
- aiohttp=3.9.5=py312h80987f9_0
6+
- astroid=3.2.2=py312hca03da5_0
67
- blas=1.0=openblas
78
- bottleneck=1.3.7=py312ha86b861_0
89
- brotli-python=1.0.9=py312h313beb8_8
910
- bzip2=1.0.8=h80987f9_6
1011
- ca-certificates=2024.3.11=hca03da5_0
1112
- certifi=2024.6.2=py312hca03da5_0
1213
- charset-normalizer=2.0.4=pyhd3eb1b0_0
14+
- dill=0.3.8=py312hca03da5_0
1315
- et_xmlfile=1.1.0=py312hca03da5_1
1416
- expat=2.6.2=h313beb8_0
1517
- idna=3.7=py312hca03da5_0
18+
- isort=5.9.3=pyhd3eb1b0_0
1619
- jinja2=3.1.4=py312hca03da5_0
1720
- libcxx=14.0.6=h848a8c0_0
1821
- libffi=3.4.4=hca03da5_1
1922
- libgfortran=5.0.0=11_3_0_hca03da5_28
2023
- libgfortran5=11.3.0=h009349e_28
2124
- libopenblas=0.3.21=h269037a_0
2225
- llvm-openmp=14.0.6=hc6e5704_0
26+
- mccabe=0.7.0=pyhd3eb1b0_0
2327
- ncurses=6.4=h313beb8_0
2428
- numexpr=2.8.7=py312h0f3ea24_0
2529
- numpy=1.26.4=py312h7f4fdc5_0
2630
- numpy-base=1.26.4=py312he047099_0
2731
- openssl=3.0.13=h1a28f6b_2
2832
- pandas=2.2.1=py312hd77ebd4_0
2933
- pip=24.0=py312hca03da5_0
34+
- pylint=3.2.2=py312hca03da5_0
3035
- pysocks=1.7.1=py312hca03da5_0
3136
- python=3.12.3=h99e199e_1
3237
- python-dateutil=2.9.0post0=py312hca03da5_2
@@ -39,6 +44,7 @@ dependencies:
3944
- soupsieve=2.5=py312hca03da5_0
4045
- sqlite=3.45.3=h80987f9_0
4146
- tk=8.6.14=h6ba3021_0
47+
- tomlkit=0.11.1=py312hca03da5_0
4248
- tzdata=2024a=h04d1e81_0
4349
- urllib3=2.0.3=py312hca03da5_0
4450
- wheel=0.43.0=py312hca03da5_0

0 commit comments

Comments
 (0)