Code Monkey home page Code Monkey logo

fixio's Introduction

fixio - FIX Protocol Support for Netty Build Status Codacy Badge

Overview

Why One More FIX Protocol API

This API is intended to replace well known QuickFIX/J in high-frequency trading scenarios.

Design goals

  1. Implement FIX Protocol Java API with as low memory footprint as possible in order to eliminate unnecessary GC overhead, thus improving overall application performance under high load.
  2. Provide FIX Protocol Codecs for Netty, to make it possible to get rid of Apache Mina which is used by QuickFIX/J as a transport layer.
  3. Avoid using expensive operations:
    • Avoid synchronization.
    • Replace BigDecimals with custom Fixed Point Number implementation for financial data.
    • Reuse java.util.Calendar and java.util.TimeZone instances.

The API has a number of limitations, so it may be not suitable for any FIX application.

Limitations

  1. Logon message encryption is not supported. EncryptMethod(98)=0
  2. XmlData is not supported
  3. Message encodings other than US-ASCII are not supported.
  4. Message resending and resend requests are not supported.
  5. ...

Performance

Currently fixio can beat QuickFix performance in simple scenario. See performance comparison.

Getting Started

  1. Download ZIP archive or clone/fork the repository.
  2. Build and install project artifacts to your local maven repository: mvn clean install
  3. Add the dependency to your project
<dependency>
    <groupId>kpavlov.fixio</groupId>
    <artifactId>core</artifactId>
    <version>1.2</version>
</dependency>

You'll also need a slf4j API implementation at runtime, so please add appropriate dependency, e.g.:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

Examples

You may find working example of client and server applications in module "examples".

I recommend running server with Concurrent Mark Sweep Collector enabled: -XX:+UseConcMarkSweepGC and increased Survivor spaces (-XX:SurvivorRatio=4).

Writing Simple FIX Client

To create a simple FIX client you need to:

  1. Implement FixApplication. You may extend FixApplicationAdapter as a quick start.

  2. Create an instance of FixClient and initialize if with FixApplication you've just created and classpath reference to FIX session settings property file.

  3. Invoke FixClient.connect(host, port) to initiate connection. Method connect(...) returns a ChannelFeature which which will be notified when a channel is closed, so you may invoke the method sync() on it if you wish to wait for connection to be closed.

FixApplication app = new FixApplicationAdapter();
client = new FixClient(app);

// set settings file location related to classpath
client.setSettingsResource("/client.properties");

// connect to specified host and port
ChannelFeature closeFeature = client.connect("localhost", 10201);

// wait until FIX Session is closed
closeFeature.sync();

// Shutdown FIX client
client.disconnect();

SSL Support for Client

You may set a property ssl=true in client.properties file.

Or configure FixSessionSettingsProvider by hand. See FixSessionSettingsProvider.Params.SSL.

You may find more information in User Guide and Wiki pages.

fixio's People

Contributors

dependabot[bot] avatar juddgaddie avatar kpavlov avatar renovate[bot] avatar tom-smalls 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

fixio's Issues

Migrate to Java 8

I'd love to migrate to java 8 but somebody may still use jdk 7 for production.

End of Java 7 Public Updates is April 2015

If somebody is using Java 7, please give rise a voice!

How to logon with username/password

Hi!

I would like to ask you if it is possible with Fixio to send LOGON request along with user credentials. So far I use fixClient.connect() method which has no option like that.

Thanks a lot.

RequestValidationError.IncorrectMDEntryType

@kouyusanpi:
Request:
8=FIX.4.3|9=184|35=V|49=***|56=***|34=2|50=***|57=***|52=20180305-04:05:04.434|128=***|262=161f4559330|263=1|264=1|265=0|146=1|55=EUR/USD|460=4|167=FOR|267=1|269=0|10=249|

Response:
8=FIX.4.3|9=164|35=Y|34=2|49=***|50=***|52=20180305-04:05:04.570|56=***|57=***|58=RequestValidationError.IncorrectMDEntryType|262=161f4559330|281=3|10=038

See #40

Support multiple fields with same tag

@kouyusanpi:

I am programing FIX,The following question:
Market Data Request: Subscription
8=FIX.4.3|9=205|35=V|34=177|49=quote.TestOrg.TestUser.dev|50=TestOrg|52=201402 2617:03:32.405|56=client.fxgrid.integral.com|128=Broker13|262=3ee|263=1|264=1| 265=0|146=1|55=EUR/USD|460=4|167=FOR|267=2|269=0|269=1|10=059|
the Subscription message has two Tag:269, In the FIXIO that how can i do it. The FixMessageBuilder is Map type.

Feature requests/questions

What happens when the connection is lost? Do I get an exception from FixApplicationAdapter in the following method?

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        LOGGER.error("Uncaught application exception.", cause);
        ctx.close().sync();
    }

QuickFixJ has a retry mechanism when the connection is lost but I'm unsure there is one here, if there isn't I will probably retry myself with my own rate limiter.

Another question not related, will you give a name to the project with something more searchable? Maybe you can create a small user's list for questions @reactivefix or @netty-fix -suggestions-

As for Maven project maybe group ID something like io.fix

Is there any API documentation for fixio?

I am very much new to the Stock exchange market. I just started looking into QuickFix and when I am searching for that I found this project is very much useful for me. But I didn't found any API documentation. Can anyone provide me the documents, so that I can start as quick as possible. I will be very graceful if anyone can provide me some more examples than they are already in the project source library. I have already worked with the examples in the library and I can able to see that, only a session is being created.After that nothing is being happening. Can anyone help me how can I place some orders from the initiator to the acceptor and again receive the response back? Some more examples with added order placing will help me a lot. I am very much interested in this project. I am really fed up with QuickFix latency and this the only thing that can help me a lot.

I am also very much new to GitHub. And I am extremely sorry if this is the wrong place to ask such type of questions.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency org.apache.maven.plugins:maven-shade-plugin to v3.5.3
  • Update dependency org.apache.maven.plugins:maven-source-plugin to v3.3.1
  • Update dependency org.apache.maven.plugins:maven-surefire-plugin to v2.22.2
  • Update dependency org.assertj:assertj-core to v3.25.3
  • Update dependency org.javassist:javassist to v3.30.2-GA
  • Update dependency org.mockito:mockito-core to v2.28.2
  • Update dependency pl.pragmatists:JUnitParams to v1.1.1
  • Update jmh.version to v1.37 (org.openjdk.jmh:jmh-generator-annprocess, org.openjdk.jmh:jmh-core)
  • Update dependency net.sf.saxon:Saxon-HE to v12
  • Update dependency org.apache.maven.plugins:maven-deploy-plugin to v3
  • Update dependency org.apache.maven.plugins:maven-failsafe-plugin to v3
  • Update dependency org.apache.maven.plugins:maven-gpg-plugin to v3
  • Update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3
  • Update dependency org.apache.maven.plugins:maven-release-plugin to v3
  • Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3
  • Update dependency org.mockito:mockito-core to v5
  • Update slf4j monorepo to v2 (major) (org.slf4j:slf4j-simple, org.slf4j:slf4j-api)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

maven
benchmark/pom.xml
  • org.openjdk.jmh:jmh-core 1.20
  • org.openjdk.jmh:jmh-generator-annprocess 1.20
  • org.apache.maven.plugins:maven-shade-plugin 3.1.0
core/pom.xml
  • junit:junit 4.13.1
  • pl.pragmatists:JUnitParams 1.0.4
  • org.apache.commons:commons-lang3 3.4
  • org.javassist:javassist 3.19.0-GA
  • net.sf.xsltmp:xslt-generator-maven-plugin 1.8
  • net.sf.saxon:Saxon-HE 9.8.0-3
pom.xml
  • io.netty:netty-all 4.1.14.Final
  • org.slf4j:slf4j-api 1.7.25
  • it.unimi.dsi:fastutil 8.1.0
  • org.slf4j:slf4j-simple 1.7.25
  • org.apache.maven.plugins:maven-source-plugin 3.0.1
  • org.apache.maven.plugins:maven-javadoc-plugin 2.10.4
  • org.apache.maven.plugins:maven-gpg-plugin 1.6
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.6.7
  • org.apache.maven.plugins:maven-release-plugin 2.5.3
  • org.apache.maven.plugins:maven-surefire-plugin 2.21.0
  • org.apache.maven.plugins:maven-failsafe-plugin 2.21.0
  • org.apache.maven.plugins:maven-deploy-plugin 2.8.2
  • org.apache.maven.plugins:maven-jar-plugin 3.0.2
  • org.apache.maven.plugins:maven-resources-plugin 3.0.2
  • org.mockito:mockito-core 2.12.0
  • org.assertj:assertj-core 3.9.1

  • Check this box to trigger a request for Renovate to run again on this repository

BodyLength and Checksum not set?

Hi!

I noticed during my testing that in message header there was no BodyLength tag which is required by the FIX Protocol specification (and I suspect this issue as a reason why I was being constantly disconnected from server).
Also Checksum tag in trailer is always set to 0, don't know if I have to set it somehow or it is a default value.

Thanks in advance for you help.

FixMessageImpl add MsgSeqNum throw Unparseable int:

image
When my MsgSeqNum is 1, I want add it to FixMessageImpl, so I invoke message.add(int tagNum, byte[] value). First I turn MsgSeqNum from int to byte[], The byte array i get is [0, 0, 0, 1], it will go to IntField. In this function, It find if (digit > 9 || digit < 0) It will throw a expetion, but [0, 0, 0, 1] to int.The result is 1, but by the function it throw a exception so I think it will be a bug.

why write a '1' at the end of a tag value pair?

private static void writeField(int fieldNum, String stringValue, ByteBuf out) {
out.writeBytes(Integer.toString(fieldNum).getBytes(CHARSET));
out.writeByte('=');
out.writeBytes(stringValue.getBytes(CHARSET));
out.writeByte(1);
}

i thought the last line should be out.writeByte(';') ?

Extend API to support adding field by dataType, tagNum and value.

use the fix tag number instead of a tag name, it becomes very confusing switching back and forth. This object oriented idea of taking a fix tag number, change it to a name, then use the name everywhere, then finally output a fix tag number again, sounds good in OO theory but is a pain. It would be simpler have the api only based on fix tag numbers.

comment by Robert J Wolf.

API does not actually use tag names (strings).
It uses tag numbers (int) and enums (fixio.fixprotocol.FieldType), generated from FIX 5.0 SP2 specification.
It is possible to use either int or enum in methods like "message.add(tag, value)". Use numbers for non-standard (custom) tags.

It should be possible to add new field to FixMessageBuilder by specifying dataType, tagNum and value, without lookup a FieldType by tagNum.

I have no idea how to get rid of this lookup when parsing message from stream, because there is no information what kind of field should be added to FixMessage.

Add method: FixMessage.getByIndex(int index)

let the program know the exact order of the individual tags on incoming messages and to control the exact order of the individual tags on outgoing messages. some FIX gateways I have seen mandate an exact order of the individual fix tags and will reject messages. We all know the FIX protocol allows tags in any order but numerous systems cannot handle tags not the desired order

comment by Robert J Wolf.

Field order is defined by their insertion order in FixMessageBuilder, and by order of appearance in the stream for FixMessage due to Fields are stored in ArrayList internally.
To ensure field order in outgoing message, please add them to FixMessageBuilder in that order.

Add a method to fetch a field by index, something like:
FixMessageFragment FixMessage.getByIndex(int index)

Index should be absolute (not relative to message body).

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.