# Finmart to Finmars

**Overview**

The **Finmars-to-Finmars** module enables exporting and sending data from a common Finmars controlling space (which includes multiple portfolios) to a private client space.

**Exported Data Includes:**

- **Portfolio**
- **Account**
- **Currency**
- **Instrument**
- **Counterparty**
- **Responsible**
- **Complex Transaction**
- **Price History**
- **Currency History**
- **Portfolio History**

**Requirements**

- Both the sender and recipient spaces must have **standard configurations** (same versions).

# Installation

1. In the **sender space**, navigate to **Add-ons → Marketplace**.
2. Locate the **Finmars-to-Finars** module and install it.
3. Go to **Workflow → Schedules**:
    
    
    - URL format: `https://{domain_name}/{realm_code}/{space_code}/w/schedule`
4. Create a new schedule and fill out the form with the following details:
    
    <table><thead><tr><th>**Field**</th><th>**Value**</th></tr></thead><tbody><tr><td>**usercode**</td><td>Unique name</td></tr><tr><td>**name**</td><td>Name of the schedule</td></tr><tr><td>**workflow user code**</td><td>`com.finmars.finmars-to-finmars:init-export`</td></tr><tr><td>**crontab**</td><td>`* * * * *` (Format: Minute, Hour, Day of Month, Month, Day of Week)</td></tr><tr><td>**notes**</td><td>Optional notes</td></tr><tr><td>**payload**</td><td>`{}` (Empty JSON)</td></tr><tr><td>**manager**</td><td>Select `"Yes"`</td></tr><tr><td>**enabled**</td><td>Select `"Yes"`</td></tr></tbody></table>
5. Wait for the space data to be exported to storage. You can check the exported data in **Explorer → "export\_data" folder**.

# Usage

### **Obtaining a JWT Token**

You can retrieve a JWT token via an API **POST request** using the following URL pattern: **https://{domain\_name}/{realm\_code}/{space\_code}/api/v1/auth-tokens/personal-access-token/create-token/**

### **Sending Data for a Single Portfolio**

1. In the **sender space**, go to **Workflow → Home**.
2. Locate and run the workflow with **user code: com.finmars.finmars-to-finmars:send**
3. Use the following **payload data format** when running the workflow:
    
    ```json
    {
       "portfolio_code": "<The portfolio code in the current space>",
       "export_date": "<The date of the export>",
       "domain_name": "<The domain name of the private client space>",
       "realm_code": "<The realm code of the private client space>",
       "space_code": "<The space code of the private client space>",
       "jwt_token": "<The JWT token for accessing the private client space>"
    }
    ```

### **Sending Data for a Date Range**

1. In the **sender space**, go to **Workflow → Home**.
2. Locate and run the workflow with **user code**: **com.finmars.finmars-to-finmars:send**
3. Use the following **payload data format**:
    
    ```json
    {
       "export_date_from": "<Start date of the export>",
       "export_date_to": "<End date of the export>",
       "domain_name": "<The domain name of the private client space>",
       "realm_code": "<The realm code of the private client space>",
       "space_code": "<The space code of the private client space>",
       "jwt_token": "<The JWT token for accessing the private client space>"
    }
    ```