#unix-timestamp #trading #session #technical-analysis #data-analysis #determine #time-series

trading_sessions

A lightweight library in Rust for identifying and verifying trading sessions

4 releases

new 0.1.3 Apr 26, 2024
0.1.2 Mar 20, 2024
0.1.1 Feb 28, 2024
0.1.0 Feb 28, 2024

#10 in #technical-analysis

Download history 198/week @ 2024-02-23 56/week @ 2024-03-01 8/week @ 2024-03-08 154/week @ 2024-03-15 64/week @ 2024-03-22 143/week @ 2024-03-29 15/week @ 2024-04-05 6/week @ 2024-04-12

243 downloads per month

MIT license

14KB
61 lines

Trading Sessions

A Rust crate for identifying and verifying trading sessions based on Unix timestamps.

Getting Started

Add the following to your Cargo.toml:

[dependencies]
trading_sessions = "0.1.0"

Features

Examples

IdentifyTradingSession

use trading_sessions::IdentifyTradingSession;

let session_identifier = IdentifyTradingSession::new(1708574400);
assert_eq!(session_identifier.identify_trading_session(), "Tokyo");

SessionVerification

use trading_sessions::SessionVerification;

let verifier = SessionVerification::new(1708574400, "Tokyo".to_string());
assert!(verifier.verify());

SessionColumn

use polars::prelude::*;
use trading_sessions::SessionColumn;

let df = df! {
    "time" => [1708574400, 1708596000, 1708696800]
}.unwrap();
let lazy_frame = df.lazy();
let mut session_column = SessionColumn::new(lazy_frame);
session_column.apply_session_column();
let result_df = session_column.lazyframe.collect().unwrap();
assert_eq!(result_df.column("Session").unwrap().str_value(0).unwrap(), "Tokyo");

Return Types

Successful operations return a string representing the trading session or a boolean indicating the verification result. Errors are typically handled by the calling code and are dependent on the context in which these functions are used.

Notes

  • The crate assumes all timestamps are in UTC.
  • Daylight Saving Time is not considered in the current version.

Dependencies

~17–27MB
~433K SLoC