medovarszki / ibkrfacade

Interactive Brokers API wrapper and trading toolbox
22 stars 9 forks source link

Upgrade to Redis-OM Spring Boot 3.1.3 #9

Closed paulmac closed 8 months ago

paulmac commented 8 months ago

Hi Mihaly, I've commited a whole bunch of changes of ibkr to my fork. It is rearranged for Redis-OM style. Read the comments and have a look at the code and see if you agree with what I have done. I do not not use the ContractDetail, it's to cumbersome, I have a class called SimpleContract which contains the 4 or 5 attributes necesary, it is a Redis OM Json object, I could include it and merge with your Option, making it a Json object also if you agree, also there needs to be a client now to implement the ExecHandler interaface for TWs responses. The rest of the changes should be logical for you. Paul.

medovarszki commented 8 months ago

Hey Paul! Wow, I'm really glad you find this idea interesting and are contributing to its refinement. I'll check your changes in detail in the following days and merge them back if you don't mind.

However, I'll keep the Trend Trading Strategy because it's an important example for understanding the core idea behind the concept.

paulmac commented 8 months ago

Hi Mihaly, I am using IBKR facade as a library for my algo trading bot. Therefore I have not commited the skeleton, the initialise data etc. Therefore this branch does not run and can't be tested as is. I can add these artifacts after you have had a look. Again; I don't use ContractDetails nor ContractSamples. I use a SimpleContract redis-om json object :

import com.ib.client.Contract; @Data @Builder @Document public class SimpleContract { @Id @Indexed private String id; // ULID @NonNull @Indexed private Integer conid; @NonNull @Indexed private String symbol; // ("EUR"); @NonNull @Indexed private Types.SecType secType; // e.g "CFD"; @NonNull @Indexed private String currency; private String exchange;

public Contract toContract() {
    Contract con = new Contract();
    con.secType(this.secType.toString());
    con.symbol(this.symbol);
    con.currency(this.currency);
    con.exchange(this.exchange);
    return con;
}

}

I can place this in IBKR facade together with Option which makes sense IMHO

So an Option Contract becomes ....

public class SimpleContract { @Id @Indexed private String id; // ULID @NonNull @Indexed private Integer conid; private Option option ... }

JSON allows for contained objects