Git Product home page Git Product logo

code's Introduction

The code presented here relates to the book chapter cited below. There are two implementations of the trading model algorithm:

  1. code.java: This class is intended to give an overview of how the trading model algorithm functions. However, the focus lies not on the framework supporting the trading model. As a result, users are required to implement some of their own code in order to get the trading model running.

  2. LimitOrders: A folder containing a fully functional version of the Alpha Engine utilizing limit orders.

Source:

The Alpha Engine: Designing an Automated Trading Algorithm
Golub, Anton and Glattfelder, James B. and Olsen, Richard B.
High Performance Computing in Finance
Chapman & Hall/CRC Series in Mathematical Finance
2017

A preprint is available at SSRN.

Abstract

We introduce a new approach to algorithmic investment management that yields profitable automated trading strategies. This trading model design is the result of a path of investigation that was chosen nearly three decades ago. Back then, a paradigm change was proposed for the way time is defined in financial markets, based on intrinsic events. This definition lead to the uncovering of a large set of scaling laws. An additional guiding principle was found by embedding the trading model construction in an agent-base framework, inspired by the study of complex systems. This new approach to designing automated trading algorithms is a parsimonious method for building a new type of investment strategy that not only generates profits, but also provides liquidity to financial markets and does not have a priori restrictions on the amount of assets that are managed.

code's People

Contributors

antonvongolub avatar jbglattfelder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code's Issues

code.java: unsafe removal from a collection during for loop

In code.java, the for loops starting at 867 and again at 935 attempt to iterate through the entire List of prices, but if the take profit conditions are met, the List of prices is modified, leading to an incomplete iteration over the loop.

``https://github.com/AntonVonGolub/Code/blob/c361282e0d5317690b87d8c93ea9e45e2f7ab4fb/code.java#L867-L879

This implies that the current position decreasing logic does not behave as intended.

Please see this discussion for how to achieve removal safely.

Confusion about code.java not supporting trading model

Hi,

First I want to say that I appreciate your effort to make such examples.

And second...
I'm confused with some text inside the code.java example and differences with the LimitOrder example. Would you mind explain more about their differences. Because it seems to me that the only differences between these two examples are a few TODO's which have been implemented in the LimitOrder and putting Limit order type instead of instant market order type.

Are there any other differences which make code.java 'not supporting trading model' as you mentions in readme section?

Regards,
Dave

ch.olsen?

Hello,

In code.java there's a bunch of imports from ch.olsen.products and routes. Is it possible for me to get access to those libraries?

Thanks

Unused code

Hi!

I am porting you code to Python and was able to get most of it done.
One trouble I seem to have is with the Liquidity class. It looks like it is not used anywhere. Only the LocalLiquidity is used. Is that right and the Liquidity class can be safely removed or am I missing something?

Runner.run() return values

I assume that Runner is actually intrinsic events detector, while run(price) method updates the detector's state and returns the event detected, if any.

For return value, it seems that 0 stands for No event, 1 = Direction changed up, 2 = Overshoot up, -1 and -2 is the same only for down events.

If so, why in line 660, in LocalLiquidity does it return 2, which is according to the above Overshoot up, when the closure it's in handles a type == -1 (direction down)?

AntonVonGolub/Code The code is not working

Hi
Recently I downloaded a code from following URL
(https://github.com/AntonVonGolub/Code/blob/master/code.java) to run for research purpose.

I deleted several imports "ch.olsen~~~" unused imports
and joined with other library imports, by pressing "ctrl + shift + o" and selected the library related with
'olsen'.

but i still have difficulties to run the code.
To illustrate, Main code is blank(empty) ,and also it seemed like some class definition codes are also missing.
(AtomInput,Atomabstr and so on). I assume this is the part of the project's code or some of the class definitions are included in ch.olsen library. Should I have to find external library file(ch.olsen~~) and import to the project to run this code?

Could you please tell how to proceed to run the code?
Thank you .

Contrarian grid system with averaging?

Hi @jbglattfelder,

I read the paper and looked into the both sample codes, but couldn't see many differences with a grid system which opens a contrarian position after an overshoot(which is called a gap or level in grid system) and averages down/up when position is in loss.

For calculating the lot in case of averaging down/up the agent uses liquidity indicator (which is called lot multiplier in averaging system).

I'm afraid I've overlooked something important in this concept that makes this better than a grid system. But I don't know what!
I will really appreciate it if you point me to the differences or advantages of this concept compared to a grid system with averaging the losses.

with regards,
Armin

Question about order closing

Hello,

Many thanks for your paper and sharing your work on github ;-)
I really like your ideas.
I'm testing it, trying to make it work with my own backtesting framework, with minimal changes.

So far, I'm launching only one CoastlineTrader with delta = 0.0005 for long positions.

My assumptions and understanding of your implementation is that

  • You have at the same time opposite positions on the same market but coming from different agents / deltas.
  • The position.s (limit order impl.) of one agent is closed when a given profit is reached by making a market order of volume of all disbalanced orders
  • When a agent in buying mode (for example) decascades, a sell limit order is made in order to close some of the previous buy (eventually taking a loss)

Is that correct or does the sell limit order force the position in the opposite direction so that an agent in buy mode could also open positions in both directions ? The methods makeBuyFilled and makeSellFilled take the profit and remove the orders from the disbalanced orders so I don't think a same agent manages positions in opposite directions but I just wanted to be 100% sure.

