Skip to content

Instantly share code, notes, and snippets.

@Rahulzz
Rahulzz / MarketDataFeed.cs
Created February 23, 2024 11:30
Upstox API - Market Feeder - C# Sample
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: MarketDataFeed.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
@Rahulzz
Rahulzz / upstox_market_feeder_dynamic_subscription.py
Created January 30, 2024 00:51
Upstox API - Market Feeder - Sample for Dynamic Subscription
import asyncio
import json
import ssl
import websockets
from google.protobuf.json_format import MessageToDict
import MarketDataFeed_pb2 as pb
import upstox_client
async def establish_connection(configuration):
@Rahulzz
Rahulzz / Upstox Developer API.postman_collection.json
Created October 23, 2023 16:10
Upstox Developer API - Postman Collection
{
"info": {
"_postman_id": "628c6320-6b30-4c04-9945-7de283730c26",
"name": "Upstox Developer API",
"description": "Build your App on the Upstox platform\n\n<img src=\"/developer/api-documentation/images/brokerage_free_banner.png\" alt=\"Banner\">\n\n<a href=\"https://marketing-creative-and-docs.s3.ap-south-1.amazonaws.com/API_T%26C/T%26C+apply.pdf\">\\* Terms and Conditions</a>\n\n<h2>Introduction</h2>\n\nUpstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.\n\nAll requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as JSON or CSV for a few API calls.\n\nTo be able to use these APIs you need to create an App in the Developer Console and generate your **apiKey** and **apiSecret**. You can use a redirect
@Rahulzz
Rahulzz / token.py
Created September 21, 2023 07:40
Generate Access Token
import requests
import json
headers = {
"accept": "application/json",
"Api-Version": "2.0",
"Content-Type": "application/x-www-form-urlencoded",
}
auth_url = "https://api-v2.upstox.com/login/authorization/token"
@Rahulzz
Rahulzz / upstox_place_order_market_sell.py
Last active August 9, 2023 08:47
Upstox API - Place order API - Sample for MARKET SELL order
from __future__ import print_function
import upstox_client
from upstox_client.rest import ApiException
from pprint import pprint
def place_order(api_version, configuration, order_details):
api_instance = upstox_client.OrderApi(
upstox_client.ApiClient(configuration))
api_response = api_instance.place_order(order_details, api_version)
@Rahulzz
Rahulzz / A_Sample_Websocket_Python_Client.md
Last active July 10, 2023 12:23
Upstox API v2 - Python Websocket Sample Implementation

Python websocket client example for Upstox API v2.

Step 1: Install the SDK using the following command pip install upstox-python-sdk

Step 2: Download the proto from here and build a python module out of it using protobuf. Sample module attached (MarketDataFeed_pb2.py)

Step 3: