Git Product home page Git Product logo

Comments (9)

nwillemse avatar nwillemse commented on August 15, 2024 1

@ryankennedyio I am able to connect to my account more than once using multiple python programs... I just set a different client id in the script. I do have a FA account though, don't know if that makes a difference.

from qstrader.

moonlight16 avatar moonlight16 commented on August 15, 2024

UPDATE:
I found this on quandl's website:
https://www.quandl.com/blog/useful-lists#Continuous-Futures-Contracts

There's a link to get Futures Metadata, which contains a ton of useful information such as contract sizes, etc...

So I'll leave this issue for discussion on integration of futures support into qstrader (either in principle on adding this under private branches or making this a publicly available feature support).

from qstrader.

ryankennedyio avatar ryankennedyio commented on August 15, 2024

I'm keen for this.

I think Mike has hinted at forex support. I think futures would be a definite necessity in order to allow for "proper" diversification.

I think this almost brings up another interesting point in that some instruments should or could have associated metadata. E.g., futures have contract size and expiry date, options have strike price and expiry date, even stocks have the number of shares issued, EPS, etc.

I guess most "real" strategies would make use of that extra data around an instrument. I've been thinking about how to add that in a neat manner, but not thinking hard enough to actually come up with anything :)

from qstrader.

moonlight16 avatar moonlight16 commented on August 15, 2024

THOUGHT:
I noticed Michael has another forex qstrader, and I suppose he did this because the pricing is much different than equities (I'm finding the same for futures). But I'm concerned about separating these traders because a single portfolio could trade various different instruments (i.e. forex, futures, and equities) from within the same account. So I'm leaning towards (for my own needs) keeping these within the same qstrader. Thoughts?

from qstrader.

ryankennedyio avatar ryankennedyio commented on August 15, 2024

I'm kinda considering that "strategies" should actually keep some kind of reference to the "positions" that they're responsible for, with risk manager having a more overall view of the folio.

That would allow a single account to run multiple strategies, across multiple instruments. I agree 100% within the same QSTrader. IB for example (probably going to be the most popular "live" broker) only allows 1 connection to an account at a time, which basically forces us into needing QStrader to handle everything.

I'm gonna play with some forex data in QStrader this weekend, so I might have some further thoughts RE system design handling multiple instruments soon.

from qstrader.

moonlight16 avatar moonlight16 commented on August 15, 2024

Yes, actually I’ve started playing with the code in this respect. I have added a Ticker class that allows a bunch of metadata to be passed around the QSTrader. Such as ticker type (Equity, Future, Option, Forex, etc..), point/tick value, tick size, margin required, and even such things as the Quandl code and data ranges for pulling backtested data. Once I get something substantial maybe I can share what I have. I’m currently playing with figuring out how to do the math for the PNL, Portfolio buying power, etc... between equities vs futures.

On Jun 16, 2016, at 8:17 PM, Ryan Kennedy [email protected] wrote:

I'm kinda considering that "strategies" should actually keep some kind of reference to the "positions" that they're responsible for, with risk manager having a more overall view of the folio.

That would allow a single account to run multiple strategies, across multiple instruments. I agree 100% within the same QSTrader. IB for example (probably going to be the most popular "live" broker) only allows 1 connection to an account at a time, which basically forces us into needing QStrader to handle everything.

I'm gonna play with some forex data in QStrader this weekend, so I might have some further thoughts RE how to handle allowing multiple instruments soon.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #31 (comment), or mute the thread https://github.com/notifications/unsubscribe/AGuWKu1zhjO7JlC9XM_U50egNt85cSNhks5qMhHEgaJpZM4I1iw9.

from qstrader.

moonlight16 avatar moonlight16 commented on August 15, 2024

I wanted to get some discussion going again about this features request. If I can get some feedback, then possibly I can start putting together the changes. In fact I've already started working on some changes in a private branch but its becoming painful to keep rebasing ontop of new incoming changes. So its about time I start see if I can get these changes ready for a pull request. But first, I'd like to get some feedback on the approach I'm taking. As well as get some guidance on integration into qstrader.

Let me first enumerate the topics:

  1. Using Quandl datasets
    I'm going to first start developing using datasets from quandl. They have pretty good coverage for daily bars covering most liquid future contracts (continuous, front month). See:
    https://www.quandl.com/data/CHRIS/CME_SP2-S-P-500-Futures-Continuous-Contract-2-SP2
    I would love to find a source for tick data, but sorry, I'm not paying money for that yet.
    So my first step was to get a quandl price handler working. I previously submitted a pull request, but admittedly I wasn't happy with the changes. See:
    #53
    So maybe I'll republish my changes again and see where it goes.

  2. Futures Pricing
    Futures pricing doesn't work the same as Equities. 1 tick does not always equal 0.01 USD as in equities. Each futures contract has its own tick size/value that is fixed. So I created a new folder/class to define these values for each futures contract: qstrader/ticker/ticker.py.

In addition, I had to make changes inside portfolio_handler.py, portfolio.py, and position.py to account for futures pricing. Rather than just modifying those files directly, I copied and split them out into their own folder qstrader/futures/portolio_handler.py, etc. From a design perspective, we probably ought to break out the existing files into appropriate classes. But for development purposes I found it easier to work out on my own copy of the code. So I'll need to redesign these files to make integration easier. Thoughts?

  1. Margin Requirements
    Each brokerage has its own margin formula as I understand it (or maybe not?). I've been trading out of a TDAmeritrade brokerage account, using their TOS (ThinkOrSwim) platform. I've noticed TD will calculate a different margin requirements for each futures contract, as well as different values if its an IRA or regular account (reg T margin). So in the ticker class, for each contract, I assigned a fixed margin value. Is there a better way to do this? I think this discussion only applies to backtesting only against raw dataset, whereas if your connected to a live brokerage account (i.e. IB) I would assume they can provide the margin required in real-time.

At this point I would have maybe posted my changes for review. But unfortunately some recent changes broke my code. I had depended upon DisplayStrategies for debugging, but now that's gone. I'm curious how others are debugging/validating bar-by-bar and trade-by-trade?

from qstrader.

ryankennedyio avatar ryankennedyio commented on August 15, 2024

@jacohn16

1) Market Data:
I have a working feed from Interactive Brokers (#186). That might be a good base if you want to do futures through IB. It might actually almost work as is. Just request a subscription to an IB Futures Contract, but will need modifications to the Position (because the returned BarEvent will be assumed to be an equity). More below.

2) Modifications to Instruments:
Yes we need a good think about this. Particularly in a way that will support at least FX and Options too. Maybe we can do something like subclassing the Event, into FXTick, FXBar, FuturesTick, FuturesBar, OptionsTick -- etc etc etc etc as necessary? Then the relevant Strategy and Risk classes are able to implement specific logic according to the type of event that comes in.

3) Margin:
I think this is brokerage specific too. I guess we'll decide on supporting a single method out-of-the-box and ensure it's easy enough to override that.

I think Rob Carver (qoppac.blogspot.com.au) has a few resources on trading futures with IB in python.

Good point about the DisplayStrategy. I needed that a few days ago actually. Can we get that in again @mhallsmoore ?

from qstrader.

enriqueromualdez avatar enriqueromualdez commented on August 15, 2024

Hi all,

Have there been any further developments on this? I'm hoping to add FX integration as well.. A bit unsure as to whether I should go about it as per @ryankennedyio 's recommendation of subclassing Event or going about it @jacohn16 's way, via modifying portfolio, position, and portfolio_handler...

Any ideas?

from qstrader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.