### Algorithm Console

Tanulytics Strategy Factory builds alternate investment strategies focused on maximizing returns and minimizing variability and drawdowns. Alpha factors are found by stress testing ideas, utilizing quantitative finance methods & basic machine learning.

##### Ask -> Define -> Acquire

###### 1. What are your goals and objectives [“MoneyRiskManagement”]

` a. Assets/Portfolio (Current Position)`

b. Expected Return/Year

c. Drawdown

d. Average Holding Period

Set certain criteria for whether it moves onto the final step.

##### Wrangle -> Prepare

###### 2. Ideas (Strategy Factory) [“AlgoXchange/StrategyFactory”]

##### Explore -> Analyze -> Model

###### 3. Quick Test [“AlgoBACKTESTING”]

`a. Simple-Limited Period test --> Will tell you if your idea has any merit at all.`

###### 4. Detailed Testing [“AlgoBACKTESTING”]

` a. Walk Forward Testing`

b. Optimization

c. Monte Carlo Simulations - Take those trades and mix the order up randomly

##### Execute -> Communicate

###### 5. Incubation [“AlgoXchange”] *(sits on a shelf ready for deployment. Running in paper Trades, periodic checking to see if what’s its doing.)*

` a. Yes`

b. No

c. Evaluate it longer

###### 6. Portfolio Evaluation Once a month [“MoneyRiskManagement”]

` a. Bring in new ones (from shelf)`

b. Increase size of existing ones

###### 7. Go Live [“MoneyRiskManagement”]/[“XeQT”]

###### 8. Criteria for when you're going to stop trading your system [“MoneyRiskManagement”]

`a. X drawdown.`

Algorithmic Tradingis developing fully automated(Full-Auto)trading systems (Front to Back) whereasQuantitative Tradingis developing mathematically driven trading systems with a degree of automation(Semi-Auto)anywhere in the process.

#### Monte Carlo Simulation (Ver 1.0)

- n —
*number of trails (for simulation)* - t —
*number of trades* - win —
*win rate (%)* - ratio —
*reward-to-risk ratio* - risk —
*risk per trade (%)* - aum —
*starting account size (USD)*

`import numpy as np`

import numpy.random as npr

import matplotlib.pyplot as plt

import scipy

from scipy import stats

import pandas as pd

%matplotlib inline#

import numpy.random as npr

import matplotlib.pyplot as plt

import scipy

from scipy import stats

import pandas as pd

%matplotlib inline#

`Monte Carlo Simulation Algorithm`

`def monteCarlo(n,t,win,ratio,risk,aum):`

folio = []

for each in range(n):

equity = [aum]

#test = npr.rand(n,t) # Randomizer

sim = npr.binomial(1,win,t) # Bimonial Distribution

for i in range(t):

if sim[i] == 1:

result = equity[i]+equity[i]*risk*ratio

if sim[i] == 0:

result = equity[i]-equity[i]*risk

equity.append(result)

folio.append(equity)

folio = pd.DataFrame(folio).transpose()

folio.plot(legend=False)

return folio

folio = []

for each in range(n):

equity = [aum]

#test = npr.rand(n,t) # Randomizer

sim = npr.binomial(1,win,t) # Bimonial Distribution

for i in range(t):

if sim[i] == 1:

result = equity[i]+equity[i]*risk*ratio

if sim[i] == 0:

result = equity[i]-equity[i]*risk

equity.append(result)

folio.append(equity)

folio = pd.DataFrame(folio).transpose()

folio.plot(legend=False)

return folio

`def returnsAnalysis(folio):`

r = (((folio[t:]/aum)-1)*100).transpose()

print(r.describe())

return r

r = (((folio[t:]/aum)-1)*100).transpose()

print(r.describe())

return r

`# Run Simulation`

n = 100 # number of scenarios

t = 12 # number of trades per scenario

win = 0.70 # win rate (%)

avg_win = 1650

avg_loss = 1650

ratio = avg_win/avg_loss # reward-to-risk ratio

risk = 0.02 # risk per trade (%)

aum = 10000 # starting account size (USD)

n = 100 # number of scenarios

t = 12 # number of trades per scenario

win = 0.70 # win rate (%)

avg_win = 1650

avg_loss = 1650

