<jupyter_start><jupyter_text>Here we have presented very small apporach just to give an overview that our library is working for the virtual environment we have created.<jupyter_code>#importing required libraries

from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from infertrade.utilities.performance import calculate_portfolio_performance_python
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
data = pd.read_csv("LBMA_Gold.csv")
data.shape
data.head()
data.dtypes
data.isnull().any()
data['LBMA/GOLD usd (pm)'].describe()
data['LBMA/GOLD usd (pm)'].value_counts().head(10)
plt.hist(data['LBMA/GOLD usd (pm)'])
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
sns.distplot(data['LBMA/GOLD usd (pm)'])
data['LBMA/GOLD usd (pm)'] = data['LBMA/GOLD usd (pm)'].fillna(data['LBMA/GOLD usd (pm)'].median())
data['LBMA/GOLD usd (pm)'].isnull().sum()
def buy_on_small_rises(df: pd.DataFrame) -> pd.DataFrame:
    """A rules that buys when the market rose between 2% and 10% from previous close."""
    df["allocation"] = 0.0
    df.loc[df["price"].pct_change(50) >= 0.02, "allocation"] = 0.25
    df.loc[df["price"].pct_change(50) >= 0.05, "allocation"] = 0.5
    df.loc[df["price"].pct_change(50) >= 0.10, "allocation"] = 0.0
    return df

my_dataframe_without_allocations = data.rename(columns={"LBMA/GOLD usd (pm)": "price", "Date": "date"})
my_dataframe_with_allocations = buy_on_small_rises(my_dataframe_without_allocations)
my_dataframe_with_returns = calculate_portfolio_performance_python(my_dataframe_with_allocations)
my_dataframe_with_returns.plot(x="date", y=["allocation", "portfolio_return"])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14863325740318906, 'fraction_numerical': 0.01651480637813212, 'mean_word_length': 6.774336283185841, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '214403', 'license': 'Apache-2.0', 'n_tokens_mistral': 664, 'n_tokens_neox': 627, 'n_words': 133, 'path': 'conda_installation_walkthrough_for_infertrade/example/example.ipynb', 'repo_name': 'fhashim/infertrade', 'size': '1756'}