cjol / Algo-Trading

An algorithmic trading game.
0 stars 0 forks source link

Frontend #10

Open alanrusnak opened 10 years ago

alanrusnak commented 10 years ago

Hey, I started working on the frontend (JSON -> Graph). JFreeChart is a good library, easy to use.

  1. 5 External JARs are needed: - 3 for parsing JSON http://wiki.fasterxml.com/JacksonDownload (Core, Annotations and Databind) 2 for graphs, JFreeChart and JCommon http://sourceforge.net/projects/jfreechart/files/ I am not sure if I can add them from my computer, so we can do it on Monday
  2. We are storing results as (Timestamp,X). the problem is that Map compares timestamps by .compare() and does not allow duplicates in the map. So if the algorithm on some ticks takes <1ms we might lose some data. In my opinon we should store Results as (int TickNumber,X). It is better for comparison of data and I dont think the user cares what time the algorithm was executed.
  3. I am going to be quite busy this week (Lent Bumps - several races next week), so I will not be able to finish the frontend. If anyone has some time, familiarising yourself with JFreeChart Developers Guide would be good.
  4. Where does the frontend fit into our project? I see it as quite external thing at the moment , basically an interactive JSON -> Graph convereter.
cjol commented 10 years ago

I'm not sure your point 3 makes sense maybe you didn't finish writing it out properly? When I decided to key ticks by Timestamp, I thought that the Timestamps provided were of the simulation time, not the time the tick was executed - I thought it would be good to be able to display what time the results correspond to in "market time". It doesn't really matter what they're keyed by. With that said, Timestamp sort of intuitively makes sense if we are going to key by anything, since we are getting a new packet of data with every tick. Otherwise just a List probably makes more sense than a Map at all.

alanrusnak commented 10 years ago

OK, fair enough. I just tested it quickly, we'll see on monday once we integrate it. It's not a big problem to modify it.

cjol commented 10 years ago

I still don't know what you're talking about! I think there are words missing from your original post, and I can't see your code to compare.

Additional thoughts from re-reading your post. What do we need JacksonDownload for? The JSON.org jar that I used to serialise objects to JSON can also deserialise, so I assume Jackson is necessary for more than just parsing JSON? You should be able to import JFreeChart by adding this dependency to the client package's pom.xml:

<dependency>
    <groupId>jfree</groupId>
    <artifactId>jfreechart</artifactId>
    <version>1.0.13</version>
</dependency>

@mildbyte can you clarify whether Maven does automatic dependency resolution? I.e. http://mvnrepository.com/artifact/jfree/jfreechart/1.0.13 suggests that jcommon is required, but do we have do add jcommon to the pom.xml too or is maven magic?

The frontend fits into the client package somewhere, although since the client is currently just a FileLoader, there's nowhere yet for it to be integrated. Some more thought is probably required here before we write too much code!

alanrusnak commented 10 years ago

Yeah... there were bits missing in the original between angle brackets <>. I changed it now to (). It was just an idea, we can stick to Timestamp. I used Jackson only for parsing e.g.:

TreeMap<String, Integer> map = new TreeMap<String, Integer>();
        ObjectMapper mapper = new ObjectMapper();

        try {
            map = mapper.readValue(jsonData.toString(),
                    new TypeReference<TreeMap<String, Integer>>() {
                    });
        } catch (IOException e) {
            e.printStackTrace();
        }

I will have a look at JSON.org

Thanks for clarifying

mildbyte commented 10 years ago

Hey guys,

@Hephistocles Yeah, seems like Maven does resolve transitive dependencies too: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies. If I add your XML to a pom.xml and do dependency: resolve, it also seems to fetch jfree.jcommon.