Saturday, 24 June 2017

Quantstrat Forex Broker

Dieser Beitrag wird eine eingehende Überprüfung der Alpha Architect8217s Quantitative Momentum Buch. Meiner Meinung nach ist das Buch für diejenigen, die Praktiker in der Fondsverwaltung in den einzelnen Equity-Bereich sind, und enthält immer noch Ideen, die darüber nachzudenken, außerhalb des Raumes ist toll. Allerdings profitiert das in diesem Buch genannte System von der verschachtelten Rangfolge (ordnen Sie entlang der Achse X, nehmen Sie das oberste Dezil, rangieren Sie entlang der Achse Y innerhalb des oberen Dezils in X und nehmen Sie das obere Dezil entlang der Achse Y, was im Wesentlichen die Auswahl auf 1 beschränkt Universum). Darüber hinaus ist das Buch nicht viel für die Berührung der Volatilität Kontrollen, die das System erheblich verbessert haben können. Bevor ich in die Hauptlast dieses Posten einsteige, möchte ich meinen Lesern wissen lassen, dass ich meine Nüsse und Schrauben der Quantstrat-Reihe von Beiträgen als formalen Datacamp-Kurs formalisiert habe. Datacamp ist ein sehr billiger Weg, um ein Bündel von R zu lernen, und Finanzanwendungen gehören zu diesen Themen. Mein Kurs umfasst die Grundlagen der quantstrat, und wenn diejenigen, die den Kurs wie es zu vervollständigen, kann ich sehr gut erstellen erweiterte quantstrat Module auf datacamp. I8217m in der Hoffnung, dass die Finanz-Kurse gut angenommen werden, da es finanzielle Themen in R I8217d wie ich selbst lernen, dass eine 45-minütige Vortrag doesn8217t wirklich ausreichen für (wie Dr. David Matteson8217s ändern Punkte Magie, PortfolioAnalytics, und so weiter). Auf jeden Fall ist hier der Link. So beginnen let8217s mit einer Zusammenfassung des Buches: Teil 1 ist einige Kapitel, die die riesige Expose sind - von, warum Impuls arbeitet (oder mindestens, seit mindestens 20 Jahren seit 1993 gearbeitet hat), dass menschliche Vorurteile und irrationales Verhalten in handeln Bestimmte Weisen, die Anomaliearbeit zu bilden. Dann gibt es auch das Karriere-Risiko (AKA it8217s ein Risikofaktor, und so, wenn Ihr Benchmark SPY ist und Sie über eine 3-jährige Periode der Underperformance laufen, haben Sie ein hohes Karriere-Risiko) und im Wesentlichen eine ganze Litanei, warum ein professionelles Vermögen Manager würde gefeuert, aber wenn Sie nur mit der Anomalie über viele viele Jahre halten und reiten mehrjährige Strecken der relativen Underperformance, you8217ll kommen voraus auf lange Sicht. Im Allgemeinen fühle ich mich wie there8217s Arbeit getan werden, wenn dies das beste, was getan werden kann, aber okay, I8217ll akzeptieren. Im Wesentlichen ist Teil 1 für die Uneingeweihten. Für diejenigen, die um das Momentum Block ein paar Mal gewesen sind, können sie direkt überspringen. Leider ist es die Hälfte des Buches, so dass ein wenig saurer Geschmack im Mund verlässt. Als nächstes ist Teil zwei, wo, meiner Meinung nach, das wahre Fleisch und Kartoffeln des Buches8211die 8220how8221. Grundsätzlich kann der Algorithmus folgendermaßen abgekocht werden: Nehmen Sie das Universum von Groß - und Mittelkapseln auf, so gehen Sie folgendermaßen vor: 1) Sortieren Sie die Aktien in Dezile um 2-12 Momentum8211, dh am Ende eines jeden Monats wird das Momentum berechnet Von letztem Monat8217s Schlusskurs abzüglich des Schlusskurses vor 12 Monaten. Im wesentlichen geht aus der Forschung hervor, daß es einen Rückwirkungseffekt auf den 1-Monats-Impuls gibt. Dieser Effekt wird jedoch nach meiner Erfahrung nicht in das ETF-Universum übertragen. 2) Hier ist der interessante Teil, der das Buch auf eigene Faust aufnimmt (meiner Meinung nach): nach dem Sortieren in Dezile das obere Dezil durch folgende Metrik zuordnen: Multiplizieren Sie das Vorzeichen des 2-12-Impulses mit der folgenden Gleichung: (Negative Renditen 8211 positiv). Im Wesentlichen ist die Idee hier, um die Glätte des Impulses zu bestimmen. Das heißt, in der extremsten Situation vorstellen, eine Aktie, die absolut nichts für 230 Tage, und dann hatte einen massiven Tag, gab es seine gesamte Preisschätzung (denken Sie, Google, wenn es einen 10-Sprung von besser als erwartete Zahlen hatte Berichte), und im anderen Extrem, eine Aktie, die hatte einfach jeden Tag eine kleine positive Preisschätzung. Offensichtlich wollen Sie die zweite Art von Lager. Das ist diese Idee. Wieder, sortieren Sie in Dezile, und nehmen Sie das obere Dezile. Daher lässt Sie das obere Dezil des oberen Dezils mit 1 des Universums. Im Grunde macht dies die Idee sehr schwer zu replizieren8211since you8217d brauchen, um eine massive Universum von Aktien aufzuspüren. Das heißt, ich denke, der Ausdruck ist eigentlich eine ziemlich gute Idee als Stand-In für Volatilität. Das heißt, unabhängig davon, wie flüchtig ein Vermögenswert ist, obgleich es so flüchtig wie eine Ware wie DBC oder als nicht-volatil ist, wie ein festverzinsliches Produkt wie SHY, ist dieser Ausdruck eine interessante Art und Weise zu bezeichnen, dass dieser Weg choppy8221 vs 8220dieser Weg ist Glatt8221. Ich könnte diesen Ausdruck auf meinem Blog weiter in die Zukunft zu untersuchen. 3) Schließlich, wenn das Portfolio dreht sich mehr als vierteljährlich statt monatlich, die besten Monate, um es zu drehen sind die Monate vor Ende des Quartals Monat (das heißt, Februar, Mai, August, November), weil ein Bündel von Amateur-Asset Manager wie 8220window dress8221 ihre Portfolios. Das heißt, sie hatten ein mieses Viertel, so dass im letzten Monat, bevor sie vierteljährliche Aussagen senden müssen, laden sie auf einige neue Gewinner, so dass ihre Kunden don8217t denken sie8217re als Amateur, wie sie wirklich loslassen, und there8217s ein Stoß für Dies. Ähnlich hat Januar einige verkaufende Anomalien wegen der Steuerverlusternte. Soweit praktische Implementierungen gehen, denke ich, das ist eine sehr nette Geste. Die Tatsache, dass das Umdrehen jeden Monat kann ein bisschen zu teuer sein, mag ich, dass Wes und Jack sagen 8220sure, wollen Sie es drehen einmal alle drei Monate, aber auf welche Monate8221. It8217s eine sehr gute Frage zu fragen, ob es bedeutet, dass Sie einen zusätzlichen Prozentpunkt oder 150 Bps pro Jahr von, dass es nur die Transaktionskosten und dann einige decken könnte. Alles in allem ist es eine ziemlich einfach zu verstehende Strategie. Allerdings ist das Teil, das Art von Gates aus dem Buch zu einer perfekten Replikation ist die Schwierigkeit bei der Erlangung der CRSP-Daten. Allerdings empfehle ich Alpha Architect für die Offenlegung des gesamten Algorithmus von Anfang bis Ende. Darüber hinaus, wenn die grundlegenden 2-12 Impuls ist nicht genug, there8217s ein Anhang, die andere Arten von Impulsideen (Verdienst Impuls, Rangfolge von Distanz zu 52-Wochen-Hochs, absolute historische Impuls, und so weiter). Keine dieser Strategien ist wirklich so viel besser als die grundlegende Preis-Impuls-Strategie, so dass sie dort für die Interessierten dort, aber es scheint there8217s nichts wirklich bahnbrechenden dort. Das ist, wenn Sie einmal im Monat Handel, es8217s nur so viele Möglichkeiten zu sagen 8220hey, ich glaube, diese Sache geht up8221 Ich mag auch, dass Wes und Jack berührte die Tatsache, dass Trendfolgen, während es doesn8217t insgesamt CAGR oder Sharpe verbessern , Macht eine massive Menge auf max Drawdown zu verbessern. Das heißt, wenn mit der Aussicht, 70-80 von allem zu verlieren konfrontiert, und verlieren nur 30, dass8217s eine einfache Wahl zu machen. Trendfolgen ist gut, auch eine vereinfachte Version. Alles in allem denke ich, dass das Buch vollendet, was es anfängt zu tun, das ist, einen gut-erforschten Algorithmus zu präsentieren. Letztlich ist die Punchline auf Alpha Architect8217s Website (ich glaube, sie haben eine Art von monatlichen Lager-Filter). Darüber hinaus gibt das Buch an, dass es bessere risikoadjustierte Renditen gibt, wenn es mit dem Algorithmus kombiniert wird, der in dem 8220quantitativen Wert8221 Buch umrissen wird. In meiner Erfahrung habe ich nie Wert-Algorithmen beeindrucken mich in den Backtests I8217ve getan, aber ich kann Kreide, die bis zu mir mit allen verschiedenen Bewertungs-Metriken unerfahren. Meine Kritik am Buch ist jedoch: Der Momentum-Algorithmus im Buch vermisst, was ich fühle, ist eine Schlüsselkomponente: Volatility Targeting Control. Einfach, das Papier 8220momentum hat seine Momente8221 (die ich in meiner Hypothese-driven Entwicklung Reihe von Beiträgen abgedeckt) im Wesentlichen besagt, dass die üblichen Fama-Französisch Momentum Strategie weit besser aus einer Risiko-Belohnung Strategie durch Deleveraging während Zeiten übermäßiger Volatilität, und Vermeidung von Impulsabbrüchen. I8217m nicht sicher, warum Wes und Jack didn8217t berühren dieses Papier, da die Umsetzung ist sehr einfach (Ziel / realisierte Volatilität Hebelwirkung Faktor). Idealerweise würde ich lieben, wenn Wes oder Jack mir den Strom der Rückkehr für diese Strategie schicken könnten (vorzugsweise täglich, aber monatlich auch funktioniert). Im Grunde halte ich dieses Buch sehr umfassend. Allerdings denke ich, es hat auch eine etwas 8220don8217t versuchen diese zu Hause8221 fühlen, um es aufgrund der Datenanforderung zu replizieren. Sicherlich, wenn Ihr Broker berechnet Sie 8 eine Transaktion, it8217s nicht eine machbare Strategie, um mehrere tausend Dollar pro Jahr auf Transaktionskosten fallen, die nur Ihre Rückkehr zu Ihrem Broker geben. Aber ich frage mich, ob die QMOM ETF (von Alpha Architect, natürlich) ist in der Tat eine bessere Version dieser Strategie, außerhalb der Managementgebühr. Auf jeden Fall lautet meine abschließende Meinung: Während dieses Buch ein bisschen Wissen auf dem Tisch hinterlässt, vollzieht es das Ganze, was es zu tun gibt, ist klar mit seinen Verfahren und bietet einige lohnende Ideen. Für den Preis eines nicht-technischen Lehrbuchs (aka jene 60 Bücher über amazon), ist dieses Buch ein stehlen. Danke fürs Lesen. ANMERKUNG: Während ich zurzeit in einer erfolgreichen Analytik-Kapazität beschäftigt bin, bin ich daran interessiert, über Vollzeitstellen näher zu den Themen in diesem Blog zu hören. Wenn Sie eine Vollzeitstelle haben, die von meinen gegenwärtigen Sachkenntnissen profitieren kann, informieren Sie mich bitte. Meine Linkedin finden Sie hier. Dieser Beitrag wird etwa versuchen, das Depmix-Paket für Online-Status-Vorhersage verwenden. Während das Depmix-Paket bewundernswert ist, wenn es darum geht, die Zustände der Vergangenheit zu beschreiben, wird bei der Verwendung für eine Schrittvorhersage unter der Annahme, dass der Zustand von morgen8217s identisch zu heute8217s ist, das verdeckte Markov-Modellprozess, das innerhalb des Pakets gefunden wird, nicht durchgeführt Erfüllen. Dieser Beitrag wurde von Michael Halls-Moore, der vor kurzem einige R-Code über die Verwendung der depmixS4-Bibliothek, um versteckte markov Modelle verwenden motiviert. In der Regel bin ich ungern, um Beiträge zu Themen Ich don8217t fühlen, habe ich ein absolut Front-to-Back-Verständnis von, aber I8217m dies in der Hoffnung, von anderen lernen, wie man angemessen online-Status-Raum-Vorhersage, oder 8220regime switching8221 tun Wie es in mehr finanziellen Parole genannt werden kann. Während ich die übliche Theorie der versteckten Markov-Modelle (das heißt, es kann regen oder es kann sonnig sein, aber man kann nur das Wetter beurteilen, die von den Kleidern sehen Sie Leute tragen außerhalb Ihres Fensters, wenn Sie aufwachen) gesehen haben, und haben gearbeitet Mit Spielzeugbeispielen in MOOCs (Udacity8217s self-driving car course befasst sich mit ihnen, wenn ich mich richtig erinnere8211 oder vielleicht war es der AI-Kurs), am Ende des Tages ist Theorie nur so gut wie, wie gut eine Implementierung auf reale Daten arbeiten kann . Für dieses Experiment habe ich beschlossen, SPY-Daten seit Beginn und nehmen Sie eine vollständige in-Probe 8220backtest8221 auf die Daten. Das heißt, angesichts der Tatsache, dass der HMM-Algorithmus von depmix die gesamte Historie der Rückkehr sieht, führt der Algorithmus mit dieser 8220god8217s eye8221-Ansicht der Daten korrekt die Regime ein, wenn die Backtest-Ergebnisse irgendeine Angabe sind Dr. Halls-Moore8217s. Im Wesentlichen, während ich wählte drei Staaten, stellte ich fest, dass alles mit einem Intercept über Null ist ein Bull-Zustand, und unter Null ist ein Bärenstaat, so im Wesentlichen, es reduziert auf zwei Staaten. Mit dem Ergebnis: Also, nicht besonders schrecklich. Der Algorithmus arbeitet, Art, Art, Recht Nun, let8217s versuchen Online-Vorhersage jetzt. So, was ich hier getan habe, war ich ein erweitertes Fenster, beginnend von 500 Tagen seit SPY8217s Anfang, und hielt es zu erhöhen, von einem Tag auf einmal. Meine Vorhersage war, trivial genug, der jüngste Tag, mit einem 1 für einen Bullenstaat und ein -1 für einen Bärenstaat. Ich lief diesen Prozess parallel (auf einem Linux-Cluster, weil windows8217s doParallel Bibliothek scheint nicht einmal wissen, dass bestimmte Pakete geladen werden, und es8217s mehr chaotisch), und das erste große Problem ist, dass dieser Vorgang dauerte etwa drei Stunden auf sieben Kerne für Etwa 23 Jahre der Daten. Nicht gerade ermutigend, aber Rechenzeit isn8217t teuer in diesen Tagen. So let8217s sehen, wenn dieser Prozess tatsächlich funktioniert. Erstens, let8217s testen, ob der Algorithmus tut, was es tatsächlich tun soll und einen Tag der Vorgriffs-Bias (das heißt, der Algorithmus sagt uns den Zustand am Ende des Tages8211 so richtig ist es sogar für diesen Tag). Mit dem Ergebnis: So, angeblich, scheint der Algorithmus zu tun, was es entworfen wurde zu tun, die zu einem Zustand für einen bestimmten Datensatz zu klassifizieren ist. Nun, die wichtigste Frage: wie gut tun diese Vorhersagen auch nur einen Tag im Voraus Du8217d denke, dass Staatsraum Vorhersagen würde von Tag zu Tag sparsam sein, angesichts der langen Geschichte, richtig mit dem Ergebnis: Das heißt, ohne die Vorausschau Bias, die Zustandsraumvorhersagealgorithmus ist schädlich. Warum ist das gut, hier8217s die Handlung der Staaten: Kurz gesagt, scheint der Online-hmm-Algorithmus im Depmix-Paket seine Meinung sehr leicht zu ändern, mit offensichtlichen (negativen) Implikationen für tatsächliche Handelsstrategien. Also, dass wraps es für diesen Beitrag. Grundsätzlich ist hier die Hauptbotschaft: Dort ist ein großer Unterschied zwischen dem Laden der deskriptiven Analyse (AKA 8220, wo warst du, warum die Dinge passieren8221) gegen die prädiktive Analyse (das heißt, wenn ich die Zukunft richtig voraussage, bekomme ich einen positiven Lohn8221 ). Meiner Meinung nach, während beschreibende Statistiken haben ihren Zweck in Bezug auf die Erklärung, warum eine Strategie möglicherweise durchgeführt haben, wie es getan hat, letztlich, wir immer auf der Suche nach besseren Vorhersage-Tools. In diesem Fall scheint das Depmix, zumindest in dieser 8220-out-of-the-box8221-Demonstration, nicht das Werkzeug dafür zu sein. Wenn jemand hatte Erfolg mit der Verwendung von depmix (oder andere Regime-Switching-Algorithmus in R) für die Vorhersage, würde ich gerne sehen, Arbeit, die Details der Prozedur genommen, wie es8217s ein Bereich I8217m suchen, um meine Toolbox zu erweitern, aber don8217t haben einige besondere Gute Leads. Im Wesentlichen, wie ich an diesen Beitrag denken, wie ich meine eigenen Erfahrungen mit dem Paket zu beschreiben. Danke fürs Lesen. HINWEIS: Am 5. Oktober werde ich in New York City sein. Am 6. Oktober werde ich auf der Trading Show im Programming Wars-Panel präsentieren. HINWEIS: Mein aktueller Analytics-Vertrag steht zum Ende des Jahres zur Prüfung zur Verfügung, daher bin ich offiziell auf der Suche nach weiteren Angeboten. Wenn Sie eine Vollzeitrolle haben, die von den Fähigkeiten profitieren kann, die Sie auf meinem Blog sehen, bitte in Verbindung treten mit mir. Mein linkedin Profil finden Sie hier. Dieser Beitrag stellt eine Komponente bedingte Wert auf Risiko-Mechanik gefunden in PerformanceAnalytics aus einem Papier von Brian Peterson, Kris Boudt und Peter Carl geschrieben. Dies ist ein Mechanismus, der ein einfach-zu-Anruf-Mechanismus für die Berechnung der Komponente erwarteten Fehlbetrag in Anlagenrenditen, wie sie für ein Portfolio gelten. Während die genaue Mechanik ziemlich komplex ist, ist der Aufwand, dass die Laufzeit fast augenblicklich ist, und diese Methode ist ein solides Werkzeug für die Aufnahme in Asset Allocation Analyse. Für diejenigen, die sich für eine eingehende Analyse der Intuition des komponentenbedingten Wertes in Gefahr interessieren, verweise ich sie auf das Papier von Brian Peterson, Peter Carl und Kris Boudt. Grundsätzlich ist hier die Idee: Alle Vermögenswerte eines gegebenen Portfolios haben einen marginalen Beitrag zu seinem gesamten Bedingungsrisiko (auch als erwarteter Fehlbetrag bekannt) 8211, dh der erwartete Verlust, wenn der Verlust eine bestimmte Schwelle überschreitet. Zum Beispiel, wenn Sie wissen wollen, Ihre 5 erwarteten Fehlbetrag, dann it8217s der Durchschnitt der schlechtesten 5 Renditen pro 100 Tage, und so weiter. Für Rücksendungen mit einer täglichen Auflösung kann die Idee eines erwarteten Fehlbetrags klingen, als gäbe es niemals genügend Daten in einem ausreichend schnellen Zeitrahmen (in einem Jahr oder weniger), die Formel für den erwarteten Fehlbetrag in den PerformanceAnalytics-Vorgabewerten ist eine Approximationsberechnung mit a Cornish-Fisher-Expansion, die sehr gute Ergebnisse liefert, solange der p-Wert nicht zu extrem ist (das heißt, es arbeitet für relativ sane p-Werte wie der 1-10-Bereich). Der Komponenten-Bedingungs-Value-at-Risk hat zwei Verwendungen: Erstens, wenn keine Eingabegewichte angegeben werden, verwendet er einen gleichwertigen Standardwert, der es ermöglicht, eine Risikobewertung für jedes einzelne Asset bereitzustellen, ohne den Forscher zu belasten, um seine eigenen Korrelations - / Kovarianzheuristiken zu schaffen . Zweitens, wenn mit einem Satz von Gewichten versehen, ändert sich die Ausgabe, um den Beitrag der verschiedenen Vermögenswerte im Verhältnis zu diesen Gewichten widerzuspiegeln. Dies bedeutet, dass diese Methode sehr gut funktioniert mit Strategien, die Vermögenswerte auf der Grundlage von Impuls ausschließen, aber müssen ein Gewichtungsschema für die verbleibenden Vermögenswerte. Darüber hinaus ermöglicht diese Methode auch eine Ex-post-Analyse des Risikobeitrags zu sehen, welches Instrument dazu beigetragen, was zu riskieren. Erstens, eine Demonstration, wie der Mechanismus arbeitet mit dem Edhec-Datensatz. Es gibt hier keine Strategie, nur eine Demonstration der Syntax. Dies wird einen gleichgewichtigen Beitrag aus allen Fonds im edhec-Datensatz annehmen. So ist tmp der Beitrag des erwarteten Fehlbetrags von jedem der verschiedenen edhec Manager über den gesamten Zeitraum. Hierbei handelt es sich um die Ausgabe: Der wichtigste Teil davon ist der prozentuale Anteil (der letzte Ausgang). Beachten Sie, dass es negativ sein kann, was bedeutet, dass bestimmte Fonds gewinnen, wenn andere verlieren. Zumindest war dies der Fall über den aktuellen Datensatz. Diese Vermögenswerte diversifizieren ein Portfolio und senken sogar den erwarteten Fehlbetrag. In diesem Fall gewichtete ich gleichmäßig die ersten zehn Manager im Edhec-Datensatz und setzte Nullgewicht in den letzten drei ein. Darüber hinaus können wir sehen, was passiert, wenn die Gewichte nicht gleich sind. Dieses Mal, beachten Sie, dass, wie das Gewicht in der Cabrio-Arb-Manager erhöht, so auch seinen Beitrag zu maximal erwarteten Fehlbetrag. Für einen zukünftigen Backtest möchte ich einige Datenanfragen machen. Ich möchte das Universum in Faber8217s Global Asset Allocation Buch zu finden. Das heißt, die Simulationen in diesem Buch gehen zurück auf 1972, und ich frage mich, ob jemand da draußen hat täglich Rückkehr für diese Vermögenswerte / Indizes. Während einige ETFs in die frühen 2000er Jahre zurückgehen, gibt es einige, die ziemlich spät beginnen, wie DBC (Rohstoffe, Anfang 2006), GLD (Gold, Anfang 2004), BWX (Foreign Bonds, Ende 2007) und FTY (NAREIT, 2007). Als acht Jahre Backtest wäre ein bisschen kurz, ich frage mich, ob jemand Daten mit mehr Geschichte hatte. Eine andere Sache, werde ich in New York für die Handelsausstellung. Und sprachen über die 8220 Programmierung wars8221 Panel am 6. Oktober. Danke fürs Lesen. HINWEIS: Während ich derzeit bin, bin ich auch auf der Suche nach einer dauerhaften Position, die von meinen Fähigkeiten profitieren kann, wenn mein aktueller Vertrag endet. Wenn Sie eine solche Öffnung haben oder wissen, werde ich gerne mit Ihnen sprechen. Dieser Beitrag wird eine Funktion, um die Erstellung Harry Long Art Rebalancing Strategien von SeekingAlpha für interessierte Leser zu vereinfachen. Wie Harry Long erklärt hat, sind die meisten, wenn nicht alle seine Strategien mehr für Demonstrationszwecke eher als tatsächliche empfohlene Investitionen. Also, da Harry Long einige Artikel über Seeknig Alpha veröffentlicht hat, hatte ich einen Leser oder zwei Leser, seine Strategien (wieder) zu analysieren. Anstatt dies zu tun, I8217ll einfach dieses Tool, das ist ein Wrapper, automatisiert die Erfassung von Daten und simuliert Portfolio-Rebalancing mit einer Zeile Code. Hier ist das Werkzeug. Es holt die Daten für Sie (in der Regel von Yahoo, aber ein großes Dankeschön an Herrn Helumth Vollmeier im Falle von ZIV und VXX), und hat die Möglichkeit, entweder nur eine Equity-Kurve und einige Statistiken (CAGR, annualisiert Standard-dev , Sharpe, max Drawdown, Calmar) oder geben Sie den Return-Stream als Ausgang, wenn Sie mehr Analyse in R. machen wollen. Hier8217s ein Beispiel für das einfache Erhalten der Statistiken, mit einem 80 XLP / SPLV (they8217re mehr oder weniger austauschbar) Und 20 TMF (aka 60 TLT, also ein 80/60 Portfolio), von einem der Harry Long8217s Artikel. Nichts außergewöhnliches von dem, was wir von einem ausgewogenen Aktien / Renten-Portfolio erwarten könnten. Generell tut es gut, hat seinen größten Drawdown in der Finanzkrise, und einige andere Beulen in der Straße, aber insgesamt, glaube ich, eine ziemlich Vanille 8220set es und vergessen es8221 Art der Sache. Und hier wäre der Weg, um den Strom der einzelnen täglichen Renditen zu erhalten, vorausgesetzt, Sie wollten diese beiden Instrumente wöchentlich, anstelle von jährlich (wie ist die Standardeinstellung) auszugleichen. Und jetzt let8217s erhalten einige Statistiken. Stellt sich heraus, verschieben die Rebalancing von jährlich auf wöchentlich didn8217t haben viel von einem Effekt hier (außer geben einen Haufen Geld an Ihren Broker, wenn Sie in Transaktionskosten, die dies doesn8217t berücksichtigt). So, that8217s, wie dieses Werkzeug arbeitet. Die Ergebnisse, natürlich, beginnen mit den neuesten instrument8217s Anfang. Der Trick, meiner Meinung nach, ist zu versuchen, Proxy-Ersatz mit längeren Geschichten für neuere ETFs, die einfach gehebelten ETFs, wie die Verwendung eines 60 Gewicht in TLT mit einem 80 Gewicht in XLP anstelle eines 20 Gewicht in TMF mit 80 Zuweisung In SPLV. Zum Beispiel, hier sind einige Proxies: SPXL XLP SPXL / UPRO SPY 3 TMF TLT 3 Das heißt, I8217ve arbeitete mit Harry Long vor, und er entwickelt mehr anspruchsvolle Strategien hinter den Kulissen, so I8217d empfehlen, dass SeekingAlpha Leser seine öffentlich freigegebene Strategien als nehmen Konzept-Demonstrationen, im Gegensatz zu vollwertigen Investition Ideen, und kontaktieren Sie Herrn Long selbst über mehr individuelle, private Lösungen für Investment-Institutionen, wenn Sie so interessiert sind. Danke fürs Lesen. HINWEIS: Ich bin derzeit im Nordosten. Während ich derzeit bin, interessiere ich mich für die Vernetzung mit Einzelpersonen oder Unternehmen im Hinblick auf mögliche Kooperationsmöglichkeiten. In diesem Beitrag wird gezeigt, wie der Umsatz bei der Nutzung von Renditebasierten Daten unter Verwendung von PerformanceAnalytics und der Return. Portfolio-Funktion in R zu berücksichtigen ist. Dies wird anhand einer Grundstrategie für die neun Sektoren-SPDRs demonstriert. Zunächst einmal handelt es sich hierbei um eine Frage, die ein Robert Wages in der Mailingliste R-SIG-Finance gestellt hat. Zwar gibt es viele Einzelpersonen gibt mit einer Fülle von Fragen (viele von denen kann gefunden werden, um auf diesem Blog bereits demonstriert werden), gelegentlich gibt es eine Industrie Veteran, ein Doktorand Student von Stanford, oder andere sehr intelligente Person, die Wird eine Frage zu einem Thema, dass ich haven8217t noch berührt auf diesem Blog, die einen Beitrag zu einem anderen technischen Aspekt in R zeigen demonstrieren wird zu stellen. Dies ist einer dieser Zeiten. Also, diese Demonstration wird über die Berechnung der Umsatz im Returns Space mit dem PerformanceAnalytics-Paket. Ausserhalb des PortfolioAnalytics-Pakets ist PerformanceAnalytics mit seiner Return. Portfolio-Funktion das Go-to-R-Paket für Portfolio-Management-Simulationen, da es einen Satz von Gewichten, einen Satz von Renditen und eine Reihe von Portfolio-Renditen für die Analyse generieren kann Mit dem Rest der PerformanceAnalytics8217s Funktionen. Auch hier ist die Strategie: Nehmen Sie die 9 Dreibund-Sektor SPDRs (da gibt es vier-Buchstaben-ETFs jetzt), und am Ende eines jeden Monats, wenn der bereinigte Preis liegt über seinem 200-Tage gleitenden Durchschnitt, in sie investieren . Normalisieren Sie über alle investierten Sektoren (dh 1 / 9th, wenn in alle 9, 100 in 1 investiert, wenn nur 1 in 100 Bargeld investiert ist, die mit einem Nullrückkehrvektor gekennzeichnet sind, wenn keine Sektoren investiert werden). It8217s eine einfache, Spielzeug-Strategie, wie die Strategie isn8217t der Punkt der Demonstration. Hier ist der grundlegende Setup-Code: So erhalten Sie die SPDRs, setzen sie zusammen, berechnen ihre Renditen, erzeugen das Signal und erstellen den Null-Vektor, da Return. Portfolio Gewichte unter 1 als Entnahme behandelt und Gewichte über 1 als Zusatz Von mehr Kapital (große FYI hier). Nun, hier8217s, wie man den Umsatz berechnet: Also, der Trick ist: Wenn Sie Return. portfolio aufrufen, verwenden Sie die ausführliche TRUE-Option. Dies schafft mehrere Objekte, darunter Rückkehr, BOP. Weight und EOP. Weight. Diese stehen für Beginn der Periode Gewicht und Ende der Periode Gewicht. Die Art und Weise, dass Umsatz berechnet wird, ist einfach der Unterschied zwischen der Rückkehr der Rückzahlung des zugeteilten Portfolios von seinem vorherigen Endpunkt zu dem, wo dieses Portfolio zu Beginn des nächsten Zeitraums steht. Das heißt, das Ende des Periodengewichts ist der Beginn des Periodendriftes nach Berücksichtigung der Drift / Rückkehr des Tag8217s für dieses Asset. Der neue Anfang des Zeitraums Gewicht ist das Ende der Periode Gewicht plus jede Transaktion, die getan worden wäre. Um somit die tatsächlichen Transaktionen (oder den Umsatz) zu finden, subtrahiert man das vorherige Ende des Periodengewichts von dem Beginn des Periodengewichts. Dies ist, was solche Transaktionen für diese Strategie aussehen. Etwas, das wir mit solchen Daten tun können, dauert einen einjährigen rollierenden Umsatz, der mit folgendem Code erreicht wird: Es sieht so aus: Dies bedeutet im Wesentlichen, dass ein Jahr2007 im Wert von Zwei-Wege-Umsatz (das heißt, wenn der Verkauf eines vollständig investierten Portfolios ist 100 Umsatz, und den Kauf einer völlig neuen Satz von Vermögenswerten ist ein weiterer 100, dann zwei-Wege-Umsatz ist 200) ist rund 800 bei maximal. Das kann für einige Leute ziemlich hoch sein. Nun, hier8217s die Anwendung, wenn Sie die Transaktionskosten bei 20 Basispunkten pro Prozentpunkt gehandelt (das heißt, es kostet 20 Cent zu 100 Transaktionen) zu bestrafen. Also, bei 20 Basispunkten auf Transaktionskosten, das dauert etwa ein Prozent in Renditen pro Jahr aus dieser (zugegebenermaßen schrecklichen) Strategie. Das ist keineswegs vernachlässigbar. So, das ist, wie Sie tatsächlich berechnen Umsatz und Transaktionskosten. In diesem Fall war das Transaktionskostenmodell sehr einfach. Da Return. portfolio jedoch Transaktionen auf der einzelnen Asset-Ebene zurückgibt, könnte man mit der Modellierung der Transaktionskosten so komplex wie möglich sein. Danke fürs Lesen. ANMERKUNG: Ich werde ein Blitzgespräch an R / Finance geben, also für die Besucher, Sie8217ll in der Lage sein, mich dort zu finden. Dieser Beitrag wird einen leicht verständlichen Fehler beim Schreiben von vektorisierten Backtests skizzieren, indem man ein am Ende einer Periode erhaltenes Signal verwendet, um eine Position in derselben Periode einzugeben (oder zu verlassen). Der Unterschied in den Ergebnissen, die man erhält, ist massiv. Heute sah ich zwei getrennte Beiträge von Alpha Architect und Mike Harris, die sich beide auf ein Papier von Valeriy Zakamulin bezogen, dass einige vorhergehende Trendfolgesuche von Glabadanidis mit schlimmen Ergebnissen durchgeführt wurden und dass Glabadanidis8217s Ergebnisse nur durch die Einrichtung von Lookahead-Bias reproduzierbar waren. Der folgende Code zeigt, wie diese Vorgriff-Bias zu reproduzieren. Zuerst wird die Einrichtung einer grundlegenden gleitenden durchschnittlichen Strategie auf dem SampP 500 Index von so weit zurück wie Yahoo-Daten liefern. Und hier ist, wie die lookahead Bias zu initiieren. Dies sind die 8220results8221: Natürlich ist diese Eigenkapitalkurve von keinem Nutzen, also hier8217s eins in der logarithmischen Skala. Wie man sehen kann, macht die Vorausschau eine gewaltige Differenz. Hier sind die numerischen Ergebnisse: Wieder, absolut lächerlich. Beachten Sie, dass bei Verwendung von Return. Portfolio (die Funktion in PerformanceAnalytics) dieses Paket automatisch die nächste Periode8217s zurückgibt, anstelle des aktuellen, für Ihre Gewichte. Jedoch für diejenigen, die 8220simple8221 Backtests, die schnell mit vektorisierten Operationen durchgeführt werden können, kann ein Off-by-one-Fehler machen den Unterschied zwischen einem Backtest im Bereich der vernünftigen und reinen Unsinn. Allerdings, wenn man für diesen Unsinn testen, wenn mit unmöglich zu replizieren Ergebnisse, die Mechanismen oben ist der Weg, es zu tun konfrontiert. Nun, auf andere Nachrichten: I8217d danken Gerald M für den Aufenthalt auf der Spitze eines der Logical Invest Strategien8211Namely, ihre einfache globale Marktrotation Strategie umrissen in einem Artikel aus einem früheren Blog-Post. Bis März 2015 (das Datum des Blogposts) hatte sich die Strategie gut entwickelt. Doch nach dem genannten Zeitpunkt Es war eine vollständige Katastrophe, die im Nachhinein offensichtlich war, als ich es durch die Hypothese getrieben Entwicklungsprozess Rahmenprozess schrieb ich über früher. Obwohl es sehr viel darum geht, nicht nur wegen der kurzfristigen Underperformance eine Strategie wegzuwerfen, und dass Anomalien wie Momentum und Wert aufgrund des Karriererisikos aufgrund der kurzfristigen Underperformance bestehen, ist es niemals eine gute Sache Wenn eine Strategie historisch große Verluste schafft, vor allem, nachdem sie in einer so bescheidenen Ecke der quantitativen Finanzwelt veröffentlicht wurde. Auf jeden Fall war dies ein Beitrag zeigt einige Mechanik, und ein Update auf eine Strategie, die ich vor nicht allzu langer Zeit. Danke fürs Lesen. ANMERKUNG: Ich bin immer interessiert, über neue Gelegenheiten zu erfahren, die von meiner Sachkenntnis profitieren können, und bin immer glücklich, zu vernetzen. Mein LinkedIn Profil finden Sie hier. Dieser Beitrag wird Licht auf die Werte von R2s hinter zwei ziemlich simplistischen Strategien 8212 die einfache 10 Monate SMA, und ihre relative, die 10 Monate Momentum (das ist einfach ein Unterschied von SMAs, wie Alpha Architect zeigte in ihrem Buch DIY Financial Advisor. Vor nicht allzu langer Zeit fragte mich ein Freund von mir namens Josh eine Frage zu R2s in der Finanzwirtschaft. He8217s Abschluss seiner Promotion in Statistik in Stanford, so dass, wenn die Leute, die Fragen, fragen mich Fragen, I8217d wie sie zu beantworten. Seine Behauptung ist, dass in Einige Modelle, die weniger als perfekte Vorhersagekraft haben (EG R2s von .4 zum Beispiel), können noch sehr vielversprechende Vorhersagen liefern, und dass, wenn jemand ein Finanzmodell haben sollte, das in der Lage war, 40 der Varianz der Renditen zu erklären , Könnten sie glücklich in den Ruhestand mit diesem Modell machen sie sehr wohlhabend. In der Tat 4 ist ein sehr optimistischer Ausblick (um es leicht), wie dieser Beitrag zeigen wird. Um dieses Beispiel zu veranschaulichen, nahm ich zwei 8220staple8221 Strategien 8212 kaufen SPY, wenn Ist der monatliche Schlusskurs über seinem zehnmonatigen einfachen gleitenden Durchschnitt, und wenn sein zehnmonatiges Momentum (grundsätzlich die Differenz eines zehnmonatigen gleitenden Durchschnitts und seiner Verzögerung) positiv ist. Während diese Modelle vereinfacht sind, werden sie ubiquitär gesprochen, und viele Impulsstrategien sind eine Verbesserung auf diesen Grundlinien, 8220 out-of-the-box8221 Strategien. Hier ist der Code, um das zu tun: Und hier sind die Ergebnisse: Kurzum, der SMA10 und der 10-Monats-Momentum (alias ROC 10 aka MOM10) übertreffen sowohl den Kauf als auch den Hold, nicht nur in absoluten Renditen, (Sharpe - und Calmar-Verhältnisse). Auch hier wird die vereinfachte Analyse und viele Modelle wesentlich anspruchsvoller, dafür aber ein einfaches, anschauliches Beispiel mit zwei Strategien, die eine Benchmark übertreffen (auf lange Sicht ohnehin). Nun, die Frage ist, was war der R2 dieser Modelle Um dies zu beantworten, nahm ich ein rollenden Fünf-Jahres-Fenster, das im Wesentlichen fragte: wie gut diese Mengen (das Verhältnis zwischen dem Schlusskurs und dem gleitenden Durchschnitt 8211 1 oder die Zehnmonatiges Momentum) vorherzusagen, welcher Anteil der Varianz durch die monatlichen Renditen erklärt wird, die gegenüber den Vormonaten8217s-Signalen in numerischer Form zurückgerechnet werden (vielleicht nicht die beste Rahmung, da das Signal binär ist, im Gegensatz zu kontinuierlichem, das ist Was zurückgedreht wird, aber let8217s setzen, die beiseite, wieder, zum Zwecke der Illustration). Hier8217s der Code, um die Antwort zu generieren. And the answer, in pictorial form: In short, even in the best case scenarios, namely, crises which provide momentum/trend-following/call it what you will its raison d8217etre, that is, its risk management appeal, the proportion of variance explained by the actual signal quantities was very small. In the best of times, around 20. But then again, think about what the R2 value actually is8211it8217s the percentage of variance explained by a predictor. If a small set of signals (let alone one) was able to explain the majority of the change in the returns of the SampP 500, or even a not-insignificant portion, such a person would stand to become very wealthy. More to the point, given that two strategies that handily outperform the market have R2s that are exceptionally low for extended periods of time, it goes to show that holding the R2 up as some form of statistical holy grail certainly is incorrect in the general sense, and anyone who does so either is painting with too broad a brush, is creating disingenuous arguments, or should simply attempt to understand another field which may not work the way their intuition tells them. Danke fürs Lesen. This review will review the 8220Adaptive Asset Allocation: Dynamic Global Portfolios to Profit in Good Times 8211 and Bad8221 book by the people at ReSolve Asset Management. Overall, this book is a definite must-read for those who have never been exposed to the ideas within it. However, when it comes to a solution that can be fully replicated, this book is lacking. Okay, it8217s been a while since I reviewed my last book, DIY Financial Advisor. from the awesome people at Alpha Architect. This book in my opinion, is set up in a similar sort of format. This is the structure of the book, and my reviews along with it: Part 1: Why in the heck you actually need to have a diversified portfolio, and why a diversified portfolio is a good thing. In a world in which there is so much emphasis put on single-security performance, this is certainly something that absolutely must be stated for those not familiar with portfolio theory. It highlights the example of two people8211one from Abbott Labs, and one from Enron, who had so much of their savings concentrated in their company8217s stock. Mr. Abbott got hit hard and changed his outlook on how to save for retirement, and Mr. Enron was never heard from again. Long story short: a diversified portfolio is good, and a properly diversified portfolio can offset one asset8217s zigs with another asset8217s zags. This is the key to establishing a stream of returns that will help meet financial goals. Basically, this is your common sense story (humans love being told stories) so as to motivate you to read the rest of the book. It does its job, though for someone like me, it8217s more akin to a big 8220wait for it, wait for it8230and there8217s the reason why we should read on, as expected8221. Part 2: Something not often brought up in many corners of the quant world (because it8217s real life boring stuff) is the importance not only of average returns, but when those returns are achieved. Namely, imagine your everyday saver. At the beginning of their careers, they8217re taking home less salary and have less money in their retirement portfolio (or speculation portfolio, but the book uses retirement portfolio). As they get into middle age and closer to retirement, they have a lot more money in said retirement portfolio. Thus, strong returns are most vital when there is more cash available to the portfolio, and the difference between mediocre returns at the beginning and strong returns at the end of one8217s working life as opposed to vice versa is astronomical and cannot be understated. Furthermore, once in retirement, strong returns in the early years matter far more than returns in the later years once money has been withdrawn out of the portfolio (though I8217d hope that a portfolio8217s returns can be so strong that one can simply 8220live off the interest8221). Or, put more intuitively: when you have 10,000 in your portfolio, a 20 drawdown doesn8217t exactly hurt because you can make more money and put more into your retirement account. But when you8217re 62 and have 500,000 and suddenly lose 30 of everything, well, that8217s massive. How much an investor wants to avoid such a scenario cannot be understated. Warren Buffett once said that if you can8217t bear to lose 50 of everything, you shouldn8217t be in stocks. I really like this part of the book because it shows just how dangerous the ideas of 8220a 50 drawdown is unavoidable8221 and other 8220stay invested for the long haul8221 refrains are. Essentially, this part of the book makes a resounding statement that any financial adviser keeping his or her clients invested in equities when they8217re near retirement age is doing something not very advisable, to put it lightly. In my opinion, those who advise pension funds should especially keep this section of the book in mind, since for some people, the long-term may be coming to an end, and what matters is not only steady returns, but to make sure the strategy doesn8217t fall off a cliff and destroy decades of hard-earned savings. Part 3: This part is also one that is a very important read. First off, it lays out in clear terms that the long-term forward-looking valuations for equities are at rock bottom. That is, the expected forward 15-year returns are very low, using approximately 75 years of evidence. Currently, according to the book, equity valuations imply a negative 15-year forward return. However, one thing I will take issue with is that while forward-looking long-term returns for equities may be very low, if one believed this chart and only invested in the stock market when forecast 15-year returns were above the long term average, one would have missed out on both the 2003-2007 bull runs, and the one since 2009 that8217s just about over. So, while the book makes a strong case for caution, readers should also take the chart with a grain of salt in my opinion. However, another aspect of portfolio construction that this book covers is how to construct a robust (assets for any economic environment) and coherent (asset classes balanced in number) universe for implementation with any asset allocation algorithm. I think this bears repeating: universe selection is an extremely important topic in the discussion of asset allocation, yet there is very little discussion about it. Most research/topics simply take some 8220conventional universe8221, such as 8220all stocks on the NYSE8221, or 8220all the stocks in the SampP 5008221, or 8220the entire set of the 50-60 most liquid futures8221 without consideration for robustness and coherence. This book is the first source I8217ve seen that actually puts this topic under a magnifying glass besides 8220finger in the air pick and choose8221. Part 4: and here8217s where I level my main criticism at this book. For those that have read 8220Adaptive Asset Allocation: A Primer8221. this section of the book is basically one giant copy and paste. It8217s all one large buildup to 8220momentum rank min-variance optimization8221. All well and good, until there8217s very little detail beyond the basics as to how the minimum variance portfolio was constructed. Namely, what exactly is the minimum variance algorithm in use Is it one of the poor variants susceptible to numerical instability inherent in inverting sample covariance matrices Or is it a heuristic like David Varadi8217s minimum variance and minimum correlation algorithm The one feeling I absolutely could not shake was that this book had a perfect opportunity to present a robust approach to minimum variance, and instead, it8217s long on concept, short on details. While the theory of 8220maximize return for unit risk8221 is all well and good, the actual algorithm to implement that theory into practice is not trivial, with the solutions taught to undergrads and master8217s students having some well-known weaknesses. On top of this, one thing that got hammered into my head in the past was that ranking also had a weakness at the inclusion/exclusion point. E. G. if, out of ten assets, the fifth asset had a momentum of say, 10.9, and the sixth asset had a momentum of 10.8, how are we so sure the fifth is so much better And while I realize that this book was ultimately meant to be a primer, in my opinion, it would have been a no-objections five-star if there were an appendix that actually went into some detail on how to go from the simple concepts and included a small numerical example of some algorithms that may address the well-known weaknesses. This doesn8217t mean Greek/mathematical jargon. Just an appendix that acknowledged that not every reader is someone only picking up his first or second book about systematic investing, and that some of us are familiar with the 8220whys8221 and are more interested in the 8220hows8221. Furthermore, I8217d really love to know where the authors of this book got their data to back-date some of these ETFs into the 90s. Part 5: some more formal research on topics already covered in the rest of the book8211namely a section about how many independent bets one can take as the number of assets grow, if I remember it correctly. Long story short You easily get the most bang for your buck among disparate asset classes, such as treasuries of various duration, commodities, developed vs. emerging equities, and so on, as opposed to trying to pick among stocks in the same asset class (though there8217s some potential for alpha there8230just8230a lot less than you imagine). So in case the idea of asset class selection, not stock selection wasn8217t beaten into the reader8217s head before this point, this part should do the trick. The other research paper is something I briefly skimmed over which went into more depth about volatility and retirement portfolios, though I felt that the book covered this topic earlier on to a sufficient degree by building up the intuition using very understandable scenarios. So that8217s the review of the book. Overall, it8217s a very solid piece of writing, and as far as establishing the why, it does an absolutely superb job. For those that aren8217t familiar with the concepts in this book, this is definitely a must-read, and ASAP. However, for those familiar with most of the concepts and looking for a detailed 8220how8221 procedure, this book does not deliver as much as I would have liked. And I realize that while it8217s a bad idea to publish secret sauce, I bought this book in the hope of being exposed to a new algorithm presented in the understandable and intuitive language that the rest of the book was written in, and was left wanting. Still, that by no means diminishes the impact of the rest of the book. For those who are more likely to be its target audience, it8217s a 5/5. For those that wanted some specifics, it still has its gem on universe construction. Overall, I rate it a 4/5. Danke fürs Lesen. Happy new year. This post will be a quick one covering the relationship between the simple moving average and time series momentum. The implication is that one can potentially derive better time series momentum indicators than the classical one applied in so many papers. Okay, so the main idea for this post is quite simple: I8217m sure we8217re all familiar with classical momentum. That is, the price now compared to the price however long ago (3 months, 10 months, 12 months, etc.). E. G. P(now) 8211 P(10) And I8217m sure everyone is familiar with the simple moving average indicator, as well. E. G. SMA(10). Well, as it turns out, these two quantities are actually related. It turns out, if instead of expressing momentum as the difference of two numbers, it is expressed as the sum of returns, it can be written (for a 10 month momentum) as: MOM10 return of this month return of last month return of 2 months ago 8230 return of 9 months ago, for a total of 10 months in our little example. This can be written as MOM10 (P(0) 8211 P(1)) (P(1) 8211 P(2)) 8230 (P(9) 8211 P(10)). (Each difference within parentheses denotes one month8217s worth of returns.) Which can then be rewritten by associative arithmetic as: (P(0) P(1) 8230 P(9)) 8211 (P(1) P(2) 8230 P(10)). In other words, momentum 8212 aka the difference between two prices, can be rewritten as the difference between two cumulative sums of prices. And what is a simple moving average Simply a cumulative sum of prices divided by however many prices summed over. Here8217s some R code to demonstrate. With the resulting number of times these two signals are equal: In short, every time. Now, what exactly is the punchline of this little example Here8217s the punchline: The simple moving average is8230fairly simplistic as far as filters go. It works as a pedagogical example, but it has some well known weaknesses regarding lag, windowing effects, and so on. Here8217s a toy example how one can get a different momentum signal by changing the filter. With the following results: While the difference of EMA10 strategy didn8217t do better than the difference of SMA10 (aka standard 10-month momentum), that8217s not the point. The point is that the momentum signal is derived from a simple moving average filter, and that by using a different filter, one can still use a momentum type of strategy. Or, put differently, the main/general takeaway here is that momentum is the slope of a filter, and one can compute momentum in an infinite number of ways depending on the filter used, and can come up with a myriad of different momentum strategies. Danke fürs Lesen. NOTE: I am currently contracting in Chicago, and am always open to networking. Contact me at my email at ilya. kipnisgmail or find me on my LinkedIn here. This post will outline a first failed attempt at applying the ensemble filter methodology to try and come up with a weighting process on SPY that should theoretically be a gradual process to shift from conviction between a bull market, a bear market, and anywhere in between. This is a follow-up post to this blog post. So, my thinking went like this: in a bull market, as one transitions from responsiveness to smoothness, responsive filters should be higher than smooth filters, and vice versa, as there8217s generally a trade-off between the two. In fact, in my particular formulation, the quantity of the square root of the EMA of squared returns punishes any deviation from a flat line altogether (although inspired by Basel8217s measure of volatility, which is the square root of the 18-day EMA of squared returns), while the responsiveness quantity punishes any deviation from the time series of the realized prices. Whether these are the two best measures of smoothness and responsiveness is a topic I8217d certainly appreciate feedback on. In any case, an idea I had on the top of my head was that in addition to having a way of weighing multiple filters by their responsiveness (deviation from price action) and smoothness (deviation from a flat line), that by taking the sums of the sign of the difference between one filter and its neighbor on the responsiveness to smoothness spectrum, provided enough ensemble filters (say, 101, so there are 100 differences), one would obtain a way to move from full conviction of a bull market, to a bear market, to anything in between, and have this be a smooth process that doesn8217t have schizophrenic swings of conviction. Here8217s the code to do this on SPY from inception to 2003: And here8217s the very underwhelming result: Essentially, while I expected to see changes in conviction of maybe 20 at most, instead, my indicator of sum of sign differences did exactly as I had hoped it wouldn8217t, which is to be a very binary sort of mechanic. My intuition was that between an 8220obvious bull market8221 and an 8220obvious bear market8221 that some differences would be positive, some negative, and that they8217d net each other out, and the conviction would be zero. Furthermore, that while any individual crossover is binary, all one hundred signs being either positive or negative would be a more gradual process. Apparently, this was not the case. To continue this train of thought later, one thing to try would be an all-pairs sign difference. Certainly, I don8217t feel like giving up on this idea at this point, and, as usual, feedback would always be appreciated. Danke fürs Lesen. NOTE: I am currently consulting in an analytics capacity in downtown Chicago. However, I am also looking for collaborators that wish to pursue interesting trading ideas. If you feel my skills may be of help to you, let8217s talk. You can email me at ilya. kipnisgmail, or find me on my LinkedIn here . Post navigation CategoriesStop-Limit Orders A Stop-Limit order is an instruction to submit a buy or sell limit order when the user-specified stop trigger price is attained or penetrated. The order has two basic components: the stop price and the limit price. When a trade has occurred at or through the stop price, the order becomes executable and enters the market as a limit order, which is an order to buy or sell at a specified price or better. A Stop-Limit eliminates the price risk associated with a stop order where the execution price cannot be guaranteed, but exposes the investor to the risk that the order may never fill even if the stop price is reached. The investor could miss the market altogether. Interactive Brokers may simulate certain order types on its books and submit the order to the exchange when it becomes marketable. The IB website contains a page with exchange listings. The linked page for each exchange contains an expandable Order Types section, listing the order types submitted using that exchanges native order type and the order types that are simulated by IB for that exchange. See our Exchange Listings . For stop-limit orders simulated by IB, customers may use IBs default trigger methodology or configure their own customized trigger methodology. Customers should be aware that IBs default trigger method for stop-limit orders may differ depending on the type of product ( e. g. stocks, options, futures, etc. ). To modify the trigger method for a specific stop-limit order, customers can access the Trigger Method field in the order preset. Customers can also modify the default trigger method for all Stop orders by selecting the Edit menu item on their Trade Workstation trading screen and then selecting the Trigger Method dropdown list from the TWS Global Configuration menu item. For more information on modifying the trigger method, as well as a detailed description of the default trigger method for each product type, please see the TWS Users Guide section entitled Modify the Stop Trigger Method located here . The Reference Table to the upper right provides a general summary of the order type characteristics. The checked features are applicable in some combination, but do not necessarily work in conjunction with all other checked features. For example, if Options and Stocks, US and Non-US, and Smart and Directed are all checked, it does not follow that all US and Non-US Smart and direct-routed stocks support the order type. It may be the case that only Smart-routed US Stocks, direct-routed Non-US stocks and Smart-routed US Options are supported. Mosaic Example In this example, the investor holds a 99,000 short position in shares of ticker BAC and wants to enter an order aimed at preserving capital while at the same time limiting the price he is willing to pay to buy back the shares. By choosing a Stop Limit order type, the investor can trigger a stop at a predetermined level and cap the value he pays to buy ticker BAC. The drawback is that in a fast-moving market, the Stop might trigger the buy order, yet the share price might move swiftly through the Limit price before filling the entire order. Enter the ticker in the Order Entry panel and select the Buy button. The existing position is automatically displayed and by clicking on the Position field, the user can auto-populate the Quantity field. Next, from the Order Type dropdown field select STP LMT and enter the Stop price at which the trade will start to execute. Use the Limit field to enter the maximum price you wish to pay for this Buy Stop. Use the Time-in-Force field to select DAY or GTC before clicking the Submit button to transmit your order. Classic TWS Example Order Type In Depth - Stop Limit Sell Order Step 1 Enter a Stop Limit Sell Order Youre long 200 shares of XYZ stock at an Average Price of 14.95 (your entry price). You want to sell those 200 shares but you want to limit your loss to 190.00, so you create a Stop Limit order with a Stop Price of 14.10 and a Limit Price of 14.00. If the price of XYZ falls to 14.10, a limit order to sell 200 shares at 14.00 will be triggered at that price. Step 2 Order Transmitted Youve transmitted your Stop Limit sell order. If the price of XYZ falls to your Stop Price of 14.10, a limit order to sell 200 shares at a limit price of 14.00 will be submitted. IB may simulate stop orders with the following default triggers: Sell Simulated Stop-Limit Orders become limit orders when the last traded price is less than or equal to the stop price. Buy Simulated Stop-Limit Orders become limit orders when the last traded price is greater than or equal to the stop price. Unless you select otherwise, simulated stop-limit orders in stocks will only be triggered during regular NYSE trading hours ( i. e. . 9:30 a. m. to 4 p. m. EST, Monday to Friday). IBs default trigger methodology also contains additional conditions which can vary depending on the type of product traded. For a detailed description of IBs trigger methodology, including information on how to modify the default trigger methodology, see the Trigger Method topic in the TWS Users Guide. With the exception of single stock futures, simulated stop orders in U. S. futures contracts will only be triggered during regular trading hours unless you select otherwise. Regular trading hours can be determined by mousing over the clock in the time in force field or the contract description window. After hours quotes made outside of regular trading hours can differ significantly from quotes made during regular trading hours. Stop orders configured to trigger outside of regular NYSE trading hours with a trigger method set to Bid/Ask may trigger in illiquid markets and/or on quotes with wide bid/ask spreads. Native stop limit orders sent to IDEM are only filled up to the quantity available at the exchange. Any unfilled order quantity will be cancelled. For special notes and details on U. S. futures stop limit orders, click here . IB SM. InteractiveBrokers, IB Universitätskonto, Interaktive Analytik, IB Optionen Analytics SM. IB SmartRouting SM. Portfolio Analyst TM und IB Trader Workstation SM sind Dienstleistungsmarken und / oder Warenzeichen von Interactive Brokers LLC. Unterlagen für eventuelle Ansprüche und statistische Informationen werden auf Anfrage zur Verfügung gestellt. Alle angezeigten Handelssymbole dienen nur zur Veranschaulichung und sind nicht für die Darstellung von Empfehlungen gedacht. Das Verlustrisiko im Online-Handel von Aktien, Optionen, Futures, Forex, ausländischen Aktien und Anleihen kann erheblich sein. Optionen sind nicht für alle Anleger geeignet. Für weitere Informationen lesen Sie die Merkmale und Risiken der standardisierten Optionen. Für eine Kopie besuchen Sie theocc / about / publications / character-risks. jsp. Vor dem Handel müssen die Kunden die entsprechenden Risikohinweise auf unserer Warnings and Disclaimers Seite - interactivebrokers / disclosure lesen. Der Margin-Handel ist nur für anspruchsvolle Anleger mit hoher Risikobereitschaft geeignet. Sie können mehr als Ihre erste Investition zu verlieren. Weitere Informationen zu Margin-Darlehen finden Sie unter interactivebrokers / interest. Sicherheits-Futures beinhalten ein hohes Risiko und sind nicht für alle Anleger geeignet. Der Betrag, den Sie verlieren können, ist möglicherweise größer als Ihre ursprüngliche Investition. Vor dem Trading Sicherheit Futures, lesen Sie bitte die Security Futures Risk Disclosure Statement. Für eine Kopie besuchen interactivebrokers / Offenlegung. Es besteht ein erhebliches Verlustrisiko im Devisenhandel. Der Abrechnungstermin der Devisengeschäfte kann aufgrund von Zeitzonenunterschieden und Feiertagen variieren. Beim Handel über Devisenmärkte, kann dies dazu führen, dass Fremdkapital zur Begleichung von Devisengeschäften. Der Zinssatz für Fremdkapital muss bei der Berechnung der Kosten für Trades über mehrere Märkte betrachtet werden. INTERACTIVE BROKERS ENTITIES INTERACTIVE BROKERS LLC ist ein Mitglied NYSE - FINRA - SIPC und reguliert von der US Securities and Exchange Commission und der Commodity Futures Trading Commission. Hauptsitz: One Pickwick Plaza, Greenwich, CT 06830 USA interactivebrokers INTERACTIVE BROKERS CANADA INC. Ist Mitglied der Investment Industry Regulatory Organisation of Canada (IIROC) und Mitglied - Kanadischer Investor Protection Fund. Kennen Sie Ihren Berater: Sehen Sie sich den IIROC AdvisorReport an. Der Handel von Wertpapieren und Derivaten kann ein hohes Risiko beinhalten und Anleger sollten auf das Risiko vorbereitet sein, ihre gesamte Investition zu verlieren und weitere Beträge zu verlieren. Interactive Brokers Canada Inc. ist ein ausführender Händler und bietet keine Anlageberatung oder Empfehlungen zum Kauf oder Verkauf von Wertpapieren oder Derivaten. Sitz der Gesellschaft: 1800 McGill College Avenue, Suite 2106, Montreal, Quebec, H3A 3J6, Kanada. Interactivebrokers. ca INTERAKTIVE BROKER (INDIEN) PVT. LTD. Ist Mitglied von NSE. BSE NSDL sebi. gov. in. Regn. NS: IN-DP-NSDL-301-2008 NSE: INB / F / E 231288037 (CM / FO / CD) BSE: INB / F / E 011288033 (CM / FO / CD) CIN-U67120MH2007FTC170004. Sitz der Gesellschaft: 502 / A, Times Square, Andheri Kurla Straße, Andheri East, Mumbai 400059, Indien. Tel: 91-22-61289888 / Fax: 91-22-61289898 interactivebrokers. co. in INTERAKTIVE BROKER SECURITIES JAPAN INC. 187 03-4588-9700 (830-1730) Sitz der Gesellschaft: 4th Floor Tekko Kaikan, 3-2-10 Nihonbashi Kayabacho, Chuo-Ku, Tokyo 103-0025 Japan interactivebrokers. co. jp INTERAKTIVE BROKER HONG KONG LIMITED wird von der Hong Kong Securities and Futures Commission reguliert und ist Mitglied der SEHK und der HKFE. Registered Office: Suite 1512, Two Pacific Place, 88 Queensway, Admiralty, Hong Kong SAR interactivebrokers. hkDear Brokers8230 Whatever software we8217re using for automated trading: We all need some broker connection for the algorithm to receive price quotes and place trades. Seemingly a simple task. And almost any broker supports it through a protocol such as FIX, through an automated platform such as MT4, or through a specific broker API. But if you think you can quickly hook up your trading software to a broker API, you8217re up for a bad surprise. Dear brokers 8211 please read this post and try to make hacker8217s and coder8217s lifes a little easier A broker API allows software to trade, receive price quotes, and download price history. Those three functions are essential for an automated system. Good-to-have additional features are retrieving trade status, account status, and asset parameters. That8217s six functions, or seven when you count login/logout. A broker API has often more than 100 functions. So you should assume that at least the 6 essential are more than covered. But sadly, it is not so. The debacle begins already with installing and starting up the API. API startup Installing and starting a broker API can be so simple. The ideal case is a broker that provides no software at all, but just a protocol and a URL for a TCP/IP or UDP connection. You can then use well-established libraries such as curl or enet for connecting to the broker. In the second-best case you get an API DLL that you can redistribute to your clients. Your software then just calls the login function of that DLL, submits the authentification data and the connection is established. But for some unknown reason, many brokers feel obliged to provide connections to their APIs in much more complex and creative ways. Broker A required any user to run an API installation package. After an installation dialogue with several Windows incompatibility warnings, the installer produced a bunch of DLLs. Then you can go through a lengthy procedure with many steps of building up all the internal tables and data structures that you need for connecting to your account. In a previous version, the installer also modified the Registry, so you could not step around it and distribute the DLLs directly to your clients together with your software. They had to go through the installation procedure themselves. This is fortunately not required anymore with the current version. Broker B offers no direct connection at all. You have the choice of connecting either to their bloated Java trade platform, or to a small 8220Gateway8221 program. When you connect to the Java platform, your software must once per day log out, restart the platform, and log in again since the platform automatically shuts down every 24 hours. When you connect through the 8220Gateway8221, you can not open their platform at the same time (not even from a different PC). So you can8217t even check your positions. If you do, the Gateway connection breaks down and must be manually re-established. This is not a bug as you might think. It is intentionally implemented this way (according to the broker) as a service to their users. Both broker A and broker B are major, world-wide operating Forex and stock brokers. Getting price quotes Broker A keeps its asset prices in a 8220Quote Table8221 on his server. For getting a price quote you must first subscribe to that asset. For this you do not just call a function, you build up a 8220Request Factory8221 and generate a 8220Subscription Request8221. Now you can enter the procedure of receiving a response on your request, which involves the creation of a 8220Response Listener8221. Subscribing to an asset this way takes about 30 primary lines of C code 8211 and this does not include the secondary code for sending the requests, generating listeners, and all the supplementary stuff. My clients can consider themselves fortunate that I don8217t charge by code line. Getting the price itself then only requires looking up the asset in the server8217s quote table. Broker B makes it easy: You can not subscribe market quotes by API at all. You must do that manually on their website, and it is not free (except for Forex). For getting the price, a simple API call is sufficient. Or would be, if you knew the primary exchange, secondary exchange, asset type and sub-type, and other asset parameters. If any of them is not right, you get no price. And don8217t think that these exchange and other parameters are documented somewhere. You8217re supposed to find them out by trial and error, or to ask fellow programmers on the Internet. Getting price history Although any algorithm trades in real time, it still needs price history on startup for calculating initial values of its indicators and price-analyzing functions. With no access to price history, you had to wait a couple days before the first trade can be placed. Since this is not really practical, price history is an essential API function. Broker A provides price history with no major problem. I can almost not believe it. Ok, you must again fire up the 8220Request Factory8221, generate requests and listeners, but about 50 code lines enable you to download historical prices. The broker charges no fee for those prices (you can even download them with a demo account), and at least the recent data, from 2010 and above, is in acceptable quality. Eight out of ten points for the price history from broker A. Broker B again got creative and enterprising. Their price history from demo accounts is worthless 8211 you must indeed open a real account and deposit 10,000 when you want historical data. This sum, of course, is also required from a poor coder who only wants to implement a function for getting price history. Not that you get it then easily. Technically it8217s simple 8211 a few lines of code are enough 8211 but you only have 60 requests. After that, the price history server is shut down for 10 minutes. 60 requests are enough for a single-asset system, but not for starting a portfolio system, and certainly not for backtests. Why this bizarre limit Maybe broker B can8217t afford a fast Internet connection for their price history server. Maybe they are using the CEO8217s old PC, located in his living room, and the bandwidth goes down anytime when his kids play Tetris on it. Whatever the reason, that8217s only one out of ten points for the price history from broker B. Is there a broker with even zero points for the price history Yes, there is: Broker C has no API function for retrieving historical prices at all. Apparently they had not expected that someone would really use their API. I had no choice but to advise my client to choose another broker for his algorithmic system. Handling trades We programmers tend to think binary. When we send a fill-or-kill order to the broker API, we assume that the position will be either opened (8220yes8221), or it will not (8220no8221). But from time to time, broker APIs produce a third result, like 8220maybe8221 or 8220I won8217t tell8221. A position that is maybe opened or maybe not can result in an orphaned trade . This is a trade opened by the broker, but not reported back to the trading software, and consequently not under automated control. This trade won8217t be closed by a reversal or stop and can thus accumulate a large loss. It can blow the account. Orphaned trades are not a good thing. Theoretically, they would be so easy to prevent. The API just needs to provide a simple order function with an identifier and a validity limit, like this: openAtMarket(string Asset, int Amount, int ID, int SecondsValid) ID dear broker, please store this identifier together with the trade and use it for retrieving the trade status in case of doubt. SecondsValid dear broker, please disregard the order when after the given number of seconds your API still doesn8217t know if it can fill it or not, or is unable to confirm it for whatever reason. That8217s the ideal, but how8217s the reality Broker A accepts a ton of parameters in his order functions, but no user-supplied trade ID and no SecondsValid limit. After sending an order and going through the usual 8220Request Factory8221 and 8220Response Listener8221 rigmarole, you8217ll receive a confirmation and can retrieve the trade identifier for managing or closing it later. Or you8217ll get notified that the order failed. Or neither of both. It happens that the API does not react at all on your order, maybe due to a server hickup, an Internet outage, or because it became confused by too many Factories and Listeners. Then you can only guess if your order made it to the server or not. If it did, you have an orphaned trade. But at least you can relatively easily identify and close it manually. Broker B provides a simple order function, even with a user-supplied ID . And you get confirmation by a simple callback function that the order was filled or not. Usually not, since broker B needs again lots of information about the asset and the order routing, and won8217t execute the order if something is missing or not fitting together. But at least you know the ID. This makes you think that you can later check the trade status. Think again: Broker B won8217t reveal any information about your trades. At least not to you. In fact they do not store your trades at all. They only store net positions. So there is no way to identify orphans. Not even manually, since you can8217t open the trade platform as long as an automated system is running. Account parameters and trading costs Broker A provides a function where you can request leverage, pip size, pip cost, rollover, and any other parameters of the selected asset. Enough information to calculate margin and trading costs in advance, what is a good thing for an automated system 8211 if there weren8217t an important parameter missing. The API does not allow to retrieve the commission. You must enter it manually and store it per asset. Why this important parameter is not provided by the API remains broker A8217s secret. Broker B does not have this problem, as its API provides no asset and trading cost information at all 8211 not even the leverage. For compensation, it supports a sort of 8220virtual order8221 that can be used to calculate profit, similar to Zorro8217s 8220phantom trades8221. Theoretically you could use that to calculate some of the asset parameters in a complex way from a series of virtual orders with different lot sizes. My clients didn8217t pay me for that. For simulating a broker B account in a backtest, you must therefore enter all required asset parameters and trading costs manually in a spreadsheet 8211 which is no easy task due to the complicated fee and margin structure of that broker. There are APIs for almost all imaginable software tasks. And most are well structured nowadays and relatively easy to use. Why is it not so with most broker APIs Dear brokers: If you think about providing API access to your customers, please look first into other broker8217s solutions for learning how NOT to do it. And if really necessary, please add detailed documentation about which of the market or order parameters are really required and in which combination. And if you then still are not sure how to implement your new API, just hire me. I had the dubious pleasure to implement dozens of APIs so far, and can show you how an API for algo trading should look like. And even though you8217ll then have to hand over some shekels to my employer, you8217ll make up for this by winning an excellent reputation. At least among the poor coders and hackers who have to implement your API. 12 thoughts on ldquoDear Brokers8230rdquo Geeze. That8217s unfortunate, I8217m not looking forward to having to deal with this as I get my system up and running. Any broker you recommend for the best API I can not recommend any broker API as 100 perfect, but Oanda has a relatively good API. But it also depends on what you want to trade. Forex brokers offer usually better APIs than stock brokers, and newcomers have better APIs than old-established brokers 8211 which is at least an encouraging sign. Dependent on the API structure, you8217ll need between one afternoon and one week for the implementation. So it8217s a manageable task even with a very bad API. Broker B has its challenges no doubt. Java bloat is still a huge problem. Thinkorswim8217s java bloat is even worse. Anyways I believe there is a workaround the problem of Broker B8217s problem 8211 to concurrently connect with the gateway and trading platform. Using the account management website portal one can create a secondary username that is tied to the same account. Login to the gateway with the secondary username and login to the platform with the primary username. Thanks for the hint The problem with this workaround: you can only create secondary user names for the main account, not for additional accounts such as a paper account that you8217re normally using when you code and test an API implementation. But for trading with the main account this does indeed step around the connection issue of broker B. The ideal broker for algo trading would provide a binary protocol for MD and trades (also instruments description and metadata on start up or by request). The historical MD and trades available as the same binary format messages but downloaded as files. Is there such a broker even for one venue in one single country (I don8217t know one.) I am reaching out to you from IG Markets 8211 global leader in CFDs. We are interested in discussing potential marketing collaboration. We are looking for algo trading communities to work with. IG provides a strong platform supporting Web API, Auto trading and MT4. We would love to see if affiliation or IB partnership opportunities with financial-hacker. I8217d like to schedule a convenient time to have a chat and discuss further. Would you be available sometime next week ARIEL LAO Digital Marketing Specialist IG, Level 15, 55 Collins Street, Melbourne VIC 3000 D: 61398601751 T: 61398601711 ig 40 YEARS OF TRADING INDICES SHARES FOREX COMMODITIES BINARIES We tried a number of Forex APIs, and eventually settled on Dukascopy JForex. It8217s a huge, rambling Java API, but very flexible and powerful, with excellent access to decent quality historical data. It was one of very few that enabled us to execute the more unusual aspects of our strategy. You can run strategies on their servers (if you trust them with your code), client side within their trading client, or client side with their SDK. Data goes back and forth as Java objects, so unless you set up a fancy bridge you8217re working in Java. You run across the odd bug but there8217s usually another way to do things, and the one time we hit a show-stopper they fixed it for us. Commission and spread are very competitive and execution has been OK so far. An actual Swiss bank, so the regulation gives a measure of comfort. In the UK, Atom8 white labels the Dukas marketplace and offers tax benefits to UK residents. Leave a Reply Cancel reply Post navigation


No comments:

Post a Comment