From f0857f86c2c36b758f53ecc6b65659c06ad0b19b Mon Sep 17 00:00:00 2001 From: Axel Gard Date: Thu, 4 Nov 2021 11:01:38 +0100 Subject: [PATCH] added a new test file for exchange and comment on name in readme --- README.md | 30 +++++++++++++++--------------- cira/exchange.py | 12 ++++++------ tests/test_exchange.py | 0 tests/test_stock.py | 1 - 4 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 tests/test_exchange.py diff --git a/README.md b/README.md index 9f6b065..cdf0c59 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ The project is available [here](https://github.com/AxelGard/paper-trader).
However after working on this for alomst a year (off and on) I realized that I had alomst build a small library for using the Alpaca API. So I thought that I would make this into a real library so that you can get started with quantitative paper trading as well. -The name [cira](https://en.wikipedia.org/wiki/Cria) is the word for a baby alpaca and because this is a simple and small lib I thought it would be a perfect fit. +The name [cira](https://en.wikipedia.org/wiki/Cria) is a miss spelling of the word for a baby alpaca cria and because this is a simple and small lib I thought it would be a perfect fit. [Axel Gard](https://github.com/AxelGard) is main developer for cira. -Things to checkout: +Things to checkout: * [News](https://github.com/AxelGard/cira/discussions/categories/news) * [Wiki](https://github.com/AxelGard/cira/wiki/Storing-the-Alpaca-API-key) @@ -66,41 +66,41 @@ stock.sell(1) New classes with cira v.2! ```python -portfolio = cira.Portfolio() # methods for your portfolio -exchange = cira.Exchange() # methods for exchange +portfolio = cira.Portfolio() # methods for your portfolio +exchange = cira.Exchange() # methods for exchange stock = cira.Stock("TSLA") # a class for one stock ``` for a example with the new classes check out this simple **[index fund](https://github.com/AxelGard/cira/wiki/Examples#simple-index-fund)** -## [Wiki](https://github.com/AxelGard/cira/wiki) and docs +## [Wiki](https://github.com/AxelGard/cira/wiki) and docs To see what more you can do check out the [wiki](https://github.com/AxelGard/cira/wiki). I also have an example of how to build a [index fund trader with cira](https://github.com/AxelGard/cira/wiki/Examples#simple-index-fund). -## Versioning & News +## Versioning & News For more [news](https://github.com/AxelGard/cira/discussions/categories/news) ### v.2.0.0, new structure! -With cira v.2.0.0 has a new structure and classes! +With cira v.2.0.0 has a new structure and classes! With this new classes and structure you will be able to use the library more simply. Checkout the [example page on the wiki](https://github.com/AxelGard/cira/wiki/Examples). The main classes are the Stock, Portfolio and Exchange. ### Want the old version? -For backwards compatibility I made sure to fork cira in to [cira-classic](https://github.com/AxelGard/cira-classic) and cira-classic is also available on [pypi with pip](https://pypi.org/project/cira-classic/). +For backwards compatibility I made sure to fork cira in to [cira-classic](https://github.com/AxelGard/cira-classic) and cira-classic is also available on [pypi with pip](https://pypi.org/project/cira-classic/). if you find bug plz let me know with a issue. If you know how to solve the problem then you can of course make a pull request and I will take a look at it. -### Have a question? +### Have a question? -If you have a question about cira, want to share what you built with cira or want to talk to others using cira, -you can checkout the [discussions page](https://github.com/AxelGard/cira/discussions) or make issue if that is more fitting. +If you have a question about cira, want to share what you built with cira or want to talk to others using cira, +you can checkout the [discussions page](https://github.com/AxelGard/cira/discussions) or make issue if that is more fitting. -## Development -If you want to help develop cira you are more then welcome to do so. -Feel free to make a pull request or issue. +## Development +If you want to help develop cira you are more then welcome to do so. +Feel free to make a pull request or issue. To install cira with all the dev req. ```bash git clone git@github.com:AxelGard/cira.git @@ -121,7 +121,7 @@ pytest ``` ### Coding style -I'm trying to follow the [pep8](https://pep8.org/) standard notation. +I'm trying to follow the [pep8](https://pep8.org/) standard notation. I try to make the library to be so intuitive as possible for easy of use. ## License diff --git a/cira/exchange.py b/cira/exchange.py index fc9976b..b9ab14f 100644 --- a/cira/exchange.py +++ b/cira/exchange.py @@ -3,10 +3,10 @@ class Exchange: - """ - This is the class instence of the Exchange. - This class is used for interaction with the exchanges, - for exampel NYSE. The exchange returns data and list of Stocks. + """ + This is the class instence of the Exchange. + This class is used for interaction with the exchanges, + for exampel NYSE. The exchange returns data and list of Stocks. """ def __init__(self): self.name = "" @@ -23,7 +23,7 @@ def __init__(self): self._historical_data = {} @property - def is_open(self): + def is_open(self) -> bool: """ returns if exchange is open """ self._is_open = alpaca.api().get_clock().is_open return self._is_open @@ -59,4 +59,4 @@ def historical_data(self): self._historical_data = {} for stk in self.stocks: self._historical_data[stk.symbol] = stk.historical_data() - return self._historical_data \ No newline at end of file + return self._historical_data diff --git a/tests/test_exchange.py b/tests/test_exchange.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_stock.py b/tests/test_stock.py index f9308fc..d5ed4f0 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -35,5 +35,4 @@ def test_historical_data(): """ Test that we historical data can be collected """ stk = cira.Stock("PYPL") days = 10 - print(stk.historical_data(days)) assert len(stk.historical_data(days)) == days