Skip to content

No-Trade-No-Life/Yuan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Language TS Contributors Forks Stargazers MIT License

Discord Issues Bugs Open Bugs Closed


Logo

Yuan

The investment Operating System for everyone

AI empowered, global market, serverless, cloud-native, and privacy.

Access the Yuan GUI from any device Β»

Read the Docs πŸ“– Β· Report Bug πŸ› Β· Request Feature πŸ’‘ Β· Join Discord

About The Project

image

image

image

I'm a software engineer. And I want to make money through quantitative and automatic trading.

There are many great tools and platforms available. However, I didn't find one that suited my needs, so I created Yuan.

Here's why:

  • My trading strategy is secret. I am afraid someone illegally obtained the results. I want to test and run it on trusted devices.
  • The historical data is highly reused and never updated anymore. I want to download the data once and use it forever. So the data should be free.
  • I want to work everywhere from any device. I don't want to install prerequisites (Python or any others) before starting my work. Most devices have installed browsers. So I want to use a browser to work.
  • The market is similar around the world. I want to trade in any global market without changing any strategy code. Write once, and run everywhere.
  • Real-world trading is important. The trading system should be highly available. I want to create and maintain them easily.
  • My money is dispersed across many accounts. I want to manage them in one place.

For more general usages:

  • Maybe you feel troubled about coding. You can ask an AI assistant for help. Just tell AI your idea and run. AI can complete the code.

In summary, I hope Yuan can be an operating system, which helps you control your money.

(back to top)

Why use Yuan

Powerful Web GUI

With Yuan Web GUI, you have access to a comprehensive solution for creating, testing, and managing your trading system, as well as deploying and monitoring your applications. The GUI is completely open-source and can be deployed anywhere, without an internet connection. You can easily switch between multiple environments using just one GUI, making your experience more streamlined.

We have designed the GUI with modern browsers in mind, and it integrates with the latest web technologies, such as WebWorker, FileSystemHandle, WebRTC, and more. It is highly responsive and fast, and we are constantly working to make it even better for you.

Although the GUI is currently written in Chinese, we have plans to make it internationalized, so you can use it in your native language in the future. We welcome contributions to the project's translation, so everyone can benefit from this amazing tool. You can access the GUI for free under the MIT license, without the need to install anything - simply use the GUI.

Simple language and AI assistant

If you're interested in developing a trading strategy without the need to learn a new language or DSL, the modern JavaScript/TypeScript language is an excellent option. You can use any IDE to write your code and any version control system to manage it. If you have difficulty with coding, you can seek assistance from an AI assistant by communicating your idea to it.

// It's a simple trend-tracking trading strategy that uses the SMA indicator.
import { useSMA, useSimplePositionManager } from '@libs';
export default () => {
  const { close } = useOHLC('Y', 'XAUUSD', 'PT1H');
  const ma20 = useSMA(close, 20);
  const accountInfo = useAccountInfo();
  const [targetVolume, setTargetVolume] = useSimplePositionManager(accountInfo.account_id, 'XAUUSD');
  useEffect(() => {
    const idx = close.length - 2;
    if (close[idx] > ma20[idx]) {
      setTargetVolume(1);
    } else {
      setTargetVolume(0);
    }
  }, [close.length]);
};

More examples can be found here.

Local, cloud...or hybrid!

Yuan is a hybrid-cloud software that allows you to deploy your trading system in your home or public cloud simultaneously. You can start using your home PC and then gradually switch to the public cloud as your business grows. Choosing between your home PC or the public cloud will depend on your availability, costs, privacy, and security requirements.

Extension-first Ecosystem

In Yuan, extensions are treated as first-class citizens. Many core features are built and distributed as extensions. You can use extensions to add new features, connect with more markets, and enhance your experience. You can download extensions from the community or create your own extensions to share with others.

(back to top)

Built with

TypeScript reactivex react kubernetes docker prometheus mongodb zeromq openai nginx pnpm monaco editor vite rollup ajv webrtc letsencrypt

(back to top)

Getting started (for developers) πŸš€

Prerequisites: nodejs >= 18.17.0, docker for image build, and rush for mono repo management.

npm install -g @microsoft/rush

Then you can install dependencies and build projects

rush update && rush build

If you have no docker installed, you can skip the docker build by setting the environment variable CI_RUN to true.

CI_RUN=true rush build

(back to top)

Packages

Libraries

All the libraries should be independent of the platform by default. They can be used in the browser, node.js, or other platforms. And provide both ESM and CommonJS modules.

  • @yuants/data-model Data Model and related utils.
  • @yuants/protocol Network protocol, service definition and infrastructure.
  • @yuants/utils Some general utils that are not found in the community.
  • @yuants/kernel The kernel of Time-Machine. Time-Machine can travel from history to the future. This package also contains some useful units and scenes.
  • @yuants/agent Agent is a trading bot. The agent contains the core of the trading strategy.
  • @yuants/extension This defined the extension interface. You can use extensions to enhance your experience.
  • @yuants/prometheus-client Prometheus client for the browser / node. Better performance than promjs.

Apps

