### Install finmarketpy from GitHub Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Install the latest version of finmarketpy directly from the repository. ```bash pip install git+https://github.com/cuemacro/finmarketpy.git ``` -------------------------------- ### Install Chartpy Library Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Installs the chartpy visualization library. ```bash pip install chartpy ``` -------------------------------- ### Install Findatapy Library Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Installs the findatapy library for market data access. ```bash pip install findatapy ``` -------------------------------- ### Add More Option Examples Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Includes additional examples demonstrating the usage of option pricing and related functionalities. ```python # Added more option examples ``` -------------------------------- ### Install dependencies from GitHub Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Install the latest versions of chartpy and findatapy from their respective repositories. ```bash pip install git+https://github.com/cuemacro/chartpy.git pip install git+https://github.com/cuemacro/findatapy.git ``` -------------------------------- ### Install Arctic Library Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Installs the arctic wrapper for MongoDB, which facilitates saving and loading pandas DataFrames. ```bash pip install arctic ``` -------------------------------- ### Install ArcticDB and findatapy via Conda Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Commands to set up a new conda environment and install the required libraries. ```bash conda create -n py310arcticdb python=3.10 conda activate py310arcticdb conda install anaconda pip install arcticdb finmarketpy chartpy findatapy ``` -------------------------------- ### FX Spot Total Returns with Intraday Data and Numba Example Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md FX spot total returns now support intraday data, and an example is provided. Also fixes a Numba implementation problem. ```python # FX spot total returns now supports intraday data and added example # Fixed problem with Numba implementation of FX spot total returns ``` -------------------------------- ### Add Total Returns to Options Indices Example Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Includes total returns in the example for constructing options indices. ```python # Added total returns in example for options indices construction ``` -------------------------------- ### Install dependencies from PyPI Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Install stable versions of chartpy and findatapy from the Python Package Index. ```bash pip install chartpy pip install findatapy ``` -------------------------------- ### Create Development Conda Environment and Install Packages Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Set up a development environment by creating a conda environment with pip, then installing necessary packages for working on findatapy code directly. ```bash conda create -n devcuemacro python=3.6 pip activate devcuemacro pip install pandas twython pytz requests numpy pandas_datareader quandl statsmodels multiprocess ... ``` -------------------------------- ### Install FinancePy with specific version Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Install FinancePy and its required dependencies while avoiding version conflicts. ```bash pip install numba numpy scipy llvmlite ipython pandas prettytable pip install financepy==0.370 --no-deps ``` -------------------------------- ### Add Binder and Edit Backtest Example Notebook Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Integrates Binder for interactive notebook execution and adds more descriptive content to the `backtest_example` Jupyter notebook. ```python # Added Binder, so can run notebooks interactively # Edited backtest_example Jupyter notebook with more description ``` -------------------------------- ### Install AWS CLI on Linux Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Command to install the AWS CLI tool on Debian-based Linux distributions. ```bash sudo apt install awscli ``` -------------------------------- ### Improve QuickChart with Labels and Fix Example Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Enhances the `QuickChart` functionality by adding additional labels and correcting the provided example. ```python # Improved QuickChart, adding additional labels, fixing example ``` -------------------------------- ### Add FX Vol Surface Interpolation and Animated Example Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Implements FX vol surface interpolation using the FinancePy library and includes an animated example. ```python # Added FX vol surface interpolation (using FinancePy library underneath) + animated example ``` -------------------------------- ### Activate Conda Environment and Install findatapy Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Activate the previously created conda environment and install findatapy using pip from its GitHub repository. ```bash activate cuemacro pip install git+https://github.com/cuemacro/findatapy.git ``` -------------------------------- ### Fix Vol Surface Examples for New FXVolSurface Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Updates the vol surface examples to be compatible with the new `FXVolSurface` implementation. ```python # Fix vol surface examples to work with new FXVolSurface ``` -------------------------------- ### Import Libraries for Backtesting and Data Loading Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Imports essential libraries for backtesting, market data handling, FX conversion, logging, signal generation, and plotting. Ensure all dependencies are installed. ```python import warnings warnings.simplefilter(action='ignore', category=FutureWarning) # for backtest and loading data from finmarketpy.backtest import BacktestRequest, Backtest from findatapy.market import Market, MarketDataRequest, MarketDataGenerator from findatapy.util.fxconv import FXConv # for logging from findatapy.util.loggermanager import LoggerManager # for signal generation from finmarketpy.economics import TechIndicator, TechParams # for plotting from chartpy import Chart, Style ``` -------------------------------- ### Import Market and Request Classes Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Import necessary classes from the findatapy library for market data requests. Ensure findatapy is installed. ```python from findatapy.market import Market, MarketDataRequest ``` -------------------------------- ### Configure TechIndicator Parameters Source: https://context7.com/cuemacro/finmarketpy/llms.txt Set up technical parameters for calculating indicators like SMA. Ensure data is filled appropriately for calculations. This example configures SMA period and fillna. ```python from finmarketpy.economics import TechIndicator, TechParams import pandas as pd # Create sample price data dates = pd.date_range('2020-01-01', periods=500, freq='B') prices = pd.DataFrame({'EURUSD.close': 1.1 + 0.05 * pd.np.random.randn(500).cumsum()}, index=dates) # Configure technical parameters tech_params = TechParams() tech_params.sma_period = 50 tech_params.fillna = True ``` -------------------------------- ### Update Trend Following Example with FRED Data Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md This change updates the trend following example to utilize data from FRED (Federal Reserve Economic Data). ```python # Changed trend following example to use FRED ``` -------------------------------- ### Fix EventStudy Issue with Start Window Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Corrects an issue in `EventStudy` where the start window was before the time series. ```python # Fixed EventStudy issue when start window is before time series ``` -------------------------------- ### Add FX Forwards Pricer and Total Return Calculator Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Introduces an FX forwards pricer with examples for interpolation and implied depo calculations, and an FX forwards total return calculator. Rewrites FX spot indices construction using Numba. ```python # Added FX forwards pricer with examples # Interpolation of odd dates # Implied depo calculations # Added FX forwards total return calculator with examples # Rewrote FX spot indices construction to use Numba ``` -------------------------------- ### Create Conda Environment with Anaconda Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Create a conda environment that includes the anaconda metapackage, which installs a large set of common data science libraries. ```bash conda create -n devcuemacro python=3.6 anaconda ``` -------------------------------- ### Add Straddle Total Returns and Fix FXOptionsCurve Positioning Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Introduces total returns for straddles with an example and fixes positioning flips and expiring on days without market data in `FXOptionsCurve`. ```python # Added total returns for straddle (with example) # Fixed positioning flip and expiring on day without market data on FXOptionsCurve ``` -------------------------------- ### Define Custom FX Trend Strategy Source: https://context7.com/cuemacro/finmarketpy/llms.txt Implement a custom FX trend following strategy by subclassing TradingModel. Override methods to define parameters, load assets, and construct trading signals. This example sets up backtest parameters, loads market data, and generates SMA signals. ```python from finmarketpy.backtest import TradingModel, BacktestRequest from finmarketpy.economics import TechIndicator from findatapy.market import Market, MarketDataRequest, MarketDataGenerator import datetime class MyTrendStrategy(TradingModel): """Custom FX trend following strategy""" def __init__(self): super(TradingModel, self).__init__() self.market = Market(market_data_generator=MarketDataGenerator()) self.FINAL_STRATEGY = "FX Trend" self.DEFAULT_PLOT_ENGINE = "plotly" self.br = self.load_parameters() def load_parameters(self, br=None): """Define backtest parameters""" if br is not None: return br br = BacktestRequest() br.start_date = "04 Jan 1989" br.finish_date = datetime.datetime.utcnow().date() br.spot_tc_bp = 0.5 br.ann_factor = 252 # Volatility targeting br.signal_vol_adjust = True br.signal_vol_target = 0.1 br.signal_vol_max_leverage = 5 br.portfolio_vol_adjust = True br.portfolio_vol_target = 0.1 # Technical parameters br.tech_params.sma_period = 200 br.include_benchmark = True return br def load_assets(self, br=None): """Load market data for strategy""" br = self.load_parameters(br=br) tickers = ["EURUSD", "USDJPY", "GBPUSD", "AUDUSD"] vendor_tickers = ["DEXUSEU", "DEXJPUS", "DEXUSUK", "DEXUSAL"] md_request = MarketDataRequest( start_date=br.start_date, finish_date=br.finish_date, freq="daily", data_source="alfred", tickers=tickers, fields=["close"], vendor_tickers=vendor_tickers, vendor_fields=["close"], cache_algo="cache_algo_return") asset_df = self.market.fetch_market(md_request) # Define basket structure basket_dict = {t: [t] for t in tickers} basket_dict["FX Trend"] = tickers return asset_df, asset_df, None, basket_dict def construct_signal(self, spot_df, spot_df2, tech_params, br, run_in_parallel=False): """Generate trading signals""" tech_ind = TechIndicator() tech_ind.create_tech_ind(spot_df, "SMA", tech_params) return tech_ind.get_signal() def construct_strategy_benchmark(self): """Define benchmark for comparison""" md_request = MarketDataRequest( start_date=self.br.start_date, finish_date=self.br.finish_date, freq="daily", data_source="alfred", tickers=["EURUSD"], vendor_tickers=["DEXUSEU"], fields=["close"], vendor_fields=["close"], cache_algo="cache_algo_return") return self.market.fetch_market(md_request) # Run the strategy model = MyTrendStrategy() model.construct_strategy() # Generate plots model.plot_strategy_pnl() # Final strategy P&L model.plot_strategy_leverage() # Portfolio leverage model.plot_strategy_group_pnl_trades() # Individual trade P&Ls model.plot_strategy_group_benchmark_pnl() # Component cumulative P&Ls model.plot_strategy_group_benchmark_pnl_ir() # Information ratios # Access strategy data strategy_returns = model.strategy_pnl() strategy_signals = model.strategy_signal() strategy_leverage = model.strategy_leverage() ret_stats = model.strategy_pnl_ret_stats() ``` -------------------------------- ### Create Conda Environment with Pip Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Use this command to create a new conda environment that includes pip, ensuring packages are installed in the environment's site-packages folder. ```bash conda create -n cuemacro python=3.6 pip ``` -------------------------------- ### Get surprise vs market moves Source: https://context7.com/cuemacro/finmarketpy/llms.txt Compares market moves against economic surprise data for a given currency pair and event. Requires a DataFrame containing market data and surprise fields. ```python surprise_moves = ef.get_surprise_against_intraday_moves_over_event( df, cross="USDJPY", event_fx="USD", event_name="US Employees on Nonfarm Payrolls Total MoM Net Change SA", start="01 Jan 2015", end="31 Dec 2023", offset_list=[1, 5, 30, 60], # Minutes after release add_surprise=True, surprise_field='survey-average') ``` -------------------------------- ### Fetch Tick Market Data Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Fetches tick-level market data for a specified date range and ticker. Requires MarketDataRequest object setup. ```python from findatapy.market.ioengine import IOEngine md_request_download = MarketDataRequest( start_date="04 Jan 2021", finish_date="05 Jan 2021", category="fx", data_source='dukascopy', freq="tick", tickers=["USDJPY"], fields=["bid", "ask", "bidv", "askv"], data_engine=None ) market = Market() df_tick = market.fetch_market(md_request=md_request_download) ``` ```python print(df_tick) ``` -------------------------------- ### Revamp Jupyter Notebook for Market Data Download Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Updates the Jupyter notebook for downloading market data using findatapy with a revamped structure and examples. ```python # Revamped Jupyter notebook for downloading market data with findatapy ``` -------------------------------- ### Fetch Market Data from S3 using MarketDataRequest Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Configure MarketDataRequest to fetch data from an S3 bucket by setting the data_engine property. This example demonstrates reading data from a Parquet file stored in S3 and printing the resulting DataFrame. ```python md_request.data_engine = folder + '/*.parquet' df = market.fetch_market(md_request) print(df) ``` -------------------------------- ### Fetch Latest Market Data with Cache Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Fetches the latest version of market data using the Market interface and a local cache. Ensure the MarketDataRequest object is properly configured with start and end dates, data engine, and cache algorithm. ```python md_request_local_cache = MarketDataRequest( md_request=md_request_download ) md_request_local_cache.start_date = "04 Jan 2021 10:00" md_request_local_cache.finish_date = "06 Jan 2021 14:00" md_request_local_cache.data_engine = arcticdb_conn_str md_request_local_cache.cache_algo = "cache_algo_return" df_read_tick = Market().fetch_market(md_request=md_request_local_cache) ``` ```python # We should see the 1st write and 2nd append combined, ie. latest write print("No as_of specified, so we'll get the latest write!") print(df_read_tick) ``` -------------------------------- ### Add QuickChart, Resample Returns, and Custom Backtest Parameters Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Introduces `QuickChart` for easy market data download and plotting, adds the ability to resample returns, and allows more custom parameters in backtests. ```python # Added QuickChart for one line download of market data and plotting # Added feature to resample returns # Allow more custom parameters in backtest ``` -------------------------------- ### Create Market and Chart objects Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Sets up the plotting engine and the market data generator for fetching data. ```python chart = Chart(engine='matplotlib') market = Market(market_data_generator=MarketDataGenerator()) ``` -------------------------------- ### Configure AWS CLI Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Command to initialize AWS credentials and configuration settings. ```bash aws configure ``` -------------------------------- ### Constructing a Market Data Request Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Initializes a market data request using a Quandl API key from environment variables. ```python # Change this to your own Quandl API key quandl_api_key = os.environ['QUANDL_API_KEY'] md_request = market.create_md_request_from_str(md_request_str='fx.quandl.daily.NYC', md_request=MarketDataRequest(start_date='01 Jan 2021', finish_date='27 May 2021', quandl_api_key=quandl_api_key)) ``` -------------------------------- ### Initialize findatapy and chartpy environment Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Imports necessary libraries and disables logging and warnings for cleaner output. ```python import datetime from chartpy import Chart, Style from findatapy.market import Market, MarketDataGenerator, MarketDataRequest # So we don't see deprecated warnings... when you're coding it's usually good to leave these! import warnings warnings.filterwarnings('ignore') # Disable logging messages, to make output tidier import logging import sys logging.disable(sys.maxsize) ``` -------------------------------- ### Initialize Backtest Objects Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Initializes the main classes required for setting up and running a backtest: `Backtest`, `BacktestRequest`, and `FXConv`. These objects will be configured in subsequent steps. ```python backtest = Backtest() br = BacktestRequest() fxconv = FXConv() ``` -------------------------------- ### Initialize Logger and Datetime Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Sets up the logger for the application and imports the datetime module for date-related operations. This is standard housekeeping for Python scripts. ```python # housekeeping logger = LoggerManager().getLogger(__name__) import datetime ``` -------------------------------- ### Fix Benchmark Return Statistics Calculation Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Corrects a bug in the TradingModel when calculating benchmark return statistics with different start and finish dates. ```python # Fixed bug when calculating benchmark return statistics in TradingModel with different start/finish date ``` -------------------------------- ### Configure ArcticDB Connection String Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Sets up the ArcticDB connection string, allowing switching between local LMDB storage and S3 backend. Ensure AWS authentication is configured for S3. ```python local_storage = True # To switch between local storage or s3, it's a matter of changing the # connection string (also you need to make sure your AWS S3 authentication is set etc.) if local_storage: arcticdb_conn_str = "arcticdb:lmdb://tempdatabase?map_size=2GB" else: # https://docs.arcticdb.io/latest/#s3-configuration gives more details # Note we need to prefix arcticdb: to the front so findatapy # knows what backend engine to use region = "eu-west-2" bucket_name = "burger_king_whopper" # Not sure, if this name is taken :-) path_prefix = "test" arcticdb_conn_str = f"arcticdb:s3s://s3.{region}.amazonaws.com:{bucket_name}?path_prefix={path_prefix}&aws_auth=true" ``` -------------------------------- ### Enhance FXOptionPricer and Total Returns Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Includes additional work on `FXOptionPricer` and `FXOptionCurve` for total returns, speeding up the solver and handling non-convergence. Allows options entry on user-specified dates. ```python # Additional work on FXOptionPricer and total returns (FXOptionCurve) # Speed up and deal with non-convergence of solver # Allow options entry on user specified dates ``` -------------------------------- ### Configure ArcticDB Parameters Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Set the ArcticDB dictionary configuration on a MarketDataRequest object. ```python md_request_download.arcticdb_dict = arcticdb_dict ``` -------------------------------- ### Get vol for a specific delta Source: https://context7.com/cuemacro/finmarketpy/llms.txt Retrieves the implied volatility for a specific delta and expiry date from the constructed FX volatility surface. Requires the delta, expiry date, and the FXVolSurface object. ```python vol_25d = fx_vol_surface.get_vol_for_delta_expiry( delta=0.25, expiry_date="2023-09-30") ``` -------------------------------- ### Get vol for a specific strike and tenor Source: https://context7.com/cuemacro/finmarketpy/llms.txt Retrieves the implied volatility for a specific strike price and expiry date from the constructed FX volatility surface. Requires the strike, expiry date, and the FXVolSurface object. ```python vol = fx_vol_surface.get_vol_for_strike_expiry( strike=1.10, expiry_date="2023-12-30") ``` -------------------------------- ### Set ArcticDB Write Parameters Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Configures parameters for writing data to ArcticDB, including versioning, write style, and filtering options. Be cautious when using 'force_create_library'. ```python # Set various parameters to govern how we write to ArcticDB, to use # versioning arcticdb_dict = { # If this is set to true removes previous versions (so we only record # the final version). Not pruning versions will take more disk space. "prune_previous_versions": False, # Do we want to append to existing records or write # If you attempt to append with an overlapping chunk, you'll # get an assertion failure, "update" allows you to change existing data "write_style": "write", # "write" / "append" / "update" # If set to true will remove any existing library, before writing (careful with this!!) "force_create_library": False, # This enables us to take advantage of ArcticDB's filtering of columns/dates # otherwise we would download the full dataset, and then filter # in Pandas "allow_on_disk_filter": True, # You can also specify your own custom queries for ArcticDB "query_builder": None } ``` -------------------------------- ### Configure Backtest Parameters Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Sets the date range, transaction costs, and volatility targeting parameters for the backtest engine. ```python br.start_date = "02 Jan 1990" br.finish_date = datetime.datetime.utcnow() br.spot_tc_bp = 0 # 2.5 bps bid/ask spread br.ann_factor = 252 # have vol target for each signal br.signal_vol_adjust = True br.signal_vol_target = 0.05 br.signal_vol_max_leverage = 3 br.signal_vol_periods = 60 br.signal_vol_obs_in_year = 252 br.signal_vol_rebalance_freq = 'BM' br.signal_vol_resample_freq = None tech_params = TechParams(); tech_params.sma_period = 200; indicator = 'SMA' ``` -------------------------------- ### Add FX Vanilla Option Pricing and Total Return Indices Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Implements FX vanilla option pricing using FinancePy and calculates total return indices for these options. ```python # Added FX vanilla option pricing (via FinancePy) # Calculate total return indices for FX vanilla options ``` -------------------------------- ### Reinstall Redis on Unix Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Reinstalls the Redis in-memory database on Unix-based systems. ```bash brew reinstall redis ``` -------------------------------- ### Add Jupyter Notebook for ArcticDB Support Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Introduces a Jupyter notebook demonstrating the new ArcticDB support integrated with findatapy. ```python # Added Jupyter notebook for new ArcticDB support from findatapy ``` -------------------------------- ### Add VolStats and FX Total Return Calculations Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Introduces `VolStats` for realized vol, vol risk premium, and implied vol. Adds FX total return calculations for spot positions and begins work on forwards. Adapts FX vol code to the latest FinancePy and calculates implied PDF. ```python # Added VolStats and examples to calculate realized vol, vol risk premium and implied vol addons # Added FX total return calculations for FX spot positions # Begun to add FX total return calculations for FX forwards (incomplete) # Adapted FX vol code to latest version of FinancePy (note, may need to download via GitHub instead of PyPI) # Also calculated implied PDF for FX vol surface using FinancePy underneath ``` -------------------------------- ### Create FX vol surface object Source: https://context7.com/cuemacro/finmarketpy/llms.txt Creates an FXVolSurface object for interpolation and analysis of FX volatility surfaces. Requires market data, asset details, tenors, and specifies interpolation method and delta calculation methods. ```python fx_vol_surface = FXVolSurface( market_df=market_df, asset="EURUSD", field="close", tenors=["1W", "1M", "3M", "6M", "1Y"], vol_function_type="CLARK5", # Interpolation method atm_method="fwd-delta-neutral", delta_method="spot-delta") ``` -------------------------------- ### Visualize Portfolio Performance Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Configures chart styling and generates a plot of the portfolio cumulative index. ```python style = Style() style.title = "FX trend strategy" style.source = 'FRED' style.scale_factor = 1 style.file_output = 'fx-trend-example.png' Chart().plot(port, style=style) ``` -------------------------------- ### Write Market Data to Disk Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Save the fetched DataFrame to disk or S3 in Parquet format using the IOEngine. ```python IOEngine().write_time_series_cache_to_disk(folder, df, engine='parquet', md_request=md_request) ``` -------------------------------- ### Create S3 Bucket via CLI Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Command to create a new S3 bucket in a specific AWS region. ```bash aws s3api create-bucket --bucket my-bucket --region us-east-1 ``` -------------------------------- ### Fetch Market Data with Redis Caching Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Fetches market data using Redis caching. Ensure Redis is running and set `cache_algo` to `cache_algo_return` for optimal performance. ```python df = market.fetch_market(md_request_str='fx.quandl.daily.NYC', md_request=MarketDataRequest(start_date='01 Jan 2021', finish_date='27 May 2021', quandl_api_key=quandl_api_key, cache_algo='cache_algo_return')) print(df) ``` -------------------------------- ### Fetch Later Market Data Vintage Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Fetches the later version of market data by explicitly setting the 'as_of' parameter to the later download time. This demonstrates how to access the most recent data. ```python # We can also specify the later write time md_request_local_cache.as_of = later_download_time df_read_tick = Market().fetch_market(md_request=md_request_local_cache) ``` -------------------------------- ### Execute Backtest and Print Positions Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Runs the trading P&L calculation and outputs the final signal positions. ```python contract_value_df = None # use the same data for generating signals backtest.calculate_trading_PnL(br, asset_df, signal_df, contract_value_df, run_in_parallel=False) port = backtest.portfolio_cum() port.columns = [indicator + ' = ' + str(tech_params.sma_period) + ' ' + str(backtest.portfolio_pnl_desc()[0])] signals = backtest.portfolio_signal() # print the last positions (we could also save as CSV etc.) print(signals.tail(1)) ``` -------------------------------- ### Configure S3 Storage Path Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Define the S3 bucket path for storing market data files. ```python folder = 's3://type-here' ``` -------------------------------- ### Configure Backtest Parameters with BacktestRequest Source: https://context7.com/cuemacro/finmarketpy/llms.txt Use BacktestRequest to define essential backtest settings such as dates, transaction costs, volatility targeting, and position limits. ```python from finmarketpy.backtest import BacktestRequest # Create and configure a BacktestRequest br = BacktestRequest() # Basic backtest settings br.start_date = "01 Jan 2010" br.finish_date = "31 Dec 2023" br.spot_tc_bp = 2.5 # Transaction cost in basis points br.ann_factor = 252 # Annualization factor (trading days per year) # Signal-level volatility targeting br.signal_vol_adjust = True # Enable vol targeting per signal br.signal_vol_target = 0.10 # Target 10% annualized volatility br.signal_vol_max_leverage = 5 # Maximum leverage per signal br.signal_vol_periods = 20 # Lookback for volatility calculation br.signal_vol_obs_in_year = 252 # Observations per year br.signal_vol_rebalance_freq = "BME" # Rebalance at month end # Portfolio-level volatility targeting br.portfolio_vol_adjust = True br.portfolio_vol_target = 0.10 br.portfolio_vol_max_leverage = 3 br.portfolio_vol_periods = 60 br.portfolio_vol_rebalance_freq = "BME" # Position limits br.max_net_exposure = 2.0 # Maximum net exposure br.max_abs_exposure = 4.0 # Maximum absolute exposure # Stop loss and take profit br.stop_loss = -0.02 # 2% stop loss br.take_profit = 0.05 # 5% take profit # Output settings br.calc_stats = True # Calculate return statistics br.write_csv = False # Don't write CSV output br.include_benchmark = True # Include benchmark comparison # Technical indicator parameters br.tech_params.sma_period = 200 # 200-day SMA for trend following ``` -------------------------------- ### Fetch raw market data using a custom ticker string Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Downloads data for an arbitrary ticker not defined in the CSV files by using the 'raw' prefix. ```python df = market.fetch_market("raw.data_source.bloomberg.tickers.VIX.vendor_tickers.VIX Index", start_date='week') print(df) ``` -------------------------------- ### Fetch Market Data from Quandl Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Retrieves market data for a specific category string using a Quandl API key. Requires the QUANDL_API_KEY environment variable or a fallback string. ```python try: import os QUANDL_API_KEY = os.environ['QUANDL_API_KEY'] except: QUANDL_API_KEY = 'TYPE_YOUR_KEY_HERE' df = market.fetch_market(md_request_str="fx.quandl.daily.NYC", start_date='year', md_request=MarketDataRequest(quandl_api_key=QUANDL_API_KEY)) print(df.head(5)) ``` -------------------------------- ### Build the surface for a specific date Source: https://context7.com/cuemacro/finmarketpy/llms.txt Builds the FX volatility surface for a specific valuation date. Requires the FXVolSurface object and the desired date. ```python fx_vol_surface.build_vol_surface(value_date="2023-06-30") ``` -------------------------------- ### Fetch Market Data Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Initialize a MarketDataRequest and fetch tick data for a specific ticker. ```python from findatapy.market.ioengine import IOEngine md_request = MarketDataRequest( start_date='04 Jan 2021', finish_date='05 Jan 2021', category='fx', data_source='dukascopy', freq='tick', tickers=['EURUSD'], fields=['bid', 'ask', 'bidv', 'askv'], data_engine=None ) market = Market() df = market.fetch_market(md_request=md_request) ``` ```python print(df) ``` -------------------------------- ### Custom Data Credentials Class Source: https://github.com/cuemacro/finmarketpy/blob/master/INSTALL.md Use this class to override default configuration parameters like data folder paths and API keys. Place this file in the 'util' folder to ensure it's not overwritten during upgrades. ```python class DataCred(object): folder_historic_CSV = "E:/tickdata/historicCSV" folder_time_series_data = "C:/timeseriesdata" config_root_folder = "E:/Remote/yen/conf/" ###### FOR ALIAS TICKERS # config file for time series categories time_series_categories_fields = \ config_root_folder + "conf/time_series_categories_fields.csv" # we can have multiple tickers files (separated by ";") time_series_tickers_list = config_root_folder + "conf/time_series_tickers_list.csv;" + \ config_root_folder + "conf/futures_contracts_tickers.csv" time_series_fields_list = config_root_folder + "conf/time_series_fields_list.csv" # config file for long term econ data all_econ_tickers = config_root_folder + "conf/all_econ_tickers.csv" econ_country_codes = config_root_folder + "conf/econ_country_codes.csv" econ_country_groups = config_root_folder + "conf/econ_country_groups.csv" default_market_data_generator = "marketdatagenerator" # Quandl settings quandl_api_key = "XYZ" # Twitter settings (you need to set these up on Twitter) TWITTER_APP_KEY = "XYZ" TWITTER_APP_SECRET = "XYZ" TWITTER_OAUTH_TOKEN = "XYZ" TWITTER_OAUTH_TOKEN_SECRET = "XYZ" # FRED API key fred_api_key = "XYZ" # database settings need to be filled in even if you aren't going to use one # main database settings db_server = '127.0.0.1' # cache database settings db_cache_server = '127.0.0.1' db_cache_port = '6379' write_cache_engine = 'redis' # Override multithreading for certain categories of downloads override_multi_threading_for_categories = [] ``` -------------------------------- ### Load FX Market Data from FRED Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Loads historical daily closing prices for specified USD FX crosses from FRED. Requires a FRED API key, which can be set as an environment variable or directly in the code. Uses 'internet_load_return' cache algorithm. ```python try: import os FRED_API_KEY = os.environ['FRED_API_KEY'] except: FRED_API_KEY = 'TYPE_YOUR_KEY_HERE' # pick USD crosses in G10 FX # note: we are calculating returns from spot (it is much better to use to total return # indices for FX, which include carry) logger.info("Loading asset data...") tickers = ['EURUSD', 'USDJPY', 'GBPUSD', 'AUDUSD', 'USDCAD', 'NZDUSD', 'USDCHF', 'USDNOK', 'USDSEK'] vendor_tickers = ['DEXUSEU', 'DEXJPUS', 'DEXUSUK', 'DEXUSAL', 'DEXCAUS', 'DEXUSNZ', 'DEXSZUS', 'DEXNOUS', 'DEXSDUS'] md_request = MarketDataRequest( start_date="01 Jan 1989", # start date finish_date=datetime.date.today(), # finish date freq='daily', # daily data data_source='alfred', # use FRED as data source tickers=tickers, # ticker (findatapy) fields=['close'], # which fields to download vendor_tickers=vendor_tickers, # ticker vendor_fields=['close'], # which Bloomberg fields to download cache_algo='internet_load_return', fred_api_key=FRED_API_KEY) # how to return data market = Market(market_data_generator=MarketDataGenerator()) asset_df = market.fetch_market(md_request) spot_df = asset_df ``` -------------------------------- ### Execute Backtest with Backtest Engine Source: https://context7.com/cuemacro/finmarketpy/llms.txt The Backtest class processes asset prices and signals to calculate P&L and performance metrics. Requires data fetching via findatapy and signal generation via TechIndicator. ```python from finmarketpy.backtest import Backtest, BacktestRequest from finmarketpy.economics import TechIndicator, TechParams from findatapy.market import Market, MarketDataRequest, MarketDataGenerator from chartpy import Chart, Style import datetime # Initialize backtest engine backtest = Backtest() br = BacktestRequest() # Configure backtest parameters br.start_date = "02 Jan 1990" br.finish_date = datetime.datetime.utcnow() br.spot_tc_bp = 2.5 br.ann_factor = 252 br.signal_vol_adjust = True br.signal_vol_target = 0.05 br.signal_vol_max_leverage = 3 br.signal_vol_periods = 60 # Load market data md_request = MarketDataRequest( start_date="01 Jan 1989", finish_date=datetime.date.today(), freq='daily', data_source='alfred', tickers=['EURUSD', 'USDJPY', 'GBPUSD'], fields=['close'], vendor_tickers=['DEXUSEU', 'DEXJPUS', 'DEXUSUK'], vendor_fields=['close'], cache_algo='internet_load_return') market = Market(market_data_generator=MarketDataGenerator()) asset_df = market.fetch_market(md_request) # Generate trading signals using SMA crossover tech_params = TechParams() tech_params.sma_period = 200 tech_ind = TechIndicator() tech_ind.create_tech_ind(asset_df, "SMA", tech_params) signal_df = tech_ind.get_signal() # Run backtest backtest.calculate_trading_PnL(br, asset_df, signal_df, contract_value_df=None, run_in_parallel=False) # Extract results portfolio_cum = backtest.portfolio_cum() # Cumulative P&L portfolio_pnl = backtest.portfolio_pnl() # Daily returns portfolio_signal = backtest.portfolio_signal() # Position signals portfolio_leverage = backtest.portfolio_leverage() # Leverage over time ret_stats = backtest.portfolio_pnl_ret_stats() # Return statistics ``` -------------------------------- ### Generate comprehensive return statistics and plots Source: https://context7.com/cuemacro/finmarketpy/llms.txt Generates detailed return statistics and plots for a trading strategy. Requires a run TradingModel instance and specifies the analysis engine. ```python ta = TradeAnalysis() ta.run_strategy_returns_stats(model, engine="finmarketpy") ``` -------------------------------- ### Import findatapy Market Modules Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Imports the necessary classes for market data requests and management. ```python import datetime from findatapy.market import Market, MarketDataRequest ``` -------------------------------- ### Import necessary libraries for Market Data Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Imports the Market and MarketDataRequest classes from the findatapy.market module, and IOEngine for potential file operations. ```python import os from findatapy.market import Market, MarketDataRequest # In this case we are saving predefined tick tickers to disk, and then reading back from findatapy.market.ioengine import IOEngine ``` -------------------------------- ### Fetch market data Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Executes the data request using the market object. ```python df = market.fetch_market(md_request) ``` -------------------------------- ### Fetch daily market data using a string ticker Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Fetches daily EURUSD data from Bloomberg using a predefined ticker string. Requires blpapi and a Bloomberg Terminal subscription. ```python df = market.fetch_market("fx.bloomberg.daily.NYC.EURUSD.close") print(df) ``` -------------------------------- ### Sensitivity analysis - test different parameter combinations Source: https://context7.com/cuemacro/finmarketpy/llms.txt Performs sensitivity analysis on a trading strategy by testing various parameter combinations, particularly for volatility targeting. Requires a list of parameter dictionaries and corresponding display names. ```python parameter_list = [ {"portfolio_vol_adjust": True, "signal_vol_adjust": True}, {"portfolio_vol_adjust": False, "signal_vol_adjust": False}, {"portfolio_vol_target": 0.05, "signal_vol_target": 0.05}, {"portfolio_vol_target": 0.15, "signal_vol_target": 0.15} ] pretty_names = [ "Vol Target 10%", "No Vol Target", "Vol Target 5%", "Vol Target 15%" ] ta.run_arbitrary_sensitivity( model, parameter_list=parameter_list, pretty_portfolio_names=pretty_names, parameter_type="volatility targeting") ``` -------------------------------- ### Refactor TradingModel Weight Construction Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Refactors the `TradingModel` class for improved construction of weights. ```python # Refactored TradingModel when constructing weights ``` -------------------------------- ### Read Market Data from Disk Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Retrieve previously saved market data from a specific file path. ```python s3_filename = folder + '/backtest.fx.dukascopy.tick.NYC.EURUSD.parquet' df = IOEngine().read_time_series_cache_from_disk(s3_filename, engine='parquet') print(df) ``` -------------------------------- ### Define Quandl market data request Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Configures a MarketDataRequest to fetch interest rate data from Quandl using an API key. ```python try: import os QUANDL_API_KEY = os.environ['QUANDL_API_KEY'] except: QUANDL_API_KEY = 'TYPE_YOUR_KEY_HERE' # Monthly average of UK resident monetary financial institutions' (excl. Central Bank) sterling # Weighted average interest rate, other loans, new advances, on a fixed rate to private non-financial corporations (in percent) # not seasonally adjusted md_request = MarketDataRequest( start_date="01 Jan 2005", # start date data_source='quandl', # use Quandl as data source tickers=['Weighted interest rate'], fields=['close'], # which fields to download vendor_tickers=['BOE/CFMBJ84'], # ticker (Bloomberg) vendor_fields=['close'], # which Bloomberg fields to download cache_algo='internet_load_return', quandl_api_key=QUANDL_API_KEY) # how to return data ``` -------------------------------- ### Set FinancePy Version Requirement and Refactor FXVolSurface Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Sets the required FinancePy version to 0.220 and refactors the FXVolSurface class accordingly. ```python # Set FinancePy version required to 0.220 and refactored FXVolSurface for # this ``` -------------------------------- ### Retrieve predefined categories from ConfigManager Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Accesses the ConfigManager to list all available data categories and filter them by source. ```python from findatapy.util import ConfigManager cm = ConfigManager().get_instance() # Get all the categories for raw data (note this won't include generated categories like fx-vol-market, # which aggregate from many other categories) categories = list(cm.get_categories_from_tickers()) # Filter those categories which include quandl quandl_category = [x for x in categories if 'quandl' in x] print(quandl_category) ``` -------------------------------- ### Append Data to ArcticDB Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Configure a MarketDataRequest for appending data by setting the write_style and using the Market wrapper. ```python # Now download a second set of data and write it for "append" # Note: we'll get an assertion error, if we try to append before the end # of the existing time series on disk md_request_download.start_date = "06 Jan 2021" md_request_download.finish_date = "07 Jan 2021" md_request_download.arcticdb_dict["write_style"] = "append" df_tick_later = market.fetch_market(md_request=md_request_download) IOEngine().write_time_series_cache_to_disk(data_frame=df_tick_later, engine=arcticdb_conn_str, md_request=md_request_download) ``` -------------------------------- ### Fetching Market Data Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/s3_bucket_example.ipynb Retrieves market data from the specified source using the request object. ```python df = market.fetch_market(md_request) print(df) ``` -------------------------------- ### Adapt FXVolSurface to FinancePy and Add FXOptionsCurve Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Changes `FXVolSurface` to better fit the newest FinancePy version and adds the missing `FXOptionsCurve` class. ```python # Changed FXVolSurface to fit better with newest FinancePy # Added missing FXOptionsCurve class ``` -------------------------------- ### Fix FX Vol Surface Parameters Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Addresses issues with incorrect pushing of 10-day quotes on the FX vol surface and adds extra parameters for `FXOptionsCurve`, freezing FX implied rates, and calendars. ```python # Fixed incorrect pushing of 10d quotes on FX vol surface # Added extra parameters for FXOptionsCurve, freezing FX implied, calendar etc. ``` -------------------------------- ### Customize Strike Range for FX Vol Surface Extraction Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Adds functionality to customize the strike range when extracting FX vol surfaces. ```python # Customize strike range for extracting FX vol surface ``` -------------------------------- ### Update Existing Data in ArcticDB Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Fetches market data for a specific date range and updates an existing continuous chunk in ArcticDB. Ensure the update range is within or adjacent to existing data to avoid errors. ```python md_request_download.start_date = "06 Jan 2021" md_request_download.finish_date = "07 Jan 2021" md_request_download.arcticdb_dict["write_style"] = "update" df_tick_later = market.fetch_market(md_request=md_request_download) ``` -------------------------------- ### Export to Excel with positions and trades Source: https://context7.com/cuemacro/finmarketpy/llms.txt Exports a detailed trading strategy report, including returns, positions, and trade sizes, to an Excel file. Requires a run TradingModel instance and a specified output file name. ```python ta.run_excel_trade_report( model, excel_file='strategy_report.xlsx') ``` -------------------------------- ### Generate Technical Signals Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/backtest_example.ipynb Initializes the technical indicator engine and computes signals based on the provided spot data and parameters. ```python logger.info("Running backtest...") # use technical indicator to create signals # (we could obviously create whatever function we wanted for generating the signal dataframe) tech_ind = TechIndicator() tech_ind.create_tech_ind(spot_df, indicator, tech_params); signal_df = tech_ind.get_signal() ``` -------------------------------- ### Fetch Earlier Market Data Vintage Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Retrieves an earlier version of market data by setting the 'as_of' parameter in the MarketDataRequest. This allows access to historical data vintages. ```python # Let's instead take the first vintage md_request_local_cache.as_of = earlier_download_time df_read_tick = Market().fetch_market(md_request=md_request_local_cache) # We should only see the earlier vintage print("See the earlier vintage write!") print(df_read_tick) ``` -------------------------------- ### Write Time Series to ArcticDB Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Use IOEngine to persist a DataFrame to ArcticDB using a MarketDataRequest for automatic filename construction. ```python IOEngine().write_time_series_cache_to_disk(data_frame=df_tick, engine=arcticdb_conn_str, md_request=md_request_download) # Snap the time, so we can fetch this vintage later earlier_download_time = datetime.datetime.now().utcnow() ``` -------------------------------- ### Modify and Write Market Data to ArcticDB Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/arcticdb_example.ipynb Scales the dataframe by a factor of 10 and persists the changes to the disk cache using the IOEngine. ```python df_tick_later = df_tick_later * 10.0 IOEngine().write_time_series_cache_to_disk(data_frame=df_tick_later, engine=arcticdb_conn_str, md_request=md_request_download) ``` -------------------------------- ### Convert Library Ticker to Vendor Ticker Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Maps an internal library ticker string to its corresponding vendor-specific ticker format. ```python vendor_tickers = cm.convert_library_to_vendor_ticker_str("fx.quandl.daily.NYC.EURUSD") print(vendor_tickers) ``` -------------------------------- ### Fetch intraday market data using a string ticker Source: https://github.com/cuemacro/finmarketpy/blob/master/finmarketpy_examples/finmarketpy_notebooks/market_data_example.ipynb Fetches intraday EURUSD data for the past week using a predefined ticker string. ```python df = market.fetch_market("fx.bloomberg.intraday.NYC.EURUSD.close", start_date='week') print(df) ``` -------------------------------- ### Add S3 Jupyter Notebook for findatapy Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Provides a Jupyter notebook for using findatapy with Amazon S3 storage. ```python # Added S3 Jupyter notebook for use with findatapy ``` -------------------------------- ### Day-of-month performance analysis Source: https://context7.com/cuemacro/finmarketpy/llms.txt Performs an analysis of trading strategy performance broken down by the day of the month. Requires a run TradingModel instance. ```python ta.run_day_of_month_analysis(model) ``` -------------------------------- ### Fix Missing GBP Depo Tickers and Startup on MacOS Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Resolves issues with missing GBP depo tickers and startup problems on newer macOS versions. ```python # Fixed missing GBP depo tickers # Fixed startup on newer MacOS ``` -------------------------------- ### Load FX vol surface data Source: https://context7.com/cuemacro/finmarketpy/llms.txt Loads FX volatility surface data from a specified data source (e.g., Bloomberg) for a given asset and date range. Requires MarketDataRequest object to specify parameters. ```python market = Market(market_data_generator=MarketDataGenerator()) md_request = MarketDataRequest( start_date="01 Jan 2020", finish_date="31 Dec 2023", data_source="bloomberg", category="fx-vol-market", tickers=["EURUSD"], cache_algo="internet_load_return") market_df = market.fetch_market(md_request) ``` -------------------------------- ### Helper Code for TradingModel Boilerplate Reduction Source: https://github.com/cuemacro/finmarketpy/blob/master/README.md Provides helper code to reduce boilerplate in TradingModel implementations. ```python # Helper code to reduce boiler plate code for TradingModel ``` -------------------------------- ### Transaction cost sensitivity analysis Source: https://context7.com/cuemacro/finmarketpy/llms.txt Analyzes the impact of transaction costs on strategy performance by shocking the cost parameter across a range of values. Requires a list of transaction cost values to test. ```python tc_values = [0, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0] ta.run_tc_shock(model, tc=tc_values) ```