Developing "Spartan"

BTW don't take my mocking of Java seriously, I think it's a great productive language/ecosystem. Especially recently when they've been taking ideas on how to un-enterprise various things.
Java is the only language I seem to understand. I keep on trying to understand Python, but somehow I am never able to analyze the functionality of a piece of Python code by reading it. So I stick to what I do understand. Hobby trader and hobby programmer.
 
Java is the only language I seem to understand. I keep on trying to understand Python, but somehow I am never able to analyze the functionality of a piece of Python code by reading it. So I stick to what I do understand. Hobby trader and hobby programmer.

I think different languages appeal to different modes of thinking. I'm sure people with different learning styles "prefer" different programming languages.
 
@nooby_mcnoob I noticed your keeness for ib_insync on another thread. Are you using it in production?

Right not I plan to reinvent that particular wheel and wrap the python API myself as I've done in my current system, but I am not 100% decided (nearly at that decision point though).

GAT
 
@nooby_mcnoob I noticed your keeness for ib_insync on another thread. Are you using it in production?

Right not I plan to reinvent that particular wheel and wrap the python API myself as I've done in my current system, but I am not 100% decided (nearly at that decision point though).

GAT

Yes I am using it, it's a no brainer in my opinion! But I do have my own interface on top of it.

upload_2020-1-17_8-38-54.png
 
I recently added the ability to trade futures to Spartan and obviously it isn't a complicated thing necessarily (handled similarly to options, with minor differences at the periphery), I thought it was pretty cool how easy it was for me to modify the same UI I use everywhere else to add the futures-specific stuff but just when trading futures. Here is the UI-related code:

upload_2020-1-19_18-56-33.png


Lets me toggle between using micros (for ES/NQ) by using the bindCheckbox button with a boolean value. I know it isn't impressive but I thought it was cool.
 
  • Like
Reactions: d08
I just went through a terrifying ordeal with SQLite saying "Database is locked". Famous error message which drives people nuts.

Apparently, some background process went crazy and left the DB open.

No harm done.

Should probably back it up though...
 
I've been having performance issues with my charting code when the market goes crazy. The problem is that plotly requires to redisplay each and every point on every update, at least when it is run in a Jupyter notebook (I have built my UI/monitoring in Jupyter widgets.)

So I went down the path of trying out various different libraries and found some promising candidates. But before I went down the path of learning all their stupid little problems I sat and thought about whether I truly need every single tick to be reflected in the chart. The answer is no, I can wait for 1 second. So I update the chart to update once per second. Voila, no more problems.

Keeping it simple! CPU usage down from 100% CPU to 40% CPU. Of course I'd like to solve this problem eventually but for now it's OK.

Edit: the code, for completeness:

I used to have a terrible CPU issue with Matplotlib and almost abandoned it but ended up solving it pretty easily. When you have your chart drawn out on the axis, everything on the chart can be accessed with the get_children() method for said axis. It's some kind of list and the first three elements in the list are always the candle bodies and stems. Call the remove() method on those and they disappear. Then just use the candlestick2_ohlc() function to put the updated candles back on there. It does completely redraw all the candles (though there is a way to just get the last one though I'm too lazy to put it together) but on my machine I can update my charts every 100 milliseconds and it takes about 10% CPU so maybe give that a shot. I'll attach a little snippet with some of the relevant code to give you an idea if you aren't familiar with it.

Edit: If you Google candlestick2_ohlc you'll find plenty of stuff
 

Attachments

  • Selection_015.png
    Selection_015.png
    28.2 KB · Views: 17
I used to have a terrible CPU issue with Matplotlib and almost abandoned it but ended up solving it pretty easily. When you have your chart drawn out on the axis, everything on the chart can be accessed with the get_children() method for said axis. It's some kind of list and the first three elements in the list are always the candle bodies and stems. Call the remove() method on those and they disappear. Then just use the candlestick2_ohlc() function to put the updated candles back on there. It does completely redraw all the candles (though there is a way to just get the last one though I'm too lazy to put it together) but on my machine I can update my charts every 100 milliseconds and it takes about 10% CPU so maybe give that a shot. I'll attach a little snippet with some of the relevant code to give you an idea if you aren't familiar with it.

Ooh thanks, I'll try this next time!
 
One of the things I've been wanting/needing is cached bar calculations. I've got realtime/static charting built off of the tick database plus all my research is done off of the tick database. The simplest thing to do is probably to have a table per tick -> bar configuration I want and just update that in realtime as data comes in. This would centralize all the calculations.

Not sure how other people deal with it.
 
Back
Top