My custom trading platform in Python - Matlab, R project and Python | futures io social day trading
futures io futures trading


My custom trading platform in Python
Updated: Views / Replies:8,966 / 41
Created: by donedge Attachments:5

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 5  
 
Thread Tools Search this Thread
 

My custom trading platform in Python

  #21 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received


donedge View Post
Hi @DarkPoolTrading,


I have not entered that part of my project. Will let you know when I do.



No problem. I'm up and running already. Linux + iqfeed API + python. All working.

Diversification is the only free lunch
Reply With Quote
 
  #22 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,231 received


DarkPoolTrading View Post
No problem. I'm up and running already. Linux + iqfeed API + python. All working.

Did you solve your Wine + IQFeed + connect problem? If so you should post a follow-up in that thread to help others in the future.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #23 (permalink)
Elite Member
Louisville, Kentucky
 
Futures Experience: Intermediate
Platform: Sierra Chart, IRT
Broker/Data: Various
Favorite Futures: Futures
 
empty's Avatar
 
Posts: 92 since Oct 2012
Thanks: 1,906 given, 177 received

Pyfolio


Interesting project to do portfolio analysis in Python

https://github.com/quantopian/pyfolio

Reply With Quote
 
  #24 (permalink)
Elite Member
Palo Alto, CA
 
Futures Experience: Intermediate
Platform: MultiCharts, NSDT, Python
Broker/Data: IB/IQfeed
Favorite Futures: E6, ES
 
Posts: 10 since Apr 2010
Thanks: 122 given, 13 received


DarkPoolTrading View Post
No problem. I'm up and running already. Linux + iqfeed API + python. All working.

Please do come back and post, how you made this work, I've been trying to get this working with docker and wine, seems like a hit or miss, would be nice to get some pointers.

Also can you share the python code to get realtime data from iqfeed, I got the historical data working based on some example code i found on dtn forums.

thanks again for the earlier code dumps!


Last edited by jaikumarm; September 10th, 2015 at 07:13 PM. Reason: typo and grammar fixes
Reply With Quote
 
  #25 (permalink)
 Vendor: diversifyportfolio.com 
PTA, Gauteng
 
Futures Experience: Advanced
Platform: Self built + Sierra + TWS
Favorite Futures: Stocks and Options
 
DarkPoolTrading's Avatar
 
Posts: 1,036 since May 2012
Thanks: 1,244 given, 1,304 received


jaikumarm View Post
Please do come back and post, how you made this work, I've been trying to get this working with docker and wine, seems like a hit or miss, would be nice to get some pointers.

Also can you share the python code to get realtime data from iqfeed, I got the historical data working based on some example code i found on dtn forums.

thanks again for the earlier code dumps!

To be honest I can't recall exactly what the problem was, but just to give you an idea of how things are currently setup (and working):

- Wine 1.7.38
- I do not use docker (although i've heard it makes things easier and more stable, I just haven't tried it)
- I startup iqfeed via the terminal. Make sure to enter your product name, login id, password and version number. If you leave out the version number it doesn't work. eg: wine ./iqconnect.exe -product your_product_name -login your_login_id -password your_password -autoconnect -version 1
- I have the following installed in wine. Note I also use Sierra Chart within wine which needs the visual c++. Not sure if iqfeed also needs it or not, but anyway:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


I will admit that iqfeed under wine is not as stable as I would like, but it works.

Regarding code, if you can get historical data then it is very easy to get streaming data, you just change the port. I can't really post all the code because it is all very specific to my environment so will be of zero use to anyone else. But I can post a few snippets just to give you a general idea:

Connecting to iqfeed:

 
Code
    def confirm_protocol(self, sock, recv_buffer=1024):

            data = sock.recv(recv_buffer)
            print(str(data.decode('utf-8')))

    def init_iqfeed(self, symbol_list):

        host = "127.0.0.1"
        port = 5009

        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((host, port))

        protocol_str = 'S,SET PROTOCOL,5.1\r\n'
        sock.sendall(protocol_str.encode())
        self.confirm_protocol(sock)

        message = 'S,SELECT UPDATE FIELDS,Symbol,Open,Last TimeMS,Last Date\r\n'
        sock.sendall(message.encode())

        message = 'S,SET CLIENT NAME,strategy_xyz\r\n'
        sock.sendall(message.encode())

        return sock

I generally use two threads, one for reading in the streaming data and one for processing it:

 
Code
        incoming_data_queue = deque()
        outgoing_data_queue = deque()
        socket_lock = threading.Lock()
        symbol_df_lock = threading.Lock()

        thread_stream_reader = threading.Thread(target=self.read_streaming_data,
                                                args=(sock, incoming_data_queue, outgoing_data_queue, socket_lock))
        thread_stream_reader.start()

        thread_data_processor = threading.Thread(target=self.process_queued_data,
                                                 args=(sock, incoming_data_queue, outgoing_data_queue, symbol_prices_df,
                                                       currently_watching_list, max_simultaneous, socket_lock, symbol_df_lock))
        thread_data_processor.start()

Method for reading in the streaming data:
In this method I am using the summary field (P) but you would just change that to whatever you need. If you're interested in the actual trades, you would monitor the 'Q' field.
I am also using a queue to cycle through multiple stocks so you could just ignore all that if you only want to look at one instrument at a time.

Basically what I do is cycle through X number of stocks, receive their summary field (P), process the data (in a different thread), remove the stock from the watchlist and add the next one. By doing this I can cycle though thousands of stocks in a few seconds to get their latest update (summary field).

