Skip to content

Commit

Permalink
Bumped to version 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinali1 committed Jun 8, 2015
1 parent d1c5a00 commit 13024dd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
7 changes: 5 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Valuehorizon Forex 0.3.1 documentation!

The foreign exchange market (forex, FX, or currency market) is a global decentralized market for the trading of currencies. In terms of volume of trading, it is by far the largest market in the world. This reusable Django app provides you with the tools to keep track of a set of currencies and their price data.

Valuehorizon Forex includes two models - ``Currency`` and ``CurrencyPrice``. All ``Currency`` data are provided and maintained. Some sample ``CurrencyPrice``
data are provided, but for a full production dataset, you will have to source this data yourself.
Valuehorizon Forex includes two models - ``Currency`` and ``CurrencyPrice``.
All ``Currency`` data are provided and maintained. Some sample ``CurrencyPrice`` data are provided,
but for a full production dataset, you will have to source the ``CurrencyPrice`` data yourself.

Contents:

Expand All @@ -20,6 +21,8 @@ Contents:
data
usage
examples
documentation
faq
api

Indices and tables
Expand Down
3 changes: 2 additions & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ First, install the ``python-dev`` library through the package manager::

$ sudo apt-get install python-dev

Next, install ``numpy`` and ``pandas``::
Next, install ``lxml``, ``numpy`` and ``pandas``::
$ pip install lxml
$ pip install numpy
$ pip install pandas

Expand Down
2 changes: 1 addition & 1 deletion forex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '0.4.1' # pragma: no cover
__version__ = '0.6.1' # pragma: no cover
15 changes: 12 additions & 3 deletions forex/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def generate_dataframe(self, start_date=None, end_date=None):
class CurrencyPriceManager(Manager):
""" Adds some added functionality """

def generate_dataframe(self, symbols=None, date_index = None):
def generate_dataframe(self, symbols=None, date_index=None, price_type="mid"):
"""
Generate a dataframe consisting of the currency prices (specified by symbols)
from the start to end date
Expand All @@ -89,8 +89,17 @@ def generate_dataframe(self, symbols=None, date_index = None):
df = DataFrame.from_records(forex_data_array, index='date')

df['date'] = df.index
df['mid_price'] = (df['ask_price'] + df['bid_price']) / 2
df = df.pivot(index='date', columns='symbol', values='mid_price')

if price_type == "mid":
df['price'] = (df['ask_price'] + df['bid_price']) / 2
elif price_type == "ask_price":
df['price'] = df['ask_price']
elif price_type == "bid_price":
df['price'] = df['bid_price']
else:
raise ValueError("price_type must be on of 'ask', 'bid' or 'mid'")

df = df.pivot(index='date', columns='symbol', values='price')
df = df.reindex(date_index)
df = df.fillna(method="ffill")
unlisted_symbols = list(set(symbols) - set(df.columns))
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'forex.tests.south_settings')
'forex.settings.test_settings')

from django.core.management import execute_from_command_line

Expand Down
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tox
Django==1.8.1
numpy==1.9.2
pandas==0.13.0
lxml==3.4.4

0 comments on commit 13024dd

Please sign in to comment.