) print(str(e)) from jinja2 import Environment, FileSystemLoader from chartpy import Canvas, Chart, Style import plotly.graph_objs as go from tcapy.conf.constants import Constants from tcapy.util.utilfunc import UtilFunc # compatible with Python 2 *and* 3: ABC = abc.ABCMeta('ABC', (object, ), {'__slots__': ()}) constants = Constants() class Renderer(object): """Creates HTML pages based on a dictionary input full of charts and can also convert them to PDF. Can both write HTML/PDF to disk or return as a string, which is easier to consume by certain callers such as a webserver. """ def __init__(self): self._util_func = UtilFunc() @abc.abstractmethod def render_elements(self, elements_to_render_dict, title=None, output_filename=None,
# # Copyright 2018 Cuemacro # # See the License for the specific language governing permissions and limitations under the License. # import os from tcapy.conf.constants import Constants from tcapy.util.loggermanager import LoggerManager from tcapy.data.databasesource import DatabaseSourceCSV from tcapy.data.databasesource import DatabaseSourceArctic, DatabaseSourcePyStore, DatabaseSourceInfluxDB, DatabaseSourceKDB constants = Constants() if __name__ == '__main__': logger = LoggerManager.getLogger(__name__) PLOT_BACK_DATA = False data_vendor = 'ncfx' # 'dukascopy' or 'ncfx' # Either use 'arctic' or 'pystore' or 'influxdb' or 'kdb' to store market tick data market_data_store = 'arctic' logger.info("About to upload data to " + market_data_store) ## YOU WILL NEED TO CHANGE THE BELOW LINES #########################################################################
from tcapy.analysis.tcarequest import MarketRequest from tcapy.data.databasesource import DatabaseSourceCSVBinary as DatabaseSourceCSV from tcapy.data.databasesource import \ DatabaseSourceMSSQLServer, DatabaseSourceMySQL, DatabaseSourceSQLite, \ DatabaseSourceArctic, DatabaseSourceKDB, DatabaseSourceInfluxDB, DatabaseSourcePyStore import datetime from collections import OrderedDict from tcapy.util.customexceptions import * logger = LoggerManager().getLogger(__name__) constants = Constants() from tcapy.util.mediator import Mediator tcapy_version = constants.tcapy_version # check that your database has market and trade data for these before running the test logger.info('Make sure you have created folder ' + constants.csv_folder + ' & ' + constants.temp_data_folder + ' otherwise tests will fail') ######################################################################################################################## # YOU MAY NEED TO CHANGE THESE start_date = '26 Apr 2017' finish_date = '05 Jun 2017'
# data_test_creator.fetch_test_database() # Load up market data from CSV and dump into SQL database ticker = ['EURUSD', 'GBPUSD', 'AUDUSD', 'NZDUSD', 'USDCAD', 'USDCHF', 'USDNOK', 'USDSEK', 'EURNOK', 'EURSEK', 'USDTRY', 'USDJPY'] # Trades for these tickers ticker_trade = ['EURUSD', 'GBPUSD', 'AUDUSD', 'NZDUSD', 'USDCAD', 'USDCHF', 'EURNOK', 'EURSEK', 'USDJPY', 'AUDJPY', 'NZDCAD', 'EURJPY'] # folder = '/ext_data/tcapy_data/' folder = None if folder is None: folder = Constants().test_data_folder # Copy market data from flat files (can be either .csv or .h5 file - much quicker to use .h5 files) # to Arctic market database # This relies on you have market data stored in H5 files already (eg. by downloading from DukasCopy) # note: whilst free FX data can be used for testing (in particular for generating randomised trades), # we recommend using higher quality data for actual benchmark if COPY_MARKET_CSV_DATA : csv_file = ['test_market_' + x + '.h5' for x in ticker] csv_market_data = [os.path.join(folder, x) for x in csv_file] data_test_creator.populate_test_database_with_csv(csv_market_data = csv_market_data, ticker = ticker, csv_trade_data = None, if_exists_table = 'append', if_exists_ticker = 'replace')