Skip to content

Commit d7d10d6

Browse files
committed
A few initial bits
0 parents  commit d7d10d6

File tree

9 files changed

+333
-0
lines changed

9 files changed

+333
-0
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.egg-info
2+
.python-version
3+
*.py[co]
4+
__pycache__
5+
MANIFEST
6+
dist/
7+
build/
8+
.tox/
9+
.idea
10+
.DS_Store
11+
.virtualenv
12+
.venv
13+
*.iml
14+
.cache/
15+
.coverage
16+
docs/cov
17+
docs/doctrees
18+
docs/html
19+
config.yaml

Makefile

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.PHONY: docs
2+
.PHONY: list
3+
.PHONY: lint
4+
.PHONY: upload
5+
.PHONY: venv
6+
.PHONY: venv3
7+
.PHONY: active
8+
.PHONY: active3
9+
.PHONY: dev
10+
.PHONY: dev3
11+
.PHONY: tox
12+
.PHONY: cov
13+
.PHONY: covhtml
14+
15+
list:
16+
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
17+
18+
active3: #run surrounded by backticks
19+
. .venv/bin/activate
20+
21+
active: #run surrounded by backticks
22+
. .virtualenv/bin/activate
23+
24+
dev:
25+
python27 setup.py develop
26+
27+
dev3:
28+
python3 setup.py develop
29+
30+
venv:
31+
virtualenv .virtualenv
32+
.virtualenv/bin/pip install -e .
33+
.virtualenv/bin/pip install -r requirements.txt
34+
35+
venv3:
36+
python3 -m venv .venv
37+
.venv/bin/pip install -e .
38+
.venv/bin/pip install -r requirements.txt
39+
40+
test:
41+
pytest
42+
43+
lint:
44+
pylint --ignore=test nyc-mt-cc
45+
46+
cov:
47+
py.test --cov=nyc-mt-cc nyc-mt-cc/test/
48+
49+
covhtml:
50+
py.test --cov-report html:docs/cov --cov=nyc-mt-cc nyc-mt-cc/test/
51+
52+
upload: docs
53+
python setup.py sdist upload
54+
55+
docs:
56+
python setup.py build_sphinx --build-dir docs
57+
58+
tox:
59+
tox

README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
Cryptolio - Cryptocurrency Portfolio Manager and Simulator
2+
============================================================
3+
4+
[![CircleCI](https://circleci.com/gh/tolidano/cryptolio/tree/master.svg?style=svg&circle-token=ee9c3dee22d9d1309f54504e52018f844c2e9cf8)](https://circleci.com/gh/tolidano/cryptolio/tree/master)
5+
6+
Copyright Shawn Tolidano, All Rights Reserved.
7+
8+
Say something.
9+
10+
What is this?
11+
-------------
12+
13+
- Say something
14+
15+
Say something
16+
17+
Quickstart
18+
----------
19+
20+
### Using Cryptolio
21+
22+
If you just want to jump in and use it, follow this simple set of steps:
23+
24+
1. API Key and Secret
25+
26+
In code, if you've followed the above, you would do the following:
27+
```
28+
from __future__ import print_function
29+
WRITE_CODE
30+
```
31+
32+
### Setup for Development
33+
34+
If you are interested in doing development on Cryptolio, you need the
35+
following packages:
36+
- python (sudo yum install python27, sudo apt-get
37+
install python)
38+
- python development (sudo yum install python27-devel,
39+
sudo apt-get install python-devel)
40+
- pip (sudo yum install python27-pip,
41+
sudo apt-get install python-pip)
42+
- virtualenv (sudo pip install
43+
virtualenv)
44+
- make (sudo yum install make, sudo apt-get install make)
45+
46+
You run:
47+
- make venv (create a virtualenv)
48+
- \`make active\` (activate the virtualenv, the backticks are important)
49+
- make dev (setuptools for development)
50+
51+
Now you’re ready to develop.
52+
53+
Be sure to:
54+
- Keep code coverage over 90%
55+
- Write relevant unit tests
56+
- Write Python doc strings
57+
- Regenerate coverage and docs (make covhtml and make docs)
58+
59+
How This Works
60+
--------------
61+
62+
Say something.
63+
64+
Caching values
65+
--------------
66+
67+
If you want to cache values, consider also adding:
68+
[pylru](https://pypi.python.org/pypi/pylru/) Then you can write a
69+
function in your codebase like:
70+
71+
```python
72+
import pylru
73+
@lrudecorator(100)
74+
def get_from_countdown(line, station):
75+
return COUNTDOWN.get(line, station)
76+
```
77+
Building documentation
78+
----------------------
79+
80+
To build the documentation from the python docstrings, run:
81+
82+
make docs
83+
84+
And you can browse those here:
85+
\<CRYPTOLIO\>/docs/html/index.html
86+
87+
Running tests
88+
-------------
89+
90+
All tests are in the cryptolio/test/ directory. To run them do the
91+
following:
92+
93+
make test
94+
95+
You can also generate a coverage report:
96+
97+
make cov
98+
99+
You can generate the HTML version:
100+
101+
make covhtml
102+
103+
You can browse this locally from:
104+
\<CRYPTOLIO\>/docs/cov/index.html

config.yaml.example

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Visit GDAX to get a key
2+
gdax_api_key: GDAX_API_KEY
3+
gdax_api_secret: GDAX_API_SECRET
4+
5+
# Visit Bitstamp to get a key
6+
bitstamp_api_key: BITSAMP_API_KEY
7+
bitstamp_api_secret: BITSTAMP_API_SECRET
8+
9+
# Visit Gemini to get a key
10+
gemini_api_key: GEMINI_API_KEY
11+
gemini_api_secret: GEMINI_API_SECRET

cryptolio/cli.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /usr/bin/env python
2+
"""
3+
This helper is used as an entry point in setuptools.
4+
"""
5+
from __future__ import print_function, absolute_import
6+
import argparse
7+
from nyc_countdown_clock.clock import Clock
8+
9+
10+
def add_args(parser):
11+
"""
12+
Add command line arguments
13+
"""
14+
parser.add_argument('-f', '--config', required=True, help='YAML configuration file for NYC CC')
15+
parser.add_argument('-s', '--stop', help='Stop on a line')
16+
parser.add_argument('-l', '--line', help='Subway line or bus route')
17+
parser.add_argument('-t', '--list', action='store_true', help='List all available lines')
18+
19+
20+
def run_cli():
21+
"""
22+
Entry point in setup tools and argument parser builder.
23+
"""
24+
parser = argparse.ArgumentParser(description='CLI tool for NYC CC')
25+
add_args(parser)
26+
parsed_args = parser.parse_args()
27+
28+
cli = Clock(config=parsed_args.config)
29+
if parsed_args.list is True:
30+
cli.list()
31+
elif parsed_args.stop is not None:
32+
if parsed_args.line is not None:
33+
print(cli.get_times_for_stop_on_line(stop=parsed_args.stop, line=parsed_args.line))
34+
else:
35+
print(cli.get_times_for_stop_on_line(stop=parsed_args.stop))
36+
else:
37+
if parsed_args.line is not None:
38+
print(cli.get_times_for_stop_on_line(line=parsed_args.line))
39+
else:
40+
print('You have to specify something to retrieve')

cryptolio/test/cli_test.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Tests for CLI.
3+
"""
4+
import unittest
5+
import mock
6+
from nyc_countdown_clock.cli import run_cli
7+
8+
9+
class CliTest(unittest.TestCase):
10+
11+
@mock.patch('nyc_countdown_clock.cli.Clock')
12+
@mock.patch('nyc_countdown_clock.cli.argparse.ArgumentParser')
13+
def test_run_cli_no_conf(self, arg_mock, clock_mock):
14+
arg_mock.return_value.parse_args.return_value.conf = None
15+
arg_mock.return_value.parse_args.return_value.stop = 'TEST_STOP'
16+
arg_mock.return_value.parse_args.return_value.line = 'TEST_LINE'
17+
run_cli()
18+
19+
@mock.patch('nyc_countdown_clock.cli.Clock')
20+
@mock.patch('nyc_countdown_clock.cli.argparse.ArgumentParser')
21+
def test_run_cli_get(self, arg_mock, clock_mock):
22+
arg_mock.return_value.parse_args.return_value.conf = 'TEST_FILE'
23+
arg_mock.return_value.parse_args.return_value.stop = 'TEST_STOP'
24+
arg_mock.return_value.parse_args.return_value.line = 'TEST_LINE'
25+
run_cli()
26+
27+
@mock.patch('nyc_countdown_clock.cli.Clock')
28+
@mock.patch('nyc_countdown_clock.cli.argparse.ArgumentParser')
29+
def test_run_cli_list(self, arg_mock, clock_mock):
30+
arg_mock.return_value.parse_args.return_value.list = True
31+
run_cli()

requirements.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
future>=0.16
2+
PyYAML>=3.10
3+
4+
BitstampClient>=2.2.0
5+
geminipy>=0.0.3
6+
gdax>=1.0.6
7+
8+
mock>=1.0.1
9+
pylint>=1.7.2
10+
pytest>=3.2.1
11+
pytest-cov>=2.5.0
12+
tox>=2.8.0

setup.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from setuptools import setup
2+
3+
VERSION = open('VERSION').read().strip()
4+
with open('requirements.txt') as f:
5+
INSTALL_REQUIRES = f.read().splitlines()
6+
with open('requirements.txt') as f:
7+
TEST_REQUIRES = f.read().splitlines()
8+
with open('LICENSE') as f:
9+
LICENSE = f.read()
10+
with open('README.rst') as f:
11+
README = f.read()
12+
13+
setup(
14+
name='Cryptolio',
15+
version=VERSION,
16+
author='Shawn Tolidano',
17+
author_email='[email protected]',
18+
packages=['cryptolio'],
19+
url='https://github.com/tolidano/cryptolio',
20+
download_url='https://github.com/toliadno/cryptolio/tarball/%s' % VERSION,
21+
license=LICENSE,
22+
description='Cryptocurrency portfolio manager and simulator',
23+
keywords='cryptocurrency portfolio manager simulator bitcoin btc ethereum eth litecoin ltc',
24+
long_description=README,
25+
package_data={'': ['README.rst']},
26+
install_requires=INSTALL_REQUIRES,
27+
tests_require=TEST_REQUIRES,
28+
test_suite='cryptolio/test',
29+
entry_points={
30+
'console_scripts': ['cryptolio=cryptolio.cli:run_cli'],
31+
},
32+
classifiers=[
33+
'Programming Language :: Python :: 2.7',
34+
'Programming Language :: Python :: 3',
35+
'Programming Language :: Python :: 3.2',
36+
'Programming Language :: Python :: 3.3',
37+
'Programming Language :: Python :: 3.4',
38+
'Programming Language :: Python :: 3.5',
39+
'Programming Language :: Python :: 3.6',
40+
'Development Status :: 3 - Alpha',
41+
'License :: Freely Distributable',
42+
'Natural Language :: English',
43+
'Operating System :: OS Independent',
44+
'Topic :: Utilities',
45+
],
46+
)

tox.ini

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tox]
2+
envlist = py27, py36
3+
skip_missing_interpreters = True
4+
5+
[testenv]
6+
commands = py.test --cov=aws_lockbox aws_lockbox/test/
7+
deps =
8+
pytest
9+
mock
10+
coverage
11+
pytest-cov

0 commit comments

Comments
 (0)