In [1]:
from __future__ import print_function
from __future__ import division
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
sns.set_context(rc={'figure.figsize': (14, 7) } )
figzize_me = figsize =(14, 7)
import warnings; warnings.filterwarnings('ignore')
import os
import sys
# 使用insert 0即只使用github,避免交叉使用了pip安装的abupy,导致的版本不一致问题
sys.path.insert(0, os.path.abspath('../'))
import abupy
abupy.env.enable_example_env_ipython()
In [2]:
from abupy import ABuSymbolPd
tsla_df = ABuSymbolPd.make_kl_df('usTSLA', n_folds=2)
tsla_df.tail()
Out[2]:
In [3]:
from abupy import tl
jumps = tl.jump.calc_jump(tsla_df)
In [4]:
jumps
Out[4]:
In [5]:
# sw[0]代表非时间因素的jump_power,sw[1]代表时间加权因素的jump_power,当sw[0]=1时与非加权方式相同,具体实现请参考源代码
jump_pd = tl.jump.calc_jump_line_weight(tsla_df, sw=(0.5, 0.5))
In [6]:
tl.wave.calc_wave_abs(tsla_df, xd=21, show=True)
Out[6]:
In [7]:
from abupy import EStoreAbu, abu
abu_result_tuple_train = abu.load_abu_result_tuple(n_folds=5, store_type=EStoreAbu.E_STORE_CUSTOM_NAME,
custom_name='train_cn')
# 只筛选orders中有交易结果的单子
has_result = abu_result_tuple_train.orders_pd[
abu_result_tuple_train.orders_pd.result == -1]
# 随便拿一个交易数据作为示例
sample_order = has_result.ix[100]
In [9]:
abupy.env.disable_example_env_ipython()
In [10]:
from abupy import ABuMarketDrawing
_ = ABuMarketDrawing.plot_candle_from_order(sample_order)
In [11]:
from abupy import nd
nd.macd.plot_macd_from_order(sample_order, date_ext=252)
In [12]:
nd.boll.plot_boll_from_order(has_result.ix[100], date_ext=252)
In [13]:
nd.ma.plot_ma_from_order(has_result.ix[100], date_ext=252, time_period=[10, 20, 30, 60, 90, 120])
In [ ]:
In [ ]: