There was a company last week that showed off their bitcoin algos and I wrote a comment that basically said don't use them and I felt bad about it for the rest of the week. I'll try to just be positive here:)
To weigh in on the mention of using doubles for finance....
Using double for finance, perfectly fine.
All trading systems I've seen use double, from HFT systems to deep learning AI systems that open and close potions over months. Double is fine for most algo trading, heck the exchanges and dark pools I've talked with use double.
What you can possibly do with this.
1) Learn how to write the logic of an trading algorithm.
2) learn the basics of technical trading, with MACD, Keltner channels, vortex and Bollinger band indicators. They've definitely put the time in to getting the indicators that FX traders like to use.
What you can't do with this system.
1) React to currency fluctuations on a tick by tick basis. FX is just so fast and precise, there is a reason that professional FX traders mix FX spot quotes from multiple sources, we use 4 at the fund I work at and some use up to 10 sources. There is also a reason why FX is quoted to 4 decimal places while equities are to 2, sometimes 3 for penny stocks.
2) Use this in a real world setting. I can't see any privacy policy or contract indicating what happens when shit goes wrong. We are talking about money here, you can't just half ass this kind of thing.
Plus they use FXCM which had this new out about them:
> LONDON—Foreign-exchange trading firm FXCM Inc. FXCM +0.08% agreed to pay fines and refunds totaling almost £10 million ($16.7 million) to settle allegations by a U.K. financial regulator that the company withheld profits from clients and failed to inform British authorities that it was under investigation in the U.S.
> The Financial Conduct Authority said that U.K. units of FXCM withheld £6 million from customers on foreign-exchange transactions between August 2006 and December 2010. The regulator said the broker pocketed profits when exchange rates moved in its customers' favor while a trade was in process, but it passed on losses that occurred on other trades.
A lean algorithm will comfortably execute every tick even in a busy market. Of course if it can't be processed before the next tick comes in, subsequent executions will run late, though we leave this up to the trader and hope to just provide the most performant execution environment we can.
We find no issues running scripts of reasonably high complexity. Of course if you have a particularly heavy algorithm it may be better suited to running at interval close.
With regard to legal position, you're absolutely right. While we're in beta you can connect to live broker accounts, though we are blocking order requests from actually being sent. We want to be water tight both technically and legally before we full launch with regulatory authorization, lifting this restriction and allowing real money to be risked.
As with brokers, we just want to support as many as we can. FXCM were a natural first choice for integration as they have excellent support for API solutions and have the most fully featured FIX implementation we've come across. Of course it's up to the trader to establish if any conflict of interest scenario exists between themselves and the broker.
> [Can't] React to currency fluctuations on a tick by tick basis. FX is just so fast and precise.
I don't see any reason why they couldn't aggregate prices and compute them tick-by-tick? JavaScript can run really fast these days
> [Can't] Use this in a real world setting. I can't see any privacy policy or contract indicating what happens when shit goes wrong. We are talking about money here, you can't just half ass this kind of thing.
I mostly agree and I wouldn't use it, but if you're just starting out and can't afford to build your own platform, it might be worth considering?
> There is a reason that professional FX traders mix FX spot quotes from multiple sources, we use 4 at the fund I work at and some use up to 10 sources.
We use 15 :) (Although two are internal flow from other desks)
> Plus they use FXCM which had this new out about them
We use FXCM. If they quote and fill the best price, I don't really care how they arrived at it. But that's just me.
> There is also a reason why FX is quoted to 4 decimal places while equities are to 2, sometimes 3 for penny stocks.
Isn't the reason that most FX rates are O(1) (eg EURUSD is about 1.34, cable is about 1.7) whereas most stocks are O(10) or even O(100) and O(1000)?
If you take an FX rate that isn't O(1) eg USDJPY which is about 100, the convention is that it's quoted to 2 decimal places, like a stock (though there are some exceptions, eg USDMXN is around 13 but it's quoted to 4dp, and USDRUB is around 35 and also quoted to 4dp).
Stocks in the US are quoted to 2 decimal places because of reg NMS rule 612 (the subpenny rule). Any displayed quotes above $1.00 are priced in pennies and below $1 you can quote in increments of $0.0001. Trades can however happen in subpenny increments. For example retail internalizers may offer subpenny price improvement (e.g. market is 20.00 x 20.01 - retail market sell order gets filled at 20.0001). Also non-displayed bids and offers may exist at subpenny increments (e.g. market is 20.00 x 20.01 and there is a non-displayed midpoint peg buy at 20.005 at nasdaq - incoming marketable sell will match and print at 20.005).
I'm in the "professional automated trading" space. This is by far the most common vendor mistake. "We make trading simple!" is pretty much a surefire way to mediocrity at best.
"We make tax law simple!"
"We make heart surgery simple!"
^^ similar silly things, only you don't ever see them
The thing is, no one actually DOES make anything simpler. They just restrict the toolset with which you can solve problems to things that work for the 80% cases.
Quick example, I want to build a dynamic portfolio based on a subset of S&P 500, with no sectors exposure, no market exposure (delta and beta flat), no capitalisation exposure, and I want to avoid trading a stock from one week before until one week after their earning announcements.
This is a very simple example of a common portfolio universe but tools like quantopian and cloud9trader (even though the latter doesn't support stocks yet so they're out of scope here) just don't provide the required data. I can't find an index historical composition, security data doesn't include its market cap, its sector, the next earnings announcement date.
I can't even start working on my signals since I'm unable to select my stocks.
I don't think this platform is for equities (yet?). They only support FXCM, which is a spot FX outfit. Based on the pricing, it seems to me these guys are targeting, mainly, retail FX traders.
This is actually interesting if you combine it with the other HN thread currently on the FP. Its about pyrasite.com, which allows you to read/write into another python process.
https://news.ycombinator.com/item?id=8160149
Garbage collection would be a problem in realtime algos. And efficiency is ~10x slower than C. But as far as writing bug free code, I'd take JavaScript over C. But I'd take Java over both of them and the JVM has a lot of GC configuration options (in addition to real-time JVMs, but those can cost a lot of money).
Anyhow, for user-submitted code like this trading site, I think JS is the only realistic option since it can be sandboxed so safely.
I hope to not come off as too critical, but there's a ridiculously wide margin between this and what trading firms in the low latency space do.
I don't know of a single firm that's successful in the time horizon that a lot of pseudo-HFT systems operate in. (The 10ms-3s range) And that's assuming an ideal fee situation...
Most of the people ignoring the LL arms race target RV opportunities on the 30s+ range. This involves taking a pretty big step back from microsctructure/toxicity models.
> Most of the people ignoring the LL arms race target RV opportunities on the 30s+ range. This involves taking a pretty big step back from microsctructure/toxicity models.
A double can store every integer from -2^53 to 2^53, which seems sufficient to do financial work.
2^53 is 9,007,199,254,740,992
If you want to denote that the last three digits are for fractional dollars (i.e. each integer represents 1/10th of a penny) then you can store any monetary value from -$9 trillion to $9 trillion.
EDIT: Note that it's tempting to think that you can skip converting decimal currency to integer as long as you only use <= 3 digits after the decimal and you're storing values of less than 9 trillion, i.e. it's tempting to think you're safe storing a value like $1,283.212 directly in a double without converting to integer. But I'm pretty sure that's mistaken. You always need to convert to integer so that you're storing 1,283,282 in a double, not $1,283.212
The reason is because certain decimal values which can be represented in base 10 can't be represented in base 2. For example, $0.1 can't be stored into a double as-is; if you try to store 0.1 into a double, you'll get:
0.1000000000000000055511...
which is where the inaccuracies can start to come into play. Whereas if you convert $0.1 to integer, you'll be storing the value 100 into a double, which comes out to exactly 100 without any error.
Of course, the error may be so small as to be insignificant, but the point is, I'm absolutely certain that integers between -2^53 and 2^53 can be perfectly represented by doubles, but I'm not certain that <= 3 digits of decimal precision can always be accurately represented by doubles for values of less than 9 trillion.
EDIT2: You have to be careful when converting between currencies, too. For example, right now $2 = 204 yen. If you're storing yen, 2^53 yen is different from 2^53 one-tenth-pennies, so the max value that you can store is specific to each currency. This seems like potentially a tricky problem, and may be what the parent commenter was referring to when saying doubles aren't so good for financial work. Still, though, 2^53 integers of precision may be sufficient regardless of which currency you're using.
Correct. The solution is usually that they'll just create special functions for doing numeric comparisons, that accept an adjustable epsilon margin of error, to use instead of the built-in numeric comparison functions.
There're a lot of silly myths about investment software on hacker news / reddit. Truth is that the code is usually much more hastily written, but with more tests or redundant systems implemented to cross validate results.
The idea that precise decimal types will be used throughout the systems is a bit silly. All the data typically will be going though off the shelf machine learning models, all of which just used plain floating types.
Chrome 36. Refresh solved the problem (seems the buttons silently fail if there are network issues). Now having trouble connecting to the broker servers. Network on my end is now fine, though.
I was waiting to see the thing in action before commenting, but here goes anyway. What are your latencies like (market data and orders)? Do your algo's have to depend entirely on current indicators/market data, or is there a way to use historical data? I'm a former HFT/algorithmic trading systems dev myself and the performance requirements in that particular domain was pretty high. At one point, even C++ and close-packed binary data transfer wasn't enough. I was wondering how you're managing with Javascript?
Please let me know if you're continuing to have issues. All seems fine my end.
You can stick the following in your browser console to log server latency stamps on incoming market data:
require(["registry"], function (registry) {
var instrument = registry.get("instruments").get("EUR/USD");
instrument.on("tick", function (data) {
console.log("Server latency (ms):", data.get("serverLatency"));
});
});
Of course replace "EUR/USD" for whichever instrument you want to monitor. 10-20ms is typical for comms between our instances and the brokers (we get similar results for outgoing trade execution requests, factoring in the round trip).
Our stack is largely JavaScript. We've found NodeJS to be blisteringly fast and lending itself perfectly for this kind of application (low memory, high throughput, heavy processing).
We have a backesting framework for running against historical data. Do you have a requirement for pulling historical data into an algorithm during live trading? We haven't included this in out API, though it would be fairly trivial to implement. It's key though that algos run with as little in memory data as possible. We also include a framework for writing your own custom technical indicators. These are naturally set up to pull historical data so may be what you're after. These and the built in indicators can be used in your script by just calling e.g. sma(10)
Currently the API doesn't support multiple instruments though an individual trading session already pulls in whatever currency pairs are required to convert from term currency to your account currency to calculate unrealized profit and to allow you to set quantity in as a risk percentage of account balance... basically not much work involved in supporting. Will get it prioritised.
Definitely would like to include Bitcoin and are looking into our options at the moment.
To weigh in on the mention of using doubles for finance....
Using double for finance, perfectly fine. All trading systems I've seen use double, from HFT systems to deep learning AI systems that open and close potions over months. Double is fine for most algo trading, heck the exchanges and dark pools I've talked with use double.
What you can possibly do with this.
1) Learn how to write the logic of an trading algorithm.
2) learn the basics of technical trading, with MACD, Keltner channels, vortex and Bollinger band indicators. They've definitely put the time in to getting the indicators that FX traders like to use.
What you can't do with this system.
1) React to currency fluctuations on a tick by tick basis. FX is just so fast and precise, there is a reason that professional FX traders mix FX spot quotes from multiple sources, we use 4 at the fund I work at and some use up to 10 sources. There is also a reason why FX is quoted to 4 decimal places while equities are to 2, sometimes 3 for penny stocks.
2) Use this in a real world setting. I can't see any privacy policy or contract indicating what happens when shit goes wrong. We are talking about money here, you can't just half ass this kind of thing.
Plus they use FXCM which had this new out about them:
http://online.wsj.com/news/articles/SB1000142405270230425560...
> LONDON—Foreign-exchange trading firm FXCM Inc. FXCM +0.08% agreed to pay fines and refunds totaling almost £10 million ($16.7 million) to settle allegations by a U.K. financial regulator that the company withheld profits from clients and failed to inform British authorities that it was under investigation in the U.S.
> The Financial Conduct Authority said that U.K. units of FXCM withheld £6 million from customers on foreign-exchange transactions between August 2006 and December 2010. The regulator said the broker pocketed profits when exchange rates moved in its customers' favor while a trade was in process, but it passed on losses that occurred on other trades.