Product updates

– 6 min read

Simplify financial app development with the Writer Framework and Palmyra-Fin

Sam Julien

Sam Julien   |  August 15, 2024

Simplify financial app development with the Writer Framework and Palmyra-Fin

TL;DR by Writer

In the financial industry, a simple chatbot isn’t enough. You need a full-featured web app that can handle complex data interactions, provide detailed visualizations, and deliver dynamic user experiences to meet the demands of financial analysis and decision making. Palmyra-Fin and the Writer Framework are ‌tools designed to revolutionize financial analysis app development. Explore the code behind one of our most powerful financial apps.

Building a generative AI app for financial analysis is a complex dance of navigating regulatory requirements, ensuring data accuracy, and delivering real-time insights. Think about the complexity of sifting through extensive financial reports, interpreting nuanced terminology, and making sense of detailed charts and graphs that track market trends and company performance. Even after you’ve built your app to handle this data, presenting your analysis in a visually compelling way is still a hurdle.

In the financial sector, a simple chatbot isn’t enough. You need a full-featured web application that can combine complex data analysis, detailed visualizations, and dynamic user experiences into a single analyst dashboard.

The good news: with our new Palmyra-Fin model and our app development tool, the Writer Framework, you can make a financial analysis app that connects real-time data, makes useful reports, and shows interactive charts.

Let’s take a look at these components of the Writer generative AI platform and how you can use them to build a powerful app that turns raw financial data into actionable insights and clear visualizations.

What’s the Writer Framework and Palmyra-Fin?

At Writer, we’ve worked with companies ranging from fintech startups to financial service leaders like Vanguard to power their AI app development. At the core of our success are two powerful tools:

The Writer Framework is an open-source drag-and-drop builder with a Python backend for building web apps that are fully integrated with the Writer platform. The Writer Framework is part of our AI Studio, a suite of development tools that make it fast and easy to build feature-rich AI apps.

Palmyra-Fin is an LLM trained for financial generative AI apps to do real-world financial tasks. It outperformed other models and was the first model to pass the CFA Level III exam with a 73% score!

Here are just a few use cases for it:

  • Investment research: Generate detailed reports and analyses of investment opportunities.
  • Financial analysis: Interpret complex financial statements and metrics.
  • Sentiment analysis: Analyze market sentiment based on financial news and reports.

We built a sample app to showcase how the Writer Framework and Palmyra-Fin can be used to create a powerful financial research dashboard. The app pulls in real-time company data like stock values, income statements, and the latest news. It then instantly analyzes market trends and company performance with Palmyra-Fin.

Finance app

We’ve got the code for you in this GitHub repo. Or you can watch the video below for a walkthrough of the app.

Let’s take a look at the app’s three main features in action.

When the user selects the “Analyze Trends” button, the stock data from Yahoo Finance via the yfinance Python library is packaged and sent to Palmyra-Fin, which then generates insights. You can even change the output language. So, if you wanted to generate this in French, you can select “French,” then “Analyze Trends”, and it’ll send the insights back to you en français. 😉

Here’s the code that sends the data to Palmyra-Fin and updates parts of the application state when the analysis is complete:

def generate_stock_analysis(state):
    _refresh_window(state)  
    if(state["prompt_parameters_lang"] == ""):
        state["prompt_parameters_lang"] == "English"

    state["message"] = f"% {state["symbol"]} trends will be analyzed here in {state['prompt_parameters_lang']}"
    stock_name = state["symbol"]
    stock_data = state["main_df"][:365]
        
    rounded_value = round(state["prompt_parameters_words"], 0)
    language = state["prompt_parameters_lang"]
    integer_value = int(rounded_value)

    prompt = stock_prompts.format(language=language, stock_name=stock_name,words=integer_value,stock_data=stock_data)
    submission = writer.ai.complete(prompt, config={"model": "palmyra-fin-32k", "temperature": 0.7, "max_tokens": 8192})
    state["analysis"] = submission.strip()
    state["message"] = f"+ {state["symbol"]} trends analyzed"
    state["show_analysis_text"]["visible"] = True
    state["show_analysis_text"]["language"] = True
        
    return submission

Visualizing income statements

Select the “Visualize income statement” button to turn your income data into clear visualizations, including income statement analysis, risks, opportunities, and conclusions. A cool way to see raw financial data transformed into actionable insights!

Here’s how it works:

  1. The data is turned into a chart with a Python library called Plotly.
  2. The data is sent to Palmyra-Fin along with the stock data to summarize the information.

Here’s the code that constructs the prompt with the stock and income data, sends it to Palmyra-Fin, and updates the parts of the application state when the analysis is complete:

def generate_income_analysis(state):
    _refresh_window(state)
    state["message"] = f"% {state["symbol"]} income statement will be visualized here"
    stock_name = state["symbol"]
    stock_data = state["main_df"][:365]
    income_statement_data = state["income_statement_df"][:365]
    prompt = income_prompts.format(
        income_statement_data=income_statement_data,
        stock_data=stock_data,
        stock_name=stock_name,
    )
    submission = writer.ai.complete(prompt, config={"model": "palmyra-fin-32k", "temperature": 0.7, "max_tokens": 8192})
    state["analysis"] = submission.strip()
    state["message"] = f"+ {state["symbol"]} income statement visualized"
    state["show_income_metrics"]["visible"] = True
    state["show_analysis_text"]["visible"] = True
    state["show_bar_graph"]["visible"] = True
    return submission

Summarizing earnings calls

The app includes a feature to retrieve recent earnings call transcripts for the selected stock. These transcripts are then sent to Palmyra-Fin, which generates a concise summary of the earnings call.

Here’s the code that uses Palmyra-Fin to summarize the earnings call for the selected stock:

def summarize_earnings(state):
    _refresh_window(state)  
    state["message"] = f"% {state["symbol"]} earnings call will be summarized here"
    
    earnings_transcript = state["earnings_transcript"]
    prompt = earnings_prompt.format(earnings_transcript=earnings_transcript)
    submission = writer.ai.complete(prompt, config={"model": "palmyra-fin-32k", "temperature": 0.7, "max_tokens": 8192})
    state["message"] = f"+ {state["symbol"]} earnings call summary"
    state["analysis"] = submission.strip()
    state["show_analysis_text"]["visible"] = True

In the repo, we’ve provided sample earnings call data. There are paid APIs you could use to pull real-time earnings call data, such as FMP.

Show off what you build!

The Writer Framework combined with Palmyra-Fin gives you the control and creativity to build a fully functional web app that can instantly analyze financial data. The code is available on GitHub, and you can start building with the Writer Framework through Writer AI Studio. New sign-ups will receive $10 in credits to try it out.

Feel free to reach out to me on X or LinkedIn and let me know what you’re building! 🚀