-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use a dataclass to represent company info. * Rename test modules for PyTest to see them. Instead of `python3 run_all_tests.py`, just `pytest` should suffice now. * Test data obtained from MSN Money. * Add a test for Yahoo! Finance. Also: Fix current price condition in MSN Money. * Update CI recipe to only run `pytest`. * Prune logic not required to run the tests with PyTest. With UnitTest, adding the module to import paths was mandatory. PyTest runs fine without that, as long as the logic is organized into a package.
- Loading branch information
Showing
8 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class CompanyInfo: | ||
ticker_symbol: str | ||
name: str | ||
description: str | ||
industry: str | ||
current_price: float | ||
average_volume: float | ||
market_cap: float | ||
shares_outstanding: int | ||
pe_high: float | ||
pe_low: float | ||
roic: float | ||
roic_averages: [float] | ||
equity: float | ||
equity_growth_rates: [float] | ||
free_cash_flow: float | ||
free_cash_flow_growth_rates: [float] | ||
revenue: float | ||
revenue_growth_rates: [float] | ||
eps: float | ||
eps_growth_rates: [float] | ||
debt_equity_ratio: float | ||
last_year_net_income: float | ||
total_debt: float |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from isthisstockgood.CompanyInfo import CompanyInfo | ||
from isthisstockgood.DataFetcher import DataFetcher | ||
|
||
|
||
def test_msn_money(): | ||
test_ticker = 'MSFT' | ||
test_name = 'Microsoft Corp' | ||
|
||
data = get_msn_money_data(test_ticker) | ||
|
||
assert data.ticker_symbol == test_ticker | ||
assert data.name == test_name | ||
assert data.description != '' | ||
assert data.industry != '' | ||
assert data.current_price > 0.0 | ||
assert data.average_volume > 0 | ||
assert data.market_cap > 0.0 | ||
assert data.shares_outstanding > 0 | ||
assert data.pe_high > 0.0 | ||
assert data.pe_low > 0.0 | ||
assert data.roic != [] | ||
assert data.roic_averages != [] | ||
assert data.equity != [] | ||
assert data.equity_growth_rates != [] | ||
assert data.free_cash_flow != [] | ||
assert data.free_cash_flow_growth_rates != [] | ||
assert data.revenue != [] | ||
assert data.revenue_growth_rates != [] | ||
assert data.eps != [] | ||
assert data.eps_growth_rates != [] | ||
assert data.debt_equity_ratio > 0.0 | ||
assert data.last_year_net_income > 0.0 | ||
assert data.total_debt >= 0.0 | ||
|
||
def test_yahoo(): | ||
test_ticker = 'MSFT' | ||
test_name = 'Microsoft Corp' | ||
|
||
data = get_yahoo_data(test_ticker) | ||
|
||
assert data.ticker_symbol == test_ticker | ||
assert float(data.five_year_growth_rate) > 0.0 | ||
|
||
def get_msn_money_data(ticker): | ||
data_fetcher = DataFetcher() | ||
data_fetcher.ticker_symbol = ticker | ||
|
||
# Make all network request asynchronously to build their portion of | ||
# the json results. | ||
data_fetcher.fetch_msn_money_data() | ||
|
||
# Wait for each RPC result before proceeding. | ||
for rpc in data_fetcher.rpcs: | ||
rpc.result() | ||
|
||
return CompanyInfo(**vars(data_fetcher.msn_money)) | ||
|
||
def get_yahoo_data(ticker): | ||
data_fetcher = DataFetcher() | ||
data_fetcher.ticker_symbol = ticker | ||
|
||
# Make all network request asynchronously to build their portion of | ||
# the json results. | ||
data_fetcher.fetch_yahoo_finance_analysis() | ||
|
||
# Wait for each RPC result before proceeding. | ||
for rpc in data_fetcher.rpcs: | ||
rpc.result() | ||
|
||
return data_fetcher.yahoo_finance_analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
tests/RuleOneInvestingCalculationsTest.py → tests/test_RuleOneInvestingCalculations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters