SparkLib (0.1.4)
This is rest-api for interacting with https://spark.maticalgos.com . It provides functionalities to manage accounts, strategies, place orders, and much more.
This is rest-api for interacting with https://spark.maticalgos.com . It provides functionalities to manage accounts, strategies, place orders, and much more.
Authentication with email
Login to SparkLib using your email and password to generate an auth token.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
userid* |
string | Email ID of the user. |
password* |
string | Password of the user. |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
access_token |
string | Access token generated by the API |
token_type |
string | Type of token generated by the API |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # Example with email and password userid = "test@gmail.com" password = "password" # Initialize the SparkLib object with email and password spark = SparkLib(userid=userid, password=password) # Make a request to the API to generate a token response = spark.generate_token() # Print the response received from the API print(response)
Response samples
- 200
- 400
{- "access_token": "Your Access Token",
- "token_type": "bearer"
}
Authentication with API Key
Login to SparkLib using your API Key to generate an auth token.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
AuthKey* |
string | API key of the user. |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
access_token |
string | Access token generated by the API |
token_type |
string | Type of token generated by the API |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # Example with API key AuthKey = "YOUR_API_KEY" # Initialize the SparkLib object with API key spark = SparkLib(apikeys=AuthKey) # Make a request to the API to generate a token response = spark.generate_token() # Print the response received from the API print(response)
Response samples
- 200
- 400
{- "access_token": "Your Access Token",
- "token_type": "bearer"
}
Profile
Get the profile of the user.
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
message |
string | A message indicating the result of the request |
data |
array | Contains user profile information, including: |
ID |
integer | User ID |
Name |
string | User's name |
Email |
string | User's email address |
PhoneNo |
string | User's phone number |
LastLogin |
string | Date of the last login , format: 'YYYY-MM-DD' |
CreatedOn |
string | Date the account was created , format: 'YYYY-MM-DD' |
UCC |
string | User's unique customer code |
Disabled |
string | Indicates if the user is disabled |
UserType |
string | Type of user (e.g., basic) |
AuthKey |
string | Authentication key for the user |
acLimit |
integer | Account limit |
stLimit |
integer | Strategy limit |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get the profile profile = spark.profile() # Print the response received from the API print(profile)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "message": "User exists",
- "data": [
- {
- "ID": 9,
- "Name": "Your Name",
- "Email": "Your Email",
- "PhoneNo": "Your PhoneNo",
- "LastLogin": "2024-05-23",
- "CreatedOn": "2024-04-26",
- "UCC": "UCC",
- "Disabled": null,
- "UserType": "basic",
- "AuthKey": "859886096d65qwd",
- "acLimit": 3,
- "stLimit": 15
}
]
}
All Accounts
Get All accounts details of the user.
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains account information, including: |
Clientid |
string | Unique identifier for the client |
AccountName |
string | Name of the account |
LastLogin |
string | Date of the last login , format: 'YYYY-MM-DD' |
UCC |
string | User's unique customer code |
Trade |
string | Trade information, if any (can be null) |
Broker |
string | Broker associated with the account, for more information View Details |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get All Accounts associated with the user all_Accounts = spark.getAllAccounts() # Print the response received from the API print(all_Accounts)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Clientid": "F000000:test",
- "AccountName": "test",
- "LastLogin": "2024-05-09",
- "UCC": "F000000",
- "Trade": null,
- "Broker": "testBroker"
}, - {
- "Clientid": "A000000",
- "AccountName": "account_name",
- "LastLogin": "2024-05-22",
- "UCC": "F000000",
- "Trade": null,
- "Broker": "FYERS"
}
], - "message": "Data Received"
}
Single Account
Get details of a specific account.
Query Parameter
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains account information, including: |
Clientid |
string | Unique identifier for the client |
ApiKey |
string | API key associated with the account |
AccountName |
string | Name of the account |
LastLogin |
string | Date of the last login |
UCC |
string | User's unique customer code |
Chatid |
string | Telegram chat ID associated with the account |
BotKeys |
string | Telegram bot keys associated with the account |
Sessionid |
string | Session ID for the account |
Trade |
string | Trade information, if any (can be null) |
Broker |
string | Broker associated with the account ,for more information View Details |
Redirecturl |
string | Redirect URL for the account |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get account details of a single account single_Account = spark.getOneAccount(accountName='account_name') # Print the response received from the API print(single_Account)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Clientid": "XV00000",
- "ApiKey": "UQ123234-102",
- "AccountName": "account_name",
- "LastLogin": "2024-05-22",
- "UCC": "F000000",
- "Chatid": "5217000000",
- "BotKeys": "5725000000:AAFUAEiQicZg",
- "Sessionid": "eyJ0eXXXXXXXX2c5-Y3RgS8wR14g",
- "Trade": null,
- "Broker": "FYERS",
}
], - "message": "Data Received"
}
Generate Authcode For broker account
Generate an auth code for a specific broker account linked with spark.
Query Parameter
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get account details of a single account authcode = spark.generateAuthcode(accountName='account_name') # Print the response received from the API print(authcode)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "loginUrl": ""
}
], - "message": "Login url generated"
}
Validate Authcode
Validate the auth code for a specific account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
broker* |
string | Broker name ,for more information View Details |
authcode* |
string | Auth code |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get account details of a single account Val_authcode = spark.validateAuthcode(authcode=access_token,broker='FYERS') # Print the response received from the API print(Val_authcode)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Logged in successfully"
}
Validate Session
Update the sessionid for a specific account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
sessionid |
string | Session ID (access_token) |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib access_token = 'eyJ0eXXXXXXXX 2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get update access token validate_session = spark.validateSessionid(accountname='account_name',sessionid) # Print the response received from the API print(validate_session)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "session id updated"
}
Linked Strategy per Account
Get Linked Strategy per Account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
StrategyName |
string | Name of the strategy |
AccountName |
string | Name of the account |
UCC |
string | User's unique customer code |
Multiplier |
integer | Multiplier value |
Activate |
integer | Activate status |
Capital |
float | Capital amount |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get the list of strategies linked to the account Strategies = spark.getlinkStrategyAccount(accountName='account_name') # Print the response received from the API print(Strategies)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "message": "Data Received",
- "data": [
- {
- "StrategyName": "Strategy1",
- "AccountName": "account_name",
- "UCC": "F000000",
- "Multiplier": 1,
- "Activate": 1,
- "Capital": 0
}
]
}
Activate Account
Activate an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
activate* |
string | Activate('Y') |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Trade |
string | Trading Active or Inactive |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to activate an account activate = spark.activateAccount(accountName='account_name',activate='Y') # Print the response received from the API print(activate)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Trade": "Y"
}
], - "message": "Trading activated"
}
Deactivate Account
Deactivate an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
activate* |
string | Deactivate('N') |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Trade |
string | Trading Active or Inactive |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to deactivate an account deactivate = spark.activateAccount(accountName='account_name',activate='N') # Print the response received from the API print(deactivate)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Trade": "N"
}
], - "message": "Trading deactivated"
}
All Strategies
Get All strategies details of the user.
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains strategy information, including: |
ID |
integer | Strategy ID |
StrategyName |
string | Name of the strategy |
Description |
string | Description of the strategy |
StrategyType |
string | Type of strategy (Intraday, Positional, etc.) |
UCC |
string | User's unique customer code |
Display |
string | Display information (Private, Public) |
ForwardTest |
string | Forward test information (Y or N) |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get All Strategies associated with the user all_Strategies = spark.getStrategy() # Print the response received from the API print(all_Strategies)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "ID": 1,
- "StrategyName": "Strategy1",
- "Description": "Description of the strategy",
- "StrategyType": "Intraday",
- "UCC": "F000000",
- "Display": "Private",
- "ForwardTest": "Y"
}
], - "message": "Strategy data received"
}
Create Strategy
Create a new strategy.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
strategyName* |
string | Name of the strategy |
strategyType* |
string | Type of strategy (Intraday, Positional, etc.) |
description |
string | Description of the strategy |
display |
string | Display information (Private, Public) |
forwardTest |
string | Forward test information (Y or N) |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to add a new strategy strategy_res = spark.addStrategy(strategyName='test_strategy', Description='This is test strategy', StrategyType='Intraday', Display='Private', ForwardTest='N') # Print the response received from the API print(strategy_res)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Added"
}
Modify Strategy
Update an existing strategy.
Query Attribute
Attribute | Data Type | Description |
---|---|---|
strategyName* |
string | Name of the strategy |
Request Attributes
Attribute | Data Type | Description |
---|---|---|
StrategyType* |
string | Type of strategy (Intraday, Positional, etc.) |
Description |
string | Description of the strategy |
Display |
string | Display information (Private, Public) |
ForwardTest |
string | Forward test information (Y or N) |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to update the strategy strategy_res = spark.modifyStrategy(strategyName='test_strategy', Description='This is test strategy', StrategyType='Intraday', Display='Private', ForwardTest='N') # Print the response received from the API print(strategy_res)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Modified"
}
Delete Strategy
Delete an existing strategy.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
strategyName* |
string | Name of the strategy |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the requestuccessful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to delete a strategy strategy_res = spark.deleteStrategy(strategyName='test_strategy') # Print the response received from the API print(strategy_res)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Deleted"
}
Linked Strategy per Account
Get Linked Strategy per Account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
StrategyName |
string | Name of the strategy |
AccountName |
string | Name of the account |
UCC |
string | User's unique customer code |
Multiplier |
integer | Multiplier value |
Activate |
integer | Activate status |
Capital |
float | Capital amount |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get the list of strategies linked to the account Strategies = spark.getlinkStrategyAccount(accountName='account_name') # Print the response received from the API print(Strategies)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "message": "Data Received",
- "data": [
- {
- "StrategyName": "Strategy1",
- "AccountName": "account_name",
- "UCC": "F000000",
- "Multiplier": 1,
- "Activate": 1,
- "Capital": 0
}
]
}
All Linked Strategies
Get All linked strategies details of the user.
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains linked strategy information, including: |
StrategyID |
integer | Strategy ID |
StrategyName |
string | Name of the strategy |
AccountName |
string | Name of the account |
Multiplier |
integer | Multiplier value |
Activate |
integer | Activate status |
UCC |
string | User's unique customer code |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get the linked information linked_info = spark.getlinkStrategy() # Print the response received from the API print(linked_info)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "StrategyID": 1,
- "StrategyName": "Strategy1",
- "AccountName": "account_name",
- "UCC": "F000000",
- "Multiplier": 1,
- "Activate": 1,
- "Capital": 0
}
], - "message": "Data Received"
}
Add Link Strategy
Add Link between strategy and an account.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
StrategyName* |
string | Name of the strategy |
AccountName* |
string | Name of the account |
Multiplier* |
integer | Multiplier value |
Activate* |
integer | Activate status (0 or 1) |
Capital* |
float | Capital amount |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to link a strategy to an account link_res = spark.addlinkStrategy(strategyName='test_strategy', accountName='account_Name', Multiplier=1, Activate=1, Capital=0) # Print the response received from the API print(link_res)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Added"
}
Modify Link Strategy
Modify the link between strategy and an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
StrategyName* |
string | Name of the strategy |
AccountName* |
string | Name of the account |
Request Attributes
Attribute | Data Type | Description |
---|---|---|
Multiplier* |
integer | Multiplier value |
Activate* |
integer | Activate status (0 for No, 1 for Yes) |
Capital* |
float | Capital amount |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to modify the strategy linked_info = spark.modifylinkStrategy(strategyName='temp',accountName='account_name',Multiplier=1,Activate=1,Capital=10000) # Print the response received from the API print(linked_info)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Link modified"
}
Delete Link Strategy
Delete the link between strategy and an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
StrategyName* |
string | Name of the strategy |
AccountName* |
string | Name of the account |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) Make a request to the API to delete a link between a strategy and an account linked_info = spark.deletelinkStrategy(strategyName='test_1', accountName='test') # Print the response received from the API print(linked_info)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Strategy Link Deleted"
}
Activate Account
Activate an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
activate* |
string | Activate('Y') |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Trade |
string | Trading Active or Inactive |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to activate an account activate = spark.activateAccount(accountName='account_name',activate='Y') # Print the response received from the API print(activate)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Trade": "Y"
}
], - "message": "Trading activated"
}
Deactivate Account
Deactivate an account.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
activate* |
string | Deactivate('N') |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Trade |
string | Trading Active or Inactive |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to deactivate an account deactivate = spark.activateAccount(accountName='account_name',activate='N') # Print the response received from the API print(deactivate)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "Trade": "N"
}
], - "message": "Trading deactivated"
}
Reconnect Websocket
Reconnect the websocket connection.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to reconnect the order websocket status = spark.reconnect_orderWS(accountName='account_name') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Reconnecting to WS"
}
Place Order
Place an order.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
orderType* |
string | Type of order (Market, Limit,SL-Limit) ,for more information View Details |
productType* |
string | Type of product (Intraday,Delivery) ,for more information View Details |
token* |
string | Token of the Instrument (eg. NSE:13528) |
qty* |
integer | Quantity |
transType* |
string | Transaction type (Buy,Sell) ,for more information View Details |
limitPrice |
float | Limit price |
splitby |
integer | To split order in batches |
triggerPrice |
float | Trigger price |
ForwardTest |
boolean | Forward test :False |
operations |
object | Operations information |
timeLimit |
integer | Time limit |
shouldExecute |
boolean | Should execute |
priceBuffer |
integer | Price buffer |
identifier |
string | To execute order in single account ,eg 'UCC:account_name' |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
string | Strategy reference ID |
placedIn |
string | Accounts in which order is placed |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to place an order status = spark.placeorder(strategyName='test_1', orderType='Market', productType='Intraday', token = 'NSE:13528', qty = 1, transType = 'Buy', limitPrice=80, splitby = 0, triggerPrice = 81, forwardTest = False, operations = {"timeLimit": 0,"shouldExecute": False,"priceBuffer": 0}, identifier = F000000:test_1) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "strefID": "123456",
- "placedIn": [
- "F000000:account_name"
]
}
], - "message": "Order placed in F000000:account_name"
}
Modify Order
Modify an existing order.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
strefID* |
string | Strategy reference ID |
orderType |
string | Type of order (Market, Limit,SL-Limit) ,for more information View Details |
limitPrice |
float | Limit price , required for LIMIT order |
triggerPrice |
float | Trigger price |
identifier |
string | Identifier |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
string | Strategy reference ID |
placedIn |
string | Account in which order is placed |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to modify an order status = spark.modifyorder(strategyName='test_1', orderType='Market', limitPrice=80, triggerPrice = 81, identifier = None, strefID=344, ) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "strefID": "123",
- "placedIn": [
- "F000000:account_name"
]
}
], - "message": "Order modified in F000000:account_name"
}
Cancel Order
Cancel an existing order.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
strefID* |
string | Strategy reference ID |
identifier |
string | Identifier |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
string | Strategy reference ID |
placedIn |
string | Account in which order is placed |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to cancel the order status = spark.cancelorder(strategyName='test_1', identifier = 'F000000:test_1', strefID=344, ) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "strefID": "123",
- "placedIn": [
- "F000000:account_name"
]
}
], - "message": "Order cancelled in F000000:account_name"
}
Stop Operation
Stop an operation.
Request Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
strefID* |
string | Strategy reference ID |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
string | Strategy reference ID |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to cancel the order status = spark.stopOperation(strategyName='test_1', strefID=344, )
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "strefID": "123"
}
], - "message": "Operations stopped on 344"
}
Cancel All Orders
Cancel all orders of a particular type.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
ctype* |
string | Type of commond ('strategy','account') |
strategyname* |
string | Name of the strategy |
accountName* |
string | Name of the account |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to cancel all orders of a strategy status = spark.CancalAll(ctype='strategy',strategyName='test_1',accountName='test') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Request sent to Cancel All Orders in StrategyName : test_1 with AccountName : test"
}
Square Off All Orders
Square off all orders of a particular type.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
ctype* |
string | Type of commond ('strategy','account') |
strategyname* |
string | Name of the strategy |
accountName* |
string | Name of the account |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to SquareOff all orders of a strategy or account status = spark.SquareOff(ctype='strategy',strategyName='test_1',accountName='test') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Request sent to Square Off all positions in StrategyName : test_1 with AccountName : test"
}
Square Off Single Position
Square off a Single Position.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
accountName* |
string | Name of the account |
token* |
string | Token of the Instrument (eg. NSE:13528) |
positionType* |
string | Type of position (Intraday,Delivery) |
at_limit* |
float | At limit price(true,false) |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
string | Strategy reference ID |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to cancel all orders of a strategy status = spark.squareOffSingle(strategyName='test_1', accountName='account_name', token= 'NSE:13528', positionType='Intraday', at_limit='true' ) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "strefID": "123"
}
], - "message": "Order Placed, Position Squared off"
}
Manual Square Off
Manual Square off a Single Position.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
strategyname* |
string | Name of the strategy |
accountName* |
string | Name of the account |
token* |
string | Token of the Instrument (eg. NSE:13528) |
positionType* |
string | Type of position (Buy,Sell) |
tradedPrice* |
float | Traded price |
tradedAt* |
string | Traded at |
qty* |
integer | Quantity |
ordersPlaced* |
integer | no of orders placed |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to cancel all orders of a strategy status = spark.manualSquareOff(strategyName='test_1', accountName='account_name', token= 'NSE:13528', positionType='Buy', tradedPrice=80, tradedAt='2024-05-24T12:56:45.830Z', qty=1, ordersPlaced=1 ) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Position closed manually"
}
Order Book
Get the order book details.
Query Parameters
Attribute | Data Type | Description |
---|---|---|
accountName |
string | Account name |
strategyName |
string | Strategy name |
strefid |
integer | Strategy reference ID |
reftag |
integer | Reference tag |
withorders |
boolean | Include orders of splitby |
today |
boolean | Include only today's orders |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
UCC |
string | Your Client Code |
AccountName |
string | Account name |
strefID |
integer | Strategy reference ID |
reftag |
integer | Reference tag |
StrategyName |
string | Strategy name |
orderType |
string | Type of order (Market, Limit,SL-Limit) ,for more information View Details |
productType |
string | Type of product (Intraday,Delivery) ,for more information View Details |
price |
float | Price |
limitPrice |
float | Limit price |
triggerPrice |
float | Trigger price |
token |
string | Token of the Instrument (eg. NSE:13528) |
segment |
string | Segment |
symbol |
string | Symbol |
qty |
integer | Quantity |
transType |
string | Transaction type (Buy,Sell) ,for more information View Details |
splitby |
integer | To split order in batches |
Operations |
object | Operations information |
ordersplaced |
integer | No. of Orders placed |
ordersdone |
integer | No. of Order, that are not with status of placed/pending |
ordersexecuted |
integer | No. of Orders with status of Executed |
placed_at |
string | Placed at |
recon_at |
string | Reconciled at |
trade_at |
string | Trade at |
filledQty |
integer | Filled quantity |
tradedQty |
integer | Traded quantity |
tradeValue |
float | Trade value |
tradePrice |
float | Trade price |
status |
string | Status |
active |
integer | Active |
ForwardTest |
boolean | Forward test information |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get orderbook status = spark.orderbook(strategyName='test_1', accountName='test', withorders=False, strefid = None, reftag = None, today = True) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "UCC": "F000000",
- "AccountName": "test",
- "strefID": 351,
- "reftag": 421,
- "StrategyName": "test_1",
- "orderType": "Market",
- "productType": "Intraday",
- "price": 86.95,
- "limitPrice": 0,
- "triggerPrice": 0,
- "token": "NSE:13528",
- "segment": "C",
- "symbol": "GMRINFRA-EQ",
- "qty": 1,
- "transType": "Buy",
- "splitby": 0,
- "Operations": "{\"timeLimit\": 0, \"shouldExecute\": false, \"priceBuffer\": 0.0}",
- "ordersplaced": 1,
- "ordersdone": 1,
- "ordersexecuted": 1,
- "placed_at": "2024-05-24T19:03:04",
- "recon_at": "2024-05-24T21:01:41",
- "trade_at": "2024-05-24T21:01:41",
- "filledQty": 1,
- "tradedQty": 1,
- "tradeValue": 86.95,
- "tradePrice": 86.95,
- "status": "Executed",
- "active": 0,
- "ForwardTest": "None"
}
], - "message": "Data Received"
}
Net Position
Retrieve the net position.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
Acname |
string | Account name |
Stname |
string | Strategy name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
accountName |
string | Account name |
bookedpnl |
float | Booked profit and loss |
openpnl |
float | Open profit and loss |
totalpnl |
float | Total profit and loss |
totalpositions |
integer | Total number of positions |
openpositions |
integer | Number of open positions |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get net position status = spark.netposition(accountName='account_name', strategyName='test_1') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "account_name": [
- {
- "bookedpnl": 0,
- "openpnl": 0,
- "totalpnl": 0,
- "totalpositions": 0,
- "openpositions": 0
}
]
}
], - "message": "Data Received"
}
Delete Order
Delete an existing order from the database. This action is used to remove the order from spark database.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
strefID* |
string | Strategy reference ID |
reftag* |
string | Reference tag |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to delete an order status = spark.deleteOrder(strefID= 355, reftag =425 ) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": null,
- "message": "Order Deleted"
}
Overview
Retrieve the account overview.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
acname* |
string | Account name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
AccountName |
string | Account name |
Broker |
string | Broker name associated with the account ,for more information View Details |
ClientID |
string | Client ID |
Trade |
string | Indicates if trading is allowed ('Y' or 'N') |
LastLogin |
string | Last login date |
totalStrategy |
integer | Total number of strategies |
runningStrategy |
integer | Number of running strategies |
CapitalDeployed |
float | Capital deployed |
bookedpnl |
float | Booked profit and loss |
openpnl |
float | Open profit and loss |
totalpnl |
float | Total profit and loss |
totalpositions |
integer | Total number of positions |
openpositions |
integer | Number of open positions |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
- Payload
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get the overview status = spark.overview(accountName='test') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "AccountName": "test",
- "Broker": "testBroker",
- "ClientID": "F000000:test",
- "Trade": "Y",
- "LastLogin": "2024-05-25",
- "totalStrategy": 1,
- "runningStrategy": 1,
- "CapitalDeployed": 0,
- "bookedpnl": 0,
- "openpnl": 0,
- "totalpnl": 0,
- "totalpositions": 0,
- "openpositions": 0
}
], - "message": "Data Received"
}
Execution Logs
Retrieve the execution logs.
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
Datetime |
string | Date and time of the log entry |
UCC |
string | Unique Client Code |
Name |
string | Name associated with the log entry |
Alert Type |
string | Type of alert (e.g., DEBUG, INFO, ERROR) |
Message |
string | Log message |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get execution logs status = spark.excutionLogs() # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": true,
- "data": [
- {
- "Datetime": "2024-05-25T13:05:52",
- "UCC": "F000000",
- "Name": "F000000:test_1",
- "Alert Type": "DEBUG",
- "Message": "Endpoint Called : PlaceOrder. Payload Received : {'UCC': 'F219076', 'StrategyName': 'F219076:test_1', 'orderType': 'Market', 'productType': 'Intraday', 'limitPrice': 0.0, 'token': 'NSE:13528', 'qty': 1, 'segment': 'C', 'transType': 'Buy', 'splitby': 0, 'triggerPrice': None, 'ForwardTest': False, 'requests': {'timeLimit': 0, 'shouldExecute': False, 'priceBuffer': 0.0}, 'identifier': 'F000000:account_name', 'from_squareoff': False}, response : {'strefID': None, 'message': 'Please activate the accounts linked with the strategy.'}, timeTaken : 0.01"
}
], - "message": "Data Received"
}
Intraday Pnl
Retrieve the intraday profit and loss.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
accountName* |
string | Account name |
strategyName* |
string | Strategy name |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Datetime |
string | Date and time of the log entry |
PNL |
float | Profit or loss |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get intraday pnl status = spark.intradaypnl(accountName='test', strategyName='test_1') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": true,
- "data": [
- {
- "Datetime": "2024-05-25T13:05:52",
- "PNL": 0
}
], - "message": "Data Received"
}
Push Trades
Convert orders to trades and push them to the database.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
allusers* |
boolean | Push trades for all users |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to push trades status = spark.pushtrades() # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Orders converted to Trades and pushed to database"
}
Trades
Get the trades.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
startDate* |
string | Start date ,format: 'YYYY-MM-DD' |
endDate* |
string | End date ,format: 'YYYY-MM-DD' |
strategyName* |
string | Name of the strategy |
accountName* |
string | Name of the account |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
UCC |
string | Your Client Code |
AccountName |
string | Account name |
StrategyName |
string | Strategy name |
symbol |
string | Symbol |
token |
string | Token of the Instrument (eg. NSE:13528) |
entryTime |
string | Entry time |
exitTime |
string | Exit time |
date |
string | Date of trade ,format: 'YYYY-MM-DD' |
transType |
string | Transaction type (Buy,Sell) ,for more information View Details |
entryPrice |
float | Entry price |
exitPrice |
float | Exit price |
qty |
integer | Quantity |
PNL |
float | Profit and Loss |
entryLTP |
float | Entry LTP |
exitLTP |
float | Exit LTP |
ForwardTest |
integer | Forward test information |
Capital |
float | Capital |
PNLper |
float | Profit and Loss percentage |
TDno |
integer | Trade number |
productType |
string | Type of product (Intraday,Delivery) ,for more information View Details |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get tradebook status = spark.tradebook(startDate = '2024-05-01', endDate = '2025-01-31', strategyName = 'test_1', accountName= 'account_name') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "UCC": "F000000",
- "AccountName": "account_name",
- "StrategyName": "test_1",
- "symbol": "GMRINFRA-EQ",
- "token": "NSE:13528",
- "entryTime": "1970-01-01T00:02:03",
- "exitTime": "2024-05-22T11:36:36",
- "date": "2024-05-22",
- "transType": "Sell",
- "entryPrice": 80,
- "exitPrice": 85.75,
- "qty": 1,
- "PNL": -5.75,
- "entryLTP": 80,
- "exitLTP": 85.75,
- "ForwardTest": 0,
- "Capital": 0,
- "PNLper": 0,
- "TDno": 292,
- "productType": "Intraday"
}
], - "message": "Tradebook data received"
}
Delete Trade
Delete a trade.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
TDno* |
integer | Trade number to be deleted |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to delete a trade status = spark.deleteTrade(TDno=292) # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [ ],
- "message": "Trade Deleted"
}
Get tokens
Get tokens for specific instrument details.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
symbol* |
string | Symbol of the instrument |
exchange* |
string | Exchange of the instrument ,for more information View Details |
expiry |
string | Expiry date of the instrument in format 'YYYY-MM-DD' |
instrument |
string | Type of instrument (e.g., FUT, OPT) ,for more information View Details |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
token |
string | Token of the instrument |
symbol |
string | Symbol of the instrument |
name |
string | Name of the instrument |
expiry |
string | Expiry date of the instrument |
strike |
integer | Strike price of the instrument |
lotsize |
integer | Lot size of the instrument |
instrumenttype |
string | Type of instrument (e.g., OPTIDX, FUTSTK) |
exch_seg |
string | Exchange segment of the instrument ,for more information View Details |
tick_size |
float | Tick size of the instrument |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get tokens status = spark.getTokens(symbol='NIFTY', exchange='NFO', instrument='OPT', expiry='2024-06-20') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "token": "44413",
- "symbol": "NIFTY20JUN2423650CE",
- "name": "NIFTY",
- "expiry": "2024-06-20",
- "strike": 23650,
- "lotsize": 25,
- "instrumenttype": "OPTIDX",
- "exch_seg": "NFO",
- "tick_size": 0.05
}
], - "message": "Data Received"
}
Get expiry dates
Get the expiry dates for options contracts.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
symbol* |
string | Symbol of the instrument |
exchange* |
string | Exchange of the instrument ,for more information View Details |
instrument* |
string | Type of instrument (e.g., FUT, OPT) ,for more information View Details |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | list of expiry dates in format 'YYYY-MM-DD' |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get expiry dates status = spark.getExpiry(symbol='NIFTY', exchange='NFO', instrument='OPT') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- "2024-05-30",
- "2024-06-06"
], - "message": "Data Received"
}
Get freeze quantity
Get the freeze quantity for a specific symbol.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
symbol* |
string | Symbol for which freeze quantity is to be retrieved |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
data |
array | Contains data response from the API |
freezeQty |
integer | Freeze quantity for the specified symbol |
message |
string | A message indicating the result of the request |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get freeze quantity status = spark.freezeqty(symbol='NIFTY') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "freezeQty": 1800
}
], - "message": "Data Received"
}
Contract Master
Retrieve the contract master data. The contract master data contains information about the contracts available for trading. It is in csv format with the following columns:
Column Name | Data Type | Description |
---|---|---|
token |
integer | Token of the Instrument |
symbol |
string | Symbol of the Instrument |
name |
string | Name of the Instrument |
expiry |
string | Expiry date of the contract ,format: 'YYYY-MM-DD' |
strike |
float | Strike price of the contract |
lotsize |
integer | Lot size of the contract |
instrumenttype |
string | Type of instrument (e.g., OPTIDX, FUTSTK) |
exch_seg |
string | Exchange segment of the contract ,for more information View Details |
tick_size |
float | Tick size of the contract |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to get contract master data status = spark.contractMaster() # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "CSV columns": "token, symbol, name, expiry, strike, lotsize, instrumenttype, exch_seg, tick_size",
- "CSV data": [
- "120947,1110360,SENSEX24JUL73300CE,SENSEX,2024-07-26,7330000.000000,10,OPTIDX,BFO,5.000000"
]
}
], - "message": "Data Received"
}
Isholiday
Check if today is a holiday for the specified exchange.
Query Attributes
Attribute | Data Type | Description |
---|---|---|
exch* |
string | Exchange (NSE,NFO) ,for more information [View Details](#tag/Appendix/Exchanges |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
status |
boolean | Indicates whether the request was successful |
error |
boolean | Indicates whether there was an error |
message |
string | A message indicating the result of the request |
data |
array | Contains data response from the API |
holiday |
boolean | Indicates if today is a holiday |
Responses
Request samples
- Python
from maticalgos.sparkLib import SparkLib # access_token access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' # Initialize the SparkLib object with API key spark = SparkLib(access_token=access_token) # Make a request to the API to check if today is a holiday status = spark.isHoliday(exch='NSE') # Print the response received from the API print(status)
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "message": "Today is a holiday.",
- "data": [
- {
- "holiday": true
}
]
}
Order Websocket
Establish a websocket connection to receive order data.
To connect to order websocket, the below input params are mandate
WebSocket endpoint: wss://apiv.maticalgos.com/orderWS?token=YOUR_ACCESS_TOKEN
Here, we are making a connection with order websocket with parameters and callback functions on_order, on_error, on_close, on_open, which are required in the Python socket connection library used. Sample callback function is shared below.
Callback Functions
Function | Description |
---|---|
on_order |
Callback function to handle order data |
on_error |
Callback function to handle error data |
on_close |
Callback function to handle close data |
on_open |
Callback function to handle open data |
Request Attributes
Attribute | Data Type | Description |
---|---|---|
token* |
string | Access token |
Response Attributes
Attribute | Data Type | Description |
---|---|---|
type |
string | Type of data ( General,OrderUpdate ) |
data |
array | Contains data response from the API |
message |
string | A message indicating the result of the request |
strefID |
integer | Strategy reference ID |
UCC |
string | Unique client code |
AccountName |
string | Account name |
StrategyName |
string | Strategy name |
qty |
integer | Quantity |
productType |
string | Type of product (Intraday,Delivery) ,for more information View Details |
token |
string | Token of the Instrument (eg. NSE:13528) |
price |
float | Price |
limitPrice |
float | Limit price |
reftag |
integer | Reference tag |
placed_at |
string | Date and time of order placement |
orderType |
string | Type of order (Market,Limit) ,for more information View Details |
triggerPrice |
float | Trigger price |
transType |
string | Transaction type (Buy,Sell) ,for more information View Details |
filledQty |
integer | Filled quantity |
status |
string | Order status , for more information View Details |
tradePrice |
float | Trade price |
orders |
array | Order details |
orderid |
string | Order ID |
placed |
boolean | Indicates if order is placed |
changed |
boolean | Indicates if order is changed |
segment |
string | Segment |
splitby |
integer | To split order in batches |
active |
boolean | Indicates if order is active |
ordersexecuted |
integer | Number of orders executed |
ordersdone |
integer | Number of orders done |
ordersplaced |
integer | Number of orders placed |
operations |
array | Operations details |
timeLimit |
integer | Time limit |
shouldExecute |
boolean | Indicates if order should be executed |
priceBuffer |
float | Price buffer |
symbol |
string | Symbol of the Instrument |
Responses
Request samples
- Python
from maticalgos.sparkLib import OrderSocket import time def on_order(message): print('test message', message) def on_error(error): print('test_error', error) def on_close(): print("### closed ###") def on_open(): print(" test on_open called") access_token = 'eyJ0eXXXXXXXX2c5-Y3RgS8wR14g' order = OrderSocket(access_token=access_token, on_order=on_order, on_error=on_error, on_close=on_close, on_connect=on_open, reconnect=True, max_reconnect_attempts=20, run_background=True ) order.connect() time.sleep(20) order.close_connection()
Response samples
- 200
- 400
{- "status": true,
- "error": false,
- "data": [
- {
- "type": "OrderUpdate",
- "message": "Data received.",
- "data": [
- {
- "strefID": 371,
- "StrategyName": "test_1",
- "qty": 1,
- "productType": "Intraday",
- "token": "NSE:13528",
- "price": 88.45,
- "limitPrice": 0,
- "reftag": 447,
- "placed_at": "2024-05-27 12:56:34.513886",
- "orderType": "Market",
- "triggerPrice": 0,
- "transType": "Buy",
- "filledQty": 0,
- "status": "Placed",
- "tradePrice": 0,
- "orders": [
- {
- "orderid": "24052700282000",
- "placed": true,
- "message": "Data received.",
- "qty": 1,
- "status": "Placed",
- "changed": true,
- "placed_at": "2024-05-27 12:56:34.612772"
}
], - "UCC": "F000000",
- "AccountName": "account_name",
- "segment": "C",
- "splitby": 0,
- "active": true,
- "ordersexecuted": 0,
- "ordersdone": 0,
- "ordersplaced": 1,
- "operations": {
- "timeLimit": 30,
- "shouldExecute": false,
- "priceBuffer": 5
}, - "symbol": "GMRINFRA-EQ"
}
]
}
], - "message": "Data Received"
}
Broker | Description |
---|---|
FYERS | FYERS Broker |
IIFL | IIFL Broker |
testBroker | Test Broker for paper trading |
Exchange | Description |
---|---|
NSE | National Stock Exchange |
BSE | Bombay Stock Exchange |
NFO | NSE Futures and Options |
BFO | BSE Futures and Options |
MCX | Multi Commodity Exchange (coming soon) |
Order Types | Description |
---|---|
Limit | Limit order |
Market | Market order |
SL-Limit | Stoplimit order (SL-L) |
Order Status | Description |
---|---|
Cancelled | Order is cancelled |
Executed | Order is executed |
Rejected | Order is rejected |
Pending | Order is pending |
Placed | Order is placed |