Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedamen committed Oct 23, 2019
1 parent 7dfc405 commit ff15728
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __pycache__/
env/
build/
develop-eggs/
dist/
dist*/
downloads/
eggs/
.eggs/
Expand Down
4 changes: 3 additions & 1 deletion finmarketpy/backtest/backtestengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ def signal(self):
import abc
import pandas
import datetime
import copy

from chartpy import Chart, Style, ChartConstants

Expand All @@ -946,6 +947,7 @@ class TradingModel(object):
DEFAULT_PLOT_ENGINE = ChartConstants().chartfactory_default_engine
SCALE_FACTOR = ChartConstants().chartfactory_scale_factor
CHART_SOURCE = ChartConstants().chartfactory_source
CHART_STYLE = Style()

DUMP_CSV = ''
DUMP_PATH = datetime.date.today().strftime("%Y%m%d") + ' '
Expand Down Expand Up @@ -1865,7 +1867,7 @@ def _strip_dataframe(self, data_frame, strip):
return data_frame

def _create_style(self, title, file_add, reduce_plot=True):
style = Style()
style = copy.deepcopy(self.CHART_STYLE)

if self.SHOW_TITLES:
style.title = self.FINAL_STRATEGY + " " + title
Expand Down
4 changes: 2 additions & 2 deletions finmarketpy/economics/eventstudy.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_economic_event_ret_over_custom_event_day(self, data_frame_in, event_date

def get_intraday_moves_over_custom_event(self, data_frame_rets, ef_time_frame, vol=False,
minute_start = 5, mins = 3 * 60, min_offset = 0 , create_index = False,
resample = False, freq = 'minutes'):
resample = False, freq = 'minutes', cumsum = True):

filter = Filter()

Expand Down Expand Up @@ -126,7 +126,7 @@ def get_intraday_moves_over_custom_event(self, data_frame_rets, ef_time_frame, v
if vol is True:
# annualise (if vol)
data_frame = data_frame.rolling(center=False,window=5).std() * math.sqrt(ann_factor)
else:
elif cumsum:
data_frame = data_frame.cumsum()

return data_frame
Expand Down
5 changes: 4 additions & 1 deletion finmarketpy_examples/tradingmodelfxtrend_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from finmarketpy.backtest import TradingModel, BacktestRequest
from finmarketpy.economics import TechIndicator

from chartpy import Style

class TradingModelFXTrend_Example(TradingModel):

def __init__(self):
Expand All @@ -37,6 +39,7 @@ def __init__(self):
self.FINAL_STRATEGY = 'FX trend'
self.SCALE_FACTOR = 1
self.DEFAULT_PLOT_ENGINE = 'matplotlib'
# self.CHART_STYLE = Style(plotly_plot_mode='offline_jupyter')

self.br = self.load_parameters()
return
Expand Down Expand Up @@ -225,7 +228,7 @@ def construct_strategy_benchmark(self):

# now examine sensitivity to different transaction costs
tc = [0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2.0]
ta.run_tc_shock(strategy, tc = tc)
ta.run_tc_shock(strategy, tc=tc)

# how does P&L change on day of month
ta.run_day_of_month_analysis(strategy)
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from setuptools import setup, find_packages

long_description = """finmarketpy is a Python based library that enables you to analyze market data and also to backtest
trading strategies using a simple to use API, which has prebuilt templates for you to define backtest."""

setup(name='finmarketpy',
version='0.11',
description='Trading Backtest library',
version='0.11.1',
description='finmarketpy is a Python based library for backtesting trading strategies',
author='Saeed Amen',
author_email='saeed@cuemacro.com',
license='Apache 2.0',
long_description=long_description,
keywords = ['trading', 'markets', 'currencies', 'pandas', 'data', 'Bloomberg', 'tick', 'stocks', 'equities'],
url = 'https://github.com/cuemacro/finmarketpy',
packages = find_packages(),
Expand Down

0 comments on commit ff15728

Please sign in to comment.