ratio = avg_win/avg_loss # reward-to-risk ratio

risk = 0.02 # risk per trade (%)

aum = 10000 # starting account size (USD)

`max = (aum*risk)/avg_loss`

print("Max # of contract exposure:",max)

print("Max # of contract exposure:",max)

`portfolio = monteCarlo(n,t,win,ratio,risk,aum)`

returns = returnsAnalysis(portfolio)

returns = returnsAnalysis(portfolio)

`# Box Plot of Returns`

c = 'black'

plt.boxplot(returns.values, sym='*', patch_artist=True, boxprops=dict(facecolor=c, color=c), capprops=dict(color=c), whiskerprops=dict(color=c), flierprops=dict(color=c, markeredgecolor=c)) # https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.boxplot

plt.grid(True)

plt.xlabel('Distribution of Returns')

plt.ylabel('ROI (%)')

c = 'black'

plt.boxplot(returns.values, sym='*', patch_artist=True, boxprops=dict(facecolor=c, color=c), capprops=dict(color=c), whiskerprops=dict(color=c), flierprops=dict(color=c, markeredgecolor=c)) # https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.boxplot

plt.grid(True)

plt.xlabel('Distribution of Returns')

plt.ylabel('ROI (%)')

`# Histogram of Returns`

plt.hist(returns.values, bins=10)

plt.grid(True)

plt.xlabel('ROI (%)')

plt.ylabel('frequency')

plt.hist(returns.values, bins=10)

plt.grid(True)

plt.xlabel('ROI (%)')

plt.ylabel('frequency')

Special thanks to all the research and open-source contributors to Data Science and knowledge in the world. Especially our partner, Dbuntu LABS who fully facilitates the process of developing Tanulytics Strategy Factory.

### Trading Plan & Process

#### The Yin & Yang (Balance) of Trading

- Objective (Evidence-Based) Planning Tools
- Develop & Document & Test Strategies
- Identify New Trade Opportunities
- Monitor Market Positions
- Automated Market Analysis
- Automated Trade Execution

The purpose of this process is to ensure the smooth running & sustainability of the trading business. It splits up the necessary goals into meaningful subgoals and prevents time-wasting and ineffective actions.

Target KPI (AUM, % Returns, AUM Mgmt Fee — 2%, Performance Bonus — 20%)

#### Investment Universe: Market News Preparation

“Just trade the swings.”

**Relevant Economic Indicators** (Bloomberg Economic Calendar on the website or FactSet Economic Calendar)

- Economic indicators are released each week
- Compare the actual economic indicator number released to its respective forecast
- Is the actual economic number better or worse than the forecast?
- Did the economic indicator report positively or negatively impact the financial markets, if so, why?
- What has been the recent trend of the economic indicator report that impacted the financial markets?

“Markets are constantly in a state of uncertainty and flux and money is made by discounting the obvious and betting on the unexpected.” — George Soros

**AMB Portfolio Company Earnings Reports & Major News Items**

- Check AMB Portfolio news items each day by adding FactSet “news” column in the Portfolio Performance tab
- Keep informed of AMB Portfolio company earnings results by adding FactSet “Exp Report Date” column in the Portfolio Performance tab
- When a company reports its quarterly earnings results, determine if the company exceeded, met, or missed consensus earnings estimates by clicking on the “Company” tab, then the “Estimates” tab, then the “Surprise History” tab in FactSet
- If the AMB portfolio company provided financial guidance (quarterly and/or annual) on the earnings call, was the guidance above, in-line or below consensus sales and/or earnings estimates?
- Did the stock react positively or negatively to the company’s earnings results? (in the “Surprise History” tab at the far right column it shows the stock price impact as a percentage)

#### Position Sizing, Risk, & Money Management

The general principle I set is a per-trade loss limit of 1% of my entire account and then a limit to the position size based on that. The expectancy is to risk a max of 1% with the potential to gain a min of 2% + on each trade. Then maximize the trade frequency and let statistics take over. If the stop is tight, I may end up getting out if the trade goes against me even a little bit, but I can always get back in at a lower/higher point (depending on if the trade is long/short).

“Look down, not up, when making your initial investment decision. If you don’t lose money, most of the remaining alternatives are good ones.”- Joel Greenblatt

## Comments