简体   繁体   中英

F# data feed abstraction

I am trying to learn F# and would like to create a platform to test trading strategies. Usually brokers API broadcasts C# events every time a tick in the book is updated. What is the proper functional way to listen to C# events and react to those? Is there an established way to abstract the implementation out from the way ticks are dispatched being able to use the same code to test online (from events) and offline (from database and or files)?

Any reference to established techniques and functional design?

Thanks in advance

The concept you are looking for is Reactive Programming , which is a style of programming that can be used with F# or almost any programming language.

If you are familiar with iterators (eg LINQ) and the level of abstraction they provide, then you can adapt that way of thinking to RP. Observable sequences represent streams of data that could be anything from asynchronous events to in-memory arrays.

Similarly to the way that LINQ is inherently functional, so chains of operations on observable sequences can be built without side-effects until your program chooses to operate on them. The F# documentation describes how to attach to events and process them as Observable sequences.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM