GithubHelp home page GithubHelp logo

emsu / prophet Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 123.0 142 KB

Financial markets analysis framework for programmers

Home Page: http://prophet.michaelsu.io

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

prophet's People

Contributors

anddam avatar desbma avatar emsu avatar jerry-dumblauskas avatar mpritham avatar rmattila avatar simongarisch avatar volcrush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prophet's Issues

Python 3 support

Please either support Python 3 or make it obvious in the README that you don't (unlike zipline).

Setup on windows

Anyone here successfully set this project up on Windows? I have tried Anaconda 2.1/2.7.9 64 bit python, and CPython 2.7.9 32 bit... get ambiguous errors about Visual C++ or missing dependencies.

Log from Anaconda 2.1/64 bit python: http://pastebin.com/Yx9i1zKP

Bug/Unnecessary code in backtest.py

There seems to be a bug in this block of code.

timestamps = prices.index.to_series().loc[start:]

# Check if the last day doesn't have data yet
# Like if it was early in the morning
if not timestamps[-1] in prices:
    timestamps = timestamps[:-1]

See https://github.com/Emsu/prophet/blob/master/prophet/backtest.py#L64-L69.

  1. That if statement will always pass. When using the in keyword with DataFrames it only checks the columns of the DataFrame. I think what you were trying to do is check the index of the DataFrame.

  2. I am not really sure why you are doing this. You grab the timestamps from the prices and then you proceed to check if timestamp[-1] is not in prices (which will never happen).

[Proposal] Plotting of daily returns and orders

It would be nice if there were a way to plot some key metrics from the backtests such as how the daily returns changed overtime or what orders were filled and when. Currently, I can manually insert plotting statements on the backtest daily returns time series.

Missing Dependencies and Broken Tests

I forked prophet and then cloned my fork. I then tried to run the quickstart.py example, but it failed because pandas-datareader and seaborn were not installed, they were not installed, because they were not in setup.py file.

Also, the integration test for the quickstart failed, because the YahooData class dose not support cache_data. I fixed this on my fork by adding both cache_path and data_path to the init methods for:

  • YahooData
  • YahooCloseData
  • PandasDataGenerator

You can find my changes in the merge that I made to my fork...

aabdullah-bos#1

If this is what, you intended. I can submit a pull request to your fork.

Cannot compare tz-naive and tz-aware " "datetime-like objects

just cloned and tried to run the quickstart and immediately stumbled on this :(

python examples/quickstart.py
Traceback (most recent call last):
  File "examples/quickstart.py", line 27, in <module>
    backtest = prophet.run_backtest(start=datetime(2010, 1, 1))
  File "/Users/hadanny/ws/prophet/prophet/app.py", line 60, in run_backtest
    timestamps = trading_days[(trading_days >= start) &
  File "/Users/hadanny/ws/prophet/venv/lib/python3.7/site-packages/pandas-0.25.0-py3.7-macosx-10.14-x86_64.egg/pandas/core/indexes/datetimelike.py", line 132, in wrapper
    result = op(self._data, maybe_unwrap_index(other))
  File "/Users/hadanny/ws/prophet/venv/lib/python3.7/site-packages/pandas-0.25.0-py3.7-macosx-10.14-x86_64.egg/pandas/core/arrays/datetimes.py", line 168, in wrapper
    self._assert_tzawareness_compat(other)
  File "/Users/hadanny/ws/prophet/venv/lib/python3.7/site-packages/pandas-0.25.0-py3.7-macosx-10.14-x86_64.egg/pandas/core/arrays/datetimes.py", line 793, in _assert_tzawareness_compat
    "Cannot compare tz-naive and tz-aware " "datetime-like objects"

Python 3.7.3

pip freeze
certifi==2019.6.16
chardet==3.0.4
cycler==0.10.0
idna==2.8
kiwisolver==1.1.0
lxml==4.4.1
matplotlib==3.1.1
numpy==1.17.0
pandas==0.25.0
pandas-datareader==0.7.4
-e git+https://github.com/Emsu/prophet.git@ea8232a649f0f323cd5aa7b47478b986647e15e0#egg=prophet
pyparsing==2.4.2
python-dateutil==2.8.0
pytz==2019.2
requests==2.22.0
scipy==1.3.1
seaborn==0.9.0
six==1.12.0
urllib3==1.25.3
wrapt==1.11.2

[Proposal] Default Price Data Source

Problem

Currently Yahoo Data is being used by default. Specifically adjusted close data to avoid splits breaking people's simulations. However, using adjusted close isn't accurate for backtesting and also seems to have broken tests as dividend and split data looks like it is adjusting price data during the test period.

Solution

I'm currently intending on changing the default price data to use Quandl's WIKI data. Splits and dividends are included in the data set. Unfortunately, the dataset doesn't include all stocks but will allow for a higher quality backtest for stocks it does include. For the serious investor, acquiring a higher quality data source is probably prudent.

[Proposal] Live Trading

Please feel free to comment on this proposal if you have any questions/changes/ideas. If you'd like to help on anything, feel free to comment on this thread and tag me.

Goal

Create an interface that allows users to potentially live trade using Prophet. This interface should be modular to allow users to use a variety of different trading API connectors.

Implementation

The initial implementation should consist of two parts. The first part should be changes to the core library to allow Prophet to accept live data from multiple data sources and output orders in different formats as a stream. The second part will be an initial reference implementation of a FIX connector to allow Prophet to accept input data over FIX and output orders to a FIX API.

Accepting Data

The proposed implementation for accepting live data from multiple DataGenerators is to use the multiprocessing library and distribute the generators to multiple processes. The Prophet library will use a thread safe queue to accept input data from these processes and ask the OrderGenerator if an order should be generated from the new data. DataGenerators will now provide a run_live method for generating live data which will be appended to the end of the dataset generated by run. The DataGenerator class itself will have a noop run_live function (basically assumes there is no live data).

Generating Orders

Currently, orders are generated and processed by a backtest and only the backtest result is outputted. For live trading, we will need a daemonizable Prophet function (live_trade?) which will accept live data from DataGenerators and yield lists of Orders to a connector. This will equate to something along the lines of connector.receive([Order(), Order()]). It will be up to the connector to decide what to do with it. The connector should be able to optionally return what price the orders were filled at or whether the orders were filled at all. Connectors could also be used for debugging or other purposes (eg. just print the orders it receives).

FIX Connectors

An order connector and data generator should be written to provide examples of how to write Prophet connectors. Currently the most promising library seems to be quickfix. The data generator should be a simple python generator that outputs formatted data received the FIX API. The order generator should submit orders via the FIX API and return metadata about orders as they are filled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.