All the apps should provide an image and publish it as a npm package. You can deploy the app by docker and Kubernetes. You can find the App List and get the image. All the apps implemented the extension interface. So you can treat them as extensions.

  • @yuants/app-host Host is a very lightweight message broker. Terminals can connect to the host and send messages to each other. Notice that all terminals in a host should trust each other. In practice, all the terminals in a host belong to the same owner. There's no need to verify every message. You can deploy multiple hosts to isolate the risk.
  • @yuants/app-market-data-collector This will deploy a terminal as a data-collecting service. The terminal collects market data from the market terminals continuously.
  • @yuants/app-data-collector This will deploy a terminal as a data-collecting service. The terminal collects series data from the data series provider terminals continuously. It's a general version of the market data collector. You can use it to collect any data series.
  • @yuants/app-agent This will deploy a terminal as the daemon service of the agent. You can run the agent in real mode. It can automatically correct the history data error. It can also automatically restart the agent when it crashes.
  • @yuants/app-alert-receiver This will deploy a terminal as an alert-receiving service. It receives alerts from the alert terminals and sends them to the notifier terminals.
  • @yuants/app-mongodb-storage This will deploy a terminal as a storage service. It stores data in MongoDB.
  • @yuants/app-email-notifier This will deploy a terminal as a notifier service. It sends notifications to your email.
  • @yuants/app-feishu-notifier This will deploy a terminal as a notifier service. It sends notifications to your Feishu by a Feishu bot.
  • @yuants/app-trade-copier This will deploy a terminal as a trade copier service. It watches the source accounts and ensures the target accounts follow the source accounts.
  • @yuants/app-metrics-collector This will deploy a terminal as a metrics-collecting service. The metrics collector collects metrics from terminals continuously. It works with Prometheus.
  • @yuants/app-account-composer This will deploy a terminal as an account-composing service. It composes multiple account info into one account info. So you can view your money dispersed across many accounts.
  • @yuants/app-general-datasource This will deploy a terminal as a general data source service. It composes multiple specific data sources into one general data source. Useful for creating an index price series.
  • @yuants/app-general-realtime-data-source This will deploy a terminal as a general real-time data source service. It's the real-time version of the general data source. Useful for creating an index price ticks.
  • @yuants/app-k8s-manifest-operator This will deploy a terminal as a Kubernetes manifest operator. It watches the manifest CRD of the Kubernetes cluster and ensures the Kubernetes cluster follows the manifest CRD. You can add manifest CRD to the k8s cluster and then the operator will deploy the resources defined in the manifest CRD.
  • @yuants/app-transfer-controller A transfer controller is a service that transfers money between accounts. It watches the transfer request and ensures the transfer is completed.

Web UI

@yuants/ui-web is the GUI. You can do anything with the GUI because we prefer to implement the feature in GUI rather than CLI. All the users use the same GUI distribution. It's independent of hosts and scenes. User has their own workspace locally. The workspace is secret. You can install extensions to enhance your workspace. Any device with a modern browser can access the GUI and its features. But currently, the layout on the desktop is the most friendly. We will enhance the experience of mobile in the future.

Documents

@yuants/docs is the document of Yuan.

It's built by Docusaurus. You can find the latest documents here.

Toolkit

@yuants/tool-kit is all you need. This provides a CLI when you need to build an extension. It helps you to build a docker image, create a bundle and more. To ensure your extension is ready to use.

Vendors

Vendors include markets, exchanges, and data sources. You can access the global market through various vendors. For some legal reason, they are probably not open to everyone. But you can use them if you gain permission from the provider.

Every vendor is a gateway to connect the external service directly. Your private data including account info and market data will not be stored in Yuan Cloud Service. You can deploy the vendor in your own cloud or local machine.

  • @yuants/vendor-ctp This connects to the "Comprehensive Transaction Platform" (CTP). The CTP platform was developed by the Shanghai Futures Exchange (SHFE). CTP provides China's future exchanges. To comply with regulations, you might have to request permission from your broker company.

  • @yuants/vendor-ccxt This connects to the "CryptoCurrency eXchange Trading Library" (CCXT). CCXT is a JavaScript / Python / PHP cryptocurrency trading library that supports many cryptocurrency exchanges and trading markets. You can use it to trade cryptocurrencies.

  • @yuants/vendor-binance This connects to the Binance Exchange. Binance is a famous crypto exchange.

  • @yuants/vendor-okx This connects to the OKX Exchange. OKX is a famous crypto exchange.

  • @yuants/vendor-huobi This connects to the Huobi Exchange. Huobi is a famous crypto exchange.

  • @yuants/vendor-gate This connects to the Gate.io Exchange. Gate.io is a famous crypto exchange.

(back to top)

Contributing

Contributions make the open-source community a fantastic place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open a feature request issue. Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contributors

Thanks sincerely to the contributors:

Zheng Chen
Zheng Chen

πŸ§‘β€πŸ« πŸ’» 🎨 πŸ‘€
Siyuan Wang
Siyuan Wang

πŸ’» πŸš‡
Jinhaolin
Jinhaolin

πŸ’»
Hobo Chen
Hobo Chen

πŸ›
Yalun Lin Hsu
Yalun Lin Hsu

πŸ’»
SakurazukaKen
SakurazukaKen

πŸ’»
Haoran Ren
Haoran Ren

πŸ’»
pruderior
pruderior

πŸ’»
playground
playground

πŸ’»

(back to top)

Contact

  • Join Discord server: Discord

(back to top)

Acknowledgments πŸ“–

  1. Yuan-Public-Workspace You can learn how to write strategy models from this repository. You can import it to your workspace from the GUI. The repository is embedded in AI with a vector database. Contribute with your examples is greatly appreciated!
  2. Yuan-Public-Data Our public data is maintained here as a repository. Free to use. Welcome to contribute if you have other data!

(back to top)

Star History

Star History Chart

(back to top)