Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmcph4/quantmotion
Python 3 library providing quantitative financial analysis
https://github.com/jmcph4/quantmotion
backtesting backtesting-trading-strategies csv finance portfolio python3 quant quantitative-finance time-series
Last synced: about 2 months ago
JSON representation
Python 3 library providing quantitative financial analysis
- Host: GitHub
- URL: https://github.com/jmcph4/quantmotion
- Owner: jmcph4
- License: mit
- Created: 2018-04-28T06:53:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T05:38:48.000Z (over 6 years ago)
- Last Synced: 2024-11-06T01:42:05.677Z (3 months ago)
- Topics: backtesting, backtesting-trading-strategies, csv, finance, portfolio, python3, quant, quantitative-finance, time-series
- Language: Python
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/jmcph4/quantmotion.svg?branch=master)](https://travis-ci.org/jmcph4/quantmotion)
# QuantMotion #
---QuantMotion is a Python 3 library assisting quantitative analysis of financial assets.
## Price Data ##
QuantMotion supports price formats common in the financial industry, for e.g. OHLC data from candlestick charts, OHLC bar charts, etc.from quantmotion.ohlcvdata import OHLCVData
price = OHLCVData(open=1.00, high=2.00, low=0.50, close=1.33)
## Time Series ##
QuantMotion provides code for manipulating time series data, for instance:from datetime import datetime
from quantmotion.timeseries import TimeSeriests = TimeSeries()
ts.insert(datetime(2018, 1, 1), OHLCVData(open=1.00, high=2.00, low=0.50, close=1.33))
ts.insert(datetime(2018, 1, 1), OHLCVData(open=1.40, high=2.03, low=1.40, close=1.23))
len(ts) # 2
ts.remove(datetime(2018, 1, 1))
len(ts) # 1## File Format Support ##
QuantMotion supports common financial file formats. CSV is likely the most common:from quantmotion.timeseries import TimeSeries
from quantmotion.convert import *with open("MSFT.csv", "r") as f:
ts = convert_csv_to_time_series(f.read())len(ts) # 100
## Portfolio Backtesting ##
QuantMotion also supports rich portfolio management and backtesting facilities. These allow portfolios to be backtested on entirely custom data and allow for custom trading strategies to be backtested across different asset classes.from datetime import datetime
from quantmotion.asset import Asset
from quantmotion.portfolio import Portfolio# list of `Asset` objects
assets = [MSFT, GOOG, APPL, WOW]
# portfolio with initial cash balance of $50,000
p = Portfolio(balance=50000)# trade on the portfolio
p.buy(MSFT, 100, datetime(2018, 1, 1))
p.buy(GOOG, 20, datetime(2017, 4, 5))
p.sell(MSFT, 50, datetime(2018, 3, 5))# value the portfolio
current_value = p.value(datetime(2018, 4, 28))
growth = p.growth()