Skip to content

Commit

Permalink
initial code import
Browse files Browse the repository at this point in the history
added license
  • Loading branch information
Dave Pettypiece committed Oct 17, 2016
1 parent c7f21ed commit 50f9cc3
Show file tree
Hide file tree
Showing 32 changed files with 1,135 additions and 87 deletions.
89 changes: 2 additions & 87 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,89 +1,4 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
*pyc
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
*.sw*
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 OANDA Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: bootstrap
bootstrap:
virtualenv env
env/bin/pip install -r requirements.txt
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
# v20-python-samples

Sample python code that uses the v20 python library

Setup
=====

The setup procedure describes how to create a virtualenv appropriate for
running the v20 sample code.

```
#
# Set up the virtualenv and install required packages
#
user@host: ~/v20-python-samples$ make bootstrap
#
# Enter the virtualenv
#
user@host: ~/v20-python-samples$ source env/bin/activate
#
# Create the v20-* launch entry points in the virtualenv. These entry points
# are aliases for the scripts which use the v20 REST API to interact with an
# account (e.g. v20-market-order, v20-trades-list, etc.)
#
(env)user@host: ~/v20-python-samples$ python setup.py develop
```

Entering the v20 environment
============================

The v20-python-samples virtualenv must be activated to ensure that the current
enviroment is set up correctly to run the sample code. This is done using the
virualenv's activate script:

```
user@host: ~/v20-python-samples$ source env/bin/activate
(env)user@host: ~/v20-python-samples$
```

The "(env)" prefix found in the prompt indicates that we are using the
virtualenv "env". To leave the virtualenv, run the deactivate function:

```
(env)user@host: ~/v20-python-samples$ deactivate
user@host: ~/v20-python-samples$
```


3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pyyaml==3.11
tabulate==0.7.5
v20==3.0.4.0
14 changes: 14 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from setuptools import setup, find_packages

setup(
name='v20-python-samples',
version='0.0.1',
packages=find_packages('src'),
package_dir={'': 'src'},
entry_points={
'console_scripts': [
'v20-configure = configure:main'
]
}
)

41 changes: 41 additions & 0 deletions src/account_details.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

from __future__ import print_function

import argparse
import common.config
from common.view import print_entity, print_collection, print_trades
from common.view import print_positions, print_orders, print_trade_summaries


def main():
parser = argparse.ArgumentParser()
common.config.add_argument(parser)
args = parser.parse_args()

account_id = args.config.active_account

api = args.config.create_context()

response = api.account.get(account_id)

account = response.get("account", "200")

print_entity(
account.title(),
account
)
print()

print_trade_summaries(account.trades)
print()

print_positions(account.positions)
print()

print_orders(account.orders)
print()


if __name__ == "__main__":
main()
Empty file added src/common/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions src/common/arg_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def parse_instrument(i):
i.replace("/", "_")
return i
Loading

0 comments on commit 50f9cc3

Please sign in to comment.