[
  {
    "objectID": "reference/Contract.html",
    "href": "reference/Contract.html",
    "title": "Contract",
    "section": "",
    "text": "Contract(self, contract_params=None)\nCreate a contract\n\n\n\n\n\nName\nType\nDescription\nDefault\n\n\n\n\ncontract_params\ndict\nFirst number to add.\nNone\n\n\n\n\n\n\n\n\n\nType\nDescription\n\n\n\n\nContract\nA Contract object",
    "crumbs": [
      "Reference",
      "ShinyBroker Objects",
      "Contract"
    ]
  },
  {
    "objectID": "reference/Contract.html#parameters",
    "href": "reference/Contract.html#parameters",
    "title": "Contract",
    "section": "",
    "text": "Name\nType\nDescription\nDefault\n\n\n\n\ncontract_params\ndict\nFirst number to add.\nNone",
    "crumbs": [
      "Reference",
      "ShinyBroker Objects",
      "Contract"
    ]
  },
  {
    "objectID": "reference/Contract.html#returns",
    "href": "reference/Contract.html#returns",
    "title": "Contract",
    "section": "",
    "text": "Type\nDescription\n\n\n\n\nContract\nA Contract object",
    "crumbs": [
      "Reference",
      "ShinyBroker Objects",
      "Contract"
    ]
  },
  {
    "objectID": "get_started.html",
    "href": "get_started.html",
    "title": "Get started with pins",
    "section": "",
    "text": "coming soon\n\nprint('coming soon')\n\ncoming soon"
  },
  {
    "objectID": "index.html",
    "href": "index.html",
    "title": "Overview",
    "section": "",
    "text": "ShinyBroker is based on the realization that in trading, everything is a reactive variable. Your orders, the prices of assets you’re tracking, current positions, Greeks, p/l– everything is time-dynamic, and can trigger trade order events according to algorithms written by the user. In ShinyBroker, those dynamic variables are kept updated over a socket connection to your account – live or paper – at Interactive Brokers, and are made accessible within Posit’s Shiny framework – a brilliant piece of coding that provides a natural sandbox for reactive variables and their live visualization as webpages.\nThe ‘hello world’ example below will walk you through a trivial setup case. You do not need an account at Interactive Brokers in order to follow the example, but it is suggested that you set up a free paper trader account with them if you’re interested in keeping track of your trades."
  },
  {
    "objectID": "index.html#hello-world-example",
    "href": "index.html#hello-world-example",
    "title": "Overview",
    "section": "Hello World Example",
    "text": "Hello World Example\nRun the base ShinyBroker app, and inject a simple bit of UI & server code.\n\nDownload and install TWS Latest for your OS. TWS (Trader Workstation) is what ShinyBroker connects to in order to communicate with IBKR and the market exchanges. Whenever you use ShinyBroker, you’ll need to have TWS open and running.\nOpen up TWS and sign in to the demo by clicking the link indicated by the yellow rectangle below. You’ll be asked for an email and whether or not you’d like IBKR to contact you. If you have a paper account already then you can certainly use it, so just sign in as usual. \nOnce you’re signed in, familiarize yourself with the system until you’re ready to move on. If you used a demo account, know that any trades you make will be erased when you log out.\nOpen the API Configuration menu using the File dropdown. You can find the menu at File &gt; Global Configuration &gt; API &gt; Settings.\nCheck Enable ActiveX and Socket Clients\nUn-check Read-only API\nYou can leave the rest of the settings alone. By default, your settings menu should look like the below: \nInstall ShinyBroker with pip install shinybroker\nIn Python, run the following: (make sure TWS is open and running)\n\n\nimport os\nimport shinybroker as sb\nfrom shiny import Inputs, Outputs, Session, App\n\n# Project Settings\nos.environ['IB_HOST'] = '127.0.0.1'\nos.environ['IB_PORT'] = '7497'\nos.environ['IB_CLIENT_ID'] = '10645'\n\napp = App(sb.sb_ui(), sb.sb_server)\n\napp.run()\n\nThis code performs three main operations:\n\nDefines where ShinyBroker can find a running instance of an IBKR client (TWS)\nCreates a Shiny app object using only the base ShinyBroker ui and server\nRuns the app\n\n\nClick the link in the command line to open up a web browser at localhost and explore the app.\n\nNote that there is nothing in the “home” tab. That space is reserved for you, the user, to inject your own graphics, controls, inputs & outputs, as well as your algorithm logic.\nLet’s demonstrate that functionality by injecting some UI, and the server code to handle the backend, into this base ShinyBroker app.\n\nStop the running instance of the ShinyBroker app and modify your code as shown below:\n\n\nimport shinybroker as sb\nfrom shiny import Inputs, Outputs, Session, App, ui, render\n\n# Project Settings\nIB_HOST = '127.0.0.1'\nIB_PORT = 7497\nIB_CLIENT_ID = 10645\n\napp_ui = sb.sb_ui(\n    ui.div(\n        ui.input_text(\n            id='sb_example_text_in',\n            label='Example Input. Type something!'\n        ),\n        ui.output_code('sb_example_text_out')\n    )\n)\n\n\ndef user_defined_server(input:Inputs, outputs:Outputs, session:Session):\n    @render.code\n    def sb_example_text_out():\n        return f\"You entered '{input.sb_example_text_in()}'.\"\n\n\ndef server(input:Inputs, outputs:Outputs, session:Session):\n    sb.sb_server(input, outputs, session)\n    user_defined_server(input, outputs, session)\n\n\napp = App(app_ui, server)\n\n\napp.run()\n\nHere, we have done two things:\n\nadded a ui: We added a text input and a text output contained within a div\nadded a server function: it reads whatever text has been input by the user into the text_input, appends “You entered” to the beginning of it, and returns the text to the text output.\n\n\nRun the modified code above. Your app should now look something like the screenshot below: \n\nIf you can get that far, success! From this simple starting point you can build a trading algorithm that does just about anything. More usage examples that cover market data, orders, positions, and other topics will be treated in other tutorials and videos accessible on this site."
  },
  {
    "objectID": "reference/index.html",
    "href": "reference/index.html",
    "title": "Reference",
    "section": "",
    "text": "These objects are the building blocks that your application uses to work with important tasks like fetching market data or submitting a trade order.\n\n\n\nContract\nCreate a contract",
    "crumbs": [
      "Reference"
    ]
  },
  {
    "objectID": "reference/index.html#shinybroker-objects",
    "href": "reference/index.html#shinybroker-objects",
    "title": "Reference",
    "section": "",
    "text": "These objects are the building blocks that your application uses to work with important tasks like fetching market data or submitting a trade order.\n\n\n\nContract\nCreate a contract",
    "crumbs": [
      "Reference"
    ]
  }
]