jean-michel-gonet / angular-backtest Goto Github PK
View Code? Open in Web Editor NEWA simple backtest framework written in typescript, to test investing strategies and considering trading costs
License: MIT License
A simple backtest framework written in typescript, to test investing strategies and considering trading costs
License: MIT License
quotes-from-xxx.service.ts
classes gives no hint about what data they actually process.README.md
so that the potential user understands how to list the financial sources he can use.README.md
, because they'll change, and we'll never remember to update the documentation.src/app/services/quotes
to match the README.md
in a satisfactory way.Fetching online data is nice because you always have it fresh, but there are some shortcomings:
The bottom line is, fetching online data has too many disadvantages.
Stock
and StockData
.exchangeRate
, pointing to exchange rate data.Where to invest when market goes bearish?
We want to compare these two options:
Make a simulation comparing the USD/CHF exchange rate and the following two strategies:
Because reinvesting dividends happens inevitably if you use market timing. Consider a strategy set with reinvestDividends=false
in the following scenario:
So the dividends are reinvested, independently of the value of reinvestDividends
, and there is no fix, as the cash from dividends is mixed with the cash from selling the assets.
RegularTransfer
class so we can have a Transfer
that considers the regular withdrawal (as of now) plus transferring the dividends when there are any.simulation
component, and see it. It is simple and satisfactory of a single individual, just wanting to test something.Because sometimes it is impossible to find the historical data for dividends (the SP500 is a special case). Just using the 'total return' index would suit a simulation where we reinvest all dividends, however this is hardly convenient because of several reasons:
Implement a market timing based on the following strategy:
periodLength
for MONTHLY
, SEMIMONTHLY
and WEEKLY
.The strategy has the following properties:
Run simulations on ACWX taking into account:
Replicate the results of:
Because it looks reasonable to buy when the P/E ratio is low, and sell when it is high.
Or is it?
y = xA
, it should say y = xTA
.Stock
class should be Quote
, and the StockData
should be QuoteHistory
.isin
property that is ubiquitous through the code should be name
.services/stock
folder. It should be services/quotes
.Because time passes, and we need to keep up
Use the official page for upgrade instructions:
Apply the --force
flag
Candlestick
, containing the open, close, highest, lowest prices.HistoricalQuotes
, fill all the gaps, so all instruments are present at all instants.You can download any data (for example: https://finance.yahoo.com/quote/%5EIBEX?p=%5EIBEX) from yahoo, save it in the appropriate folder, add it to the configuration file, and use it in a simulation.
My goal is to write a back-testing blog with plenty of simulation examples:
<simulation>
tags.Yahoo and Investing can be downloaded again via
npm run refresh-quotes SPY AGG AUG
Pros:
Cons:
Follow this tutorial:
MarketTiming
interface, so it can be used interchangeably to any other implementation.Display a vertical line with the mention Bear or Bull.
See demo here:
Until now we've been downloading stock data from SIX, YAHOO and INVESTING but, besides being a time consuming process, they only offer historical data of currently listed stock:
The idea is not to directly use data from Marketstack during simulation, because there is a limit of the monthly requests.
Instead, it is better to have the downloaded data stored locally:
We've implemented so far: the Candle filter, the EMA filter and the MACD filter:
Also, we want to use the application, so we can see how handy it is.
Compare the three filters with the following indexes:
Establish:
Keep:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.