Giter Site home page Giter Site logo

Comments (12)

jbax avatar jbax commented on September 4, 2024

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

Aha -- That hopefully explains why my simulator results differ a lot than my live results. Does that only require wiring in the, say, Binance API (limitBuy -> limitOCOBuy) and making minor modifications to that switch...case or is it more involved than that? I'm guessing most of the existing code remains intact and the live code should be way more simpler than the simulator code since the logic is server side.

from univocity-trader.

jbax avatar jbax commented on September 4, 2024

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

FYI: I'm starting to get this to work (I hope to be able to open a MR eventually) - I can submit an OCO with the values I expect. The response though is trickier because now we get back a list instead of a single value; I'm not super sure if I should hide this behind the same interfaces or fully expose the fact that we're getting a list now (one with limit_maker, one with stop_loss), but I'm leaning towards breaking whatever needs to be broken to handle both cases rather than hack away at it. Objections?

This is what their response looks like for oco:

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": 1563417480525,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos",
      "transactTime": 1563417480525,
      "price": "0.000000",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "STOP_LOSS",
      "side": "BUY",
      "stopPrice": "0.960664"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl",
      "transactTime": 1563417480525,
      "price": "0.036435",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "BUY"
    }
  ]
}

from univocity-trader.

jbax avatar jbax commented on September 4, 2024

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

Ok I have something that seems to be working. I'll let it bake for a while before opening a MR (my signals are quite slow so it takes some time to hit all the cases).

BTW During debugging I also found:

I think you meant "return order" there. I can open a separate MR for that if you want, but given it's a one liner you might just want to add that one directly ;-)

from univocity-trader.

jbax avatar jbax commented on September 4, 2024

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

I'm tracking my changes in this branch:
https://github.com/wwadge/univocity-trader-1/tree/feature/add-OCO-orders-to-live

Code seems to be working fine, but I lack unit tests at the moment so consider this as a pre-cleanup branch for now.

There's also a small bug I detected: during order processing, it does a try..finalize to update balances, but that balances update code in AccountManager is guarded by a check to avoid fetching balances if not enough tine has passed. So this sometimes leads to: a SELL is triggered, an order is placed, the updateBalance check returns stale data and the next SELL order results in an insufficient funds exception from Binance. I've fixed this in the same branch by adding a "force" flag so skip the cache check.

from univocity-trader.

jbax avatar jbax commented on September 4, 2024

Thanks a lot! I also think the "force" flag will be required there. Once I get the time I'll check it out.

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

Hmmm actually I don't think I did this right -- I'm only doing a single OCO order of say BUY if signal returned BUY.

In interactive brokers, we send 3 simultaneous orders: BUY, then an OCO of SELLs. But as far as I can tell, Binance does not support this behaviour, instead it allows you to only do OCO or a market buy or limit; to replicate the behavior of the simulator in Binance I think I have to send a manual market order first to force a buy, then immediately do an OCO with SELLs. Or alternately watch for the "filled" and then trigger the OCO but this will probably need some re-architecting work. Did I think it right?

from univocity-trader.

jbax avatar jbax commented on September 4, 2024

from univocity-trader.

wwadge avatar wwadge commented on September 4, 2024

OK - I'll work on this and open a new MR

from univocity-trader.

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.