My question is: how do you ensure that you won't close the positions managed by another agent?
Maybe my question is naive and linked to my broker... But I don't have the possibility to make the matching of the position myself. Either I close one particular position, or I close many by compensating existing positions but my brocker maximizes the profit when I do so and picks the positions opened at a lower price if closing long and the opposite for short.

In real-world, do you use the "compensatedOrders" list to make sure you close the proper positions?

Thank you in advance,

Liquidity indicator

First - thank you for publishing your work on scaling laws and trading models - it is quite amazing. I have two questions for you on the java code:
(i) LocalLiquidity uses parameters alpha and alpha weight that don't appear in equations (2) - (6) in the alpha engine paper. Could you please explain what alpha and alpha weight represent?
(ii) In calculating the surprise values and subsequent liquidity values in LocalLiquidity I can't see how the probability of K state transitions for a price trajectory in a time interval [0,T] is explicitly considered. Can you please clarify?

Why multiple agents of same order type?

Hi,

I couldn't find the reason behind having multiple agents with different threshold for the same type of orders. Suppose that after some kind of research we find out that the certain threshold applies best to a currency like "AUD_CAD". Let's assume that 0.02 has been profitable for Buy and 0.03 for Sell based on historical research on this currency. Wouldn't be logical to have only one coastlinetrader for buy and one coaslinetrader for sell with these thresholds?

I see that the source code example uses multiple coastlinetraders with different thresholds. Is there a reason for that?

Regards,
Dave

Do we keep positions overnight??

I have run the algorithm on the USD INR data and all the positions are not closed by the end of the day.
Is it supposed to be like this ? If not, is there anything special that needs to be done while transitioning between days. Or can we just treat the first point of the next day as the next point in the time series.

The Code.java is not worrking

Hi

I have recently tried to use your Code.java but due to the imports I have difficult time to use this code.

There seems several Import/Annotation issue in current code and seems like you did not uploaded the cleaned code which is not using legacies.

For example, when I tried to use this code in Eclipse system with Windows OS, there are many "red lines".

It seems several classes for example Atom , AtomInput or PriceFeedData and else are not implemented in this code.

I think it would be better if you implement all the requirements for this code in here(Code.java) or write some suggestions how to compile this code in Eclipse system or directly in Termianl(or command line prompt for Windows).

Or is there any chance that I can obtain those packages callsed "ch.olsen" ??

Lists are below ( directly copied and pased from your Code.java )

import ch.olsen.products.util.configuration.Configuration;
import ch.olsen.products.util.configuration.DoubleProperty;
import ch.olsen.products.util.configuration.EnumProperty;
import ch.olsen.products.util.configuration.StringProperty;
import ch.olsen.routes.atom.Atom;
import ch.olsen.routes.atom.AtomAbstr;
import ch.olsen.routes.atom.AtomException;
import ch.olsen.routes.atom.AtomInput;
import ch.olsen.routes.atom.AtomInputAbstr;
import ch.olsen.routes.atom.AtomOutput;
import ch.olsen.routes.atom.AtomOutputAbstr;
import ch.olsen.routes.atom.RoutesStep;
import ch.olsen.routes.cell.library.LibraryAutoDeploy;
import ch.olsen.routes.data.ArrayDataElement;
import ch.olsen.routes.data.DataElement;
import ch.olsen.routes.data.DataType;
import ch.olsen.routes.data.DoubleDataElement;
import ch.olsen.routes.data.NullDataElement;
import ch.olsen.routes.framework.RoutesFramework;

The response rate is extremely low

Hi,

I tried running the above code on the USD-INR(indian rupee) data and the response rate is very low. I mean to say that it shows a couple of trades on some days and on some days, it shows no trades. So how frequently did the model show trades when you ran on other currencies.

Also, I am feeding the data day wise. At once I just send one day's tbt data and then in the next iteration , I send the next day's data but there is no connection between the previuos day's data to the next day's data. Is that how it is supposed to be. Or should I combine the data odf several days and then run the code.

Thanks.

Threshold when position units > 30

In CoastlineTrader, when tP > 30, events will be taken from runnerG[0][1], which was initialised as following -

runnerG[0][1] = new Runner(0.50*deltaUp, 2.00*deltaDown, price, fxRate, 0.50*deltaUp, 0.50*deltaUp);

But notice that 50% of the threshold means that it will increase position sooner, since threshold is lower.

What is the logic in increasing the position faster when position is already large (>30)?

To my logic it should be the opposite - in order to reduce risk, threshold should be higher the bigger our position is.

Price change delta - linear vs. log

In line 107, Runner calculates a Math.log(price.elems.bid/extreme) when price is a PriceFeedData object, while at line 164, the it's the same method except that it receives a price of type double and it performs a linear calculation of delta price - extreme instead the previous logarithmic calculation.

Why for an object price Runner uses a logarithmic calculation and for a double it performs a linear calculation of delta?

Testing on XAUUSD (Gold)?

Thank you for your work. I have tested your theory on forex pairs and had success similar to those mentioned in Figure 1 of the article (eg NZDJPY being a profitable pair). I have also tested this on gold starting 2007 to 2017. XAUUSD failed tests as compared to forex pairs. Had you done any testing on XAUUSD or could you try and let the community know your findings? Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.