Coder Social home page Coder Social logo

financial-symbols's Introduction

Financial Symbols

Stock symbols & option contract symbols which implement the copy trait.

Build status Crates.io Documentation

use financial_symbols::{OptionContract, OptionType, Ticker};
use rust_decimal::Decimal;
use chrono::NaiveDate;
use std::str::FromStr;

let ticker = Ticker::try_from("AAPL").unwrap();

let ticker_copy = ticker;

assert_eq!(ticker, ticker_copy);
assert_eq!(ticker.as_str(), "AAPL");

let contract = OptionContract::from_iso_format("SPXW231127C03850000").unwrap();

let contract_copy = contract;
assert_eq!(contract, contract_copy);

assert_eq!(contract.ticker.as_str(), "SPXW");
assert_eq!(contract.ot_type, OptionType::Call);
assert_eq!(contract.expiry, NaiveDate::from_str("2023-11-27").unwrap());
assert_eq!(contract.strike, Decimal::from(3850));

let contract = OptionContract::from_dx_feed_symbol(".SPXW231127C3850").unwrap();
assert_eq!(contract.as_str(), "SPXW231127C03850000");

Benchmark

Tested on Apple M1 Pro 16GB Ram

from_iso_format SPXW231124P04060000
                        time:   [51.028 ns 51.099 ns 51.187 ns]
                        change: [-1.7407% -1.4017% -1.0789%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  9 (9.00%) high severe

from_iso_format TSLA240119C00066670
                        time:   [71.124 ns 71.347 ns 71.585 ns]
                        change: [-0.9598% -0.5467% -0.1513%] (p = 0.01 < 0.05)
                        Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild

from_iso_format A231215C00055000
                        time:   [48.979 ns 49.028 ns 49.104 ns]
                        change: [-1.1605% -0.8206% -0.4416%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 7 outliers among 100 measurements (7.00%)
  7 (7.00%) high severe

financial-symbols's People

Contributors

zarathustra2 avatar

Stargazers

Chao Yan avatar Michael avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.