\r\n\r\nElsen Python\r\n============\r\n\r\nThis library is the Python bindings to the Elsen API that integrate with the\r\nexisting Financial Python modeling tools like Pandas and NumPy/SciPy.\r\n\r\nEasy Install\r\n------------\r\n\r\nFor ease of use, it is recommended that you use Anaconda Python Distribution\r\nwhich is available for Windows, Mac OSX and Linux. It is a self-contained Python\r\nenvironment that is bundles all the common financial modeling tools.\r\n\r\n**[Download Anaconda](https://store.continuum.io/cshop/anaconda/)**\r\n\r\n**Mac OS X**\r\n\r\n1) [Install Anaconda](http://docs.continuum.io/anaconda/install.html#mac-install)\r\n\r\n2) Launch Terminal from the Applications:Utilities folder.\r\n\r\n3) Clone the source code for the library.\r\n\r\n```bash\r\n$ git clone git@github.com:elsen-trading/elsen-python.git\r\n```\r\n\r\nIf you do not have Git currently installed then a window will pop up to ask you to install Developer Tools. Click Continue and the run the above command again.\r\n\r\n4) Move into the library source folder.\r\n\r\n```bash\r\n$ cd elsen-python \r\n```\r\n\r\n5) Install the Elsen Python library.\r\n\r\n```bash\r\n$ python setup.py install\r\n```\r\n\r\n6) Run the example code.\r\n\r\n```bash\r\n$ python Example.py\r\n```\r\n\r\nOr to launch straight into the IPython notebook.\r\n\r\n```\r\n$ ipython notebook\r\n```\r\n\r\n**Linux**\r\n\r\n1) [Install Anaconda](http://docs.continuum.io/anaconda/install.html#linux-install)\r\n\r\n2) If you do not have Git installed, then install it.\r\n\r\n```bash\r\nsudo apt-get install git\r\n```\r\n\r\n3) Open the Dash by clicking the Ubuntu icon in the upper-left, type \"terminal\",\r\nand select the Terminal application from the results that appear.\r\n\r\n4) Clone the source code for the library.\r\n\r\n```bash\r\n$ git clone git@github.com:elsen-trading/elsen-python.git\r\n```\r\n\r\n5) Move into the library source folder.\r\n\r\n```bash\r\n$ cd elsen-python \r\n```\r\n\r\n6) Install the Elsen Python library.\r\n\r\n```bash\r\n$ python setup.py install\r\n```\r\n\r\n7) Run the example code.\r\n\r\n```bash\r\n$ python Example.py\r\n```\r\n\r\nOr to launch straight into the IPython notebook.\r\n\r\n```\r\n$ ipython notebook\r\n```\r\n\r\n**Windows**\r\n\r\nCustom Install\r\n--------------\r\n\r\n**Setuptools**\r\n\r\n```bash\r\n$ pip install -r requirements.txt\r\n$ python setup.py install\r\n```\r\n\r\nOptionally several common libraries can be integrated:\r\n\r\n```bash\r\n$ pip install pandas\r\n$ pip install numpy\r\n$ pip install ipython\r\n$ pip install matplotlib\r\n```\r\n\r\nUsage\r\n-----\r\n\r\nThe library is entirely contained in the ``elsen`` module:\r\n\r\n```python\r\nfrom elsen import *\r\n```\r\n\r\n**Authentication**\r\n\r\nTo authenticate with the system you'll require four pieces of information\r\ncontained in your *Elsen Welcome* email:\r\n\r\n* Authentication token\r\n* Application id \r\n* Username\r\n* Password\r\n\r\n```python\r\nelsen = Elsen()\r\n\r\nelsen.authenticate(\r\n app_id = app_id,\r\n username = 'bob',\r\n password = 'trader'\r\n)\r\n```\r\n\r\nAdding a new application.\r\n\r\n```python\r\nelsen.add_application(\r\n email = 'bob@elsen.co'\r\n app_id = app_id\r\n)\r\n```\r\n\r\nOnce logged in, new users can be added to an application.\r\n\r\n```python\r\nelsen.add_user(\r\n app_id,\r\n username,\r\n password,\r\n # Optional fields.\r\n first_name = 'Bob',\r\n last_name = 'Trader',\r\n email = 'bob@elsen.co'\r\n)\r\n```\r\n\r\n**Exchanges**\r\n\r\n```python\r\nIn [1]: elsen.get_exchanges()\r\nOut[1]: [u'NASDAQ', u'NYSE', u'AMEX']\r\n```\r\n\r\n**Indices**\r\n\r\n```python\r\nIn [1]: elsen.get_indices()\r\nOut[1]: [u'SP500']\r\n```\r\n\r\n**Filters**\r\n\r\nTo get the most common ( in terms of company count ) filters available in the\r\nsystem query the common filters function. The top 10 available in the system\r\nare as follows:\r\n\r\n* ``avgvol30`` - Average amount of shares traded in a 30-day period.\r\n* ``phigh250`` - Percentage to highest price that a stock has traded at during the previous year.\r\n* ``dailyvolume`` - Average amount of shares traded in a day.\r\n* ``currentprice`` - Real time price of a security or the most recent listed.\r\n* ``plow250`` - Percentage to lowest price that a stock has traded at during the previous year.\r\n* ``inc_eibt`` - Net income before taxes\r\n- ``inc_sdws`` - Weighted average common shares outstanding including dilution due to options.\r\n- ``inc_sdai`` - EPS (taking into account options) including expenses caused by unusual events.\r\n- ``inc_sbas`` - Weighted average common shares outstanding less dilution.\r\n- ``inc_sbai`` - EPS including expenses caused by unusual events such as natural disasters, etc.\r\n\r\n\r\n```python\r\nn [1]: elsen.get_filters()[0:10]\r\nOut[1]: \r\n[<>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>]\r\n```\r\n\r\n```python\r\nIn [2]: elsen.search_filters('profit')\r\nOut[2]: \r\n[<>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>]\r\n```\r\n\r\n**Indicators**\r\n\r\n```python\r\nIn [1]: elsen.get_indicators()\r\nOut[1]: \r\n[<>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>,\r\n <>]\r\n```\r\n\r\n*Relative Strength Index*:\r\n\r\n```python\r\nIn[1]: rsi = elsen.get_indicators('rsi')\r\n\r\nIn[2]: print rsi.short_desc\r\nThe Relative Strength Index (RSI) measures the trend of a securities\u2019 price by\r\nmeasuring the ratio of average gains to average losses, and converting it to an\r\nindex from 1 to 100.\r\n\r\nIn [3]: rsi.inputs()\r\n{u'action': u'BUY|SELL',\r\n u'lookback': u'# lookback periods',\r\n u'lower': u'Smallest value that will trigger an activation, inclusive.',\r\n u'name': u'RSI',\r\n u'upper': u'Largest value that will trigger an activation, inclusive.'}\r\n```\r\n\r\n*Simple Moving Average*:\r\n\r\n```python\r\nIn [1]: sma = elsen.get_indicators('sma')\r\n\r\nIn [2]: print sma.short_desc \r\nThe simple moving average is a trailing price indicator, indicating trends in\r\nsecurities prices by measuring the average closing price of a select number of\r\nperiods prior to the current period.\r\n\r\nIn [3]: print sma.inputs()\r\n{u'action': u'BUY|SELL',\r\n u'upper': u'Largest value that will trigger an activation, inclusive.',\r\n u'lower': u'Smallest value that will trigger an activation, inclusive.',\r\n u'lookback': u'Window size',\r\n u'name': u'SMA'}\r\n```\r\n\r\n**Strategies**\r\n\r\n```python\r\n# Buy when oversold\r\nind1 = Indicator(action=BUY, name=RSI, lower=1, upper=30, lookback=21)\r\n\r\n# Sell when overbought\r\nind2 = Indicator(action=SELL, name=RSI, lower=70, upper=100, lookback=21)\r\n\r\n# Filter out low price and low volume companies\r\nflt1 = Filter(name='currentprice', min=0, max=200)\r\nflt2 = Filter(name='avgvol30', min=10000000.0, max=3400000000.0)\r\n\r\n# Setup the strategy\r\nstrategy = elsen.setup_strategy(\r\n universe = 'SP900',\r\n indicators = [ind1, ind2],\r\n filters = [flt1, flt2],\r\n interval = 1)\r\n```\r\n\r\n**Simulations**\r\n\r\nTo execute the backtest apply pass the strategy object as a argument to\r\n``setup_backtest`` along with a date range.\r\n\r\n```python\r\nbacktest = elsen.setup_backtest(\r\n strategy = strategy,\r\n start = '2014-5-1',\r\n end = '2014-12-1')\r\n\r\n# Run the backtest, wait for the results.\r\nbacktest.join(timing=True)\r\nbacktest.details()\r\n```\r\n\r\nTo pull the specific details for a backtest in the system, given a specific\r\nbacktest id. Use the ``detailsfor`` function.\r\n\r\n```python\r\nIn[1]: elsen.detailsfor('dfd7faf3-e13c-4293-b55d-33bbd4fb0f9f')\r\n```\r\n\r\n**Metrics**\r\n\r\n```python\r\nIn[1]: print 'Returns: $%s' % backtest.returns()\r\nReturns: $40193.9147\r\n\r\nIn[2]: print 'Sharpe Ratio: %s' % backtest.sharpe()\r\nSharpe Ratio: 0.77072534093809145889\r\n\r\nIn[3]: print 'Alpha: %s' % backtest.alpha()\r\nAlpha: -0.140887764298623\r\n\r\nIn[4]: print 'Beta: %s' % backtest.beta()\r\nBeta: 0.0000752396488764315\r\n```\r\n\r\nTo get all of the metrics for the Backtest object you can call\r\n``help(backtest)`` to get the list of all available properties and methods.\r\n\r\nThe backtest object itself can also be converted to a Pandas dataframe, JSON\r\nobject, or serialized to a file.\r\n\r\n```python\r\nIn[1]: backtest.to_dataframe()\r\n...\r\nIn[2]: backtest.to_json()\r\n...\r\n\r\nIn [3]: backtest.to_dataframe()['drawdown']\r\nOut[4]: \r\n0 45.48239846246275415098\r\nName: drawdown, dtype: object\r\n```\r\n\r\nTo pull the individual trades for a backtest use the ``trades`` function which\r\ncan generate the resulting dataframe object.\r\n\r\n```python\r\nIn[1]: backtest.trades()\r\n...\r\nIn[2]: backtest.trades().to_dataframe()\r\n```\r\n\r\nDocumentation\r\n-------------\r\n\r\n```bash\r\n$ cd docs\r\n$ make html\r\n$ make latexpdf\r\n```\r\n\r\nFiling Issues\r\n-------------\r\n\r\nIf you file an issue with Elsen support then please put the following line at\r\nthe beginning of your script.\r\n\r\n```python\r\nenable_debugging()\r\n```\r\n\r\nIn your bug report/email to support please include the following\r\n\r\n* Script or IPython Notebook used to run your program.\r\n* The output file ``elsen-python.log``.\r\n\r\nIPython\r\n-------\r\n\r\nThe use cases are also provided in IPython notebook form for interactive usage:\r\n\r\n* [Visualization](Visualization.ipynb)\r\n\r\n```bash\r\n$ ipython notebook Visualization.ipynb\r\n```",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/elsen-trading/elsen-python",
"keywords": "",
"license": "UNKNOWN",
"maintainer": "",
"maintainer_email": "",
"name": "elsen",
"package_url": "https://pypi.org/project/elsen/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/elsen/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/elsen-trading/elsen-python"
},
"release_url": "https://pypi.org/project/elsen/0.1.2/",
"requires_dist": null,
"requires_python": null,
"summary": "Elsen API Library",
"version": "0.1.2"
},
"last_serial": 1488752,
"releases": {
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "1e1186d2d8a940c5f85f7ade1660cfa0",
"sha256": "9457a0438bcc32b0455f1bf9d6120e2247e9ec1008ad72036dcae2fc59798aa9"
},
"downloads": -1,
"filename": "elsen-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "1e1186d2d8a940c5f85f7ade1660cfa0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23963,
"upload_time": "2015-04-02T20:24:03",
"url": "https://files.pythonhosted.org/packages/f1/34/e3d703ab283114467586247e98fc49f2a287c62a4ec20ac66fc2e06b9ed4/elsen-0.1.2.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "1e1186d2d8a940c5f85f7ade1660cfa0",
"sha256": "9457a0438bcc32b0455f1bf9d6120e2247e9ec1008ad72036dcae2fc59798aa9"
},
"downloads": -1,
"filename": "elsen-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "1e1186d2d8a940c5f85f7ade1660cfa0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23963,
"upload_time": "2015-04-02T20:24:03",
"url": "https://files.pythonhosted.org/packages/f1/34/e3d703ab283114467586247e98fc49f2a287c62a4ec20ac66fc2e06b9ed4/elsen-0.1.2.tar.gz"
}
]
}