Index future simple stat and time-series backtest module
Project description
Index Futures Simple Backtest Module (Personal Usage)
Chang Sun Email
Install and Update
pip install --upgrade sc-backtest
Simple Test
- Check for factor validity
- Statistical:
- CDF
- Markout
- Hist
- Time-Series:
- Sign-Trade
- Value-Trade
- Threshold-Trade
- Report
- get_report
- Statistical:
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
from sc_backtest import simpletest
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = simpletest(is_day=True)
st.plot_cdf(x, y)
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
import sc_backtest as sb
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = sb.simpletest(is_day=True)
data = st.simple_pnl(x, y, data_return=True)
report = sb.get_report(data['delta_med'], y)
Technical Analysis
Variou moving average function
- SMA
- EMA
- WMA
- MMA
- QMA
- ...
import pandas as pd
import numpy as np
from sc_backtest import ta
wma = ta.wma(pd.Series(np.random.rand(100)), window=5)
Example
Input your factor and uderlying asset's future return series with index type as DatetimeIndex and get the composite stat and time-series plots.
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
from sc_backtest import simpletest
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = simpletest(is_day=True)
st.plot_composite(x, y, markout_periods=30, cdf_period2=5)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sc-backtest-0.0.6.tar.gz
(8.3 kB
view hashes)
Built Distribution
Close
Hashes for sc_backtest-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9105a0cd6f2e21627a5b89b14c9bd01e1c41af3b8498dcbf881a0b1841f0987c |
|
MD5 | 949e4aaa3a7427d691b2f03dfd798c46 |
|
BLAKE2b-256 | 3355d0de0bb9cec33f86bba909c92cbadf457ddeb7559d7ce020f46a57f1f8cf |