So if you want to just stream a single stock, you would monitor the 'Q' field and you would remove all the outgoing queue stuff, you would just need the incoming queue.

 
Code
    def read_streaming_data(self, sock, incoming_data_queue, outgoing_data_queue, socket_lock):

        logging.basicConfig(level=logging.DEBUG, filename='error_log.log')
        buffer_size = 4096
        buffer_content = ''
        delim='\n'
        data = True
        while data:
            with socket_lock:
                data = sock.recv(buffer_size)
            try:
                buffer_content += str(data.decode('latin-1'))
            except UnicodeDecodeError:
                logging.exception('----------------------' + str(data))

            while buffer_content.find(delim) != -1:
                line, buffer_content = buffer_content.split('\n', 1)
                if line[:1] == 'P':
                    incoming_data_queue.appendleft(line[:-1])
                    msg_unsubscribe = 'r' + line.split(',')[1] + '\r\n'
                    with socket_lock:
                        sock.sendall((msg_unsubscribe).encode())
                    if len(outgoing_data_queue) > 0:
                        new_watch = outgoing_data_queue.pop()
                        msg_subscribe = 't' + new_watch + '\r\n'
                        with socket_lock:
                            sock.sendall((msg_subscribe).encode())
                elif line[:1] == 'n':
                    print(line)
                elif 'SERVER DISCONNECTED' in line:
                    data = None


I haven't posted any code for where I process the data, but basically in the process_queued_data thread, I just pop items off the incoming_data_queue and do whatever needs to be done with it.


Hope that helps a bit, or at least gets you thinking of possible ways to get things working. Again, it is very specific to my needs, but should point you in the right direction. It really is just a simple case of choosing which port to use with iqfeed ie: Historical, streaming, etc. You don't necessarily need to use multiple threads, but it will make things run smoother and you can handle more stocks at the same time if you use specific threads for specific tasks.

If you haven't already, you should look through the example code provided by DTN when you install the API. You will find it in your wine directory under my documents/DTN/IQFeed
There are examples in Java, VB, VC#, VC++

By the way, im just a hobby programmer so my code is certainly not great.

Diversification is the only free lunch

Last edited by DarkPoolTrading; September 11th, 2015 at 01:44 PM.
Reply With Quote
The following 4 users say Thank You to DarkPoolTrading for this post:
 
  #26 (permalink)
 Vendor: sentimentrader.com 
Tulsa, OK
 
Futures Experience: Advanced
Platform: Tradestation, TOS, Python
Broker/Data: IQFeed, Tradestation, TOS
Favorite Futures: ES, SPY, Options
 
ericbrown's Avatar
 
Posts: 201 since Jan 2011
Thanks: 339 given, 234 received


jaikumarm View Post
Please do come back and post, how you made this work, I've been trying to get this working with docker and wine, seems like a hit or miss, would be nice to get some pointers.

Also can you share the python code to get realtime data from iqfeed, I got the historical data working based on some example code i found on dtn forums.

thanks again for the earlier code dumps!

There is a docker container available with IQFeed. https://github.com/bratchenko/docker-iqfeed.

Works great...been running for me for 3 months without issue.

Reply With Quote
The following user says Thank You to ericbrown for this post:
 
  #27 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,231 received


ericbrown View Post
There is a docker container available with IQFeed. https://github.com/bratchenko/docker-iqfeed.

Works great...been running for me for 3 months without issue.

Can you confirm if this works headless or does it require a desktop?

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #28 (permalink)
 Vendor: sentimentrader.com 
Tulsa, OK
 
Futures Experience: Advanced
Platform: Tradestation, TOS, Python
Broker/Data: IQFeed, Tradestation, TOS
Favorite Futures: ES, SPY, Options
 
ericbrown's Avatar
 
Posts: 201 since Jan 2011
Thanks: 339 given, 234 received


Big Mike View Post
Can you confirm if this works headless or does it require a desktop?

Mike

I'm running it headless.

Reply With Quote
The following user says Thank You to ericbrown for this post:
 
  #29 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,231 received


ericbrown View Post
I'm running it headless.

Nice. I've never used docker before, I need to read up on it.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #30 (permalink)
 Vendor: sentimentrader.com 
Tulsa, OK
 
Futures Experience: Advanced
Platform: Tradestation, TOS, Python
Broker/Data: IQFeed, Tradestation, TOS
Favorite Futures: ES, SPY, Options
 
ericbrown's Avatar
 
Posts: 201 since Jan 2011
Thanks: 339 given, 234 received



Big Mike View Post
Nice. I've never used docker before, I need to read up on it.

Mike

It is quite easy. This implementation is straightforward and step-by-step instructions are given on the github page.

Reply With Quote

Reply



futures io > > > > My custom trading platform in Python

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Big Mike's custom trading platform Big Mike Elite Automated Trading 398 July 9th, 2017 05:08 PM
Custom Stock Indices; Python/Excel/R; stats burton1995 Stocks and ETFs Trading 1 March 23rd, 2015 09:24 PM
Looking to pay someone to create many Custom Alerts & Custom Scans on ThinkOrSwim jasonbanash ThinkOrSwim Programming 1 January 30th, 2014 07:26 AM
What is the best stock trading (broker) platform for setting "custom" alerts? locussst Platforms and Indicators 1 March 4th, 2012 10:31 PM
New Trading platform Michael.H The Elite Circle 19 September 16th, 2010 01:54 PM


All times are GMT -4. The time now is 01:08 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-14 in 0.13 seconds with 20 queries on phoenix via your IP 54.234.255.29