本文整理汇总了Python中pythalesians.graphics.graphs.plotfactory.PlotFactory类的典型用法代码示例。如果您正苦于以下问题:Python PlotFactory类的具体用法?Python PlotFactory怎么用?Python PlotFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlotFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_strategy_signal_proportion
def plot_strategy_signal_proportion(self, strip = None):
signal = self._strategy_signal
long = signal[signal > 0].count()
short = signal[signal < 0].count()
flat = signal[signal == 0].count()
keys = long.index
df = pandas.DataFrame(index = keys, columns = ['Long', 'Short', 'Flat'])
df['Long'] = long
df['Short'] = short
df['Flat'] = flat
if strip is not None: keys = [k.replace(strip, '') for k in keys]
df.index = keys
df = df.sort_index()
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Strategy signal proportion).png'
try:
pf.plot_bar_graph(self.reduce_plot(df), adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:Profinact,项目名称:pythalesians,代码行数:33,代码来源:strategytemplate.py
示例2: plot_strategy_group_benchmark_pnl
def plot_strategy_group_benchmark_pnl(self):
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
#gp.color = 'RdYlGn'
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - cumulative).png'
# plot cumulative line of returns
pf.plot_line_graph(self.reduce_plot(self._strategy_group_benchmark_pnl), adapter = 'pythalesians', gp = gp)
# needs write stats flag turned on
try:
keys = self._strategy_group_benchmark_tsd.keys()
ir = []
for key in keys: ir.append(self._strategy_group_benchmark_tsd[key].inforatio()[0])
ret_stats = pandas.DataFrame(index = keys, data = ir, columns = ['IR'])
ret_stats = ret_stats.sort_index()
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark PnL - IR).png'
gp.display_brand_label = False
# plot ret stats
pf.plot_bar_graph(ret_stats, adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:swaraj007,项目名称:pythalesians,代码行数:30,代码来源:strategytemplate.py
示例3: g10_plot_gdp_cpi_une
def g10_plot_gdp_cpi_une(self, start_date, finish_date, data_type = 'cpi'):
country_group = 'g10'
if data_type == 'cpi':
df = self.get_CPI_YoY(start_date, finish_date, country_group)
elif data_type == 'gdp':
df = self.get_GDP_YoY(start_date, finish_date, country_group)
elif data_type == 'une':
df = self.get_UNE(start_date, finish_date, country_group)
df = self.hist_econ_data_factory.grasp_coded_entry(df, -1)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.plotly_location_mode = 'world'
gp.plotly_choropleth_field = 'Val'
gp.plotly_scope = 'world'
gp.plotly_projection = 'Mercator'
gp.plotly_world_readable = False
gp.plotly_url = country_group + "-" + data_type
gp.title = "G10 " + data_type
gp.units = '%'
pf.plot_generic_graph(df, type = 'choropleth', adapter = 'plotly', gp = gp)
开发者ID:Profinact,项目名称:pythalesians,代码行数:30,代码来源:commonecondatafactory.py
示例4: plot_strategy_group_leverage
def plot_strategy_group_leverage(self):
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY + ' Leverage'
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Leverage).png'
pf.plot_line_graph(self.reduce_plot(self._strategy_group_leverage), adapter = 'pythalesians', gp = gp)
开发者ID:expressoman,项目名称:pythalesians,代码行数:11,代码来源:strategytemplate.py
示例5: plot_individual_leverage
def plot_individual_leverage(self):
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY + ' Leverage'
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Individual Leverage).png'
try:
pf.plot_line_graph(self.reduce_plot(self._individual_leverage), adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:expressoman,项目名称:pythalesians,代码行数:13,代码来源:strategytemplate.py
示例6: plot_strategy_pnl
def plot_strategy_pnl(self):
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Strategy PnL).png'
try:
pf.plot_line_graph(self.reduce_plot(self._strategy_pnl), adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:expressoman,项目名称:pythalesians,代码行数:13,代码来源:strategytemplate.py
示例7: plot_strategy_group_pnl_trades
def plot_strategy_group_pnl_trades(self):
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY + " (bp)"
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Individual Trade PnL).png'
# zero when there isn't a trade exit
strategy_pnl_trades = self._strategy_pnl_trades.fillna(0) * 100 * 100
try:
pf.plot_line_graph(self.reduce_plot(strategy_pnl_trades), adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:Anhmike,项目名称:pythalesians,代码行数:16,代码来源:strategytemplate.py
示例8: plot_strategy_group_benchmark_annualised_pnl
def plot_strategy_group_benchmark_annualised_pnl(self, cols = None):
# TODO - unfinished, needs checking!
if cols is None: cols = self._strategy_group_benchmark_annualised_pnl.columns
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
gp.color = ['red', 'blue', 'purple', 'gray', 'yellow', 'green', 'pink']
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Group Benchmark Annualised PnL).png'
pf.plot_line_graph(self.reduce_plot(self._strategy_group_benchmark_annualised_pnl[cols]), adapter = 'pythalesians', gp = gp)
开发者ID:expressoman,项目名称:pythalesians,代码行数:16,代码来源:strategytemplate.py
示例9: plot_single_var_regression
def plot_single_var_regression(self, y, x, y_variable_names, x_variable_names, statistic,
tag = 'stats',
title = None,
pretty_index = None, output_path = None,
scale_factor = Constants.plotfactory_scale_factor,
silent_plot = False,
shift=[0]):
if not(isinstance(statistic, list)):
statistic = [statistic]
# TODO optimise loop so that we are calculating each regression *once* at present calculating it
# for each statistic, which is redundant
for st in statistic:
stats_df = []
for sh in shift:
x_sh = x.shift(sh)
stats_temp = self.report_single_var_regression(y, x_sh, y_variable_names, x_variable_names, st,
pretty_index)
stats_temp.columns = [ x + "_" + str(sh) for x in stats_temp.columns]
stats_df.append(stats_temp)
stats_df = pandas.concat(stats_df, axis=1)
stats_df = stats_df.dropna(how='all')
if silent_plot: return stats_df
pf = PlotFactory()
gp = GraphProperties()
if title is None: title = statistic
gp.title = title
gp.display_legend = True
gp.scale_factor = scale_factor
# gp.color = ['red', 'blue', 'purple', 'gray', 'yellow', 'green', 'pink']
if output_path is not None:
gp.file_output = output_path + ' (' + tag + ' ' + st + ').png'
pf.plot_bar_graph(stats_df, adapter = 'pythalesians', gp = gp)
return stats_df
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:46,代码来源:timeseriesreport.py
示例10: plot_strategy_signal_proportion
def plot_strategy_signal_proportion(self, strip = None):
signal = self._strategy_signal
# count number of long, short and flat periods in our sample
long = signal[signal > 0].count()
short = signal[signal < 0].count()
flat = signal[signal == 0].count()
keys = long.index
# how many trades have there been (ignore size of the trades)
trades = abs(signal - signal.shift(-1))
trades = trades[trades > 0].count()
df_trades = pandas.DataFrame(index = keys, columns = ['Trades'], data = trades)
df = pandas.DataFrame(index = keys, columns = ['Long', 'Short', 'Flat'])
df['Long'] = long
df['Short'] = short
df['Flat'] = flat
if strip is not None: keys = [k.replace(strip, '') for k in keys]
df.index = keys
df_trades.index = keys
# df = df.sort_index()
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY
gp.display_legend = True
gp.scale_factor = self.SCALE_FACTOR
try:
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Strategy signal proportion).png'
pf.plot_bar_graph(self.reduce_plot(df), adapter = 'pythalesians', gp = gp)
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Strategy trade no).png'
pf.plot_bar_graph(self.reduce_plot(df_trades), adapter = 'pythalesians', gp = gp)
except: pass
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:43,代码来源:strategytemplate.py
示例11: g10_line_plot_cpi
def g10_line_plot_cpi(self, start_date, finish_date):
today_root = datetime.date.today().strftime("%Y%m%d") + " "
country_group = 'g10-ez'
cpi = self.get_CPI_YoY(start_date, finish_date, country_group)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.title = "G10 CPI YoY"
gp.units = '%'
gp.scale_factor = 3
gp.file_output = today_root + 'G10 CPI YoY ' + str(gp.scale_factor) + '.png'
cpi.columns = [x.split('-')[0] for x in cpi.columns]
gp.linewidth_2 = 3
gp.linewidth_2_series = ['United States']
pf.plot_generic_graph(cpi, type = 'line', adapter = 'pythalesians', gp = gp)
开发者ID:Profinact,项目名称:pythalesians,代码行数:20,代码来源:commonecondatafactory.py
示例12: g10_line_plot_une
def g10_line_plot_une(self, start_date, finish_date):
today_root = datetime.date.today().strftime("%Y%m%d") + " "
country_group = 'g10-ez'
une = self.get_UNE(start_date, finish_date, country_group)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.title = "G10 Unemployment Rate (%)"
gp.units = '%'
gp.scale_factor = Constants.plotfactory_scale_factor
gp.file_output = today_root + 'G10 UNE ' + str(gp.scale_factor) + '.png'
une.columns = [x.split('-')[0] for x in une.columns]
gp.linewidth_2 = 3
gp.linewidth_2_series = ['United States']
pf.plot_generic_graph(une, type = 'line', adapter = 'pythalesians', gp = gp)
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:20,代码来源:commonecondatafactory.py
示例13: europe_plot_une
def europe_plot_une(self, start_date, finish_date):
country_group = 'all-europe'
une = self.get_UNE(start_date, finish_date, country_group)
une = self.hist_econ_data_factory.grasp_coded_entry(une, -1)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.plotly_location_mode = 'europe'
gp.plotly_choropleth_field = 'Val'
gp.plotly_scope = 'europe'
gp.plotly_projection = 'Mercator'
gp.plotly_world_readable = False
gp.plotly_url = country_group + "-unemployment"; gp.title = "Europe Unemployment"
gp.units = '%'
pf.plot_generic_graph(une, type = 'choropleth', adapter = 'plotly', gp = gp)
开发者ID:Profinact,项目名称:pythalesians,代码行数:23,代码来源:commonecondatafactory.py
示例14: usa_plot_une
def usa_plot_une(self, start_date, finish_date):
country_group = 'usa-states'; source = 'bloomberg'
une = self.get_UNE(start_date, finish_date, country_group, source = 'bloomberg')
une = self.hist_econ_data_factory.grasp_coded_entry(une, -1)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.plotly_location_mode = 'USA-states'
gp.plotly_choropleth_field = 'Val'
gp.plotly_scope = 'usa'
gp.plotly_projection = 'albers usa'
gp.plotly_world_readable = False
gp.plotly_url = country_group + "-unemployment"
gp.title = "USA Unemployment"
gp.units = 'pc'
pf.plot_generic_graph(une, type = 'choropleth', adapter = 'plotly', gp = gp)
开发者ID:Profinact,项目名称:pythalesians,代码行数:23,代码来源:commonecondatafactory.py
示例15: plot_strategy_signals
def plot_strategy_signals(self, date = None, strip = None):
######## plot signals
strategy_signal = self._strategy_signal
strategy_signal = 100 * (strategy_signal)
if date is None:
last_day = strategy_signal.ix[-1].transpose().to_frame()
else:
last_day = strategy_signal.ix[date].transpose().to_frame()
if strip is not None:
last_day.index = [x.replace(strip, '') for x in last_day.index]
print(last_day)
pf = PlotFactory()
gp = GraphProperties()
gp.title = self.FINAL_STRATEGY + " positions (% portfolio notional)"
gp.scale_factor = self.SCALE_FACTOR
gp.file_output = self.DUMP_PATH + self.FINAL_STRATEGY + ' (Positions) ' + str(gp.scale_factor) + '.png'
pf.plot_generic_graph(last_day, adapter = 'pythalesians', type = 'bar', gp = gp)
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:24,代码来源:strategytemplate.py
示例16: world_plot_cpi
def world_plot_cpi(self, start_date, finish_date):
country_group = 'world-liquid'
cpi = self.get_CPI_YoY(start_date, finish_date, country_group)
cpi = self.hist_econ_data_factory.grasp_coded_entry(cpi, -1)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.plotly_location_mode = 'world'
gp.plotly_choropleth_field = 'Val'
gp.plotly_scope = 'world'
gp.plotly_projection = 'Mercator'
gp.plotly_world_readable = False
gp.plotly_url = str(country_group) + "-cpi"
gp.title = "World Liquid CPI YoY"
gp.units = '%'
pf.plot_generic_graph(cpi, type = 'choropleth', adapter = 'plotly', gp = gp)
开发者ID:Profinact,项目名称:pythalesians,代码行数:24,代码来源:commonecondatafactory.py
示例17: g10_line_plot_gdp
def g10_line_plot_gdp(self, start_date, finish_date):
today_root = datetime.date.today().strftime("%Y%m%d") + " "
country_group = 'g10-ez'
gdp = self.get_GDP_QoQ(start_date, finish_date, country_group)
from pythalesians.graphics.graphs.plotfactory import PlotFactory
from pythalesians.graphics.graphs.graphproperties import GraphProperties
gp = GraphProperties()
pf = PlotFactory()
gp.title = "G10 GDP"
gp.units = 'Rebased'
gp.scale_factor = Constants.plotfactory_scale_factor
gp.file_output = today_root + 'G10 UNE ' + str(gp.scale_factor) + '.png'
gdp.columns = [x.split('-')[0] for x in gdp.columns]
gp.linewidth_2 = 3
gp.linewidth_2_series = ['United Kingdom']
from pythalesians.timeseries.calcs.timeseriescalcs import TimeSeriesCalcs
tsc = TimeSeriesCalcs()
gdp = gdp / 100
gdp = tsc.create_mult_index_from_prices(gdp)
pf.plot_generic_graph(gdp, type = 'line', adapter = 'pythalesians', gp = gp)
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:24,代码来源:commonecondatafactory.py
示例18: TimeSeriesRequest
time_series_request = TimeSeriesRequest(
start_date="01 Jan 1970", # start date
finish_date=datetime.date.today(), # finish date
freq='daily', # daily data
data_source='quandl', # use Quandl as data source
tickers=['EURUSD', # ticker (Thalesians)
'GBPUSD'],
fields=['close'], # which fields to download
vendor_tickers=['FRED/DEXUSEU', 'FRED/DEXUSUK'], # ticker (Quandl)
vendor_fields=['close'], # which Bloomberg fields to download
cache_algo='internet_load_return') # how to return data
ltsf = LightTimeSeriesFactory()
daily_vals = ltsf.harvest_time_series(time_series_request)
techind = TechIndicator()
tech_params = TechParams()
tech_params.sma_period = 20
techind.create_tech_ind(daily_vals, 'SMA', tech_params=tech_params)
sma = techind.get_techind()
signal = techind.get_signal()
combine = daily_vals.join(sma, how='outer')
pf = PlotFactory()
pf.plot_line_graph(combine, adapter='pythalesians')
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:29,代码来源:techindicator_examples.py
示例19: EventStudy
df_event_times.index = df_event_times.index.tz_localize(utc_time) # work in UTC time
from pythalesians.economics.events.eventstudy import EventStudy
es = EventStudy()
# work out cumulative asset price moves moves over the event
df_event = es.get_intraday_moves_over_custom_event(df, df_event_times)
# create an average move
df_event['Avg'] = df_event.mean(axis = 1)
# plotting spot over economic data event
gp = GraphProperties()
gp.scale_factor = 3
gp.title = 'USDJPY spot moves over recent NFP'
# plot in shades of blue (so earlier releases are lighter, later releases are darker)
gp.color = 'Blues'; gp.color_2 = []
gp.y_axis_2_series = []
gp.display_legend = False
# last release will be in red, average move in orange
gp.color_2_series = [df_event.columns[-2], df_event.columns[-1]]
gp.color_2 = ['red', 'orange'] # red, pink
gp.linewidth_2 = 2
gp.linewidth_2_series = gp.color_2_series
pf = PlotFactory()
pf.plot_line_graph(df_event * 100, adapter = 'pythalesians', gp = gp)
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:31,代码来源:eventstudy_examples.py
示例20: LightTimeSeriesFactory
ltsf = LightTimeSeriesFactory()
tsc = TimeSeriesCalcs()
df = tsc.create_mult_index_from_prices(ltsf.harvest_time_series(time_series_request))
gp = GraphProperties()
gp.title = "S&P500 vs Apple"
# plot first with PyThalesians and then Plotly (via Cufflinks)
# just needs 1 word to change
# (although, note that AdapterCufflinks does have some extra parameters that can be set in
# GraphProperties)
gp.plotly_username = "thalesians"
gp.plotly_world_readable = True
pf = PlotFactory()
pf.plot_generic_graph(df, type="line", adapter="pythalesians", gp=gp)
pf.plot_generic_graph(df, type="line", adapter="cufflinks", gp=gp)
# test simple Plotly bar charts - average differences in EURUSDV1M-1Y vol and USDJPYV1M-1Y slope over past sixth months
if True:
from datetime import timedelta
ltsf = LightTimeSeriesFactory()
end = datetime.datetime.utcnow()
start = end - timedelta(days=180)
tickers = ["EURUSDV1M", "EURUSDV1Y", "USDJPYV1M", "USDJPYV1Y"]
vendor_tickers = ["EURUSDV1M BGN Curncy", "EURUSDV1Y BGN Curncy", "USDJPYV1M BGN Curncy", "USDJPYV1Y BGN Curncy"]
开发者ID:humdings,项目名称:pythalesians,代码行数:30,代码来源:plotly_examples.py
注:本文中的pythalesians.graphics.graphs.plotfactory.PlotFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论